FIR: Use flexible type for generic parameters bounds
Otherwise star projections may be incorrectly approximated to strictly nullable types (as in test)
This commit is contained in:
@@ -92,7 +92,7 @@ class JavaSymbolProvider(
|
||||
stack: JavaTypeParameterStack,
|
||||
) {
|
||||
for (upperBound in javaTypeParameter.upperBounds) {
|
||||
bounds += upperBound.toFirResolvedTypeRef(this@JavaSymbolProvider.session, stack, nullability = ConeNullability.NULLABLE)
|
||||
bounds += upperBound.toFirResolvedTypeRef(this@JavaSymbolProvider.session, stack, nullability = ConeNullability.UNKNOWN)
|
||||
}
|
||||
addDefaultBoundIfNecessary()
|
||||
}
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// FILE: B.java
|
||||
public class B<E extends A> {}
|
||||
|
||||
// FILE: main.kt
|
||||
interface A {}
|
||||
|
||||
fun <D : A> foo(b: B<D>) {}
|
||||
|
||||
fun main(b: B<*>) {
|
||||
foo(b)
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
FILE: main.kt
|
||||
public abstract interface A : R|kotlin/Any| {
|
||||
}
|
||||
public final fun <D : R|A|> foo(b: R|B<D>|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun main(b: R|B<*>|): R|kotlin/Unit| {
|
||||
R|/foo|<R|captured type: lowerType = null|>(R|<local>/b|)
|
||||
}
|
||||
+5
@@ -924,6 +924,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
|
||||
runTest("compiler/fir/resolve/testData/resolve/inference/callableReferenceOnInstance.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("capturedTypeForJavaTypeParameter.kt")
|
||||
public void testCapturedTypeForJavaTypeParameter() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/inference/capturedTypeForJavaTypeParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedLambdas.kt")
|
||||
public void testNestedLambdas() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/inference/nestedLambdas.kt");
|
||||
|
||||
Generated
+5
@@ -924,6 +924,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
||||
runTest("compiler/fir/resolve/testData/resolve/inference/callableReferenceOnInstance.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("capturedTypeForJavaTypeParameter.kt")
|
||||
public void testCapturedTypeForJavaTypeParameter() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/inference/capturedTypeForJavaTypeParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedLambdas.kt")
|
||||
public void testNestedLambdas() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/inference/nestedLambdas.kt");
|
||||
|
||||
Reference in New Issue
Block a user