Treat mixed (subtyping, inference) sub-types properly in CST
This commit is contained in:
committed by
teamcity
parent
b3943f5ab6
commit
8b23d86bd9
+5
-13
@@ -204,28 +204,20 @@ object NewCommonSuperTypeCalculator {
|
|||||||
if (types.size == 1) return types.single()
|
if (types.size == 1) return types.single()
|
||||||
|
|
||||||
val nonTypeVariables = types.filter { !it.isStubTypeForVariableInSubtyping() && !isCapturedStubTypeForVariableInSubtyping(it) }
|
val nonTypeVariables = types.filter { !it.isStubTypeForVariableInSubtyping() && !isCapturedStubTypeForVariableInSubtyping(it) }
|
||||||
if (nonTypeVariables.size == 1) return nonTypeVariables.single()
|
|
||||||
|
|
||||||
assert(nonTypeVariables.isNotEmpty()) {
|
assert(nonTypeVariables.isNotEmpty()) {
|
||||||
"There should be at least one non-stub type to compute common supertype but there are: $types"
|
"There should be at least one non-stub type to compute common supertype but there are: $types"
|
||||||
}
|
}
|
||||||
|
|
||||||
val (builderInferenceStubTypes, nonBuilderInferenceStubTypes) = types.partition { it.isStubTypeForBuilderInference() }
|
val (builderInferenceStubTypes, nonStubTypes) = nonTypeVariables.partition { it.isStubTypeForBuilderInference() }
|
||||||
val areAllNonBuilderInferenceStubTypesNothing =
|
val areAllNonStubTypesNothing =
|
||||||
nonBuilderInferenceStubTypes.isNotEmpty() && nonBuilderInferenceStubTypes.all { it.isNothing() }
|
nonStubTypes.isNotEmpty() && nonStubTypes.all { it.isNothing() }
|
||||||
|
|
||||||
if (nonBuilderInferenceStubTypes.size == 1 && !areAllNonBuilderInferenceStubTypesNothing)
|
if (builderInferenceStubTypes.isNotEmpty() && (nonStubTypes.isEmpty() || areAllNonStubTypesNothing)) {
|
||||||
return nonBuilderInferenceStubTypes.single()
|
|
||||||
|
|
||||||
if (builderInferenceStubTypes.isNotEmpty()) {
|
|
||||||
// Common super type between any non stub type (except Nothing) and stub one is always Any?
|
|
||||||
if (nonBuilderInferenceStubTypes.isNotEmpty() && !areAllNonBuilderInferenceStubTypesNothing) {
|
|
||||||
return nullableAnyType()
|
|
||||||
}
|
|
||||||
return commonSuperTypeForBuilderInferenceStubTypes(builderInferenceStubTypes, stateStubTypesNotEqual)
|
return commonSuperTypeForBuilderInferenceStubTypes(builderInferenceStubTypes, stateStubTypesNotEqual)
|
||||||
}
|
}
|
||||||
|
|
||||||
val uniqueTypes = uniquify(nonTypeVariables, stateStubTypesNotEqual)
|
val uniqueTypes = uniquify(nonStubTypes, stateStubTypesNotEqual)
|
||||||
if (uniqueTypes.size == 1) return uniqueTypes.single()
|
if (uniqueTypes.size == 1) return uniqueTypes.single()
|
||||||
|
|
||||||
val explicitSupertypes = filterSupertypes(uniqueTypes, stateStubTypesNotEqual)
|
val explicitSupertypes = filterSupertypes(uniqueTypes, stateStubTypesNotEqual)
|
||||||
|
|||||||
Reference in New Issue
Block a user