mirror of
https://github.com/cincheo/jsweet.git
synced 2026-02-07 14:06:35 +00:00
added utility method to retrieve a type's upper bound (JSweet 2 catch-up d01acde34e)
This commit is contained in:
parent
f502b67b88
commit
1efa9caf6a
@ -55,6 +55,7 @@ import javax.lang.model.type.ExecutableType;
|
||||
import javax.lang.model.type.PrimitiveType;
|
||||
import javax.lang.model.type.TypeKind;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
import javax.lang.model.type.TypeVariable;
|
||||
import javax.lang.model.util.Elements;
|
||||
import javax.lang.model.util.Types;
|
||||
import javax.tools.JavaFileObject;
|
||||
@ -124,6 +125,18 @@ public class Util {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the given type is a capture and has an upper bound, returns it, else
|
||||
* return the given type unchanged.
|
||||
*/
|
||||
public TypeMirror getUpperBound(TypeMirror type) {
|
||||
if (type instanceof TypeVariable && ((TypeVariable) type).getUpperBound() != null) {
|
||||
return ((TypeVariable) type).getUpperBound();
|
||||
} else {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type arguments of a given type (if any).
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user