[fir compiler] ensure type parameters are included in the resolve scope
to resolve the next parameter bounds (KTIJ-23674)
This commit is contained in:
+6
@@ -608,6 +608,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/typeFromGetter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterInBoundsLocalFunction.kt")
|
||||
public void testTypeParameterInBoundsLocalFunction() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/typeParameterInBoundsLocalFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterInPropertyReceiver.kt")
|
||||
public void testTypeParameterInPropertyReceiver() throws Exception {
|
||||
|
||||
+5
@@ -514,6 +514,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/typeFromGetter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("typeParameterInBoundsLocalFunction.kt")
|
||||
public void testTypeParameterInBoundsLocalFunction() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/typeParameterInBoundsLocalFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("typeParameterInPropertyReceiver.kt")
|
||||
public void testTypeParameterInPropertyReceiver() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/typeParameterInPropertyReceiver.kt");
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
FILE: typeParameterInBoundsLocalFunction.kt
|
||||
package test
|
||||
|
||||
public final fun f(): R|kotlin/Unit| {
|
||||
local final fun <A, B : R|A|> f1(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package test
|
||||
fun f() {
|
||||
fun <A, B: A> f1() {}
|
||||
}
|
||||
+6
@@ -608,6 +608,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/typeFromGetter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterInBoundsLocalFunction.kt")
|
||||
public void testTypeParameterInBoundsLocalFunction() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/typeParameterInBoundsLocalFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterInPropertyReceiver.kt")
|
||||
public void testTypeParameterInPropertyReceiver() throws Exception {
|
||||
|
||||
+6
@@ -608,6 +608,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/typeFromGetter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterInBoundsLocalFunction.kt")
|
||||
public void testTypeParameterInBoundsLocalFunction() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/typeParameterInBoundsLocalFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterInPropertyReceiver.kt")
|
||||
public void testTypeParameterInPropertyReceiver() throws Exception {
|
||||
|
||||
+2
-2
@@ -611,10 +611,10 @@ open class FirDeclarationsResolveTransformer(transformer: FirAbstractBodyResolve
|
||||
return simpleFunction
|
||||
}
|
||||
|
||||
doTransformTypeParameters(simpleFunction)
|
||||
|
||||
val containingDeclaration = context.containerIfAny
|
||||
return context.withSimpleFunction(simpleFunction, session) {
|
||||
doTransformTypeParameters(simpleFunction)
|
||||
|
||||
// TODO: I think it worth creating something like runAllPhasesForLocalFunction
|
||||
if (containingDeclaration != null && containingDeclaration !is FirClass) {
|
||||
// For class members everything should be already prepared
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ fun <T> Bar<T>.takeFoo(foo: Foo<out Any?>): Int = 1
|
||||
class Inv<O>
|
||||
|
||||
fun <K : <!FINAL_UPPER_BOUND!>Inv<out Inv<out Int>><!>> main() {
|
||||
fun <T, S : <!UNRESOLVED_REFERENCE!>T<!>> Bar<T>.takeFoo(foo: Foo<in S>): String = ""
|
||||
fun <T, S : T> Bar<T>.takeFoo(foo: Foo<in S>): String = ""
|
||||
|
||||
val foo = Foo<K>()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>Bar<Inv<in Inv<in Number>>>().takeFoo(foo)<!>
|
||||
|
||||
Vendored
-17
@@ -1,17 +0,0 @@
|
||||
// !LANGUAGE: +ForbidInferringTypeVariablesIntoEmptyIntersection
|
||||
// WITH_STDLIB
|
||||
|
||||
class Foo<T>
|
||||
|
||||
class Bar<T>
|
||||
|
||||
fun <T> Bar<T>.takeFoo(foo: Foo<out Any?>): Int = 1
|
||||
|
||||
class Inv<O>
|
||||
|
||||
fun <K : <!FINAL_UPPER_BOUND!>Inv<out Inv<out Int>><!>> main() {
|
||||
fun <T, S : <!UNRESOLVED_REFERENCE!>T<!>> Bar<T>.takeFoo(foo: Foo<in S>): String = ""
|
||||
|
||||
val foo = Foo<K>()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>Bar<Inv<in Inv<in Number>>>().takeFoo(foo)<!>
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +ForbidInferringTypeVariablesIntoEmptyIntersection
|
||||
// WITH_STDLIB
|
||||
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
fun bar() {
|
||||
fun <T: <!UNRESOLVED_REFERENCE!>T<!>?> foo() {}
|
||||
<!INAPPLICABLE_CANDIDATE!>foo<!>()
|
||||
fun <<!CYCLIC_GENERIC_UPPER_BOUND!>T: T?<!>> foo() {}
|
||||
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>foo<!>()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user