Minor. Improved usability of CustomTypeVariable API

This commit is contained in:
Andrey Breslav
2014-10-12 23:16:58 +04:00
parent 070a7d4d72
commit 8e8f41e228
3 changed files with 9 additions and 6 deletions
@@ -423,8 +423,8 @@ public class ConstraintSystemImpl implements ConstraintSystem {
// Foo >: T!
// both Foo and Foo? transform to Foo! here
if (TypesPackage.isFlexible(parameterType)) {
CustomTypeVariable typeVariable = parameterType.getCapability(CustomTypeVariable.class);
if (typeVariable != null && typeVariable.getIsTypeVariable()) {
CustomTypeVariable typeVariable = TypesPackage.getCustomTypeVariable(parameterType);
if (typeVariable != null) {
constrainingType = typeVariable.substitutionResult(constrainingType);
}
}
@@ -46,4 +46,8 @@ public trait CustomTypeVariable : TypeCapability {
public fun substitutionResult(replacement: JetType): JetType
}
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);
case NO_CONFLICT:
JetType substitutedType;
if (TypesPackage.isCustomTypeVariable(type)) {
CustomTypeVariable typeVariable = type.getCapability(CustomTypeVariable.class);
assert typeVariable != null;
CustomTypeVariable typeVariable = TypesPackage.getCustomTypeVariable(type);
if (typeVariable != null) {
substitutedType = typeVariable.substitutionResult(replacement.getType());
}
else {