Search in sources :

Example 1 with BoundKind

use of com.sun.tools.javac.code.BoundKind in project ceylon-compiler by ceylon.

the class TypesImpl method getWildcardType.

/**
     * {@inheritDoc}
     */
public WildcardType getWildcardType(Collection<ReferenceType> upperBounds, Collection<ReferenceType> lowerBounds) {
    BoundKind kind;
    Type bound;
    int uppers = upperBounds.size();
    int downers = lowerBounds.size();
    if (uppers + downers > 1) {
        throw new IllegalArgumentException("Multiple bounds not allowed");
    } else if (uppers + downers == 0) {
        kind = BoundKind.UNBOUND;
        bound = env.symtab.objectType;
    } else if (uppers == 1) {
        assert downers == 0;
        kind = BoundKind.EXTENDS;
        bound = ((TypeMirrorImpl) upperBounds.iterator().next()).type;
    } else {
        assert uppers == 0 && downers == 1;
        kind = BoundKind.SUPER;
        bound = ((TypeMirrorImpl) lowerBounds.iterator().next()).type;
    }
    if (bound instanceof Type.WildcardType)
        throw new IllegalArgumentException(bound.toString());
    return (WildcardType) env.typeMaker.getType(new Type.WildcardType(bound, kind, env.symtab.boundClass));
}
Also used : Type(com.sun.tools.javac.code.Type) BoundKind(com.sun.tools.javac.code.BoundKind)

Aggregations

BoundKind (com.sun.tools.javac.code.BoundKind)1 Type (com.sun.tools.javac.code.Type)1