[NI] Implement various optimizations for incorporation algorithm
Mostly, these optimisations are picked from the old inference. Also, remove exponential complexity for flexible types in approximation, note that more correct fix for this would be to introduce new types that corresponds just to platform types to avoid nullability problems, but due to complexity it will be done later #KT-31415 Fixed
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@ package c
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
fun Array<Int>.toIntArray(): IntArray = this.<!NI;TYPE_MISMATCH!><!OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>mapTo<!>(<!NI;TYPE_MISMATCH!>IntArray(size)<!>, {<!NI;TYPE_MISMATCH!>it<!>})<!>
|
||||
fun Array<Int>.toIntArray(): IntArray = this.<!NI;TYPE_MISMATCH!><!OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>mapTo<!>(<!NI;TYPE_MISMATCH!>IntArray(size)<!>, {it})<!>
|
||||
|
||||
fun Array<Int>.toArrayList(): ArrayList<Int> = this.mapTo(ArrayList<Int>(size), {it})
|
||||
|
||||
|
||||
@@ -9,5 +9,5 @@ fun <T: Inv2<T>> foo(klass: Inv<T>): String? = null
|
||||
fun <X> bar(): Inv<X> = null!!
|
||||
|
||||
fun test() {
|
||||
<!OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>foo<!>(<!OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>bar<!>())
|
||||
<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>foo<!>(<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>bar<!>())
|
||||
}
|
||||
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// SKIP_JAVAC
|
||||
|
||||
// FILE: MySettings.java
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class MySettings<
|
||||
SS extends MySettings<SS, PS, L>,
|
||||
PS extends MyComparableSettings,
|
||||
L extends MySettingsListener<PS>
|
||||
>
|
||||
{
|
||||
public Collection<PS> getLinkedProjectsSettings() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static MySettings getSettings() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
abstract class MyComparableSettings implements Comparable<MyComparableSettings> {}
|
||||
abstract class MySettingsListener<S extends MyComparableSettings> {}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
fun test() {
|
||||
val a = MySettings.getSettings()
|
||||
a.getLinkedProjectsSettings()
|
||||
a.<!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER, OI;DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE, OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>linkedProjectsSettings<!>
|
||||
}
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
package
|
||||
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public open class MySettings</*0*/ SS : MySettings<SS!, PS!, L!>!, /*1*/ PS : MyComparableSettings!, /*2*/ L : MySettingsListener<PS!>!> {
|
||||
public constructor MySettings</*0*/ SS : MySettings<SS!, PS!, L!>!, /*1*/ PS : MyComparableSettings!, /*2*/ L : MySettingsListener<PS!>!>()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open fun getLinkedProjectsSettings(): kotlin.collections.(Mutable)Collection<PS!>!
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public open fun getSettings(): MySettings<(raw) MySettings<*, *, *>!, (raw) MyComparableSettings!, (raw) MySettingsListener<*>!>!
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// SKIP_JAVAC
|
||||
|
||||
// FILE: MySettings.java
|
||||
|
||||
import java.util.Collection
|
||||
|
||||
class MySettings<
|
||||
SS extends MySettings<SS, PS, L>,
|
||||
PS extends MyComparableSettings,
|
||||
L extends MySettingsListener<PS>
|
||||
>
|
||||
{
|
||||
public Collection<PS> getLinkedProjectsSettings() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static MySettings<?, ?, ?> getSettings() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
abstract class MyComparableSettings implements Comparable<MyComparableSettings> {}
|
||||
abstract class MySettingsListener<S extends MyComparableSettings> {}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
fun test() {
|
||||
val a = MySettings.getSettings()
|
||||
a.getLinkedProjectsSettings()
|
||||
a.<!OI;DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE, OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>linkedProjectsSettings<!>
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package
|
||||
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public/*package*/ open class MySettings</*0*/ SS : MySettings<SS!, PS!, L!>!, /*1*/ PS : MyComparableSettings!, /*2*/ L : MySettingsListener<PS!>!> {
|
||||
public/*package*/ constructor MySettings</*0*/ SS : MySettings<SS!, PS!, L!>!, /*1*/ PS : MyComparableSettings!, /*2*/ L : MySettingsListener<PS!>!>()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open fun getLinkedProjectsSettings(): kotlin.collections.(Mutable)Collection<PS!>!
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public open fun getSettings(): MySettings<*, *, *>!
|
||||
}
|
||||
+1
-1
@@ -7,7 +7,7 @@ fun <T> g (<!UNUSED_PARAMETER!>f<!>: () -> List<T>) : T {<!NO_RETURN_IN_FUNCTION
|
||||
|
||||
fun test() {
|
||||
//here possibly can be a cycle on constraints
|
||||
val <!UNUSED_VARIABLE!>x<!> = g { Collections.<!OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>emptyList<!>() }
|
||||
val <!UNUSED_VARIABLE!>x<!> = <!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>g<!> { Collections.<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>emptyList<!>() }
|
||||
|
||||
val <!UNUSED_VARIABLE!>y<!> = g<Int> { Collections.emptyList() }
|
||||
val <!UNUSED_VARIABLE!>z<!> : List<Int> = g { Collections.<!OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>emptyList<!>() }
|
||||
|
||||
Reference in New Issue
Block a user