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

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


        ProducedType type = new TypeParser(MockLoader.instance).decodeType("a&b|c", null, mockModule, mockUnit);
        Assert.assertNotNull(type);
        TypeDeclaration declaration = type.getDeclaration();
        Assert.assertNotNull(declaration);
        Assert.assertTrue(declaration instanceof UnionType);
        UnionType union = (UnionType) declaration;
        List<ProducedType> unionTypes = union.getCaseTypes();
        Assert.assertEquals(2, unionTypes.size());
       
        Assert.assertTrue(unionTypes.get(0).getDeclaration() instanceof IntersectionType);
        IntersectionType intersection = (IntersectionType) unionTypes.get(0).getDeclaration();
View Full Code Here


        ProducedType type = new TypeParser(MockLoader.instance).decodeType("a|t2<b|c,t2<d,e|f>>", null, mockModule, mockUnit);
        Assert.assertNotNull(type);
        TypeDeclaration declaration = type.getDeclaration();
        Assert.assertNotNull(declaration);
        Assert.assertTrue(declaration instanceof UnionType);
        UnionType union = (UnionType) declaration;
        List<ProducedType> caseTypes = union.getCaseTypes();
        Assert.assertEquals(2, caseTypes.size());
       
        // a
        Assert.assertEquals("a", caseTypes.get(0).getDeclaration().getName());
        Assert.assertTrue(caseTypes.get(0).getDeclaration() instanceof Class);
View Full Code Here

     * unionType: intersectionType (| intersectionType)*
     */
    private ProducedType parseUnionType() {
        ProducedType firstType = parseIntersectionType();
        if(lexer.lookingAt(TypeLexer.OR)){
            UnionType type = new UnionType(unit);
            List<ProducedType> caseTypes = new LinkedList<ProducedType>();
            type.setCaseTypes(caseTypes);
            caseTypes.add(firstType);
            while(lexer.lookingAt(TypeLexer.OR)){
                lexer.eat();
                caseTypes.add(parseIntersectionType());
            }
            return type.getType();
        }else{
            return firstType;
        }
    }
View Full Code Here

            super.stringTo(sb, '|');
        }

        @Override
        public ProducedType toProducedType(RuntimeModuleManager moduleManager) {
            UnionType ret = new UnionType(moduleManager.getModelLoader().getUnit());
            ArrayList<ProducedType> caseTypes = new ArrayList<ProducedType>(members.length);
            for(TypeDescriptor member : members)
                Util.addToUnion(caseTypes,Metamodel.getProducedType(member));
            ret.setCaseTypes(caseTypes);
            return ret.getType();
        }
View Full Code Here

TOP

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

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.