Mercurial > hg > truffle
diff graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java @ 20940:476374f3fe9a
Truffle-DSL: generate better polymorphic execute signatures
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Tue, 14 Apr 2015 15:12:48 +0200 |
parents | f83fd99b2962 |
children | 810d466073f0 |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java Tue Apr 14 15:12:48 2015 +0200 +++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java Tue Apr 14 15:12:48 2015 +0200 @@ -120,6 +120,9 @@ } public static TypeMirror boxType(ProcessorContext context, TypeMirror primitiveType) { + if (primitiveType == null) { + return null; + } TypeMirror boxedType = primitiveType; if (boxedType.getKind().isPrimitive()) { boxedType = context.getEnvironment().getTypeUtils().boxedClass((PrimitiveType) boxedType).asType(); @@ -217,6 +220,10 @@ } } + public static boolean isSubtypeBoxed(ProcessorContext context, TypeMirror from, TypeMirror to) { + return isSubtype(boxType(context, from), boxType(context, to)); + } + public static boolean isSubtype(TypeMirror type1, TypeMirror type2) { if (type1 instanceof CodeTypeMirror || type2 instanceof CodeTypeMirror) { throw new UnsupportedOperationException(); @@ -1178,7 +1185,7 @@ public static List<TypeMirror> uniqueSortedTypes(Collection<TypeMirror> types) { if (types.isEmpty()) { - return Collections.emptyList(); + return new ArrayList<>(0); } else if (types.size() <= 1) { if (types instanceof List) { return (List<TypeMirror>) types;