Search in sources :

Example 66 with Interface

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

the class DeclarationVisitor method visit.

@Override
public void visit(Tree.InterfaceDefinition that) {
    Interface i = new Interface();
    i.setDynamic(that.getDynamic());
    defaultExtendedToObject(i);
    that.setDeclarationModel(i);
    super.visit(that);
    if (i.isNativeImplementation()) {
        addMissingHeaderMembers(i);
    }
    if (i.isDynamic()) {
        i.makeMembersDynamic();
    }
// Required by IDE to be omitted: https://github.com/ceylon/ceylon-compiler/issues/2326
// if (that.getDynamic()) {
// checkDynamic(that);
// }
}
Also used : ModelUtil.getContainingClassOrInterface(org.eclipse.ceylon.model.typechecker.model.ModelUtil.getContainingClassOrInterface) Interface(org.eclipse.ceylon.model.typechecker.model.Interface) ClassOrInterface(org.eclipse.ceylon.model.typechecker.model.ClassOrInterface)

Example 67 with Interface

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

the class ExpressionVisitor method isJavaNullableMutator.

public boolean isJavaNullableMutator(Type pt, Interface cd) {
    boolean nullable = false;
    Type cst = pt.getSupertype(cd);
    if (cst == null) {
        Interface ld = unit.getJavaListDeclaration();
        cst = pt.getSupertype(ld);
        if (cst != null) {
            nullable = true;
        }
    }
    if (cst == null) {
        Interface md = unit.getJavaMapDeclaration();
        cst = pt.getSupertype(md);
        if (cst != null) {
            nullable = true;
        }
    }
    if (cst == null) {
        boolean objectArray = unit.isJavaObjectArrayType(pt);
        nullable = objectArray;
    }
    return nullable;
}
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 68 with Interface

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

the class ExpressionVisitor method visitMeasureOperator.

private void visitMeasureOperator(Tree.SegmentOp that) {
    Type lhst = leftType(that);
    Type rhst = rightType(that);
    Interface ed = unit.getEnumerableDeclaration();
    Type ot = checkSupertype(lhst, ed, that.getLeftTerm(), "left operand must be of enumerable type");
    if (!isTypeUnknown(rhst)) {
        checkAssignable(rhst, unit.getIntegerType(), that.getRightTerm(), "right operand must be an integer");
    }
    if (ot != null) {
        Type ta = ot.getTypeArgumentList().get(0);
        that.setTypeModel(unit.getMeasureType(ta));
    }
}
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 69 with Interface

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

the class TypeVisitor method visit.

@Override
public void visit(Tree.FunctionType that) {
    super.visit(that);
    Tree.StaticType rt = that.getReturnType();
    if (rt != null) {
        List<Tree.Type> argumentTypes = that.getArgumentTypes();
        Type tt = getTupleType(argumentTypes, unit);
        Interface cd = unit.getCallableDeclaration();
        Type pt = appliedType(cd, rt.getTypeModel(), tt);
        that.setTypeModel(pt);
    }
}
Also used : NothingType(org.eclipse.ceylon.model.typechecker.model.NothingType) 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) Tree(org.eclipse.ceylon.compiler.typechecker.tree.Tree) ModelUtil.getContainingClassOrInterface(org.eclipse.ceylon.model.typechecker.model.ModelUtil.getContainingClassOrInterface) Interface(org.eclipse.ceylon.model.typechecker.model.Interface) ClassOrInterface(org.eclipse.ceylon.model.typechecker.model.ClassOrInterface)

Example 70 with Interface

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

the class TypeVisitor method visit.

@Override
public void visit(Tree.ExtendedType that) {
    inExtendsOrClassAlias = that.getInvocationExpression() != null;
    super.visit(that);
    inExtendsOrClassAlias = false;
    inheritedType(that.getType());
    checkExtendedTypeExpression(that.getType());
    TypeDeclaration td = (TypeDeclaration) that.getScope();
    if (!td.isAlias()) {
        Tree.SimpleType et = that.getType();
        if (et != null) {
            Type type = et.getTypeModel();
            if (type != null) {
                TypeDeclaration etd = et.getDeclarationModel();
                if (etd != null && !(etd instanceof UnknownType)) {
                    if (etd instanceof Constructor) {
                        type = type.getExtendedType();
                        etd = etd.getExtendedType().getDeclaration();
                    }
                    if (etd == td) {
                    // unnecessary, handled by SupertypeVisitor
                    // et.addError("directly extends itself: '" +
                    // td.getName() + "'");
                    } else if (etd instanceof TypeParameter) {
                        et.addError("directly extends a type parameter: '" + type.getDeclaration().getName(unit) + "'");
                    } else if (etd instanceof Interface) {
                        et.addError("extends an interface: '" + type.getDeclaration().getName(unit) + "'");
                    } else if (etd instanceof TypeAlias) {
                        et.addError("extends a type alias: '" + type.getDeclaration().getName(unit) + "'");
                    } else if (etd instanceof NothingType) {
                        et.addError("extends the bottom type 'Nothing'");
                    } else {
                        td.setExtendedType(type);
                    }
                }
            }
        }
    }
}
Also used : UnknownType(org.eclipse.ceylon.model.typechecker.model.UnknownType) NothingType(org.eclipse.ceylon.model.typechecker.model.NothingType) 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) TypeParameter(org.eclipse.ceylon.model.typechecker.model.TypeParameter) AnalyzerUtil.setTypeConstructor(org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.setTypeConstructor) Constructor(org.eclipse.ceylon.model.typechecker.model.Constructor) AnalyzerUtil.unwrapAliasedTypeConstructor(org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.unwrapAliasedTypeConstructor) Tree(org.eclipse.ceylon.compiler.typechecker.tree.Tree) TypeAlias(org.eclipse.ceylon.model.typechecker.model.TypeAlias) 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) ModelUtil.getContainingClassOrInterface(org.eclipse.ceylon.model.typechecker.model.ModelUtil.getContainingClassOrInterface) Interface(org.eclipse.ceylon.model.typechecker.model.Interface) ClassOrInterface(org.eclipse.ceylon.model.typechecker.model.ClassOrInterface) NothingType(org.eclipse.ceylon.model.typechecker.model.NothingType)

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