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);
}
}
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;
}
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;
}
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);
}
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;
}
}
Aggregations