Java Code Examples for com.sun.tools.javac.code.Type#isParameterized()
The following examples show how to use
com.sun.tools.javac.code.Type#isParameterized() .
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: Infer.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
private List<Pair<Type, Type>> getParameterizedSupers(Type t, Type s) { Type lubResult = types.lub(t, s); if (lubResult == syms.errType || lubResult == syms.botType) { return List.nil(); } List<Type> supertypesToCheck = lubResult.isIntersection() ? ((IntersectionClassType)lubResult).getComponents() : List.of(lubResult); ListBuffer<Pair<Type, Type>> commonSupertypes = new ListBuffer<>(); for (Type sup : supertypesToCheck) { if (sup.isParameterized()) { Type asSuperOfT = asSuper(t, sup); Type asSuperOfS = asSuper(s, sup); commonSupertypes.add(new Pair<>(asSuperOfT, asSuperOfS)); } } return commonSupertypes.toList(); }
Example 2
Source File: Check.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** Check that type is a class or interface type. * @param pos Position to be used for error reporting. * @param t The type to be checked. * @param noBounds True if type bounds are illegal here. */ Type checkClassType(DiagnosticPosition pos, Type t, boolean noBounds) { t = checkClassType(pos, t); if (noBounds && t.isParameterized()) { List<Type> args = t.getTypeArguments(); while (args.nonEmpty()) { if (args.head.hasTag(WILDCARD)) return typeTagError(pos, diags.fragment(Fragments.TypeReqExact), args.head); args = args.tail; } } return t; }
Example 3
Source File: ASTPathCriterion.java From annotation-tools with MIT License | 4 votes |
private boolean checkReceiverType(int i, Type t) { if (t == null) { return false; } while (++i < astPath.size()) { ASTPath.ASTEntry entry = astPath.get(i); switch (entry.getTreeKind()) { case ANNOTATED_TYPE: break; case ARRAY_TYPE: if (t.getKind() != TypeKind.ARRAY) { return false; } t = ((Type.ArrayType) t).getComponentType(); break; case MEMBER_SELECT: // TODO break; case PARAMETERIZED_TYPE: if (entry.childSelectorIs(ASTPath.TYPE_PARAMETER)) { if (!t.isParameterized()) { return false; } List<Type> args = t.getTypeArguments(); int a = entry.getArgument(); if (a >= args.size()) { return false; } t = args.get(a); } // else TYPE -- stay? break; case TYPE_PARAMETER: if (t.getKind() != TypeKind.WILDCARD) { return false; } t = t.getLowerBound(); break; case EXTENDS_WILDCARD: if (t.getKind() != TypeKind.WILDCARD) { return false; } t = ((Type.WildcardType) t).getExtendsBound(); break; case SUPER_WILDCARD: if (t.getKind() != TypeKind.WILDCARD) { return false; } t = ((Type.WildcardType) t).getSuperBound(); break; case UNBOUNDED_WILDCARD: if (t.getKind() != TypeKind.WILDCARD) { return false; } t = t.getLowerBound(); break; default: return false; } if (t == null) { return false; } } return true; }