Skip to content

Commit 0f31cec

Browse files
committed
Fix some bounds and signatures
1 parent 8aa0ce8 commit 0f31cec

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/SignatureUtils.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,12 @@ public static String getSignature(ITypeBinding typeBinding) {
121121
return Signature.createArraySignature(getSignature(typeBinding.getComponentType()), 1);
122122
}
123123
if (typeBinding.isWildcardType()) {
124-
var upper = typeBinding.getTypeBounds();
125-
if (upper != null && upper.length > 0) {
126-
return Signature.C_EXTENDS + Stream.of(upper).map(SignatureUtils::getSignature).collect(Collectors.joining());
127-
}
128-
var lower = typeBinding.getWildcard();
129-
if (lower != null && lower != typeBinding) {
130-
return Signature.C_SUPER + SignatureUtils.getSignature(lower);
131-
}
132-
// TODO if typeBinding.getBounds(): C_EXTENDS, C_SUPER
133-
return Character.toString(Signature.C_STAR);
124+
var bounds = typeBinding.getTypeBounds();
125+
if (bounds.length == 0) {
126+
return Character.toString(Signature.C_STAR);
127+
}
128+
return (typeBinding.isUpperbound() ? Signature.C_EXTENDS : Signature.C_SUPER)
129+
+ Stream.of(bounds).map(SignatureUtils::getSignature).collect(Collectors.joining());
134130
}
135131
ITypeBinding[] typeBounds = typeBinding.getTypeBounds();
136132
if (typeBinding.isTypeVariable() || typeBinding.isWildcardType()) {

org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/dom/JavacTypeBinding.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,7 @@ public ITypeBinding[] getTypeBounds() {
14381438
return new ITypeBinding[0];
14391439
}
14401440
}
1441-
Type bounds = typeVar.getUpperBound();
1441+
Type bounds = typeVar.isSuperBound() ? typeVar.getLowerBound() : typeVar.getUpperBound();
14421442
if (bounds instanceof IntersectionClassType intersectionType) {
14431443
return intersectionType.getBounds().stream() //
14441444
.filter(Type.class::isInstance) //
@@ -1450,10 +1450,7 @@ public ITypeBinding[] getTypeBounds() {
14501450
} else if (this.type instanceof WildcardType wildcardType) {
14511451
boolean isUnbound = wildcardType.isUnbound();
14521452
boolean isSuperBound = wildcardType.isSuperBound();
1453-
if (wildcardType.type instanceof Type.TypeVar typeVar) {
1454-
return this.resolver.bindings.getTypeVariableBinding(typeVar, this.typeSymbol).getTypeBounds();
1455-
}
1456-
return new ITypeBinding[] { isUnbound || isSuperBound ?
1453+
return new ITypeBinding[] { isUnbound ?
14571454
this.resolver.resolveWellKnownType(Object.class.getName()) :
14581455
this.resolver.bindings.getTypeBinding(wildcardType.type) };
14591456
}
@@ -1688,7 +1685,7 @@ public boolean isTypeVariable() {
16881685

16891686
@Override
16901687
public boolean isUpperbound() {
1691-
return this.type.isExtendsBound();
1688+
return this.type != null && this.type.isExtendsBound();
16921689
}
16931690

16941691
@Override

0 commit comments

Comments
 (0)