Minor. Improved usability of CustomTypeVariable API
This commit is contained in:
+2
-2
@@ -423,8 +423,8 @@ public class ConstraintSystemImpl implements ConstraintSystem {
|
|||||||
// Foo >: T!
|
// Foo >: T!
|
||||||
// both Foo and Foo? transform to Foo! here
|
// both Foo and Foo? transform to Foo! here
|
||||||
if (TypesPackage.isFlexible(parameterType)) {
|
if (TypesPackage.isFlexible(parameterType)) {
|
||||||
CustomTypeVariable typeVariable = parameterType.getCapability(CustomTypeVariable.class);
|
CustomTypeVariable typeVariable = TypesPackage.getCustomTypeVariable(parameterType);
|
||||||
if (typeVariable != null && typeVariable.getIsTypeVariable()) {
|
if (typeVariable != null) {
|
||||||
constrainingType = typeVariable.substitutionResult(constrainingType);
|
constrainingType = typeVariable.substitutionResult(constrainingType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,3 +47,7 @@ public trait CustomTypeVariable : TypeCapability {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public fun JetType.isCustomTypeVariable(): Boolean = this.getCapability(javaClass<CustomTypeVariable>())?.isTypeVariable ?: false
|
public fun JetType.isCustomTypeVariable(): Boolean = this.getCapability(javaClass<CustomTypeVariable>())?.isTypeVariable ?: false
|
||||||
|
public fun JetType.getCustomTypeVariable(): CustomTypeVariable? =
|
||||||
|
this.getCapability(javaClass<CustomTypeVariable>())?.let {
|
||||||
|
if (it.isTypeVariable) it else null
|
||||||
|
}
|
||||||
@@ -187,9 +187,8 @@ public class TypeSubstitutor {
|
|||||||
return TypeUtils.makeStarProjection(typeParameter);
|
return TypeUtils.makeStarProjection(typeParameter);
|
||||||
case NO_CONFLICT:
|
case NO_CONFLICT:
|
||||||
JetType substitutedType;
|
JetType substitutedType;
|
||||||
if (TypesPackage.isCustomTypeVariable(type)) {
|
CustomTypeVariable typeVariable = TypesPackage.getCustomTypeVariable(type);
|
||||||
CustomTypeVariable typeVariable = type.getCapability(CustomTypeVariable.class);
|
if (typeVariable != null) {
|
||||||
assert typeVariable != null;
|
|
||||||
substitutedType = typeVariable.substitutionResult(replacement.getType());
|
substitutedType = typeVariable.substitutionResult(replacement.getType());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user