K2: Imitate K1 behavior for case of captured types with a raw supertype

See the comments in the code, but mostly the motivation is that once
it was decided to stick with such a legacy thing as raw types,
we are ok with some corner-cases hacks for them
(if there are not too many of them) and they don't break anything
when there are no raw types in the code.

^KT-56616 Fixed
This commit is contained in:
Denis.Zharkov
2023-02-22 13:45:53 +01:00
committed by Space Team
parent eb09a25239
commit 608cb01935
14 changed files with 172 additions and 44 deletions
@@ -19396,6 +19396,18 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
runTest("compiler/testData/diagnostics/tests/j+k/rawTypeScope.kt");
}
@Test
@TestMetadata("rawTypesFromCaptured.kt")
public void testRawTypesFromCaptured() throws Exception {
runTest("compiler/testData/diagnostics/tests/j+k/rawTypesFromCaptured.kt");
}
@Test
@TestMetadata("rawTypesFromCapturedOriginal.kt")
public void testRawTypesFromCapturedOriginal() throws Exception {
runTest("compiler/testData/diagnostics/tests/j+k/rawTypesFromCapturedOriginal.kt");
}
@Test
@TestMetadata("rawUpperBounds.kt")
public void testRawUpperBounds() throws Exception {
@@ -19402,6 +19402,18 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
runTest("compiler/testData/diagnostics/tests/j+k/rawTypeScope.kt");
}
@Test
@TestMetadata("rawTypesFromCaptured.kt")
public void testRawTypesFromCaptured() throws Exception {
runTest("compiler/testData/diagnostics/tests/j+k/rawTypesFromCaptured.kt");
}
@Test
@TestMetadata("rawTypesFromCapturedOriginal.kt")
public void testRawTypesFromCapturedOriginal() throws Exception {
runTest("compiler/testData/diagnostics/tests/j+k/rawTypesFromCapturedOriginal.kt");
}
@Test
@TestMetadata("rawUpperBounds.kt")
public void testRawUpperBounds() throws Exception {
@@ -558,6 +558,11 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
override fun useRefinedBoundsForTypeVariableInFlexiblePosition(): Boolean = true
override fun KotlinTypeMarker.convertToNonRaw(): KotlinTypeMarker {
require(this is ConeKotlinType)
return this.convertToNonRawVersion()
}
override fun createSubstitutorForSuperTypes(baseType: KotlinTypeMarker): TypeSubstitutorMarker? =
if (baseType is ConeLookupTagBasedType) createSubstitutionForSupertype(baseType, session) else null