diff --git a/core/descriptors/src/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl.java b/core/descriptors/src/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl.java index 640b4e05b35..0d5fb1fc1e6 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl.java @@ -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); } } diff --git a/core/descriptors/src/org/jetbrains/jet/lang/types/TypeCapabilities.kt b/core/descriptors/src/org/jetbrains/jet/lang/types/TypeCapabilities.kt index fbefc322258..65d81aa9903 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/types/TypeCapabilities.kt +++ b/core/descriptors/src/org/jetbrains/jet/lang/types/TypeCapabilities.kt @@ -46,4 +46,8 @@ public trait CustomTypeVariable : TypeCapability { public fun substitutionResult(replacement: JetType): JetType } -public fun JetType.isCustomTypeVariable(): Boolean = this.getCapability(javaClass())?.isTypeVariable ?: false \ No newline at end of file +public fun JetType.isCustomTypeVariable(): Boolean = this.getCapability(javaClass())?.isTypeVariable ?: false +public fun JetType.getCustomTypeVariable(): CustomTypeVariable? = + this.getCapability(javaClass())?.let { + if (it.isTypeVariable) it else null + } \ No newline at end of file diff --git a/core/descriptors/src/org/jetbrains/jet/lang/types/TypeSubstitutor.java b/core/descriptors/src/org/jetbrains/jet/lang/types/TypeSubstitutor.java index eb7c39f4c22..122b07f33c7 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/types/TypeSubstitutor.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/types/TypeSubstitutor.java @@ -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 {