Mercurial > hg > graal-jvmci-8
diff graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/OrganizedImports.java @ 16923:93e061157811
Truffle-DSL: better support for types with type arguments.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 25 Aug 2014 20:59:56 +0200 |
parents | d3f282a9e287 |
children | c22714b214d0 |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/OrganizedImports.java Mon Aug 25 16:30:40 2014 +0200 +++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/OrganizedImports.java Mon Aug 25 20:59:56 2014 +0200 @@ -107,6 +107,8 @@ b.append("? extends ").append(createTypeReference(enclosedElement, type.getExtendsBound())); } else if (type.getSuperBound() != null) { b.append("? super ").append(createTypeReference(enclosedElement, type.getExtendsBound())); + } else { + b.append("?"); } return b.toString(); } @@ -122,18 +124,23 @@ } } - if (type.getTypeArguments().size() == 0) { + List<? extends TypeMirror> genericTypes = type.getTypeArguments(); + if (genericTypes.size() == 0) { return name; } StringBuilder b = new StringBuilder(name); b.append("<"); - if (type.getTypeArguments().size() > 0) { - for (int i = 0; i < type.getTypeArguments().size(); i++) { - b.append(createTypeReference(enclosedElement, type.getTypeArguments().get(i))); - if (i < type.getTypeArguments().size() - 1) { - b.append(", "); - } + for (int i = 0; i < genericTypes.size(); i++) { + TypeMirror genericType = i < genericTypes.size() ? genericTypes.get(i) : null; + if (genericType != null) { + b.append(createTypeReference(enclosedElement, genericType)); + } else { + b.append("?"); + } + + if (i < genericTypes.size() - 1) { + b.append(", "); } } b.append(">");