Class BoundIncorporation
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static BoundIncorporationprotected static final Stringthe name to be used for Log.info, etc. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected List<Constraint> _incorporate(List<Bound> newBounds, List<Bound> oldBounds) protected SymTypeInferenceVariableprotected List<Constraint> getCommonSuperTypeConstraints(List<? extends SymTypeExpression> startTypes) Gets the constraints that exists due to common nominal super types, e.g.,a <: A<B>, a <: A<C> --> <B = C>.protected List<Constraint> getConstraintsFromCommonSuperTypes(SymTypeInferenceVariable infVar, SymTypeExpression superType1, SymTypeExpression superType2, Bound b1, Bound b2) protected List<Constraint> getConstraintsFromFilteredCommonSuperTypes(SymTypeInferenceVariable typeVar, List<? extends SymTypeExpression> commonSuperTypes) Helper forgetConstraintsFromCommonSuperTypes(de.monticore.types.check.SymTypeInferenceVariable, de.monticore.types.check.SymTypeExpression, de.monticore.types.check.SymTypeExpression, de.monticore.types3.generics.bounds.Bound, de.monticore.types3.generics.bounds.Bound), may ONLY EVER be called from this method, as it relies on a lot of assumptions.protected static BoundIncorporationprotected List<List<SymTypeExpression>> getNominalSuperTypePaths(SymTypeExpression startType) Helper forgetCommonSuperTypeConstraints(List).protected booleanhasTypeVariables(SymTypeExpression symType) protected List<Constraint> incorporate(Bound b1, Bound b2) returns the constraints resulting from a complementary bound-pair s.protected List<Constraint> incorporate(CaptureBound bCap, SubTypingBound bS) protected List<Constraint> incorporate(CaptureBound bCap, TypeCompatibilityBound bComp) basically a copy ofincorporate(CaptureBound, SubTypingBound)protected List<Constraint> incorporate(CaptureBound bCap, TypeEqualityBound bE) protected List<Constraint> incorporate(SubTypingBound b1, SubTypingBound b2) protected List<Constraint> incorporate(SubTypingBound bS, TypeCompatibilityBound bComp) protected List<Constraint> protected List<Constraint> protected List<Constraint> incorporate(TypeEqualityBound bE, TypeCompatibilityBound bComp) protected List<Constraint> static List<Constraint> incorporate(List<Bound> bounds) static List<Constraint> incorporate(List<Bound> newBounds, List<Bound> oldBounds) returns the constraints resulting from complementary bound-pairs s.protected Optional<Constraint> protected List<Constraint> protected List<Constraint> protected Optional<Constraint> protected Optional<Constraint> basically identical toincorporateNonSymmetrical(TypeEqualityBound, SubTypingBound)protected Optional<Constraint> static voidinit()protected StringprintBounds(List<Bound> bounds) protected StringprintConstraints(List<Constraint> constraints) static voidreset()protected static voidsetDelegate(BoundIncorporation newDelegate)
-
Field Details
-
LOG_NAME
the name to be used for Log.info, etc.- See Also:
-
delegate
-
-
Constructor Details
-
BoundIncorporation
public BoundIncorporation()
-
-
Method Details
-
incorporate
returns the constraints resulting from complementary bound-pairs s. JLS 21 18.3.1- Parameters:
newBounds- newly added through, e.g., constraint reductionoldBounds- have already been used to get constraints
-
incorporate
-
_incorporate
-
incorporate
returns the constraints resulting from a complementary bound-pair s. JLS 21 18.3.1 -
incorporate
-
incorporateNonSymmetrical
protected Optional<Constraint> incorporateNonSymmetrical(TypeEqualityBound b1, TypeEqualityBound b2) -
incorporate
-
incorporateNonSymmetrical
-
incorporate
-
incorporateNonSymmetrical
protected List<Constraint> incorporateNonSymmetrical(TypeCompatibilityBound b1, TypeCompatibilityBound b2) -
incorporate
-
incorporate
-
incorporateNonSymmetrical
-
incorporate
-
incorporateNonSymmetrical
protected Optional<Constraint> incorporateNonSymmetrical(TypeEqualityBound bE, TypeCompatibilityBound bComp) basically identical toincorporateNonSymmetrical(TypeEqualityBound, SubTypingBound) -
incorporate
-
incorporate
basically a copy ofincorporate(CaptureBound, SubTypingBound) -
incorporate
-
incorporateNonSymmetrical
-
getConstraintsFromCommonSuperTypes
protected List<Constraint> getConstraintsFromCommonSuperTypes(SymTypeInferenceVariable infVar, SymTypeExpression superType1, SymTypeExpression superType2, Bound b1, Bound b2) Helper forincorporateNonSymmetrical(SubTypingBound, SubTypingBound),incorporateNonSymmetrical(TypeCompatibilityBound, TypeCompatibilityBound),incorporate(SubTypingBound, TypeCompatibilityBound). Givena <: A and a <: B, due to them being supertypes of the same type, constraints follow, e.g.,List<a>andList<B>lead to the constraint<a = B>. If different rules apply (e.g., in OCL), then this method could be overwritten. However, as of now it is simply assumed that 1. One does not derive from build in collection types (this should hold!) 2. Java-Collection types simply fulfill the constraint above, which may or may not get unintuitive in combination with boxing.For TypeCompatibilityBounds, we assume the same rules, e.g.
a --> A<b>anda <: A<int>results in<b = int>. This may need to be overridden for type systems with more flexible compatibility rules, but we currently do not assume there to be a need for such a system, this seems to be a sane restriction to make. -
getConstraintsFromFilteredCommonSuperTypes
protected List<Constraint> getConstraintsFromFilteredCommonSuperTypes(SymTypeInferenceVariable typeVar, List<? extends SymTypeExpression> commonSuperTypes) Helper forgetConstraintsFromCommonSuperTypes(de.monticore.types.check.SymTypeInferenceVariable, de.monticore.types.check.SymTypeExpression, de.monticore.types.check.SymTypeExpression, de.monticore.types3.generics.bounds.Bound, de.monticore.types3.generics.bounds.Bound), may ONLY EVER be called from this method, as it relies on a lot of assumptions. It is only a separate method as it needs to be called recursively.- Parameters:
commonSuperTypes- may not contain any type variables
-
getCommonSuperTypeConstraints
protected List<Constraint> getCommonSuperTypeConstraints(List<? extends SymTypeExpression> startTypes) Gets the constraints that exists due to common nominal super types, e.g.,a <: A<B>, a <: A<C> --> <B = C>. The (nominal) supertype relationship, given the common super types as start nodes, spans a directed acyclic graph. For each pair of common super types; For each path starting at one of the common super types, there has to be at least on node common with a path starting at the other common super type. Currently, we use a simple brute-force solution.note: this allows combinations without common super types, e.g., A and B (each without any supertypes). This is due to there being the type
(A & B), which may exist in a modeling language, e.g., A and B being interfaces in Java-esque languages. One could add rules likeA & Bcannot exists if they are classes (and not interfaces) here (by overriding this method); However, alternatively (and probably the simpler choice), one can create a CoCo checking all intersections of calculated ASTMCTypes/ASTExpressions after type inference and check if they can exist according to the languages rules. S.a. SymTypeNormalizeVisitor::intersectObjectTypes -
getNominalSuperTypePaths
Helper forgetCommonSuperTypeConstraints(List). Does NOT deepclone SymTypeExpressions. -
hasTypeVariables
-
createFreshVariable
-
printConstraints
-
printBounds
-
init
public static void init() -
reset
public static void reset() -
setDelegate
-
getDelegate
-