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

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


            }*/
        }
    }

    private void addUnimplementedFormal(Class clazz, Declaration member) {
        ProducedReference unimplemented =
                member.getProducedReference(clazz.getType(),
                        Collections.<ProducedType>emptyList());
        List<ProducedReference> list =
                clazz.getUnimplementedFormals();
        if (list.isEmpty()) {
View Full Code Here


   
    public static boolean isIndirectInvocation(Tree.InvocationExpression that) {
        Tree.Term p = unwrapExpressionUntilTerm(that.getPrimary());
        if (p instanceof Tree.MemberOrTypeExpression) {
            Tree.MemberOrTypeExpression mte = (Tree.MemberOrTypeExpression) p;
            ProducedReference prf = mte.getTarget();
            return mte.getStaticMethodReference() ||
                    prf==null ||
                    !prf.isFunctional() ||
                    //type parameters are not really callable even though they are Functional
                    prf.getDeclaration() instanceof TypeParameter;
        }
        else {
           return true;
        }
    }
View Full Code Here

        }
        else {
          typeArgs = emptyList();
        }
       
        ProducedReference refinedMember = ci.getType().getTypedReference(refined, typeArgs);
        ProducedReference refiningMember = ci.getType().getTypedReference(dec, typeArgs);
        Declaration refinedMemberDec = refinedMember.getDeclaration();
    Declaration refiningMemberDec = refiningMember.getDeclaration();
    Node typeNode = getTypeErrorNode(that);
    if (refinedMemberIsDynamicallyTyped(refinedMemberDec, refiningMemberDec)) {
          checkRefiningMemberDynamicallyTyped(refined, refiningMemberDec, typeNode);
        }
    else if (refiningMemberIsDynamicallyTyped(refinedMemberDec, refiningMemberDec)) {
View Full Code Here

    private void refineValue(final Value sv,
            Tree.BaseMemberExpression bme,
            Tree.SpecifierStatement that,
            ClassOrInterface c) {
        final ProducedReference rv = getRefinedMember(sv, c);
        if (!sv.isFormal() && !sv.isDefault()
                && !sv.isShortcutRefinement()) { //this condition is here to squash a dupe message
            that.addError("inherited attribute may not be assigned in initializer and is neither formal nor default so may not be refined: " +
                    message(sv), 510);
        }
        else if (sv.isVariable()) {
            that.addError("inherited attribute may not be assigned in initializer and is variable so may not be refined by non-variable: " +
                    message(sv));
        }
        Value v = new Value();
        v.setName(sv.getName());
        v.setShared(true);
        v.setActual(true);
        v.getAnnotations().add(new Annotation("shared"));
        v.getAnnotations().add(new Annotation("actual"));
        v.setRefinedDeclaration(sv.getRefinedDeclaration());
        v.setUnit(that.getUnit());
        v.setContainer(c);
        v.setScope(c);
        v.setShortcutRefinement(true);
        setVisibleScope(v);
        c.addMember(v);
        that.setRefinement(true);
        that.setDeclaration(v);
        that.setRefined(sv);
        that.getUnit().addDeclaration(v);
        v.setType(new LazyProducedType(that.getUnit()) {
            @Override
            public Map<TypeParameter, ProducedType> initTypeArguments() {
                return rv.getType().getTypeArguments();
            }
            @Override
            public TypeDeclaration initDeclaration() {
                return rv.getType().getDeclaration();
            }
        });
    }
View Full Code Here

    private void refineMethod(final Method sm,
            Tree.BaseMemberExpression bme,
            Tree.SpecifierStatement that,
            ClassOrInterface c) {
        final ProducedReference rm = getRefinedMember(sm, c);
        if (!sm.isFormal() && !sm.isDefault()
                && !sm.isShortcutRefinement()) { //this condition is here to squash a dupe message
            that.addError("inherited method is neither formal nor default so may not be refined: " +
                    message(sm));
        }
        Method m = new Method();
        m.setName(sm.getName());
        List<Tree.ParameterList> tpls;
        Tree.Term me = that.getBaseMemberExpression();
        if (me instanceof Tree.ParameterizedExpression) {
            tpls = ((Tree.ParameterizedExpression) me).getParameterLists();
        }
        else {
            tpls = Collections.emptyList();
        }
        int i=0;
        for (ParameterList pl: sm.getParameterLists()) {
            ParameterList l = new ParameterList();
            Tree.ParameterList tpl = tpls.size()<=i ?
                    null : tpls.get(i++);
            int j=0;
            for (final Parameter p: pl.getParameters()) {
                //TODO: meaningful errors when parameters don't line up
                //      currently this is handled elsewhere, but we can
                //      probably do it better right here
                if (tpl==null || tpl.getParameters().size()<=j) {
                    Parameter vp = new Parameter();
                    Value v = new Value();
                    vp.setModel(v);
                    v.setInitializerParameter(vp);
                    vp.setSequenced(p.isSequenced());
                    vp.setAtLeastOne(p.isAtLeastOne());
                    vp.setDefaulted(p.isDefaulted());
                    vp.setName(p.getName());
                    v.setName(p.getName());
                    vp.setDeclaration(m);
                    v.setContainer(m);
                    v.setScope(m);
                    l.getParameters().add(vp);
                    v.setType(new LazyProducedType(that.getUnit()) {
                        @Override
                        public Map<TypeParameter, ProducedType> initTypeArguments() {
                            return rm.getTypedParameter(p).getFullType()
                                    .getTypeArguments();
                        }
                        @Override
                        public TypeDeclaration initDeclaration() {
                            return rm.getTypedParameter(p).getFullType()
                                    .getDeclaration();
                        }
                    });
                }
                else {
                    Tree.Parameter tp = tpl.getParameters().get(j);
                    Parameter rp = tp.getParameterModel();
                    rp.setDefaulted(p.isDefaulted());
                    rp.setDeclaration(m);
                    l.getParameters().add(rp);
                }
                j++;
            }
            m.getParameterLists().add(l);
        }
        if (!sm.getTypeParameters().isEmpty()) {
            bme.addError("method has type parameters: "
                    message(sm));
        }
        m.setShared(true);
        m.setActual(true);
        m.getAnnotations().add(new Annotation("shared"));
        m.getAnnotations().add(new Annotation("actual"));
        m.setRefinedDeclaration(sm.getRefinedDeclaration()); //Note: this is not the real root, so we set it again in ExpressionVisitor
        m.setUnit(that.getUnit());
        m.setContainer(c);
        m.setShortcutRefinement(true);
        m.setDeclaredVoid(sm.isDeclaredVoid());
        setVisibleScope(m);
        c.addMember(m);
        that.setRefinement(true);
        that.setDeclaration(m);
        that.setRefined(sm);
        that.getUnit().addDeclaration(m);
        if (that.getScope() instanceof Specification){
            ((Specification) that.getScope()).setDeclaration(m);
        }
        m.setType(new LazyProducedType(that.getUnit()) {
            @Override
            public Map<TypeParameter, ProducedType> initTypeArguments() {
                return rm.getType().getTypeArguments();
            }
            @Override
            public TypeDeclaration initDeclaration() {
                return rm.getType().getDeclaration();
            }
        });
    }
View Full Code Here

   
    private void refineValue(Tree.SpecifierStatement that) {
        Value refinedValue = (Value) that.getRefined();
        Value value = (Value) that.getDeclaration();
        ClassOrInterface ci = (ClassOrInterface) value.getContainer();
        ProducedReference refinedProducedReference =
                getRefinedMember(refinedValue, ci);
        value.setType(refinedProducedReference.getType());
    }
View Full Code Here

                .isEmpty()) {
            that.getBaseMemberExpression()
                .addError("shortcut refinement does not exactly refine any overloaded inherited member");
        }
        else {
            ProducedReference refinedProducedReference =
                    getRefinedMember(refinedMethod, ci);
            method.setType(refinedProducedReference.getType());
            List<Tree.ParameterList> parameterLists;
            Tree.Term me = that.getBaseMemberExpression();
            if (me instanceof Tree.ParameterizedExpression) {
                parameterLists =
                        ((Tree.ParameterizedExpression) me).getParameterLists();
            }
            else {
                parameterLists = emptyList();
            }
            for (int i=0; i<refinedMethod.getParameterLists().size(); i++) {
                ParameterList refinedParameters =
                        refinedMethod.getParameterLists().get(i);
                ParameterList parameters =
                        method.getParameterLists().get(i);
                Tree.ParameterList parameterList =
                        parameterLists.size()<=i ?
                                null : parameterLists.get(i);
                for (int j=0; j<refinedParameters.getParameters().size(); j++) {
                    Parameter refinedParameter =
                            refinedParameters.getParameters().get(j);
                    ProducedType refinedParameterType =
                            refinedProducedReference
                            .getTypedParameter(refinedParameter)
                            .getFullType();
                    if (parameterList==null ||
                            parameterList.getParameters().size()<=j) {
                        Parameter p = parameters.getParameters().get(j);
View Full Code Here

    }

    private void inferParameterTypesDirectly(Declaration dec,
            Tree.PositionalArgumentList pal,
            Tree.MemberOrTypeExpression mte) {
        ProducedReference pr =
                getInvokedProducedReference(dec, mte);
        List<ParameterList> pls =
                ((Functional) dec).getParameterLists();
        if (!pls.isEmpty()) {
            ParameterList pl = pls.get(0);
View Full Code Here

    }

    private void inferParameterTypesDirectly(Declaration dec,
            Tree.NamedArgumentList nal,
            Tree.MemberOrTypeExpression mte) {
        ProducedReference pr =
                getInvokedProducedReference(dec, mte);
        List<ParameterList> pls =
                ((Functional) dec).getParameterLists();
        if (!pls.isEmpty()) {
            Set<Parameter> foundParameters = new HashSet<Parameter>();
View Full Code Here

            Tree.MemberOrTypeExpression mte) {
        Tree.TypeArguments tas =
                mte instanceof Tree.StaticMemberOrTypeExpression ?
                        ((Tree.StaticMemberOrTypeExpression) mte).getTypeArguments() : null;
        List<TypeParameter> tps = ((Functional) dec).getTypeParameters();
        ProducedReference pr;
        if (mte instanceof Tree.QualifiedMemberOrTypeExpression &&
                !(((Tree.QualifiedMemberOrTypeExpression) mte).getPrimary() instanceof Tree.Package)) {
            Tree.QualifiedMemberOrTypeExpression qmte =
                    (Tree.QualifiedMemberOrTypeExpression) mte;
            ProducedType pt = qmte.getPrimary().getTypeModel().resolveAliases();
View Full Code Here

TOP

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

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.