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

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


   
    @Override public void visit(Tree.FunctionArgument that) {
        Tree.Expression e = that.getExpression();
        if (e==null) {
            Tree.Type rt = beginReturnScope(that.getType());          
            Declaration od = beginReturnDeclaration(that.getDeclarationModel());
            super.visit(that);
            endReturnDeclaration(od);
            endReturnScope(rt, that.getDeclarationModel());
        }
        else {
View Full Code Here


        }
    }

    private void checkReferenceIsNonVariable(Tree.BaseMemberExpression ref,
        boolean isSwitch) {
        Declaration d = ref.getDeclaration();
        if (d!=null) {
          int code = isSwitch ? 3101:3100;
            String help=" (assign to a new local value to narrow type)";
            if (!(d instanceof Value)) {
                ref.addError("referenced declaration is not a value: '" +
                        d.getName(unit) + "'", code);
            }
            else if (isNonConstant(d)) {
                ref.addError("referenced value is non-constant: '" +
                        d.getName(unit) + "'" + help, code);
            }
            else if (d.isDefault() || d.isFormal()) {
                ref.addError("referenced value may be refined by a non-constant value: '" +
                        d.getName(unit) + "'" + help, code);
            }
        }
    }
View Full Code Here

            me = ((Tree.ParameterizedExpression) me).getPrimary();
        }
        assign(me);
        Tree.SpecifierExpression sie = that.getSpecifierExpression();
        if (me instanceof Tree.BaseMemberExpression) {
            Declaration d = that.getDeclaration();
            if (d instanceof TypedDeclaration) {
                if (that.getRefinement()) {
                    // interpret this specification as a
                    // refinement of an inherited member
                    if (d instanceof Value) {
                        refineValue(that);
                    }
                    else if (d instanceof Method) {
                        refineMethod(that);
                    }
                    Tree.BaseMemberExpression bme =
                            (Tree.BaseMemberExpression) me;
                    bme.setDeclaration(that.getDeclaration());
                }
                else if (d instanceof MethodOrValue) {
                    MethodOrValue mv = (MethodOrValue) d;
                    if (mv.isShortcutRefinement()) {
                        String desc;
                        if (d instanceof Value) {
                            desc = "value";
                        }
                        else {
                            desc = "function";
                        }
                        me.addError(desc + " already specified: '" +
                                    d.getName(unit) + "'");
                    }
                    else if (!mv.isVariable() && !mv.isLate()) {
                        String desc;
                        if (d instanceof Value) {
                            desc = "value is neither variable nor late and";
                        }
                        else {
                            desc = "function";
                        }
                        if (mv.isToplevel()) {
                            me.addError("toplevel " + desc +
                                    " may not be specified: '" +
                                    d.getName(unit) + "'", 803);
                        }
                        else if (!mv.isDefinedInScope(that.getScope())) {
                            me.addError(desc + " may not be specified here: '" +
                                    d.getName(unit) + "'", 803);
                        }
                    }
                }
                if (hasParams && d instanceof Method &&
                        ((Method) d).isDeclaredVoid() &&
                        !isSatementExpression(sie.getExpression())) {
                    sie.addError("function is declared void so specified expression must be a statement: '" +
                            d.getName(unit) + "' is declared 'void'");
                }
                if (d instanceof Value &&
                        sie instanceof Tree.LazySpecifierExpression) {
                    ((Value) d).setTransient(true);
                }
               
                ProducedType t = that.getBaseMemberExpression().getTypeModel();
                if (that.getBaseMemberExpression()==me && d instanceof Method) {
                    //if the declaration of the method has
                    //defaulted parameters, we should ignore
                    //that when determining if the RHS is
                    //an acceptable implementation of the
                    //method
                    //TODO: this is a pretty nasty way to
                    //      handle the problem
                    t = eraseDefaultedParameters(t);
                }
                if (!isTypeUnknown(t)) {
                    checkType(t, d.getName(unit), sie, 2100);
                }
            }
            if (that.getBaseMemberExpression() instanceof Tree.ParameterizedExpression) {
                if (!(sie instanceof Tree.LazySpecifierExpression)) {
                    sie.addError("functions with parameters must be specified using =>");
View Full Code Here

    private void refineMethod(Tree.SpecifierStatement that) {
        Method refinedMethod = (Method) that.getRefined();
        Method method = (Method) that.getDeclaration();
        ClassOrInterface ci = (ClassOrInterface) method.getContainer();
        Declaration root = refinedMethod.getRefinedDeclaration();
        method.setRefinedDeclaration(root);
        if (getInterveningRefinements(method.getName(),
                getSignature(method), root,
                ci, (TypeDeclaration) root.getContainer())
                .isEmpty()) {
            that.getBaseMemberExpression()
                .addError("shortcut refinement does not exactly refine any overloaded inherited member");
        }
        else {
View Full Code Here

          if (type!=null && !isTypeUnknown(type)) {
            checkType(type, that.getSpecifierExpression());
          }
        }
        else {
            Declaration a = that.getScope()
                    .getDirectMember(p.getName(),
                            null, false);
            if (a==null) {
                that.addError("parameter declaration does not exist: '" +
                        p.getName() + "'");
View Full Code Here

   
    @Override public void visit(Tree.AttributeGetterDefinition that) {
        Tree.Type type = that.getType();
        Tree.Type rt = beginReturnScope(type);
        Value dec = that.getDeclarationModel();
        Declaration od = beginReturnDeclaration(dec);
        super.visit(that);
        endReturnScope(rt, dec);
        endReturnDeclaration(od);
        Setter setter = dec.getSetter();
        if (setter!=null) {
View Full Code Here

        Tree.SpecifierExpression se =
                that.getSpecifierExpression();
        Tree.Type type = that.getType();
        if (se==null) {
            Tree.Type rt = beginReturnScope(type);
            Declaration od =
                    beginReturnDeclaration(that.getDeclarationModel());
            super.visit(that);
            endReturnDeclaration(od);
            endReturnScope(rt, that.getDeclarationModel());
        }
View Full Code Here

    }

    @Override public void visit(Tree.AttributeSetterDefinition that) {
        Tree.Type rt = beginReturnScope(that.getType());
        Setter sd = that.getDeclarationModel();
        Declaration od = beginReturnDeclaration(sd);
        super.visit(that);
        endReturnDeclaration(od);
        endReturnScope(rt, sd);
        Tree.SpecifierExpression se = that.getSpecifierExpression();
        if (se!=null) {
View Full Code Here

    }

    @Override public void visit(Tree.MethodDefinition that) {
        Tree.Type type = that.getType();
        Tree.Type rt = beginReturnScope(type);
        Declaration od =
                beginReturnDeclaration(that.getDeclarationModel());
        super.visit(that);
        endReturnDeclaration(od);
        endReturnScope(rt, that.getDeclarationModel());
        if (type instanceof Tree.LocalModifier) {
View Full Code Here

        Tree.SpecifierExpression se = that.getSpecifierExpression();
        Method d = that.getDeclarationModel();
        Tree.Type type = that.getType();
        if (se==null) {
            Tree.Type rt = beginReturnScope(type);          
            Declaration od = beginReturnDeclaration(d);
            super.visit(that);
            endReturnDeclaration(od);
            endReturnScope(rt, d);
        }
        else {
View Full Code Here

TOP

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

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.