[FE] Show causing types in the INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION diagnostic
This commit is contained in:
committed by
teamcity
parent
6a34b184ac
commit
867ad24c86
+4
-3
@@ -67,10 +67,11 @@ class ClassicTypeSystemContextForCS(
|
||||
}
|
||||
|
||||
override fun TypeSubstitutorMarker.safeSubstitute(type: KotlinTypeMarker): KotlinTypeMarker {
|
||||
require(type is UnwrappedType, type::errorMessage)
|
||||
require(type is KotlinType, type::errorMessage)
|
||||
val unwrappedType = type.unwrap()
|
||||
return when (this) {
|
||||
is NewTypeSubstitutor -> safeSubstitute(type)
|
||||
is TypeSubstitutor -> safeSubstitute(type, Variance.INVARIANT)
|
||||
is NewTypeSubstitutor -> safeSubstitute(unwrappedType)
|
||||
is TypeSubstitutor -> safeSubstitute(unwrappedType, Variance.INVARIANT)
|
||||
else -> error(this.errorMessage())
|
||||
}
|
||||
}
|
||||
|
||||
+9
-3
@@ -902,15 +902,21 @@ internal object CheckIncompatibleTypeVariableUpperBounds : ResolutionPart() {
|
||||
continue
|
||||
}
|
||||
else -> {
|
||||
val emptyIntersectionKind = constraintSystem.getEmptyIntersectionTypeKind(upperTypes).takeIf { it.isDefinitelyEmpty() }
|
||||
?: continue
|
||||
val emptyIntersectionTypeInfo = constraintSystem.getEmptyIntersectionTypeKind(upperTypes) ?: continue
|
||||
val isInferredEmptyIntersectionForbidden = callComponents.languageVersionSettings.supportsFeature(
|
||||
LanguageFeature.ForbidInferringTypeVariablesIntoEmptyIntersection
|
||||
)
|
||||
val errorFactory =
|
||||
if (isInferredEmptyIntersectionForbidden) ::InferredEmptyIntersectionError else ::InferredEmptyIntersectionWarning
|
||||
|
||||
addError(errorFactory(upperTypes, variableWithConstraints.typeVariable, emptyIntersectionKind))
|
||||
addError(
|
||||
errorFactory(
|
||||
upperTypes,
|
||||
emptyIntersectionTypeInfo.casingTypes.toList(),
|
||||
variableWithConstraints.typeVariable,
|
||||
emptyIntersectionTypeInfo.kind
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user