Search in sources :

Example 21 with Type

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

the class AbstractTransformer method hasMatchingSignature.

private boolean hasMatchingSignature(java.util.List<Type> signature, java.util.List<Type> typedSignature) {
    if (signature.size() != typedSignature.size())
        return false;
    for (int i = 0; i < signature.size(); i++) {
        Type signatureArg = signature.get(i);
        Type typedSignatureArg = typedSignature.get(i);
        if (signatureArg != null && typedSignatureArg != null && !ModelUtil.matches(signatureArg, typedSignatureArg, typeFact()))
            return false;
    }
    return true;
}
Also used : Type(org.eclipse.ceylon.model.typechecker.model.Type) ModelUtil.appliedType(org.eclipse.ceylon.model.typechecker.model.ModelUtil.appliedType)

Example 22 with Type

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

the class AbstractTransformer method getPinnedType.

private Type getPinnedType(TypedReference ref, Type type) {
    if (isPinnedType(ref.getDeclaration().getRefinedDeclaration()) && willEraseToObject(type)) {
        Type rt = ref.getType();
        Type st = rt.getSupertype(typeFact().getSequenceDeclaration());
        if (st != null) {
            return st;
        }
        return rt.getSupertype(typeFact().getSequentialDeclaration());
    } else {
        return type;
    }
}
Also used : Type(org.eclipse.ceylon.model.typechecker.model.Type) ModelUtil.appliedType(org.eclipse.ceylon.model.typechecker.model.ModelUtil.appliedType)

Example 23 with Type

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

the class AbstractTransformer method hasSubstitutedBounds.

boolean hasSubstitutedBounds(Type pt) {
    TypeDeclaration declaration = pt.getDeclaration();
    java.util.List<TypeParameter> tps = declaration.getTypeParameters();
    final Map<TypeParameter, Type> tas = pt.getTypeArguments();
    boolean isCallable = isCeylonCallable(pt);
    for (TypeParameter tp : tps) {
        Type ta = tas.get(tp);
        // error recovery
        if (ta == null)
            continue;
        if (!tp.getSatisfiedTypes().isEmpty()) {
            for (Type bound : tp.getSatisfiedTypes()) {
                bound = bound.substitute(pt);
                if (expressionGen().needsCast(ta, bound, false, false, false))
                    return true;
            }
        }
        if (hasSubstitutedBounds(ta))
            return true;
        // Callable ignores type parameters after the first
        if (isCallable)
            break;
    }
    return false;
}
Also used : TypeParameter(org.eclipse.ceylon.model.typechecker.model.TypeParameter) JCTypeParameter(org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCTypeParameter) Type(org.eclipse.ceylon.model.typechecker.model.Type) ModelUtil.appliedType(org.eclipse.ceylon.model.typechecker.model.ModelUtil.appliedType) TypeDeclaration(org.eclipse.ceylon.model.typechecker.model.TypeDeclaration)

Example 24 with Type

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

the class AbstractTransformer method makeTypesListAttr.

private JCExpression makeTypesListAttr(java.util.List<Type> types) {
    if (types.isEmpty())
        return null;
    ListBuffer<JCExpression> upperBounds = new ListBuffer<JCTree.JCExpression>();
    for (Type type : types) {
        String typeSig = serialiseTypeSignature(type);
        upperBounds.append(make().Literal(typeSig));
    }
    JCExpression caseAttribute = make().Assign(naming.makeUnquotedIdent("value"), make().NewArray(null, null, upperBounds.toList()));
    return caseAttribute;
}
Also used : Type(org.eclipse.ceylon.model.typechecker.model.Type) ModelUtil.appliedType(org.eclipse.ceylon.model.typechecker.model.ModelUtil.appliedType) JCExpression(org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCExpression) ListBuffer(org.eclipse.ceylon.langtools.tools.javac.util.ListBuffer) JCTree(org.eclipse.ceylon.langtools.tools.javac.tree.JCTree)

Example 25 with Type

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

the class AbstractTransformer method getTypeArguments.

private java.util.List<Type> getTypeArguments(Function method) {
    java.util.List<TypeParameter> typeParameters = method.getTypeParameters();
    java.util.List<Type> typeArguments = new ArrayList<Type>(typeParameters.size());
    for (TypeParameter tp : typeParameters) typeArguments.add(tp.getType());
    return typeArguments;
}
Also used : TypeParameter(org.eclipse.ceylon.model.typechecker.model.TypeParameter) JCTypeParameter(org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCTypeParameter) Type(org.eclipse.ceylon.model.typechecker.model.Type) ModelUtil.appliedType(org.eclipse.ceylon.model.typechecker.model.ModelUtil.appliedType) ArrayList(java.util.ArrayList)

Aggregations

Type (org.eclipse.ceylon.model.typechecker.model.Type)692 ModelUtil.appliedType (org.eclipse.ceylon.model.typechecker.model.ModelUtil.appliedType)270 UnknownType (org.eclipse.ceylon.model.typechecker.model.UnknownType)263 Tree (org.eclipse.ceylon.compiler.typechecker.tree.Tree)244 TypeDeclaration (org.eclipse.ceylon.model.typechecker.model.TypeDeclaration)225 ModelUtil.intersectionType (org.eclipse.ceylon.model.typechecker.model.ModelUtil.intersectionType)207 TypeParameter (org.eclipse.ceylon.model.typechecker.model.TypeParameter)182 AnalyzerUtil.getTupleType (org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.getTupleType)176 AnalyzerUtil.spreadType (org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.spreadType)176 ModelUtil.unionType (org.eclipse.ceylon.model.typechecker.model.ModelUtil.unionType)169 ModelUtil.genericFunctionType (org.eclipse.ceylon.model.typechecker.model.ModelUtil.genericFunctionType)153 UnionType (org.eclipse.ceylon.model.typechecker.model.UnionType)130 CustomTree (org.eclipse.ceylon.compiler.typechecker.tree.CustomTree)125 TypedDeclaration (org.eclipse.ceylon.model.typechecker.model.TypedDeclaration)114 ArrayList (java.util.ArrayList)106 Declaration (org.eclipse.ceylon.model.typechecker.model.Declaration)100 JCExpression (org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCExpression)96 ClassOrInterface (org.eclipse.ceylon.model.typechecker.model.ClassOrInterface)95 IntersectionType (org.eclipse.ceylon.model.typechecker.model.IntersectionType)94 Class (org.eclipse.ceylon.model.typechecker.model.Class)87