Package com.redhat.ceylon.compiler.typechecker.model

Examples of com.redhat.ceylon.compiler.typechecker.model.Unit


    @Override
    protected Module createModule(List<String> moduleName, String version) {
        final Module module = new JsonModule();
        module.setName(moduleName);
        module.setVersion(version);
        Unit u = new Unit();
        u.setFilename(Constants.MODULE_DESCRIPTOR);
        u.setFullPath(moduleName+"/"+version);
        module.setUnit(u);
        JsonModule dep = (JsonModule)findLoadedModule(Module.LANGUAGE_MODULE_NAME, null);
        //This can only happen during initCoreModules()
        if (!(module.getNameAsString().equals(Module.DEFAULT_MODULE_NAME) || module.getNameAsString().equals(Module.LANGUAGE_MODULE_NAME)) && dep == null) {
            //Load the language module if we're not inside initCoreModules()
View Full Code Here


                        errors = true;
                    }
                }
            }
        }
        Unit unit = d.getUnit();
        if (etn!=null) {
            Tree.StaticType et = etn.getType();
            if (et!=null) {
              ProducedType t = et.getTypeModel();
              if (t!=null) {
                List<TypeDeclaration> l = t.isRecursiveRawTypeDefinition(singleton((TypeDeclaration)d));
                if (!l.isEmpty()) {
                      if (displayErrors)
                  etn.addError("inheritance is circular: definition of '" +
                      d.getName() + "' is recursive, involving " + typeList(l));
                  d.setExtendedType(unit.getType(unit.getBasicDeclaration()));
                  d.addBrokenSupertype(t);
                        d.clearProducedTypeCache();
                  errors = true;
                }
              }
            }
        }
        if (!errors) {
            List<ProducedType> list = new ArrayList<ProducedType>();
            try {
                for (ProducedType st: d.getType().getSupertypes()) {
                    addToIntersection(list, st, unit);
                }
                IntersectionType it = new IntersectionType(unit);
                it.setSatisfiedTypes(list);
        it.canonicalize().getType();
            }
            catch (RuntimeException re) {
                if (displayErrors)
                that.addError("inheritance hierarchy is undecidable: " +
                        "could not canonicalize the intersection of all supertypes of '" +
                        d.getName() + "'");
                d.getSatisfiedTypes().clear();
                d.setExtendedType(unit.getType(unit.getBasicDeclaration()));
                d.clearProducedTypeCache();
                return;
            }
            if (stn!=null) {
                for (Tree.StaticType st: stn.getTypes()) {
View Full Code Here

        }
    }
    private void checkSupertypeIntersection(Tree.StatementOrArgument that,
            TypeDeclaration td, ProducedType st1, ProducedType st2) {
        if (st1.getDeclaration().equals(st2.getDeclaration()) /*&& !st1.isExactly(st2)*/) {
            Unit unit = that.getUnit();
            if (!areConsistentSupertypes(st1, st2, unit)) {
                that.addError(typeDescription(td, unit) +
                        " has the same parameterized supertype twice with incompatible type arguments: '" +
                        st1.getProducedTypeName(unit) + " & " +
                        st2.getProducedTypeName(unit) + "'");
View Full Code Here

    }

    private void validateUpperBounds(Tree.TypeConstraint that,
            TypeDeclaration td) {
        if (!td.isInconsistentType()) {
            Unit unit = that.getUnit();
            List<ProducedType> upperBounds = td.getSatisfiedTypes();
            List<ProducedType> list =
                    new ArrayList<ProducedType>(upperBounds.size());
            for (ProducedType st: upperBounds) {
                addToIntersection(list, st, unit);
View Full Code Here

        return typeArguments;
    }*/
   
    public static Tree.Statement getLastExecutableStatement(Tree.ClassBody that) {
        List<Tree.Statement> statements = that.getStatements();
        Unit unit = that.getUnit();
        for (int i=statements.size()-1; i>=0; i--) {
            Tree.Statement s = statements.get(i);
            if (isExecutableStatement(unit, s)) {
                return s;
            }
View Full Code Here

        String typeName = type.getProducedTypeName(unit);
        return ": '" + typeName + "'" + problem;
    }
   
    static boolean checkCallable(ProducedType type, Node node, String message) {
        Unit unit = node.getUnit();
        if (isTypeUnknown(type)) {
            addTypeUnknownError(node, message);
            return false;
        }
        else if (!unit.isCallableType(type)) {
            if (!hasError(node)) {
                String extra = message(type,
                        " is not a subtype of 'Callable'", unit);
                if (node instanceof Tree.StaticMemberOrTypeExpression) {
                    Declaration d =
View Full Code Here

        if (fi!=null) {
            Tree.SpecifierExpression se = fi.getSpecifierExpression();
            if (se!=null) {
                Tree.Expression e = se.getExpression();
                if (e!=null) {
                    Unit unit = forClause.getUnit();
                    ProducedType at =
                            unit.getAnythingDeclaration().getType();
                    ProducedType neit = unit.getNonemptyIterableType(at);
                    ProducedType t = e.getTypeModel();
                    return t!=null && t.isSubtypeOf(neit);
                }
            }
        }
View Full Code Here

        if (pt!=null) {
            TypeDeclaration ptd = pt.getDeclaration();
            if (ptd instanceof IntersectionType || ptd instanceof UnionType) {
                return true;
            }
            Unit unit = pt.getDeclaration().getUnit();
            if (!ptd.isAnnotation() && !isEnum(ptd) &&
                    !ptd.equals(unit.getBooleanDeclaration()) &&
                    !ptd.equals(unit.getStringDeclaration()) &&
                    !ptd.equals(unit.getIntegerDeclaration()) &&
                    !ptd.equals(unit.getFloatDeclaration()) &&
                    !ptd.equals(unit.getCharacterDeclaration()) &&
                    !ptd.equals(unit.getIterableDeclaration()) &&
                    !ptd.equals(unit.getSequentialDeclaration()) &&
                    !pt.isSubtypeOf(unit.getType(unit.getDeclarationDeclaration()))) {
                return true;
            }
            if (ptd.equals(unit.getIterableDeclaration()) ||
                    ptd.equals(unit.getSequentialDeclaration())) {
                if (isIllegalAnnotationParameterType(unit.getIteratedType(pt))) {
                    return true;
                }
            }
        }
        return false;
View Full Code Here

    }

    @Override
    public void visit(Tree.PackageDescriptor that) {
        super.visit(that);
        Unit unit = that.getUnit();
        checkAnnotations(that.getAnnotationList(),
                unit.getPackageDeclarationType(), null);
    }
View Full Code Here

    }
   
    @Override
    public void visit(Tree.ModuleDescriptor that) {
        super.visit(that);
        Unit unit = that.getUnit();
        checkAnnotations(that.getAnnotationList(),
                unit.getModuleDeclarationType(), null);
    }
View Full Code Here

TOP

Related Classes of com.redhat.ceylon.compiler.typechecker.model.Unit

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.