Process simple CapturedType in ClassicTypeSystemContext.typeConstructorProjection as well

^KT-49101 Fixed
This commit is contained in:
Victor Petukhov
2021-10-19 14:21:55 +03:00
parent 836c6b280d
commit 2261928f4f
7 changed files with 67 additions and 2 deletions
@@ -13812,6 +13812,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/kt46727Warnings.kt");
}
@Test
@TestMetadata("kt49101.kt")
public void testKt49101() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/kt49101.kt");
}
@Test
@TestMetadata("memberScopeOfCaptured.kt")
public void testMemberScopeOfCaptured() throws Exception {
@@ -13812,6 +13812,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/kt46727Warnings.kt");
}
@Test
@TestMetadata("kt49101.kt")
public void testKt49101() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/kt49101.kt");
}
@Test
@TestMetadata("memberScopeOfCaptured.kt")
public void testMemberScopeOfCaptured() throws Exception {
@@ -13812,6 +13812,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/kt46727Warnings.kt");
}
@Test
@TestMetadata("kt49101.kt")
public void testKt49101() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/kt49101.kt");
}
@Test
@TestMetadata("memberScopeOfCaptured.kt")
public void testMemberScopeOfCaptured() throws Exception {
@@ -0,0 +1,13 @@
// FIR_IDENTICAL
class A<T: B<out Number>>(val x: T) {
fun test() {
val y: Int = x.m<<!UPPER_BOUND_VIOLATED!>C<out Number><!>>()
}
}
class B<T1> {
fun <X1: C<T1>> m(): Int = 1
}
class C<T>
@@ -0,0 +1,25 @@
package
public final class A</*0*/ T : B<out kotlin.Number>> {
public constructor A</*0*/ T : B<out kotlin.Number>>(/*0*/ x: T)
public final val x: T
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final fun test(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class B</*0*/ T1> {
public constructor B</*0*/ T1>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final fun </*0*/ X1 : C<T1>> m(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class C</*0*/ T> {
public constructor C</*0*/ T>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -13818,6 +13818,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/kt46727Warnings.kt");
}
@Test
@TestMetadata("kt49101.kt")
public void testKt49101() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/kt49101.kt");
}
@Test
@TestMetadata("memberScopeOfCaptured.kt")
public void testMemberScopeOfCaptured() throws Exception {
@@ -455,8 +455,11 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy
}
override fun CapturedTypeMarker.typeConstructorProjection(): TypeArgumentMarker {
require(this is NewCapturedType, this::errorMessage)
return this.constructor.projection
return when (this) {
is NewCapturedType -> this.constructor.projection
is CapturedType -> this.typeProjection
else -> error("Unsupported captured type")
}
}
override fun CapturedTypeMarker.withNotNullProjection(): KotlinTypeMarker {