Search in sources :

Example 71 with Interface

use of org.eclipse.ceylon.model.typechecker.model.Interface in project ceylon by eclipse.

the class AnnotationVisitor method visit.

@Override
public void visit(Tree.DocLink that) {
    super.visit(that);
    String text = that.getText();
    int pipeIndex = text.indexOf("|");
    if (pipeIndex != -1) {
        text = text.substring(pipeIndex + 1);
    }
    String kind = null;
    if (text.startsWith(DOC_LINK_MODULE)) {
        kind = DOC_LINK_MODULE;
        text = text.substring(DOC_LINK_MODULE.length());
    } else if (text.startsWith(DOC_LINK_PACKAGE)) {
        kind = DOC_LINK_PACKAGE;
        text = text.substring(DOC_LINK_PACKAGE.length());
    } else if (text.startsWith(DOC_LINK_CLASS)) {
        kind = DOC_LINK_CLASS;
        text = text.substring(DOC_LINK_CLASS.length());
    } else if (text.startsWith(DOC_LINK_INTERFACE)) {
        kind = DOC_LINK_INTERFACE;
        text = text.substring(DOC_LINK_INTERFACE.length());
    } else if (text.startsWith(DOC_LINK_FUNCTION)) {
        kind = DOC_LINK_FUNCTION;
        text = text.substring(DOC_LINK_FUNCTION.length());
    } else if (text.startsWith(DOC_LINK_VALUE)) {
        kind = DOC_LINK_VALUE;
        text = text.substring(DOC_LINK_VALUE.length());
    } else if (text.startsWith(DOC_LINK_ALIAS)) {
        kind = DOC_LINK_ALIAS;
        text = text.substring(DOC_LINK_ALIAS.length());
    }
    boolean parentheses = false;
    if (text.endsWith("()")) {
        parentheses = true;
        text = text.substring(0, text.length() - 2);
    }
    int scopeIndex = text.indexOf("::");
    String packageName;
    if (DOC_LINK_MODULE.equals(kind) || DOC_LINK_PACKAGE.equals(kind)) {
        packageName = text;
    } else {
        packageName = scopeIndex < 0 ? null : text.substring(0, scopeIndex);
    }
    String path = scopeIndex < 0 ? text : text.substring(scopeIndex + 2);
    String[] names = path.isEmpty() ? new String[0] : path.split("\\.");
    Declaration base = null;
    if (packageName == null) {
        if (names.length > 0) {
            base = that.getScope().getMemberOrParameter(that.getUnit(), names[0], null, false);
        }
    } else {
        Package pack = that.getUnit().getPackage().getModule().getPackage(packageName);
        if (pack == null) {
            if (DOC_LINK_MODULE.equals(kind)) {
                that.addUsageWarning(Warning.doclink, "module is missing: '" + packageName + "'");
            } else {
                that.addUsageWarning(Warning.doclink, "package is missing: '" + packageName + "'");
            }
        } else {
            that.setPkg(pack);
            if (DOC_LINK_MODULE.equals(kind)) {
                Package rootPack = pack.getModule().getRootPackage();
                if (pack.equals(rootPack)) {
                    that.setModule(pack.getModule());
                } else {
                    that.addUsageWarning(Warning.doclink, "module is missing: '" + packageName + "'");
                }
            }
            if (names.length > 0) {
                base = pack.getDirectMember(names[0], null, false);
            }
        }
        if (DOC_LINK_MODULE.equals(kind) || DOC_LINK_PACKAGE.equals(kind)) {
            return;
        }
    }
    if (base == null) {
        that.addUsageWarning(Warning.doclink, "declaration is missing: '" + (names.length > 0 ? names[0] : text) + "'");
    } else {
        that.setBase(base);
        if (names.length > 1) {
            that.setQualified(new ArrayList<Declaration>(names.length - 1));
        }
        for (int i = 1; i < names.length; i++) {
            if (base instanceof Value) {
                Value value = (Value) base;
                if (!value.isParameter() && !value.isTransient() && value.getTypeDeclaration() != null && value.getTypeDeclaration().isAnonymous()) {
                    base = value.getTypeDeclaration();
                }
            }
            if (base instanceof TypeDeclaration || base instanceof Functional) {
                Declaration qualified = base.getMember(names[i], null, false);
                if (qualified == null) {
                    that.addUsageWarning(Warning.doclink, "member declaration or parameter is missing: '" + names[i] + "'");
                    break;
                } else {
                    that.getQualified().add(qualified);
                    base = qualified;
                }
            } else {
                that.addUsageWarning(Warning.doclink, "not a type or functional declaration: '" + base.getName() + "'");
                break;
            }
        }
    }
    if (base != null) {
        if (kind != null && (names.length == 1 || names.length == that.getQualified().size() + 1)) {
            if (DOC_LINK_CLASS.equals(kind) && !(base instanceof Class)) {
                that.addUsageWarning(Warning.doclink, "linked declaration is not a class: '" + base.getName() + "'");
            } else if (DOC_LINK_INTERFACE.equals(kind) && !(base instanceof Interface)) {
                that.addUsageWarning(Warning.doclink, "linked declaration is not an interface: '" + base.getName() + "'");
            } else if (DOC_LINK_ALIAS.equals(kind) && !(base instanceof TypeAlias)) {
                that.addUsageWarning(Warning.doclink, "linked declaration is not a type alias: '" + base.getName() + "'");
            } else if (DOC_LINK_FUNCTION.equals(kind) && !(base instanceof Function)) {
                that.addUsageWarning(Warning.doclink, "linked declaration is not a function: '" + base.getName() + "'");
            } else if (DOC_LINK_VALUE.equals(kind) && !(base instanceof Value)) {
                that.addUsageWarning(Warning.doclink, "linked declaration is not a value: '" + base.getName() + "'");
            }
        }
        if (parentheses && !(base instanceof Functional)) {
            that.addUsageWarning(Warning.doclink, "linked declaration is not a function: '" + base.getName() + "'");
        }
    }
}
Also used : TypeAlias(org.eclipse.ceylon.model.typechecker.model.TypeAlias) Functional(org.eclipse.ceylon.model.typechecker.model.Functional) Function(org.eclipse.ceylon.model.typechecker.model.Function) FunctionOrValue(org.eclipse.ceylon.model.typechecker.model.FunctionOrValue) Value(org.eclipse.ceylon.model.typechecker.model.Value) Class(org.eclipse.ceylon.model.typechecker.model.Class) TypedDeclaration(org.eclipse.ceylon.model.typechecker.model.TypedDeclaration) TypeDeclaration(org.eclipse.ceylon.model.typechecker.model.TypeDeclaration) Declaration(org.eclipse.ceylon.model.typechecker.model.Declaration) Package(org.eclipse.ceylon.model.typechecker.model.Package) TypeDeclaration(org.eclipse.ceylon.model.typechecker.model.TypeDeclaration) Interface(org.eclipse.ceylon.model.typechecker.model.Interface) ClassOrInterface(org.eclipse.ceylon.model.typechecker.model.ClassOrInterface)

Example 72 with Interface

use of org.eclipse.ceylon.model.typechecker.model.Interface in project ceylon by eclipse.

the class ExpressionVisitor method eraseDefaultedParameters.

private Type eraseDefaultedParameters(Type type) {
    Interface cd = unit.getCallableDeclaration();
    Type callableType = type.getSupertype(cd);
    if (callableType != null) {
        List<Type> typeArgs = callableType.getTypeArgumentList();
        if (typeArgs.size() >= 2) {
            Type rt = typeArgs.get(0);
            Type pts = typeArgs.get(1);
            List<Type> argTypes = unit.getTupleElementTypes(pts);
            boolean variadic = unit.isTupleLengthUnbounded(pts);
            boolean atLeastOne = unit.isTupleVariantAtLeastOne(pts);
            if (variadic) {
                argTypes = new ArrayList<Type>(argTypes);
                Type spt = argTypes.get(argTypes.size() - 1);
                argTypes.set(argTypes.size() - 1, unit.getIteratedType(spt));
            }
            Type tt = unit.getTupleType(argTypes, variadic, atLeastOne, -1);
            return appliedType(cd, rt, tt);
        }
    }
    return type;
}
Also used : ModelUtil.intersectionType(org.eclipse.ceylon.model.typechecker.model.ModelUtil.intersectionType) ModelUtil.unionType(org.eclipse.ceylon.model.typechecker.model.ModelUtil.unionType) AnalyzerUtil.spreadType(org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.spreadType) AnalyzerUtil.getTupleType(org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.getTupleType) Type(org.eclipse.ceylon.model.typechecker.model.Type) UnknownType(org.eclipse.ceylon.model.typechecker.model.UnknownType) ModelUtil.appliedType(org.eclipse.ceylon.model.typechecker.model.ModelUtil.appliedType) ModelUtil.genericFunctionType(org.eclipse.ceylon.model.typechecker.model.ModelUtil.genericFunctionType) Interface(org.eclipse.ceylon.model.typechecker.model.Interface) ClassOrInterface(org.eclipse.ceylon.model.typechecker.model.ClassOrInterface) ModelUtil.getOuterClassOrInterface(org.eclipse.ceylon.model.typechecker.model.ModelUtil.getOuterClassOrInterface) ModelUtil.getContainingClassOrInterface(org.eclipse.ceylon.model.typechecker.model.ModelUtil.getContainingClassOrInterface)

Example 73 with Interface

use of org.eclipse.ceylon.model.typechecker.model.Interface in project ceylon by eclipse.

the class ExpressionVisitor method visit.

@Override
public void visit(Tree.TypeLiteral that) {
    if (that instanceof Tree.InterfaceLiteral || that instanceof Tree.ClassLiteral || that instanceof Tree.NewLiteral || that instanceof Tree.AliasLiteral || that instanceof Tree.TypeParameterLiteral) {
        declarationLiteral = true;
    } else {
        modelLiteral = true;
    }
    try {
        super.visit(that);
    } finally {
        declarationLiteral = false;
        modelLiteral = false;
    }
    Type t;
    TypeDeclaration d;
    Tree.StaticType type = that.getType();
    Node errorNode;
    if (type != null) {
        t = type.getTypeModel();
        d = t.getDeclaration();
        errorNode = type;
    } else {
        errorNode = that;
        ClassOrInterface classOrInterface = getContainingClassOrInterface(that.getScope());
        if (that instanceof Tree.ClassLiteral || that instanceof Tree.InterfaceLiteral) {
            d = classOrInterface;
            if (d == null) {
                errorNode.addError("no containing type");
                // EARLY EXIT!!
                return;
            } else {
                t = classOrInterface.getType();
            }
        } else {
            errorNode.addError("missing type reference");
            // EARLY EXIT!!
            return;
        }
    }
    if (t != null) {
        that.setDeclaration(d);
        that.setWantsDeclaration(true);
        if (that instanceof Tree.ClassLiteral) {
            if (!(d instanceof Class)) {
                if (d != null) {
                    errorNode.addError("referenced declaration is not a class" + getDeclarationReferenceSuggestion(d));
                }
                that.setTypeModel(unit.getClassDeclarationType());
            } else {
                that.setTypeModel(unit.getClassDeclarationType((Class) d));
            }
        } else if (that instanceof Tree.NewLiteral) {
            if (d instanceof Class) {
                Class c = (Class) d;
                Constructor defaultConstructor = c.getDefaultConstructor();
                if (defaultConstructor != null) {
                    d = defaultConstructor;
                }
            }
            if (d instanceof Constructor) {
                Constructor c = (Constructor) d;
                if (c.getParameterList() == null) {
                    that.setTypeModel(unit.getValueConstructorDeclarationType());
                } else {
                    that.setTypeModel(unit.getCallableConstructorDeclarationType());
                }
            } else if (d != null) {
                errorNode.addError("referenced declaration is not a constructor" + getDeclarationReferenceSuggestion(d));
            }
        } else if (that instanceof Tree.InterfaceLiteral) {
            if (!(d instanceof Interface)) {
                if (d != null) {
                    errorNode.addError("referenced declaration is not an interface" + getDeclarationReferenceSuggestion(d));
                }
            }
            that.setTypeModel(unit.getInterfaceDeclarationType());
        } else if (that instanceof Tree.AliasLiteral) {
            if (!(d instanceof TypeAlias)) {
                errorNode.addError("referenced declaration is not a type alias" + getDeclarationReferenceSuggestion(d));
            }
            that.setTypeModel(unit.getAliasDeclarationType());
        } else if (that instanceof Tree.TypeParameterLiteral) {
            if (!(d instanceof TypeParameter)) {
                errorNode.addError("referenced declaration is not a type parameter" + getDeclarationReferenceSuggestion(d));
            }
            that.setTypeModel(unit.getTypeParameterDeclarationType());
        } else if (d != null) {
            that.setWantsDeclaration(false);
            t = t.resolveAliases();
            if (t == null || t.isUnknown()) {
                return;
            }
            // checkNonlocalType(that.getType(), t.getDeclaration());
            if (d instanceof Constructor) {
                if (((Constructor) d).isAbstraction()) {
                    errorNode.addError("constructor is overloaded");
                } else {
                    that.setTypeModel(unit.getConstructorMetatype(t));
                }
            } else if (d instanceof Class) {
                // checkNonlocal(that, t.getDeclaration());
                that.setTypeModel(unit.getClassMetatype(t));
            } else if (d instanceof Interface) {
                that.setTypeModel(unit.getInterfaceMetatype(t));
            } else {
                that.setTypeModel(unit.getTypeMetaType(t));
            }
        }
    }
}
Also used : ClassOrInterface(org.eclipse.ceylon.model.typechecker.model.ClassOrInterface) ModelUtil.getOuterClassOrInterface(org.eclipse.ceylon.model.typechecker.model.ModelUtil.getOuterClassOrInterface) ModelUtil.getContainingClassOrInterface(org.eclipse.ceylon.model.typechecker.model.ModelUtil.getContainingClassOrInterface) TypeParameter(org.eclipse.ceylon.model.typechecker.model.TypeParameter) Constructor(org.eclipse.ceylon.model.typechecker.model.Constructor) AnalyzerUtil.unwrapAliasedTypeConstructor(org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.unwrapAliasedTypeConstructor) ModelUtil.isConstructor(org.eclipse.ceylon.model.typechecker.model.ModelUtil.isConstructor) Node(org.eclipse.ceylon.compiler.typechecker.tree.Node) TypeAlias(org.eclipse.ceylon.model.typechecker.model.TypeAlias) ModelUtil.intersectionType(org.eclipse.ceylon.model.typechecker.model.ModelUtil.intersectionType) ModelUtil.unionType(org.eclipse.ceylon.model.typechecker.model.ModelUtil.unionType) AnalyzerUtil.spreadType(org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.spreadType) AnalyzerUtil.getTupleType(org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.getTupleType) Type(org.eclipse.ceylon.model.typechecker.model.Type) UnknownType(org.eclipse.ceylon.model.typechecker.model.UnknownType) ModelUtil.appliedType(org.eclipse.ceylon.model.typechecker.model.ModelUtil.appliedType) ModelUtil.genericFunctionType(org.eclipse.ceylon.model.typechecker.model.ModelUtil.genericFunctionType) CustomTree(org.eclipse.ceylon.compiler.typechecker.tree.CustomTree) Tree(org.eclipse.ceylon.compiler.typechecker.tree.Tree) ModelUtil.findMatchingOverloadedClass(org.eclipse.ceylon.model.typechecker.model.ModelUtil.findMatchingOverloadedClass) Class(org.eclipse.ceylon.model.typechecker.model.Class) AnalyzerUtil.getPackageTypeDeclaration(org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.getPackageTypeDeclaration) TypeDeclaration(org.eclipse.ceylon.model.typechecker.model.TypeDeclaration) AnalyzerUtil.getTypeDeclaration(org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.getTypeDeclaration) Interface(org.eclipse.ceylon.model.typechecker.model.Interface) ClassOrInterface(org.eclipse.ceylon.model.typechecker.model.ClassOrInterface) ModelUtil.getOuterClassOrInterface(org.eclipse.ceylon.model.typechecker.model.ModelUtil.getOuterClassOrInterface) ModelUtil.getContainingClassOrInterface(org.eclipse.ceylon.model.typechecker.model.ModelUtil.getContainingClassOrInterface)

Example 74 with Interface

use of org.eclipse.ceylon.model.typechecker.model.Interface in project ceylon by eclipse.

the class TypeParserTests method testPossiblyEmptyIterableAbbrev.

@Test
public void testPossiblyEmptyIterableAbbrev() {
    Type type = new TypeParser(MockLoader.instance).decodeType("{a*}", null, mockDefaultModule, mockPkgUnit);
    Assert.assertNotNull(type);
    TypeDeclaration declaration = type.getDeclaration();
    Assert.assertNotNull(declaration);
    Assert.assertTrue(declaration instanceof Interface);
    Assert.assertEquals("ceylon.language::Iterable", declaration.getQualifiedNameString());
    Assert.assertEquals("{a*}", type.asString());
    Assert.assertNull(type.getQualifyingType());
}
Also used : Type(org.eclipse.ceylon.model.typechecker.model.Type) IntersectionType(org.eclipse.ceylon.model.typechecker.model.IntersectionType) UnionType(org.eclipse.ceylon.model.typechecker.model.UnionType) TypeParser(org.eclipse.ceylon.model.loader.TypeParser) TypeDeclaration(org.eclipse.ceylon.model.typechecker.model.TypeDeclaration) Interface(org.eclipse.ceylon.model.typechecker.model.Interface) ClassOrInterface(org.eclipse.ceylon.model.typechecker.model.ClassOrInterface) Test(org.junit.Test)

Example 75 with Interface

use of org.eclipse.ceylon.model.typechecker.model.Interface in project ceylon by eclipse.

the class InvocationGenerator method positionalInvocation.

private void positionalInvocation(final Tree.InvocationExpression that) {
    final Tree.Primary typeArgSource = that.getPrimary();
    final Tree.PositionalArgumentList argList = that.getPositionalArgumentList();
    final Map<TypeParameter, Type> targs = getTypeArguments(typeArgSource);
    if (gen.isInDynamicBlock() && typeArgSource instanceof Tree.BaseTypeExpression && ((Tree.BaseTypeExpression) typeArgSource).getDeclaration() == null) {
        gen.out("(");
        // Could be a dynamic object, or a Ceylon one
        // We might need to call "new" so we need to get all the args to pass directly later
        final List<String> argnames = generatePositionalArguments(typeArgSource, argList, argList.getPositionalArguments(), false, true);
        if (!argnames.isEmpty()) {
            gen.out(",");
        }
        final String fname = names.createTempVariable();
        gen.out(fname, "=");
        typeArgSource.visit(gen);
        String theargs = "";
        if (!argnames.isEmpty()) {
            theargs = argnames.toString().substring(1);
            theargs = theargs.substring(0, theargs.length() - 1);
        }
        gen.out(",", fname, ".$$===undefined?new ", fname, "(", theargs, "):", fname, "(", theargs, "))");
        // TODO we lose type args for now
        return;
    } else {
        final Tree.PositionalArgument lastArg = argList.getPositionalArguments().isEmpty() ? null : argList.getPositionalArguments().get(argList.getPositionalArguments().size() - 1);
        boolean hasSpread = lastArg instanceof Tree.SpreadArgument && that.getUnit().isUnknownArgumentsCallable(that.getPrimary().getTypeModel()) && !typeArgSource.getTypeModel().isUnknown();
        if (hasSpread) {
            gen.out(gen.getClAlias(), "spread$2(");
        }
        if (typeArgSource instanceof Tree.BaseMemberExpression) {
            final Tree.BaseMemberExpression _bme = (Tree.BaseMemberExpression) typeArgSource;
            if (gen.isInDynamicBlock()) {
                if (_bme.getDeclaration() == null || _bme.getDeclaration().isDynamic() || (_bme.getDeclaration() instanceof TypedDeclaration && ((TypedDeclaration) _bme.getDeclaration()).isDynamicallyTyped())) {
                    if (lastArg instanceof Tree.SpreadArgument && (lastArg.getTypeModel() == null || lastArg.getTypeModel().isUnknown())) {
                        BmeGenerator.generateBme(_bme, gen);
                        gen.out(".apply(0,");
                        if (argList.getPositionalArguments().size() == 1) {
                            generatePositionalArguments(typeArgSource, argList, argList.getPositionalArguments(), false, true);
                        } else {
                            gen.out("[");
                            ArrayList<Tree.PositionalArgument> subargs = new ArrayList<>(argList.getPositionalArguments().size());
                            subargs.addAll(argList.getPositionalArguments());
                            subargs.remove(subargs.size() - 1);
                            generatePositionalArguments(typeArgSource, argList, subargs, false, true);
                            gen.out("].concat(");
                            lastArg.visit(gen);
                            gen.out(")");
                        }
                        gen.out(")");
                        return;
                    }
                } else if ("ceylon.language::print".equals(_bme.getDeclaration().getQualifiedNameString())) {
                    Tree.PositionalArgument printArg = that.getPositionalArgumentList().getPositionalArguments().get(0);
                    if (ModelUtil.isTypeUnknown(printArg.getTypeModel())) {
                        // #397
                        gen.out(gen.getClAlias(), "pndo$(");
                        printArg.visit(gen);
                        gen.out(")");
                        return;
                    }
                }
            }
            BmeGenerator.generateBme(_bme, gen);
        } else if (typeArgSource instanceof Tree.QualifiedTypeExpression) {
            BmeGenerator.generateQte((Tree.QualifiedTypeExpression) typeArgSource, gen);
        } else {
            typeArgSource.visit(gen);
        }
        if (gen.opts.isOptimize() && (gen.getSuperMemberScope(typeArgSource) != null)) {
            gen.out(".call(", names.self(ModelUtil.getContainingClassOrInterface(typeArgSource.getScope())));
            if (!argList.getPositionalArguments().isEmpty()) {
                gen.out(",");
            }
        } else if (hasSpread) {
            gen.out(",");
        } else {
            gen.out("(");
        }
        // Check if args have params
        boolean fillInParams = !argList.getPositionalArguments().isEmpty();
        for (Tree.PositionalArgument arg : argList.getPositionalArguments()) {
            fillInParams &= arg.getParameter() == null;
        }
        if (fillInParams) {
            // Get the callable and try to assign params from there
            Interface cd = that.getUnit().getCallableDeclaration();
            final Type ed = that.getUnit().getEmptyType();
            Class td = that.getUnit().getTupleDeclaration();
            Type callable = typeArgSource.getTypeModel() == null ? null : typeArgSource.getTypeModel().getSupertype(cd);
            if (callable != null) {
                // This is a tuple with the arguments to the callable
                // (can be union with empty if first param is defaulted)
                Type callableArgs = callable.getTypeArgumentList().get(1);
                boolean isUnion = false;
                if (callableArgs.isUnion()) {
                    if (callableArgs.getCaseTypes().size() == 2) {
                        callableArgs = callableArgs.minus(ed);
                    }
                    isUnion = callableArgs.isUnion();
                }
                // This is the type of the first argument
                boolean isSequenced = !(isUnion || td.equals(callableArgs.getDeclaration()));
                Type argtype = isUnion ? callableArgs : callableArgs.isTypeParameter() || callableArgs.isEmpty() ? callableArgs : callableArgs.isSequence() || callableArgs.isSequential() ? callableArgs.getTypeArgumentList().get(0) : callableArgs.getTypeArgumentList().get(isSequenced ? 0 : 1);
                Parameter p = null;
                int c = 0;
                for (Tree.PositionalArgument arg : argList.getPositionalArguments()) {
                    if (p == null) {
                        p = new Parameter();
                        p.setName("arg" + c);
                        p.setDeclaration(typeArgSource.getTypeModel().getDeclaration());
                        Value v = new Value();
                        Scope scope = that.getPositionalArgumentList().getScope();
                        v.setContainer(scope);
                        v.setScope(scope);
                        v.setType(argtype);
                        p.setModel(v);
                        if (callableArgs == null || isSequenced) {
                            p.setSequenced(true);
                        } else if (!isSequenced) {
                            Type next = isUnion ? null : callableArgs.getTypeArgumentList().get(2);
                            if (next != null && next.getSupertype(td) == null) {
                                // sequential if sequenced param
                                if (next.isUnion()) {
                                    // empty|tuple
                                    callableArgs = next.minus(ed);
                                    isSequenced = !td.equals(callableArgs.getDeclaration());
                                    argtype = callableArgs.getTypeArgumentList().get(isSequenced ? 0 : 1);
                                } else {
                                    // we'll bet on sequential (if it's empty we don't care anyway)
                                    argtype = next;
                                    callableArgs = null;
                                }
                            } else {
                                // If it's a tuple then there are more params
                                callableArgs = next;
                                argtype = callableArgs == null ? null : callableArgs.getTypeArgumentList().get(1);
                            }
                        }
                    }
                    arg.setParameter(p);
                    c++;
                    if (!p.isSequenced()) {
                        p = null;
                    }
                }
            }
        }
        generatePositionalArguments(typeArgSource, argList, argList.getPositionalArguments(), false, false);
    }
    if (targs != null && !targs.isEmpty() && typeArgSource instanceof Tree.MemberOrTypeExpression && ((Tree.MemberOrTypeExpression) typeArgSource).getDeclaration() instanceof Functional) {
        if (argList.getPositionalArguments().size() > 0) {
            gen.out(",");
        }
        Functional bmed = (Functional) ((Tree.MemberOrTypeExpression) typeArgSource).getDeclaration();
        // If there are fewer arguments than there are parameters...
        final int argsSize = argList.getPositionalArguments().size();
        int paramArgDiff = bmed.getFirstParameterList().getParameters().size() - argsSize;
        if (paramArgDiff > 0) {
            final Tree.PositionalArgument parg = argsSize > 0 ? argList.getPositionalArguments().get(argsSize - 1) : null;
            if (parg instanceof Tree.Comprehension || parg instanceof Tree.SpreadArgument) {
                paramArgDiff--;
            }
            for (int i = 0; i < paramArgDiff; i++) {
                gen.out("undefined,");
            }
        }
        if (targs != null && !targs.isEmpty()) {
            TypeUtils.printTypeArguments(typeArgSource, targs, gen, false, null);
        }
    }
    gen.out(")");
}
Also used : TypeParameter(org.eclipse.ceylon.model.typechecker.model.TypeParameter) ArrayList(java.util.ArrayList) Tree(org.eclipse.ceylon.compiler.typechecker.tree.Tree) TypedDeclaration(org.eclipse.ceylon.model.typechecker.model.TypedDeclaration) Functional(org.eclipse.ceylon.model.typechecker.model.Functional) Type(org.eclipse.ceylon.model.typechecker.model.Type) Scope(org.eclipse.ceylon.model.typechecker.model.Scope) Value(org.eclipse.ceylon.model.typechecker.model.Value) Parameter(org.eclipse.ceylon.model.typechecker.model.Parameter) TypeParameter(org.eclipse.ceylon.model.typechecker.model.TypeParameter) Class(org.eclipse.ceylon.model.typechecker.model.Class) Interface(org.eclipse.ceylon.model.typechecker.model.Interface)

Aggregations

Interface (org.eclipse.ceylon.model.typechecker.model.Interface)105 ClassOrInterface (org.eclipse.ceylon.model.typechecker.model.ClassOrInterface)99 Type (org.eclipse.ceylon.model.typechecker.model.Type)64 TypeDeclaration (org.eclipse.ceylon.model.typechecker.model.TypeDeclaration)58 Tree (org.eclipse.ceylon.compiler.typechecker.tree.Tree)40 Declaration (org.eclipse.ceylon.model.typechecker.model.Declaration)35 LazyInterface (org.eclipse.ceylon.model.loader.model.LazyInterface)34 Class (org.eclipse.ceylon.model.typechecker.model.Class)32 ModelUtil.getContainingClassOrInterface (org.eclipse.ceylon.model.typechecker.model.ModelUtil.getContainingClassOrInterface)32 TypedDeclaration (org.eclipse.ceylon.model.typechecker.model.TypedDeclaration)32 UnknownType (org.eclipse.ceylon.model.typechecker.model.UnknownType)29 ModelUtil.appliedType (org.eclipse.ceylon.model.typechecker.model.ModelUtil.appliedType)27 TypeParameter (org.eclipse.ceylon.model.typechecker.model.TypeParameter)21 ModelUtil.getOuterClassOrInterface (org.eclipse.ceylon.model.typechecker.model.ModelUtil.getOuterClassOrInterface)20 UnionType (org.eclipse.ceylon.model.typechecker.model.UnionType)20 ModelUtil.intersectionType (org.eclipse.ceylon.model.typechecker.model.ModelUtil.intersectionType)19 ModelUtil.unionType (org.eclipse.ceylon.model.typechecker.model.ModelUtil.unionType)19 AnalyzerUtil.getTupleType (org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.getTupleType)18 AnalyzerUtil.spreadType (org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.spreadType)18 JCTree (org.eclipse.ceylon.langtools.tools.javac.tree.JCTree)18