f20ec3e0a6
There is added a new service named `SubstitutingScopeProvider`, that provides factory that creates captured types and approximator for them. In OI they are the same as before commit, for NI they are empty, because that approximation interferes with NI algorithm That service is injected into function descriptors and property descriptors and used for creating `SubstitutingScope` with correct services Also there is changed time when we approximate captured types in NI (after all call checkers) #KT-25290 Fixed
29 lines
1005 B
Kotlin
Vendored
29 lines
1005 B
Kotlin
Vendored
// !WITH_NEW_INFERENCE
|
|
// !CHECK_TYPE
|
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
|
// FILE: main.kt
|
|
class Inv<T>(val x: T)
|
|
|
|
class A<T : Inv<in T>> {
|
|
fun foo(): T = null!!
|
|
}
|
|
|
|
class Inv2<<!FINITE_BOUNDS_VIOLATION!>T : Inv2<in T><!>>(val x: T)
|
|
|
|
fun main(a: A<*>, j: JavaClass<*>, i2: Inv2<*>) {
|
|
// Probably it's too restrictive to suppose star projection type here as Any?,
|
|
// but looks like we can refine it later
|
|
a.foo() checkType { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Any?>() }
|
|
j.foo() checkType { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Any?>() }
|
|
i2.x checkType { _<Any?>() }
|
|
|
|
j.bar(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>, <!CONSTANT_EXPECTED_TYPE_MISMATCH!>2<!>, <!NI;TYPE_MISMATCH, OI;TYPE_MISMATCH_DUE_TO_TYPE_PROJECTIONS!>Any()<!>)
|
|
j.bar(null)
|
|
}
|
|
|
|
// FILE: JavaClass.java
|
|
public class JavaClass<T extends JavaClass<? super T>> {
|
|
public void bar(T... x) {}
|
|
public T foo() {}
|
|
}
|