improved super handling

This commit is contained in:
Timo Westkämper 2012-09-04 12:40:14 +03:00
parent 6bdaa71de4
commit f1710fa060
3 changed files with 16 additions and 2 deletions

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.mysema.codegen</groupId>
<artifactId>codegen</artifactId>
<version>0.5.2</version>
<version>0.5.3</version>
<name>Codegen</name>
<description>Code generation and compilation for Java</description>
<parent>

View File

@ -41,7 +41,12 @@ public class TypeSuper extends TypeAdapter {
@Override
public String getGenericName(boolean asArgType, Set<String> packages, Set<String> classes) {
if (!asArgType) {
return "? super " + superType.getGenericName(true, packages, classes);
if (superType instanceof TypeExtends) {
return "?";
} else {
return "? super " + superType.getGenericName(true, packages, classes);
}
} else {
return super.getGenericName(asArgType, packages, classes);
}

View File

@ -20,5 +20,14 @@ public class TypeSuperTest {
public void GetGenericName_As_ArgType() {
assertEquals("java.lang.Object", new TypeSuper(Types.STRING).getGenericName(true));
}
@Test
public void Comparable() {
// T extends Comparable<? super T>
Type comparable = new ClassType(Comparable.class);
Type type = new TypeExtends("T",
new SimpleType(comparable, new TypeSuper(new TypeExtends("T", comparable))));
assertEquals("? extends java.lang.Comparable<?>", type.getGenericName(false));
}
}