FIR: Refine inference constraints when type variable in flexible position
That issue might be fixed via changing TypeVariableMarker.shouldBeFlexible at ConeConstraintSystemUtilContext but this and some other tricks have been added because of incorrect handling of constraints where type variable has a flexible bound ^KT-51168 Fixed
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
// SKIP_TXT
|
||||
// FILE: JavaClass.java
|
||||
public class JavaClass {
|
||||
public static <K> K simpleId(K k) { // fun <K> simpleId(k: K & Any..K?): K & Any..K? =
|
||||
return k;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun takeN(n: Number?): Int = 1
|
||||
|
||||
fun bar(n: Number?) {
|
||||
fun takeN(n: Number): String = ""
|
||||
|
||||
// in K1, it was resolved to nullable takeN
|
||||
// in K2, it would be resolved to not-nullable and may fail with NPE
|
||||
takeN(JavaClass.simpleId(n)).<!UNRESOLVED_REFERENCE!>div<!>(1)
|
||||
takeN(JavaClass.simpleId(n)).length
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// SKIP_TXT
|
||||
// FILE: JavaClass.java
|
||||
public class JavaClass {
|
||||
public static <K> K simpleId(K k) { // fun <K> simpleId(k: K & Any..K?): K & Any..K? =
|
||||
return k;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun takeN(n: Number?): Int = 1
|
||||
|
||||
fun bar(n: Number?) {
|
||||
fun takeN(n: Number): String = ""
|
||||
|
||||
// in K1, it was resolved to nullable takeN
|
||||
// in K2, it would be resolved to not-nullable and may fail with NPE
|
||||
takeN(JavaClass.simpleId(n)).div(1)
|
||||
takeN(JavaClass.simpleId(n)).<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// FIR_IDENTICAL
|
||||
// SKIP_TXT
|
||||
// FILE: XBreakpointProperties.java
|
||||
public abstract class XBreakpointProperties<T> {}
|
||||
// FILE: XBreakpoint.java
|
||||
public interface XBreakpoint<P extends XBreakpointProperties> {}
|
||||
// FILE: XBreakpointType.java
|
||||
public abstract class XBreakpointType<B extends XBreakpoint<P>, P extends XBreakpointProperties> {}
|
||||
|
||||
// FILE: main.kt
|
||||
fun foo(x: XBreakpointType<XBreakpoint<*>, *>) {}
|
||||
Reference in New Issue
Block a user