Java Code Examples for com.sun.tools.javac.code.Type#TypeVar
The following examples show how to use
com.sun.tools.javac.code.Type#TypeVar .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SourceUtils.java From netbeans with Apache License 2.0 | 5 votes |
public static TypeMirror getBound(WildcardType wildcardType) { Type.TypeVar bound = ((Type.WildcardType)wildcardType).bound; try { return bound != null ? bound.bound : null; } catch (NoSuchFieldError err) { return bound != null ? bound.getUpperBound() : null; } }
Example 2
Source File: StructuralTypeEraser.java From manifold with Apache License 2.0 | 5 votes |
@Override public Type visitTypeVar( Type.TypeVar t, Void s ) { Type bound = eraseBound( t, t.getUpperBound() ); Type lower = eraseBound( t, t.lower ); if( bound == t.getUpperBound() && lower == t.lower ) { return t; } return new Type.TypeVar( t.tsym, bound, lower ); }
Example 3
Source File: JavacBinder.java From manifold with Apache License 2.0 | 5 votes |
private Type resolveGenericReturnType( Type argType, Type.ForAll forAll ) { Type.MethodType mt = forAll.asMethodType(); Type paramType = mt.getParameterTypes().get( 0 ); paramType = paramType instanceof Type.TypeVar ? paramType.getUpperBound() : paramType; Type parameterizedParamType = _types.asSuper( argType, paramType.tsym ); Map<Type.TypeVar, Type> map = new HashMap<>(); fetchTypeVars( paramType, parameterizedParamType, map ); return _types.subst( mt.getReturnType(), List.from( map.keySet() ), List.from( map.keySet().stream().map( k -> map.get( k ) ).collect( Collectors.toList() ) ) ); }
Example 4
Source File: ManAttr.java From manifold with Apache License 2.0 | 5 votes |
static Symbol.MethodSymbol resolveNegationMethod( Types types, Tag tag, Type expr ) { if( expr instanceof Type.TypeVar ) { expr = types.erasure( expr ); } if( !(expr.tsym instanceof Symbol.ClassSymbol) ) { return null; } return getMethodSymbol( types, expr, null, UNARY_MINUS, (Symbol.ClassSymbol)expr.tsym, 0 ); }
Example 5
Source File: ManAttr.java From manifold with Apache License 2.0 | 5 votes |
static Symbol.MethodSymbol resolveOperatorMethod( Types types, Tag tag, Type left, Type right ) { String opName = BINARY_OP_TO_NAME.get( tag ); if( opName == null ) { if( isComparableOperator( tag ) ) { opName = COMPARE_TO_USING; } else { return null; } } if( left instanceof Type.TypeVar ) { left = types.erasure( left ); } if( !(left.tsym instanceof Symbol.ClassSymbol) ) { return null; } int paramCount = opName.equals( COMPARE_TO_USING ) ? 2 : 1; Symbol.MethodSymbol methodSymbol = getMethodSymbol( types, left, right, opName, (Symbol.ClassSymbol)left.tsym, paramCount ); if( methodSymbol == null && paramCount == 2 && !left.isPrimitive() && isRelationalOperator( tag ) ) { // Support > >= < <= on any Comparable implementor methodSymbol = getMethodSymbol( types, left, right, COMPARE_TO, (Symbol.ClassSymbol)left.tsym, 1 ); } return methodSymbol; }
Example 6
Source File: ManAttr.java From manifold with Apache License 2.0 | 5 votes |
static boolean isAssignableWithGenerics( Types types, Type t1, Type t2 ) { if( t2 instanceof Type.TypeVar ) { Type parameterizedParamType = types.asSuper( t1, t2.getUpperBound().tsym ); return parameterizedParamType != null; } return false; }
Example 7
Source File: JNIWriter.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public R visitTypeVar(Type.TypeVar t, P p) { return defaultAction(t, p); }
Example 8
Source File: JNIWriter.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public R visitTypeVar(Type.TypeVar t, P p) { return defaultAction(t, p); }
Example 9
Source File: JavacBinder.java From manifold with Apache License 2.0 | 4 votes |
private void fetchTypeVars( Type t, Type pt, Map<Type.TypeVar, Type> map ) { new TypeVarFether( map ).visit( t, pt ); }
Example 10
Source File: JavacBinder.java From manifold with Apache License 2.0 | 4 votes |
TypeVarFether( Map<Type.TypeVar, Type> map ) { _map = map; }
Example 11
Source File: JavacBinder.java From manifold with Apache License 2.0 | 4 votes |
@Override public Void visitTypeVar( Type.TypeVar t, Type pt ) { _map.put( t, pt ); return null; }