Search in sources :

Example 1 with NamedArgument

use of org.eclipse.ceylon.compiler.typechecker.tree.Tree.NamedArgument in project ceylon by eclipse.

the class TypeArgumentInference method inferTypeArgumentFromNamedArgs.

private Type inferTypeArgumentFromNamedArgs(TypeParameter tp, ParameterList parameters, Type qt, Tree.NamedArgumentList nal, Declaration invoked) {
    boolean findingUpperBounds = isEffectivelyContravariant(tp, invoked, specifiedParameters(nal, parameters), false);
    List<NamedArgument> namedArgs = nal.getNamedArguments();
    Set<Parameter> foundParameters = new HashSet<Parameter>();
    List<Type> inferredTypes = new ArrayList<Type>(namedArgs.size());
    for (Tree.NamedArgument arg : namedArgs) {
        inferTypeArgFromNamedArg(arg, tp, qt, parameters, findingUpperBounds, inferredTypes, invoked, foundParameters);
    }
    Parameter sp = getUnspecifiedParameter(null, parameters, foundParameters);
    if (sp != null) {
        Tree.SequencedArgument sarg = nal.getSequencedArgument();
        inferTypeArgFromSequencedArg(sarg, tp, sp, findingUpperBounds, inferredTypes, sarg);
    }
    return unionOrIntersection(findingUpperBounds, inferredTypes);
}
Also used : Type(org.eclipse.ceylon.model.typechecker.model.Type) ModelUtil.intersectionType(org.eclipse.ceylon.model.typechecker.model.ModelUtil.intersectionType) ModelUtil.appliedType(org.eclipse.ceylon.model.typechecker.model.ModelUtil.appliedType) AnalyzerUtil.spreadType(org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.spreadType) AnalyzerUtil.getTupleType(org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.getTupleType) NamedArgument(org.eclipse.ceylon.compiler.typechecker.tree.Tree.NamedArgument) ArrayList(java.util.ArrayList) AnalyzerUtil.getUnspecifiedParameter(org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.getUnspecifiedParameter) Parameter(org.eclipse.ceylon.model.typechecker.model.Parameter) TypeParameter(org.eclipse.ceylon.model.typechecker.model.TypeParameter) AnalyzerUtil.getMatchingParameter(org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.getMatchingParameter) Tree(org.eclipse.ceylon.compiler.typechecker.tree.Tree) NamedArgument(org.eclipse.ceylon.compiler.typechecker.tree.Tree.NamedArgument) HashSet(java.util.HashSet)

Aggregations

ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 AnalyzerUtil.getMatchingParameter (org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.getMatchingParameter)1 AnalyzerUtil.getTupleType (org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.getTupleType)1 AnalyzerUtil.getUnspecifiedParameter (org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.getUnspecifiedParameter)1 AnalyzerUtil.spreadType (org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.spreadType)1 Tree (org.eclipse.ceylon.compiler.typechecker.tree.Tree)1 NamedArgument (org.eclipse.ceylon.compiler.typechecker.tree.Tree.NamedArgument)1 ModelUtil.appliedType (org.eclipse.ceylon.model.typechecker.model.ModelUtil.appliedType)1 ModelUtil.intersectionType (org.eclipse.ceylon.model.typechecker.model.ModelUtil.intersectionType)1 Parameter (org.eclipse.ceylon.model.typechecker.model.Parameter)1 Type (org.eclipse.ceylon.model.typechecker.model.Type)1 TypeParameter (org.eclipse.ceylon.model.typechecker.model.TypeParameter)1