Java Code Examples for com.sun.tools.javac.util.List#length()

The following examples show how to use com.sun.tools.javac.util.List#length() . 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: Flow.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
void checkCaughtType(DiagnosticPosition pos, Type exc, List<Type> thrownInTry, List<Type> caughtInTry) {
    if (chk.subset(exc, caughtInTry)) {
        log.error(pos, Errors.ExceptAlreadyCaught(exc));
    } else if (!chk.isUnchecked(pos, exc) &&
            !isExceptionOrThrowable(exc) &&
            !chk.intersects(exc, thrownInTry)) {
        log.error(pos, Errors.ExceptNeverThrownInTry(exc));
    } else if (allowImprovedCatchAnalysis) {
        List<Type> catchableThrownTypes = chk.intersect(List.of(exc), thrownInTry);
        // 'catchableThrownTypes' cannnot possibly be empty - if 'exc' was an
        // unchecked exception, the result list would not be empty, as the augmented
        // thrown set includes { RuntimeException, Error }; if 'exc' was a checked
        // exception, that would have been covered in the branch above
        if (chk.diff(catchableThrownTypes, caughtInTry).isEmpty() &&
                !isExceptionOrThrowable(exc)) {
            String key = catchableThrownTypes.length() == 1 ?
                    "unreachable.catch" :
                    "unreachable.catch.1";
            log.warning(pos, key, catchableThrownTypes);
        }
    }
}
 
Example 2
Source File: ClassDocImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private boolean hasParameterTypes(MethodSymbol method, String[] argTypes) {

        if (argTypes == null) {
            // wildcard
            return true;
        }

        int i = 0;
        List<Type> types = method.type.getParameterTypes();

        if (argTypes.length != types.length()) {
            return false;
        }

        for (Type t : types) {
            String argType = argTypes[i++];
            // For vararg method, "T..." matches type T[].
            if (i == argTypes.length) {
                argType = argType.replace("...", "[]");
            }
            if (!hasTypeName(env.types.erasure(t), argType)) {  //###(gj)
                return false;
            }
        }
        return true;
    }
 
Example 3
Source File: AnnotationDescImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns this annotation's elements and their values.
 * Only those explicitly present in the annotation are
 * included, not those assuming their default values.
 * Returns an empty array if there are none.
 */
public ElementValuePair[] elementValues() {
    List<Pair<MethodSymbol,Attribute>> vals = annotation.values;
    ElementValuePair res[] = new ElementValuePair[vals.length()];
    int i = 0;
    for (Pair<MethodSymbol,Attribute> val : vals) {
        res[i++] = new ElementValuePairImpl(env, val.fst, val.snd);
    }
    return res;
}
 
Example 4
Source File: ExecutableMemberDocImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get argument information.
 *
 * @see ParameterImpl
 *
 * @return an array of ParameterImpl, one element per argument
 * in the order the arguments are present.
 */
public Parameter[] parameters() {
    // generate the parameters on the fly:  they're not cached
    List<VarSymbol> params = sym.params();
    Parameter result[] = new Parameter[params.length()];

    int i = 0;
    for (VarSymbol param : params) {
        result[i++] = new ParameterImpl(env, param);
    }
    return result;
}
 
Example 5
Source File: Infer.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the graph nodes. First a simple node is created for every inference
 * variables to be solved. Then Tarjan is used to found all connected components
 * in the graph. For each component containing more than one node, a super node is
 * created, effectively replacing the original cyclic nodes.
 */
void initNodes(Map<Type, Set<Type>> stuckDeps) {
    //add nodes
    nodes = new ArrayList<Node>();
    for (Type t : inferenceContext.restvars()) {
        nodes.add(new Node(t));
    }
    //add dependencies
    for (Node n_i : nodes) {
        Type i = n_i.data.first();
        Set<Type> optDepsByNode = stuckDeps.get(i);
        for (Node n_j : nodes) {
            Type j = n_j.data.first();
            UndetVar uv_i = (UndetVar)inferenceContext.asUndetVar(i);
            if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) {
                //update i's bound dependencies
                n_i.addDependency(DependencyKind.BOUND, n_j);
            }
            if (optDepsByNode != null && optDepsByNode.contains(j)) {
                //update i's stuck dependencies
                n_i.addDependency(DependencyKind.STUCK, n_j);
            }
        }
    }
    //merge cyclic nodes
    ArrayList<Node> acyclicNodes = new ArrayList<Node>();
    for (List<? extends Node> conSubGraph : GraphUtils.tarjan(nodes)) {
        if (conSubGraph.length() > 1) {
            Node root = conSubGraph.head;
            root.mergeWith(conSubGraph.tail);
            for (Node n : conSubGraph) {
                notifyUpdate(n, root);
            }
        }
        acyclicNodes.add(conSubGraph.head);
    }
    nodes = acyclicNodes;
}
 
Example 6
Source File: Start.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * indicate an option with the specified list of arguments was given.
 */
private void setOption(String opt, List<String> arguments) {
    String[] args = new String[arguments.length() + 1];
    int k = 0;
    args[k++] = opt;
    for (List<String> i = arguments; i.nonEmpty(); i=i.tail) {
        args[k++] = i.head;
    }
    options.append(args);
}
 
Example 7
Source File: Start.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * indicate an option with the specified list of arguments was given.
 */
private void setOption(String opt, List<String> arguments) {
    String[] args = new String[arguments.length() + 1];
    int k = 0;
    args[k++] = opt;
    for (List<String> i = arguments; i.nonEmpty(); i=i.tail) {
        args[k++] = i.head;
    }
    options.append(args);
}
 
Example 8
Source File: ExecutableMemberDocImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get argument information.
 *
 * @see ParameterImpl
 *
 * @return an array of ParameterImpl, one element per argument
 * in the order the arguments are present.
 */
public Parameter[] parameters() {
    // generate the parameters on the fly:  they're not cached
    List<VarSymbol> params = sym.params();
    Parameter result[] = new Parameter[params.length()];

    int i = 0;
    for (VarSymbol param : params) {
        result[i++] = new ParameterImpl(env, param);
    }
    return result;
}
 
Example 9
Source File: ExecutableMemberDocImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get argument information.
 *
 * @see ParameterImpl
 *
 * @return an array of ParameterImpl, one element per argument
 * in the order the arguments are present.
 */
public Parameter[] parameters() {
    // generate the parameters on the fly:  they're not cached
    List<VarSymbol> params = sym.params();
    Parameter result[] = new Parameter[params.length()];

    int i = 0;
    for (VarSymbol param : params) {
        result[i++] = new ParameterImpl(env, param);
    }
    return result;
}
 
Example 10
Source File: TypeVariableImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the annotations of this program element.
 * Return an empty array if there are none.
 */
public AnnotationDesc[] annotations() {
    if (!type.isAnnotated()) {
        return new AnnotationDesc[0];
    }
    List<? extends TypeCompound> tas = type.getAnnotationMirrors();
    AnnotationDesc res[] = new AnnotationDesc[tas.length()];
    int i = 0;
    for (Attribute.Compound a : tas) {
        res[i++] = new AnnotationDescImpl(env, a);
    }
    return res;
}
 
Example 11
Source File: Infer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the graph nodes. First a simple node is created for every inference
 * variables to be solved. Then Tarjan is used to found all connected components
 * in the graph. For each component containing more than one node, a super node is
 * created, effectively replacing the original cyclic nodes.
 */
void initNodes() {
    //add nodes
    nodes = new ArrayList<>();
    for (Type t : inferenceContext.restvars()) {
        nodes.add(new Node(t));
    }
    //add dependencies
    for (Node n_i : nodes) {
        Type i = n_i.data.first();
        for (Node n_j : nodes) {
            Type j = n_j.data.first();
            UndetVar uv_i = (UndetVar)inferenceContext.asUndetVar(i);
            if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) {
                //update i's bound dependencies
                n_i.addDependency(n_j);
            }
        }
    }
    //merge cyclic nodes
    ArrayList<Node> acyclicNodes = new ArrayList<>();
    for (List<? extends Node> conSubGraph : GraphUtils.tarjan(nodes)) {
        if (conSubGraph.length() > 1) {
            Node root = conSubGraph.head;
            root.mergeWith(conSubGraph.tail);
            for (Node n : conSubGraph) {
                notifyUpdate(n, root);
            }
        }
        acyclicNodes.add(conSubGraph.head);
    }
    nodes = acyclicNodes;
}
 
Example 12
Source File: Infer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the graph nodes. First a simple node is created for every inference
 * variables to be solved. Then Tarjan is used to found all connected components
 * in the graph. For each component containing more than one node, a super node is
 * created, effectively replacing the original cyclic nodes.
 */
void initNodes(Map<Type, Set<Type>> stuckDeps) {
    //add nodes
    nodes = new ArrayList<Node>();
    for (Type t : inferenceContext.restvars()) {
        nodes.add(new Node(t));
    }
    //add dependencies
    for (Node n_i : nodes) {
        Type i = n_i.data.first();
        Set<Type> optDepsByNode = stuckDeps.get(i);
        for (Node n_j : nodes) {
            Type j = n_j.data.first();
            UndetVar uv_i = (UndetVar)inferenceContext.asUndetVar(i);
            if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) {
                //update i's bound dependencies
                n_i.addDependency(DependencyKind.BOUND, n_j);
            }
            if (optDepsByNode != null && optDepsByNode.contains(j)) {
                //update i's stuck dependencies
                n_i.addDependency(DependencyKind.STUCK, n_j);
            }
        }
    }
    //merge cyclic nodes
    ArrayList<Node> acyclicNodes = new ArrayList<Node>();
    for (List<? extends Node> conSubGraph : GraphUtils.tarjan(nodes)) {
        if (conSubGraph.length() > 1) {
            Node root = conSubGraph.head;
            root.mergeWith(conSubGraph.tail);
            for (Node n : conSubGraph) {
                notifyUpdate(n, root);
            }
        }
        acyclicNodes.add(conSubGraph.head);
    }
    nodes = acyclicNodes;
}
 
Example 13
Source File: Gen.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/** Derived visitor method: check whether CharacterRangeTable
 *  should be emitted, if so, put a new entry into CRTable
 *  and call method to generate bytecode.
 *  If not, just call method to generate bytecode.
 *  @see    #genStats(List, Env)
 *
 *  @param  trees    The list of trees to be visited.
 *  @param  env      The environment to use.
 *  @param  crtFlags The CharacterRangeTable flags
 *                   indicating type of the entry.
 */
public void genStats(List<JCStatement> trees, Env<GenContext> env, int crtFlags) {
    if (!genCrt) {
        genStats(trees, env);
        return;
    }
    if (trees.length() == 1) {        // mark one statement with the flags
        genStat(trees.head, env, crtFlags | CRT_STATEMENT);
    } else {
        int startpc = code.curCP();
        genStats(trees, env);
        code.crt.put(trees, crtFlags, startpc, code.curCP());
    }
}
 
Example 14
Source File: Gen.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/** Derived visitor method: check whether CharacterRangeTable
 *  should be emitted, if so, put a new entry into CRTable
 *  and call method to generate bytecode.
 *  If not, just call method to generate bytecode.
 *  @see    #genStats(List, Env)
 *
 *  @param  trees    The list of trees to be visited.
 *  @param  env      The environment to use.
 *  @param  crtFlags The CharacterRangeTable flags
 *                   indicating type of the entry.
 */
public void genStats(List<JCStatement> trees, Env<GenContext> env, int crtFlags) {
    if (!genCrt) {
        genStats(trees, env);
        return;
    }
    if (trees.length() == 1) {        // mark one statement with the flags
        genStat(trees.head, env, crtFlags | CRT_STATEMENT);
    } else {
        int startpc = code.curCP();
        genStats(trees, env);
        code.crt.put(trees, crtFlags, startpc, code.curCP());
    }
}
 
Example 15
Source File: ExecutableMemberDocImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get argument information.
 *
 * @see ParameterImpl
 *
 * @return an array of ParameterImpl, one element per argument
 * in the order the arguments are present.
 */
public Parameter[] parameters() {
    // generate the parameters on the fly:  they're not cached
    List<VarSymbol> params = sym.params();
    Parameter result[] = new Parameter[params.length()];

    int i = 0;
    for (VarSymbol param : params) {
        result[i++] = new ParameterImpl(env, param);
    }
    return result;
}
 
Example 16
Source File: Start.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * indicate an option with the specified list of arguments was given.
 */
private void setOption(String opt, List<String> arguments) {
    String[] args = new String[arguments.length() + 1];
    int k = 0;
    args[k++] = opt;
    for (List<String> i = arguments; i.nonEmpty(); i=i.tail) {
        args[k++] = i.head;
    }
    options.append(args);
}
 
Example 17
Source File: Infer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the graph nodes. First a simple node is created for every inference
 * variables to be solved. Then Tarjan is used to found all connected components
 * in the graph. For each component containing more than one node, a super node is
 * created, effectively replacing the original cyclic nodes.
 */
void initNodes(Map<Type, Set<Type>> stuckDeps) {
    //add nodes
    nodes = new ArrayList<Node>();
    for (Type t : inferenceContext.restvars()) {
        nodes.add(new Node(t));
    }
    //add dependencies
    for (Node n_i : nodes) {
        Type i = n_i.data.first();
        Set<Type> optDepsByNode = stuckDeps.get(i);
        for (Node n_j : nodes) {
            Type j = n_j.data.first();
            UndetVar uv_i = (UndetVar)inferenceContext.asUndetVar(i);
            if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) {
                //update i's bound dependencies
                n_i.addDependency(DependencyKind.BOUND, n_j);
            }
            if (optDepsByNode != null && optDepsByNode.contains(j)) {
                //update i's stuck dependencies
                n_i.addDependency(DependencyKind.STUCK, n_j);
            }
        }
    }
    //merge cyclic nodes
    ArrayList<Node> acyclicNodes = new ArrayList<Node>();
    for (List<? extends Node> conSubGraph : GraphUtils.tarjan(nodes)) {
        if (conSubGraph.length() > 1) {
            Node root = conSubGraph.head;
            root.mergeWith(conSubGraph.tail);
            for (Node n : conSubGraph) {
                notifyUpdate(n, root);
            }
        }
        acyclicNodes.add(conSubGraph.head);
    }
    nodes = acyclicNodes;
}
 
Example 18
Source File: JavacResolution.java    From EasyMPermission with MIT License 4 votes vote down vote up
private static JCExpression typeToJCTree0(Type type, JavacAST ast, boolean allowCompound, boolean allowVoid) throws TypeNotConvertibleException {
	// NB: There's such a thing as maker.Type(type), but this doesn't work very well; it screws up anonymous classes, captures, and adds an extra prefix dot for some reason too.
	//  -- so we write our own take on that here.
	
	JavacTreeMaker maker = ast.getTreeMaker();
	
	if (CTC_BOT.equals(typeTag(type))) return createJavaLangObject(ast);
	if (CTC_VOID.equals(typeTag(type))) return allowVoid ? primitiveToJCTree(type.getKind(), maker) : createJavaLangObject(ast);
	if (type.isPrimitive()) return primitiveToJCTree(type.getKind(), maker);
	if (type.isErroneous()) throw new TypeNotConvertibleException("Type cannot be resolved");
	
	TypeSymbol symbol = type.asElement();
	List<Type> generics = type.getTypeArguments();
	
	JCExpression replacement = null;
	
	if (symbol == null) throw new TypeNotConvertibleException("Null or compound type");
	
	if (symbol.name.length() == 0) {
		// Anonymous inner class
		if (type instanceof ClassType) {
			List<Type> ifaces = ((ClassType) type).interfaces_field;
			Type supertype = ((ClassType) type).supertype_field;
			if (ifaces != null && ifaces.length() == 1) {
				return typeToJCTree(ifaces.get(0), ast, allowCompound, allowVoid);
			}
			if (supertype != null) return typeToJCTree(supertype, ast, allowCompound, allowVoid);
		}
		throw new TypeNotConvertibleException("Anonymous inner class");
	}
	
	if (type instanceof CapturedType || type instanceof WildcardType) {
		Type lower, upper;
		if (type instanceof WildcardType) {
			upper = ((WildcardType)type).getExtendsBound();
			lower = ((WildcardType)type).getSuperBound();
		} else {
			lower = type.getLowerBound();
			upper = type.getUpperBound();
		}
		if (allowCompound) {
			if (lower == null || CTC_BOT.equals(typeTag(lower))) {
				if (upper == null || upper.toString().equals("java.lang.Object")) {
					return maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null);
				}
				if (upper.getTypeArguments().contains(type)) {
					return maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null);
				}
				return maker.Wildcard(maker.TypeBoundKind(BoundKind.EXTENDS), typeToJCTree(upper, ast, false, false));
			} else {
				return maker.Wildcard(maker.TypeBoundKind(BoundKind.SUPER), typeToJCTree(lower, ast, false, false));
			}
		}
		if (upper != null) {
			if (upper.getTypeArguments().contains(type)) {
				return maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null);
			}
			return typeToJCTree(upper, ast, allowCompound, allowVoid);
		}
		
		return createJavaLangObject(ast);
	}
	
	String qName;
	if (symbol.isLocal()) {
		qName = symbol.getSimpleName().toString();
	} else if (symbol.type != null && symbol.type.getEnclosingType() != null && typeTag(symbol.type.getEnclosingType()).equals(typeTag("CLASS"))) {
		replacement = typeToJCTree0(type.getEnclosingType(), ast, false, false);
		qName = symbol.getSimpleName().toString();
	} else {
		qName = symbol.getQualifiedName().toString();
	}
	
	if (qName.isEmpty()) throw new TypeNotConvertibleException("unknown type");
	if (qName.startsWith("<")) throw new TypeNotConvertibleException(qName);
	String[] baseNames = qName.split("\\.");
	int i = 0;
	
	if (replacement == null) {
		replacement = maker.Ident(ast.toName(baseNames[0]));
		i = 1;
	}
	for (; i < baseNames.length; i++) {
		replacement = maker.Select(replacement, ast.toName(baseNames[i]));
	}
	
	return genericsToJCTreeNodes(generics, ast, replacement);
}
 
Example 19
Source File: Check.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
  * Report warnings for potentially ambiguous method declarations. Two declarations
  * are potentially ambiguous if they feature two unrelated functional interface
  * in same argument position (in which case, a call site passing an implicit
  * lambda would be ambiguous).
  */
void checkPotentiallyAmbiguousOverloads(DiagnosticPosition pos, Type site,
        MethodSymbol msym1, MethodSymbol msym2) {
    if (msym1 != msym2 &&
            allowDefaultMethods &&
            lint.isEnabled(LintCategory.OVERLOADS) &&
            (msym1.flags() & POTENTIALLY_AMBIGUOUS) == 0 &&
            (msym2.flags() & POTENTIALLY_AMBIGUOUS) == 0) {
        Type mt1 = types.memberType(site, msym1);
        Type mt2 = types.memberType(site, msym2);
        //if both generic methods, adjust type variables
        if (mt1.hasTag(FORALL) && mt2.hasTag(FORALL) &&
                types.hasSameBounds((ForAll)mt1, (ForAll)mt2)) {
            mt2 = types.subst(mt2, ((ForAll)mt2).tvars, ((ForAll)mt1).tvars);
        }
        //expand varargs methods if needed
        int maxLength = Math.max(mt1.getParameterTypes().length(), mt2.getParameterTypes().length());
        List<Type> args1 = rs.adjustArgs(mt1.getParameterTypes(), msym1, maxLength, true);
        List<Type> args2 = rs.adjustArgs(mt2.getParameterTypes(), msym2, maxLength, true);
        //if arities don't match, exit
        if (args1.length() != args2.length()) return;
        boolean potentiallyAmbiguous = false;
        while (args1.nonEmpty() && args2.nonEmpty()) {
            Type s = args1.head;
            Type t = args2.head;
            if (!types.isSubtype(t, s) && !types.isSubtype(s, t)) {
                if (types.isFunctionalInterface(s) && types.isFunctionalInterface(t) &&
                        types.findDescriptorType(s).getParameterTypes().length() > 0 &&
                        types.findDescriptorType(s).getParameterTypes().length() ==
                        types.findDescriptorType(t).getParameterTypes().length()) {
                    potentiallyAmbiguous = true;
                } else {
                    break;
                }
            }
            args1 = args1.tail;
            args2 = args2.tail;
        }
        if (potentiallyAmbiguous) {
            //we found two incompatible functional interfaces with same arity
            //this means a call site passing an implicit lambda would be ambigiuous
            msym1.flags_field |= POTENTIALLY_AMBIGUOUS;
            msym2.flags_field |= POTENTIALLY_AMBIGUOUS;
            log.warning(LintCategory.OVERLOADS, pos, "potentially.ambiguous.overload",
                        msym1, msym1.location(),
                        msym2, msym2.location());
            return;
        }
    }
}
 
Example 20
Source File: Check.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
  * Report warnings for potentially ambiguous method declarations. Two declarations
  * are potentially ambiguous if they feature two unrelated functional interface
  * in same argument position (in which case, a call site passing an implicit
  * lambda would be ambiguous).
  */
void checkPotentiallyAmbiguousOverloads(DiagnosticPosition pos, Type site,
        MethodSymbol msym1, MethodSymbol msym2) {
    if (msym1 != msym2 &&
            allowDefaultMethods &&
            lint.isEnabled(LintCategory.OVERLOADS) &&
            (msym1.flags() & POTENTIALLY_AMBIGUOUS) == 0 &&
            (msym2.flags() & POTENTIALLY_AMBIGUOUS) == 0) {
        Type mt1 = types.memberType(site, msym1);
        Type mt2 = types.memberType(site, msym2);
        //if both generic methods, adjust type variables
        if (mt1.hasTag(FORALL) && mt2.hasTag(FORALL) &&
                types.hasSameBounds((ForAll)mt1, (ForAll)mt2)) {
            mt2 = types.subst(mt2, ((ForAll)mt2).tvars, ((ForAll)mt1).tvars);
        }
        //expand varargs methods if needed
        int maxLength = Math.max(mt1.getParameterTypes().length(), mt2.getParameterTypes().length());
        List<Type> args1 = rs.adjustArgs(mt1.getParameterTypes(), msym1, maxLength, true);
        List<Type> args2 = rs.adjustArgs(mt2.getParameterTypes(), msym2, maxLength, true);
        //if arities don't match, exit
        if (args1.length() != args2.length()) return;
        boolean potentiallyAmbiguous = false;
        while (args1.nonEmpty() && args2.nonEmpty()) {
            Type s = args1.head;
            Type t = args2.head;
            if (!types.isSubtype(t, s) && !types.isSubtype(s, t)) {
                if (types.isFunctionalInterface(s) && types.isFunctionalInterface(t) &&
                        types.findDescriptorType(s).getParameterTypes().length() > 0 &&
                        types.findDescriptorType(s).getParameterTypes().length() ==
                        types.findDescriptorType(t).getParameterTypes().length()) {
                    potentiallyAmbiguous = true;
                } else {
                    break;
                }
            }
            args1 = args1.tail;
            args2 = args2.tail;
        }
        if (potentiallyAmbiguous) {
            //we found two incompatible functional interfaces with same arity
            //this means a call site passing an implicit lambda would be ambigiuous
            msym1.flags_field |= POTENTIALLY_AMBIGUOUS;
            msym2.flags_field |= POTENTIALLY_AMBIGUOUS;
            log.warning(LintCategory.OVERLOADS, pos, "potentially.ambiguous.overload",
                        msym1, msym1.location(),
                        msym2, msym2.location());
            return;
        }
    }
}