diff --git a/transpiler/src/main/java/org/jsweet/transpiler/model/Util.java b/transpiler/src/main/java/org/jsweet/transpiler/model/Util.java index 1118f5c5..ba83d164 100644 --- a/transpiler/src/main/java/org/jsweet/transpiler/model/Util.java +++ b/transpiler/src/main/java/org/jsweet/transpiler/model/Util.java @@ -3,6 +3,7 @@ package org.jsweet.transpiler.model; import java.util.List; import javax.lang.model.element.Element; +import javax.lang.model.element.TypeElement; import javax.lang.model.type.TypeMirror; /** @@ -12,6 +13,11 @@ import javax.lang.model.type.TypeMirror; */ public interface Util { + /** + * Returns true if the given type is an interface. + */ + boolean isInterface(TypeElement type); + /** * Gets the qualified name for the given type. */ diff --git a/transpiler/src/main/java/org/jsweet/transpiler/model/support/UtilSupport.java b/transpiler/src/main/java/org/jsweet/transpiler/model/support/UtilSupport.java index ea22c775..dd91ed87 100644 --- a/transpiler/src/main/java/org/jsweet/transpiler/model/support/UtilSupport.java +++ b/transpiler/src/main/java/org/jsweet/transpiler/model/support/UtilSupport.java @@ -29,6 +29,7 @@ import javax.lang.model.type.TypeMirror; import org.jsweet.transpiler.JSweetContext; import org.jsweet.transpiler.model.Util; +import com.sun.tools.javac.code.Symbol.TypeSymbol; import com.sun.tools.javac.code.Type; import com.sun.tools.javac.code.Type.CapturedType; import com.sun.tools.javac.tree.JCTree; @@ -181,7 +182,7 @@ public class UtilSupport implements Util { public String getRelativePath(String fromPath, String toPath) { return org.jsweet.transpiler.util.Util.getRelativePath(fromPath, toPath); } - + @Override public String getTypeInitialValue(TypeMirror type) { if (type == null) { @@ -197,6 +198,13 @@ public class UtilSupport implements Util { return "null"; } } - + + @Override + public boolean isInterface(TypeElement type) { + if (type instanceof TypeSymbol) { + return context.isInterface((TypeSymbol) type); + } + return false; + } }