Refactoring. Minor refactoring and cleanup in FlexibleTypes.

This commit is contained in:
Stanislav Erokhin
2016-04-22 18:58:52 +03:00
parent a1d052b8fa
commit feec3566a4
3 changed files with 22 additions and 38 deletions
@@ -294,18 +294,19 @@ class LazyJavaTypeResolver(
}
private class Impl(lowerBound: KotlinType, upperBound: KotlinType) :
DelegatingFlexibleType(lowerBound, upperBound, FlexibleJavaClassifierTypeFactory), CustomTypeVariable, Specificity {
DelegatingFlexibleType(lowerBound, upperBound, FlexibleJavaClassifierTypeFactory), CustomTypeVariable {
override val delegateType: KotlinType get() = lowerBound
override fun <T : TypeCapability> getCapability(capabilityClass: Class<T>): T? {
@Suppress("UNCHECKED_CAST")
return when (capabilityClass) {
CustomTypeVariable::class.java, Specificity::class.java -> this as T
else -> super.getCapability(capabilityClass)
}
if (capabilityClass == CustomTypeVariable::class.java) return this as T
return super.getCapability(capabilityClass)
}
override val isTypeVariable: Boolean = lowerBound.getConstructor() == upperBound.getConstructor()
&& lowerBound.getConstructor().getDeclarationDescriptor() is TypeParameterDescriptor
override val isTypeVariable: Boolean = lowerBound.constructor == upperBound.constructor
&& lowerBound.constructor.declarationDescriptor is TypeParameterDescriptor
override fun substitutionResult(replacement: KotlinType): KotlinType {
return if (replacement.isFlexible()) replacement
@@ -323,7 +324,7 @@ class LazyJavaTypeResolver(
// Int! >< Int?
if (otherType.isFlexible()) return Specificity.Relation.DONT_KNOW
// Int? >< Int!
if (otherType.isMarkedNullable()) return Specificity.Relation.DONT_KNOW
if (otherType.isMarkedNullable) return Specificity.Relation.DONT_KNOW
// Int! lessSpecific Int
return Specificity.Relation.LESS_SPECIFIC
}