Class RawTypeConformanceComputer
- java.lang.Object
-
- org.eclipse.xtext.xbase.typesystem.conformance.RawTypeConformanceComputer
-
- Direct Known Subclasses:
TypeConformanceComputer
public class RawTypeConformanceComputer extends java.lang.Object
Implements conversion on the raw type level. The implementation provides hooks that are specialized by theTypeConformanceComputer
which will also check the type arguments. This architecture was chosen to avoid yet more conditions in the implementation of the type conformance check. It allows to dispatch early to the raw type check or the complete check based on the flags rather than probing this all the time in the implementation.- Noextend:
- This class is not intended to be subclassed by clients.
- Noinstantiate:
- This class is not intended to be instantiated by clients.
-
-
Field Summary
Fields Modifier and Type Field Description static int
ALLOW_BOXING
If this bit is set, boxing conversion may be applied to primitives and wrapper types.static int
ALLOW_BOXING_UNBOXING
If this bit is set, boxing and unboxing conversion may be applied to primitives and wrapper types.static int
ALLOW_FUNCTION_CONVERSION
Set this bit if synonym types should be considered.static int
ALLOW_PRIMITIVE_WIDENING
Indicates that widening conversion may be taken into account.static int
ALLOW_RAW_TYPE_CONVERSION
Indicate whether raw type conformance has to be taken into account.static int
ALLOW_SYNONYMS
Set this bit if synonym types should be considered.static int
ALLOW_UNBOXING
If this bit is set, unboxing conversion may be applied to primitives and wrapper types.static int
AS_NESTED_TYPE_ARGUMENT
Check for conformance as if the given types were used as type arguments of type arguments.static int
AS_TYPE_ARGUMENT
Check for conformance as if the given types were used as type arguments.static int
BOXING
If boxing conversion was necessary, this bit is set.static int
DEMAND_CONVERSION
If the result has this bit set, a demand conversion had to be applied to make both types compatible.static int
INCOMPATIBLE
static int
PRIMITIVE_WIDENING
This is set if primitive widening had to be applied.static int
RAW_TYPE
Indicates that the types should be checked as if they were raw types.static int
RAW_TYPE_CONVERSION
This is set if the conformance was possible due to raw type conversion.static int
SUBTYPE
Indicates that both types are in a subtype relationship.static int
SUCCESS
This bit indicates a successful check for conformance.static int
SYNONYM
If a synonym conversion was necessary, this bit is set in the result value.static int
UNBOUND_COMPUTATION_ADDS_HINTS
If otherwise unspecifiedunbound references
are given, the conformance check may alter the references andadd hints
.static int
UNBOXING
If unboxing conversion was necessary, this bit is set.static int
UNKNOWN_TYPE_PARTICIPATED
If one of the compared types was an unknown type, this bit is set in the result value.
-
Constructor Summary
Constructors Constructor Description RawTypeConformanceComputer()
-
Method Summary
-
-
-
Field Detail
-
RAW_TYPE
public static final int RAW_TYPE
Indicates that the types should be checked as if they were raw types. This bit will be set automatically if one of both types is actually a raw type andALLOW_RAW_TYPE_CONVERSION
is set.- See Also:
- Constant Field Values
-
AS_TYPE_ARGUMENT
public static final int AS_TYPE_ARGUMENT
Check for conformance as if the given types were used as type arguments. Type arguments have to be an exact type, e.g. they are not allowed to be in a subtype relationship, sinceList<Object>
is not a supertype ofList<String>
, e.g. if used as type argument,String
is not compatible toObject
.- See Also:
- Constant Field Values
-
ALLOW_RAW_TYPE_CONVERSION
public static final int ALLOW_RAW_TYPE_CONVERSION
Indicate whether raw type conformance has to be taken into account. Raw type conformance may not be considered for type arguments, e.g.Class<? extends Map>
andClass<? extends Map<String, String>>
are not compatible.- See Also:
- Constant Field Values
-
ALLOW_BOXING
public static final int ALLOW_BOXING
If this bit is set, boxing conversion may be applied to primitives and wrapper types.- See Also:
- Constant Field Values
-
ALLOW_UNBOXING
public static final int ALLOW_UNBOXING
If this bit is set, unboxing conversion may be applied to primitives and wrapper types.- See Also:
- Constant Field Values
-
ALLOW_BOXING_UNBOXING
public static final int ALLOW_BOXING_UNBOXING
If this bit is set, boxing and unboxing conversion may be applied to primitives and wrapper types.- See Also:
- Constant Field Values
-
ALLOW_PRIMITIVE_WIDENING
public static final int ALLOW_PRIMITIVE_WIDENING
Indicates that widening conversion may be taken into account.- See Also:
- Constant Field Values
-
UNBOUND_COMPUTATION_ADDS_HINTS
public static final int UNBOUND_COMPUTATION_ADDS_HINTS
If otherwise unspecifiedunbound references
are given, the conformance check may alter the references andadd hints
.- See Also:
- Constant Field Values
-
ALLOW_SYNONYMS
public static final int ALLOW_SYNONYMS
Set this bit if synonym types should be considered.- See Also:
- Constant Field Values
-
ALLOW_FUNCTION_CONVERSION
public static final int ALLOW_FUNCTION_CONVERSION
Set this bit if synonym types should be considered.- See Also:
- Constant Field Values
-
SUCCESS
public static final int SUCCESS
This bit indicates a successful check for conformance.- See Also:
- Constant Field Values
-
DEMAND_CONVERSION
public static final int DEMAND_CONVERSION
If the result has this bit set, a demand conversion had to be applied to make both types compatible. This is especially interesting for function types. Also aSYNONYM
may require a demand conversion.- See Also:
- Constant Field Values
-
SUBTYPE
public static final int SUBTYPE
Indicates that both types are in a subtype relationship.- See Also:
- Constant Field Values
-
PRIMITIVE_WIDENING
public static final int PRIMITIVE_WIDENING
This is set if primitive widening had to be applied.- See Also:
- Constant Field Values
-
UNBOXING
public static final int UNBOXING
If unboxing conversion was necessary, this bit is set.- See Also:
- Constant Field Values
-
BOXING
public static final int BOXING
If boxing conversion was necessary, this bit is set.- See Also:
- Constant Field Values
-
RAW_TYPE_CONVERSION
public static final int RAW_TYPE_CONVERSION
This is set if the conformance was possible due to raw type conversion.- See Also:
- Constant Field Values
-
SYNONYM
public static final int SYNONYM
If a synonym conversion was necessary, this bit is set in the result value.- See Also:
- Constant Field Values
-
UNKNOWN_TYPE_PARTICIPATED
public static final int UNKNOWN_TYPE_PARTICIPATED
If one of the compared types was an unknown type, this bit is set in the result value.- See Also:
- Constant Field Values
-
INCOMPATIBLE
public static final int INCOMPATIBLE
- See Also:
- Constant Field Values
-
AS_NESTED_TYPE_ARGUMENT
public static final int AS_NESTED_TYPE_ARGUMENT
Check for conformance as if the given types were used as type arguments of type arguments. E.g. anIterable<Iterable<?>>
is not assignable fromIterable<Iterable<? extends CharSequence>>
. The usage of the nested type argument is honored by this bit.- See Also:
- Constant Field Values
-
-
Method Detail
-
setSynonymTypesProvider
@Inject public void setSynonymTypesProvider(SynonymTypesProvider synonymTypesProvider)
-
isConformant
public int isConformant(LightweightTypeReference left, LightweightTypeReference right, int flags)
-
isSynonymConformant
protected int isSynonymConformant(int originalConformance, LightweightTypeReference left, LightweightTypeReference right, int flags)
-
doIsConformant
protected int doIsConformant(LightweightTypeReference left, LightweightTypeReference right, int flags)
-
doIsConformant
protected int doIsConformant(ParameterizedTypeReference left, ArrayTypeReference right, int flags)
-
doIsConformant
protected int doIsConformant(ArrayTypeReference left, ArrayTypeReference right, int flags)
-
doIsConformant
protected int doIsConformant(ArrayTypeReference left, ParameterizedTypeReference right, int flags)
-
doIsConformant
protected int doIsConformant(LightweightTypeReference left, WildcardTypeReference right, int flags)
-
doIsConformant
protected int doIsConformant(WildcardTypeReference left, LightweightTypeReference right, int flags)
-
doIsConformant
protected int doIsConformant(WildcardTypeReference left, WildcardTypeReference right, int flags)
-
doIsConformantToAnyType
protected int doIsConformantToAnyType(ParameterizedTypeReference left, int flags)
-
doIsConformant
protected int doIsConformant(LightweightTypeReference left, UnboundTypeReference right, int flags)
-
doIsConformant
protected int doIsConformant(UnboundTypeReference left, UnboundTypeReference right, int flags)
-
tryResolveAndCheckConformance
protected int tryResolveAndCheckConformance(UnboundTypeReference left, LightweightTypeReference right, int flags)
-
tryResolveAndCheckConformance
protected int tryResolveAndCheckConformance(UnboundTypeReference left, java.util.List<LightweightBoundTypeArgument> leftHints, LightweightTypeReference right, int flags)
-
isConformantToConstraints
protected int isConformantToConstraints(UnboundTypeReference left, LightweightTypeReference right, java.util.List<LightweightBoundTypeArgument> leftHints, int flags)
-
addHintAndAnnounceSuccess
protected int addHintAndAnnounceSuccess(UnboundTypeReference left, LightweightTypeReference hint, int flags)
-
isConformantMergeResult
protected int isConformantMergeResult(LightweightMergedBoundTypeArgument mergeResult, LightweightTypeReference right, int flags)
-
doIsConformant
protected int doIsConformant(ParameterizedTypeReference left, FunctionTypeReference right, int flags)
-
doIsConformant
protected int doIsConformant(FunctionTypeReference left, FunctionTypeReference right, int flags)
-
doIsConformant
protected int doIsConformant(FunctionTypeReference left, ParameterizedTypeReference right, int flags)
-
doIsConformant
protected int doIsConformant(InnerFunctionTypeReference left, InnerFunctionTypeReference right, int flags)
-
doIsConformant
protected int doIsConformant(InnerFunctionTypeReference left, InnerTypeReference right, int flags)
-
doIsConformant
protected int doIsConformant(InnerTypeReference left, InnerFunctionTypeReference right, int flags)
-
doIsConformant
protected int doIsConformant(InnerTypeReference left, InnerTypeReference right, int flags)
-
doIsConformantOuter
protected int doIsConformantOuter(LightweightTypeReference left, LightweightTypeReference right, int nestedResult, int flags)
-
doIsConformant
protected int doIsConformant(ParameterizedTypeReference left, ParameterizedTypeReference right, int flags)
-
isAssignableAsFunctionType
protected int isAssignableAsFunctionType(ParameterizedTypeReference left, ParameterizedTypeReference right, int flags)
-
internalGetPrimitiveKindFromWrapper
protected int internalGetPrimitiveKindFromWrapper(org.eclipse.xtext.common.types.JvmGenericType type)
-
doIsConformantTypeArguments
protected int doIsConformantTypeArguments(LightweightTypeReference left, LightweightTypeReference right, int flags)
This is a hook for theTypeConformanceComputer
to implement the type argument check.
-
getSuperType
protected LightweightTypeReference getSuperType(ParameterizedTypeReference current, org.eclipse.xtext.common.types.JvmType type)
This is a hook for theTypeConformanceComputer
to provide the resolved super type.
-
-