[FIR] add missing resolve to isFinalClassConstructor

fix checking for intersection types in CheckIncompatibleTypeVariableUpperBounds

we need this resolve, because getEmptyIntersectionTypeKind under
the hood uses org.jetbrains.kotlin.resolve.checkers.EmptyIntersectionTypeChecker.computeEmptyIntersectionEmptiness
which uses computeByHavingCommonSubtype where we have
isFinalClassConstructor() call, so we need to resolve to STATUS phase
to get the correct modality

^KT-56543
This commit is contained in:
Dmitrii Gridin
2023-03-29 13:07:01 +02:00
committed by Space Team
parent 641b5d5fa7
commit 3ea1f7851b
5 changed files with 3 additions and 6 deletions
@@ -303,7 +303,7 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
val symbol = toClassLikeSymbol() ?: return false
if (symbol is FirAnonymousObjectSymbol) return true
val classSymbol = symbol as? FirRegularClassSymbol ?: return false
return classSymbol.fir.modality == Modality.FINAL
return classSymbol.modality == Modality.FINAL
}
override fun TypeVariableMarker.freshTypeConstructor(): TypeConstructorMarker {
@@ -1,7 +1,7 @@
/kt48935.kt:8:35: warning: parameter 'func' is never used
/kt48935.kt:7:35: warning: parameter 'func' is never used
fun <T, V> exampleGenericFunction(func: V) where T: Base, V: (T) -> Unit {
^
/kt48935.kt:14:5: warning: type argument for a type parameter T has possible incompatible upper bounds: Base, DoesNotImplementBase (final class and interface)
/kt48935.kt:13:5: warning: type argument for a type parameter T has possible incompatible upper bounds: Base, DoesNotImplementBase (final class and interface)
exampleGenericFunction(func) // expected this to be a compilation error as the T: Base constraint should not be satisfied
^
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// FIR_IDENTICAL
// RENDER_DIAGNOSTICS_FULL_TEXT
interface Base
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// FIR_IDENTICAL
interface Base
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// FIR_IDENTICAL
// !DIAGNOSTICS: -FINAL_UPPER_BOUND -CAST_NEVER_SUCCEEDS
// !LANGUAGE: +AllowEmptyIntersectionsInResultTypeResolver