Search in sources :

Example 1 with ParameterizedTypeRef

use of org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef in project n4js by eclipse.

the class N4JSMemberRedefinitionValidator method messageImpossibleExtendsImplements.

private void messageImpossibleExtendsImplements(N4ClassifierDefinition n4ClassifierDefinition, Map<ParameterizedTypeRef, MemberList<TMember>> nonAccessibleAbstractMembersBySuperTypeRef) {
    for (Entry<ParameterizedTypeRef, MemberList<TMember>> entry : nonAccessibleAbstractMembersBySuperTypeRef.entrySet()) {
        final ParameterizedTypeRef superTypeRef = entry.getKey();
        final Type type = superTypeRef.getDeclaredType();
        final String mode = type instanceof TInterface && !(n4ClassifierDefinition instanceof N4InterfaceDeclaration) ? "implement" : "extend";
        final String message = getMessageForCLF_NON_ACCESSIBLE_ABSTRACT_MEMBERS(mode, validatorMessageHelper.description(type), validatorMessageHelper.descriptions(entry.getValue()));
        addIssue(message, superTypeRef.eContainer(), superTypeRef.eContainingFeature(), CLF_NON_ACCESSIBLE_ABSTRACT_MEMBERS);
    }
}
Also used : ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) Type(org.eclipse.n4js.ts.types.Type) MemberType(org.eclipse.n4js.ts.types.MemberType) ContainerType(org.eclipse.n4js.ts.types.ContainerType) MemberList(org.eclipse.n4js.ts.types.util.MemberList) TInterface(org.eclipse.n4js.ts.types.TInterface) N4InterfaceDeclaration(org.eclipse.n4js.n4JS.N4InterfaceDeclaration)

Example 2 with ParameterizedTypeRef

use of org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef in project n4js by eclipse.

the class PolyfillValidatorFragment method holdsExpliciteExtends.

/**
 * Constraint (Polyfill Class) 156.1
 */
private boolean holdsExpliciteExtends(PolyfillValidationState state) {
    final ParameterizedTypeRef filledTypeRef = state.n4Class.getSuperClassRef();
    if (filledTypeRef == null) {
        // (Polyfill Class) 156.1
        final String msg = getMessageForCLF_POLYFILL_EXTEND_MISSING(state.name);
        addIssue(state, msg, CLF_POLYFILL_EXTEND_MISSING);
        return false;
    }
    return true;
}
Also used : ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef)

Example 3 with ParameterizedTypeRef

use of org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef in project n4js by eclipse.

the class InferenceContext method containsInterestingLowerBound.

private boolean containsInterestingLowerBound(TypeRef[] typeRefs) {
    final Type undefinedType = RuleEnvironmentExtensions.undefinedType(G);
    final Type nullType = RuleEnvironmentExtensions.nullType(G);
    for (int i = 0; i < typeRefs.length; i++) {
        final TypeRef curr = typeRefs[i];
        if (curr instanceof ParameterizedTypeRef) {
            // for ParameterizedTypeRefs, it depends on the declared type:
            final Type currDeclType = curr.getDeclaredType();
            if (currDeclType != null && currDeclType != undefinedType && currDeclType != nullType) {
                // wow, that bound is interesting!
                return true;
            }
        } else {
            // all non-ParameterizedTypeRefs are interesting, except UnknownTypeRef:
            if (!(curr instanceof UnknownTypeRef)) {
                // wow, that bound looks intriguing!
                return true;
            }
        }
    }
    // no interesting bounds encountered
    return false;
}
Also used : ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) Type(org.eclipse.n4js.ts.types.Type) UnknownTypeRef(org.eclipse.n4js.ts.typeRefs.UnknownTypeRef) ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) TypeRef(org.eclipse.n4js.ts.typeRefs.TypeRef) UnknownTypeRef(org.eclipse.n4js.ts.typeRefs.UnknownTypeRef)

Example 4 with ParameterizedTypeRef

use of org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef in project n4js by eclipse.

the class InternalTypeSystem method applyRuleTypeYieldExpression.

protected Result<TypeRef> applyRuleTypeYieldExpression(final RuleEnvironment G, final RuleApplicationTrace _trace_, final YieldExpression y) throws RuleFailedException {
    // output parameter
    TypeRef T = null;
    TypeRef t = null;
    boolean _isMany = y.isMany();
    if (_isMany) {
        final Expression yieldValue = y.getExpression();
        /* G |- yieldValue : var TypeRef yieldValueTypeRef */
        TypeRef yieldValueTypeRef = null;
        Result<TypeRef> result = typeInternal(G, _trace_, yieldValue);
        checkAssignableTo(result.getFirst(), TypeRef.class);
        yieldValueTypeRef = (TypeRef) result.getFirst();
        final BuiltInTypeScope scope = RuleEnvironmentExtensions.getPredefinedTypes(G).builtInTypeScope;
        boolean _isGenerator = TypeUtils.isGenerator(yieldValueTypeRef, scope);
        if (_isGenerator) {
            t = this.typeSystemHelper.getGeneratorTReturn(G, yieldValueTypeRef);
        } else {
            final ParameterizedTypeRef itTypeRef = RuleEnvironmentExtensions.iterableTypeRef(G, TypeUtils.createWildcard());
            /* G |- yieldValueTypeRef <: itTypeRef */
            boolean _ruleinvocation = subtypeSucceeded(G, _trace_, yieldValueTypeRef, itTypeRef);
            final boolean isIterable = _ruleinvocation;
            if (isIterable) {
                t = scope.getAnyTypeRef();
            }
        }
    } else {
        final TypeRef actualGenTypeRef = this.typeSystemHelper.getActualGeneratorReturnType(G, y);
        if ((actualGenTypeRef != null)) {
            t = this.typeSystemHelper.getGeneratorTNext(G, actualGenTypeRef);
        }
    }
    if ((t == null)) {
        t = RuleEnvironmentExtensions.anyTypeRef(G);
    }
    T = t;
    return new Result<TypeRef>(T);
}
Also used : ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) BinaryBitwiseExpression(org.eclipse.n4js.n4JS.BinaryBitwiseExpression) AssignmentExpression(org.eclipse.n4js.n4JS.AssignmentExpression) IndexedAccessExpression(org.eclipse.n4js.n4JS.IndexedAccessExpression) UnionTypeExpression(org.eclipse.n4js.ts.typeRefs.UnionTypeExpression) FunctionExpression(org.eclipse.n4js.n4JS.FunctionExpression) PromisifyExpression(org.eclipse.n4js.n4JS.PromisifyExpression) UnaryExpression(org.eclipse.n4js.n4JS.UnaryExpression) ParenExpression(org.eclipse.n4js.n4JS.ParenExpression) ParameterizedCallExpression(org.eclipse.n4js.n4JS.ParameterizedCallExpression) AdditiveExpression(org.eclipse.n4js.n4JS.AdditiveExpression) PostfixExpression(org.eclipse.n4js.n4JS.PostfixExpression) YieldExpression(org.eclipse.n4js.n4JS.YieldExpression) ConditionalExpression(org.eclipse.n4js.n4JS.ConditionalExpression) FunctionTypeExpression(org.eclipse.n4js.ts.typeRefs.FunctionTypeExpression) RelationalExpression(org.eclipse.n4js.n4JS.RelationalExpression) NewExpression(org.eclipse.n4js.n4JS.NewExpression) IntersectionTypeExpression(org.eclipse.n4js.ts.typeRefs.IntersectionTypeExpression) AwaitExpression(org.eclipse.n4js.n4JS.AwaitExpression) CommaExpression(org.eclipse.n4js.n4JS.CommaExpression) Expression(org.eclipse.n4js.n4JS.Expression) CastExpression(org.eclipse.n4js.n4JS.CastExpression) BinaryLogicalExpression(org.eclipse.n4js.n4JS.BinaryLogicalExpression) EqualityExpression(org.eclipse.n4js.n4JS.EqualityExpression) ShiftExpression(org.eclipse.n4js.n4JS.ShiftExpression) ParameterizedPropertyAccessExpression(org.eclipse.n4js.n4JS.ParameterizedPropertyAccessExpression) MultiplicativeExpression(org.eclipse.n4js.n4JS.MultiplicativeExpression) N4ClassExpression(org.eclipse.n4js.n4JS.N4ClassExpression) ThisTypeRef(org.eclipse.n4js.ts.typeRefs.ThisTypeRef) ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) BaseTypeRef(org.eclipse.n4js.ts.typeRefs.BaseTypeRef) FunctionTypeRef(org.eclipse.n4js.ts.typeRefs.FunctionTypeRef) ExistentialTypeRef(org.eclipse.n4js.ts.typeRefs.ExistentialTypeRef) BoundThisTypeRef(org.eclipse.n4js.ts.typeRefs.BoundThisTypeRef) StructuralTypeRef(org.eclipse.n4js.ts.typeRefs.StructuralTypeRef) TypeRef(org.eclipse.n4js.ts.typeRefs.TypeRef) TypeTypeRef(org.eclipse.n4js.ts.typeRefs.TypeTypeRef) StaticBaseTypeRef(org.eclipse.n4js.ts.typeRefs.StaticBaseTypeRef) ComposedTypeRef(org.eclipse.n4js.ts.typeRefs.ComposedTypeRef) UnknownTypeRef(org.eclipse.n4js.ts.typeRefs.UnknownTypeRef) BuiltInTypeScope(org.eclipse.n4js.ts.scoping.builtin.BuiltInTypeScope) Result(org.eclipse.xsemantics.runtime.Result) StructuralTypingResult(org.eclipse.n4js.typesystem.StructuralTypingResult)

Example 5 with ParameterizedTypeRef

use of org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef in project n4js by eclipse.

the class InternalTypeSystem method typeImpl.

protected Result<TypeRef> typeImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final ShiftExpression e) throws RuleFailedException {
    try {
        final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
        final Result<TypeRef> _result_ = applyRuleTypeShiftExpression(G, _subtrace_, e);
        addToTrace(_trace_, new Provider<Object>() {

            public Object get() {
                return ruleName("typeShiftExpression") + stringRepForEnv(G) + " |- " + stringRep(e) + " : " + stringRep(_result_.getFirst());
            }
        });
        addAsSubtrace(_trace_, _subtrace_);
        return _result_;
    } catch (Exception e_applyRuleTypeShiftExpression) {
        typeThrowException(ruleName("typeShiftExpression") + stringRepForEnv(G) + " |- " + stringRep(e) + " : " + "ParameterizedTypeRef", TYPESHIFTEXPRESSION, e_applyRuleTypeShiftExpression, e, new ErrorInformation[] { new ErrorInformation(e) });
        return null;
    }
}
Also used : ErrorInformation(org.eclipse.xsemantics.runtime.ErrorInformation) ThisTypeRef(org.eclipse.n4js.ts.typeRefs.ThisTypeRef) ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) BaseTypeRef(org.eclipse.n4js.ts.typeRefs.BaseTypeRef) FunctionTypeRef(org.eclipse.n4js.ts.typeRefs.FunctionTypeRef) ExistentialTypeRef(org.eclipse.n4js.ts.typeRefs.ExistentialTypeRef) BoundThisTypeRef(org.eclipse.n4js.ts.typeRefs.BoundThisTypeRef) StructuralTypeRef(org.eclipse.n4js.ts.typeRefs.StructuralTypeRef) TypeRef(org.eclipse.n4js.ts.typeRefs.TypeRef) TypeTypeRef(org.eclipse.n4js.ts.typeRefs.TypeTypeRef) StaticBaseTypeRef(org.eclipse.n4js.ts.typeRefs.StaticBaseTypeRef) ComposedTypeRef(org.eclipse.n4js.ts.typeRefs.ComposedTypeRef) UnknownTypeRef(org.eclipse.n4js.ts.typeRefs.UnknownTypeRef) RuleApplicationTrace(org.eclipse.xsemantics.runtime.RuleApplicationTrace) EObject(org.eclipse.emf.ecore.EObject) RuleFailedException(org.eclipse.xsemantics.runtime.RuleFailedException)

Aggregations

ParameterizedTypeRef (org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef)80 TypeTypeRef (org.eclipse.n4js.ts.typeRefs.TypeTypeRef)48 TypeRef (org.eclipse.n4js.ts.typeRefs.TypeRef)47 BoundThisTypeRef (org.eclipse.n4js.ts.typeRefs.BoundThisTypeRef)45 ComposedTypeRef (org.eclipse.n4js.ts.typeRefs.ComposedTypeRef)44 ExistentialTypeRef (org.eclipse.n4js.ts.typeRefs.ExistentialTypeRef)44 StructuralTypeRef (org.eclipse.n4js.ts.typeRefs.StructuralTypeRef)44 BaseTypeRef (org.eclipse.n4js.ts.typeRefs.BaseTypeRef)42 FunctionTypeRef (org.eclipse.n4js.ts.typeRefs.FunctionTypeRef)42 ThisTypeRef (org.eclipse.n4js.ts.typeRefs.ThisTypeRef)42 UnknownTypeRef (org.eclipse.n4js.ts.typeRefs.UnknownTypeRef)42 StaticBaseTypeRef (org.eclipse.n4js.ts.typeRefs.StaticBaseTypeRef)41 RuleFailedException (org.eclipse.xsemantics.runtime.RuleFailedException)32 EObject (org.eclipse.emf.ecore.EObject)30 ErrorInformation (org.eclipse.xsemantics.runtime.ErrorInformation)23 Result (org.eclipse.xsemantics.runtime.Result)23 StructuralTypingResult (org.eclipse.n4js.typesystem.StructuralTypingResult)22 Type (org.eclipse.n4js.ts.types.Type)21 RuleApplicationTrace (org.eclipse.xsemantics.runtime.RuleApplicationTrace)21 ContainerType (org.eclipse.n4js.ts.types.ContainerType)17