K2: Add new tests for PCLA implementation
Many of them have been found & minimized at FP tests/user projects ^KT-59791 Fixed
This commit is contained in:
committed by
Space Team
parent
90feeab076
commit
7e4d9d9f64
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
// FIR_IDENTICAL
|
||||
|
||||
class Controller<T> {
|
||||
fun yield(t: T): Boolean = true
|
||||
}
|
||||
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
|
||||
fun <T, R> T.bar(x: (T) -> R): R = TODO()
|
||||
|
||||
var children: String = TODO()
|
||||
|
||||
fun main(key: String?, v: Number) {
|
||||
generate {
|
||||
yield("")
|
||||
// Here, elvis-synthetic call is not completed yet, but it's variable K is already fixed
|
||||
// Assignment is used, because for that (outside of PCLA) we would use FULL completion
|
||||
children = key ?: v.bar { it.toString() }
|
||||
}.length
|
||||
}
|
||||
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// FIR_IDENTICAL
|
||||
class Controller<T> {
|
||||
fun yield(t: T): Boolean = true
|
||||
}
|
||||
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
|
||||
|
||||
fun <R> foo(w: R, x: (R) -> R): R = TODO()
|
||||
|
||||
fun main() {
|
||||
generate {
|
||||
yield(1)
|
||||
yield(foo(2) { 3 })
|
||||
}
|
||||
}
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
// FIR_IDENTICAL
|
||||
class Controller<T>
|
||||
|
||||
fun <S> generate1(g: suspend (Controller<S>) -> Unit): S = TODO()
|
||||
fun <S> generate2(g: suspend Controller<S>.() -> Unit): S = TODO()
|
||||
|
||||
fun foo(c: Controller<String>) {}
|
||||
|
||||
fun foo() {
|
||||
val t1 = generate1 {
|
||||
foo(c = it)
|
||||
}
|
||||
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>t1<!>
|
||||
|
||||
val t2 = generate2 {
|
||||
foo(c = this)
|
||||
}
|
||||
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>t2<!>
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
// FIR_IDENTICAL
|
||||
// WITH_STDLIB
|
||||
import kotlin.reflect.KMutableProperty0
|
||||
|
||||
class Controller<T>
|
||||
|
||||
fun <S1> generate(g: suspend Controller<S1>.() -> Unit): S1 = TODO()
|
||||
|
||||
interface ReadonlyPropertyKey<V1, in K1>
|
||||
|
||||
fun <V2 : Any, K2> Controller<K2>.implement(
|
||||
propertyKey: ReadonlyPropertyKey<V2, K2>,
|
||||
getter: () -> V2,
|
||||
) {
|
||||
}
|
||||
|
||||
fun <V3 : Any, K3> Controller<K3>.implement(
|
||||
propertyKey: ReadonlyPropertyKey<V3, K3>,
|
||||
prop: KMutableProperty0<V3?>,
|
||||
) {
|
||||
}
|
||||
|
||||
interface Screen {
|
||||
val screen: Any? get() = ""
|
||||
}
|
||||
|
||||
val Name: ReadonlyPropertyKey<String, Screen> = TODO()
|
||||
|
||||
val Screen.name: String
|
||||
get() = ""
|
||||
|
||||
class A : Screen {
|
||||
fun foo() {
|
||||
generate {
|
||||
implement(Name, ::name)
|
||||
}.screen
|
||||
}
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// FIR_IDENTICAL
|
||||
fun <X> mySuspendable(block: (MyContinuation<X>) -> Unit): X = TODO()
|
||||
|
||||
interface MyContinuation<in Y> {
|
||||
fun cancel(): Unit
|
||||
}
|
||||
|
||||
fun <Z> MyContinuation<Z>.resume(value: Z) {}
|
||||
|
||||
fun cancelOrProceed(handler: (cancel: () -> Unit, proceed: () -> Unit) -> Unit) {
|
||||
mySuspendable { x ->
|
||||
// Was exception: Expected expression 'FirCallableReferenceAccessImpl' to be resolved
|
||||
handler(x::cancel) { x.resume("") }
|
||||
}.length
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// WITH_STDLIB
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.contract
|
||||
|
||||
class Controller<T> {
|
||||
fun yield(t: T): Boolean = true
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
fun <R, B : Any> Controller<R>.ensureNotNull(value: B?, shift: () -> R): B {
|
||||
contract { returns() implies (value != null) }
|
||||
return value!!
|
||||
}
|
||||
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
|
||||
|
||||
fun bar(x: Int) {}
|
||||
|
||||
fun foo(x: Int?) {
|
||||
generate {
|
||||
ensureNotNull(x) { "" }
|
||||
bar(x)
|
||||
}
|
||||
}
|
||||
compiler/testData/diagnostics/tests/inference/builderInference/considerContractsOfIncompleteCalls.kt
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
// WITH_STDLIB
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.contract
|
||||
|
||||
class Controller<T> {
|
||||
fun yield(t: T): Boolean = true
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
fun <R, B : Any> Controller<R>.ensureNotNull(value: B?, shift: () -> R): B {
|
||||
contract { returns() implies (value != null) }
|
||||
return value!!
|
||||
}
|
||||
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
|
||||
|
||||
fun bar(x: Int) {}
|
||||
|
||||
fun foo(x: Int?) {
|
||||
generate {
|
||||
ensureNotNull(x) { "" }
|
||||
bar(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// FIR_IDENTICAL
|
||||
|
||||
class Controller<T1> {
|
||||
fun yield(t: T1) {}
|
||||
}
|
||||
|
||||
fun <T2> generate(
|
||||
block: Controller<T2>.() -> Unit
|
||||
): T2 = TODO()
|
||||
|
||||
class Res<E1> {
|
||||
val e: E1 get() = TODO()
|
||||
}
|
||||
|
||||
fun foo(x: String): Res<String> = TODO()
|
||||
|
||||
fun <E2> emptyRes(): Res<E2> = TODO()
|
||||
|
||||
fun <R> myRun(r: () -> R): R = TODO()
|
||||
|
||||
fun baz(x: String?) {
|
||||
generate {
|
||||
val y = myRun {
|
||||
foo(x ?: return@myRun emptyRes())
|
||||
}
|
||||
|
||||
yield(y)
|
||||
}.e.length
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
fun <E> generate(c: Controller<E>.() -> Unit): E = TODO()
|
||||
|
||||
interface In<in T1> {
|
||||
fun call(t: T1) {}
|
||||
}
|
||||
|
||||
interface Controller<F> {
|
||||
val prop: In<F>
|
||||
fun get(): F
|
||||
}
|
||||
|
||||
fun <F> id(f: F): F = TODO()
|
||||
fun <F2> select(e1: F2, e: F2): F2 = e
|
||||
|
||||
fun main() {
|
||||
generate {
|
||||
prop.call("")
|
||||
}.length
|
||||
|
||||
generate {
|
||||
id(prop).call("")
|
||||
}.length
|
||||
|
||||
generate {
|
||||
prop.call("")
|
||||
|
||||
get().<!UNRESOLVED_REFERENCE!>length<!>
|
||||
|
||||
id(get()).length
|
||||
}.length
|
||||
|
||||
generate {
|
||||
select("", get()).length
|
||||
}.length
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
fun <E> generate(c: Controller<E>.() -> Unit): E = TODO()
|
||||
|
||||
interface In<in T1> {
|
||||
fun call(t: T1) {}
|
||||
}
|
||||
|
||||
interface Controller<F> {
|
||||
val prop: In<F>
|
||||
fun get(): F
|
||||
}
|
||||
|
||||
fun <F> id(f: F): F = TODO()
|
||||
fun <F2> select(e1: F2, e: F2): F2 = e
|
||||
|
||||
fun main() {
|
||||
generate {
|
||||
prop.call("")
|
||||
}.length
|
||||
|
||||
generate {
|
||||
id(prop).call("")
|
||||
}.length
|
||||
|
||||
generate {
|
||||
prop.call("")
|
||||
|
||||
get().<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE, DEBUG_INFO_UNRESOLVED_WITH_TARGET, UNRESOLVED_REFERENCE!>length<!>
|
||||
|
||||
id(get()).<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE, DEBUG_INFO_UNRESOLVED_WITH_TARGET, UNRESOLVED_REFERENCE!>length<!>
|
||||
}.length
|
||||
|
||||
generate {
|
||||
select("", get()).length
|
||||
}.length
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// FIR_IDENTICAL
|
||||
|
||||
interface Units<UValue : Any>
|
||||
|
||||
class SimpleDoubleUnits : Units<Double>
|
||||
|
||||
fun <BLeft : Any> build(builderCode: RendererBuilder<BLeft>.() -> Unit) {}
|
||||
|
||||
class RendererBuilder<RBLeft : Any> {
|
||||
var leftScaleCurves: CurveSet<RBLeft>? = null
|
||||
|
||||
fun addDecorations(render: suspend RenderContext<RBLeft>.() -> Unit) {}
|
||||
}
|
||||
|
||||
interface RenderContext<RCLeft : Any> {
|
||||
val leftScaleValueToY: ((RCLeft) -> Double)?
|
||||
}
|
||||
|
||||
class State {
|
||||
suspend fun render() {
|
||||
build {
|
||||
leftScaleCurves = CurveSet(SimpleDoubleUnits())
|
||||
addDecorations {
|
||||
leftScaleValueToY!!(0.67)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class CurveSet<CY : Any>(units: Units<CY>)
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
class Controller<T> {
|
||||
fun yield(t: T): Boolean = true
|
||||
fun get(): T = TODO()
|
||||
}
|
||||
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
|
||||
|
||||
interface A {
|
||||
val a: Any
|
||||
}
|
||||
|
||||
interface B : A {
|
||||
val b: Any
|
||||
}
|
||||
|
||||
fun <R> myWith(r: R, b: R.() -> Unit) {}
|
||||
|
||||
fun main(aI: A, bI: B) {
|
||||
val x = generate {
|
||||
// B <: S
|
||||
yield(bI)
|
||||
|
||||
// S <: R
|
||||
// B <: R
|
||||
// R = B
|
||||
// S = B
|
||||
myWith(get()) {
|
||||
this.a
|
||||
this.b
|
||||
}
|
||||
|
||||
yield(<!ARGUMENT_TYPE_MISMATCH!>aI<!>)
|
||||
}
|
||||
|
||||
x.a
|
||||
x.b
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
class Controller<T> {
|
||||
fun yield(t: T): Boolean = true
|
||||
fun get(): T = TODO()
|
||||
}
|
||||
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
|
||||
|
||||
interface A {
|
||||
val a: Any
|
||||
}
|
||||
|
||||
interface B : A {
|
||||
val b: Any
|
||||
}
|
||||
|
||||
fun <R> myWith(r: R, b: R.() -> Unit) {}
|
||||
|
||||
fun main(aI: A, bI: B) {
|
||||
val x = generate {
|
||||
// B <: S
|
||||
yield(bI)
|
||||
|
||||
// S <: R
|
||||
// B <: R
|
||||
// R = B
|
||||
// S = B
|
||||
myWith(get()) {
|
||||
this.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE, DEBUG_INFO_UNRESOLVED_WITH_TARGET, UNRESOLVED_REFERENCE!>a<!>
|
||||
this.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE, DEBUG_INFO_UNRESOLVED_WITH_TARGET, UNRESOLVED_REFERENCE!>b<!>
|
||||
}
|
||||
|
||||
yield(aI)
|
||||
}
|
||||
|
||||
x.a
|
||||
x.<!UNRESOLVED_REFERENCE!>b<!>
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
class Controller<T> {
|
||||
fun yield(t: T): Boolean = true
|
||||
fun get(): T = TODO()
|
||||
}
|
||||
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
|
||||
|
||||
fun bar(x: Any) {}
|
||||
fun <R> myWith(r: R, b: (R) -> Unit) {}
|
||||
|
||||
fun main() {
|
||||
generate {
|
||||
// S <: Any
|
||||
bar(get())
|
||||
|
||||
// S <: R
|
||||
// Any <: R
|
||||
myWith(get()) {
|
||||
it.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
|
||||
yield("")
|
||||
}.length
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
class Controller<T> {
|
||||
fun yield(t: T): Boolean = true
|
||||
fun get(): T = TODO()
|
||||
}
|
||||
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
|
||||
|
||||
fun bar(x: Any) {}
|
||||
fun <R> myWith(r: R, b: (R) -> Unit) {}
|
||||
|
||||
fun main() {
|
||||
generate {
|
||||
// S <: Any
|
||||
bar(get())
|
||||
|
||||
// S <: R
|
||||
// Any <: R
|
||||
myWith(get()) {
|
||||
it.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE, DEBUG_INFO_UNRESOLVED_WITH_TARGET, UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
|
||||
yield("")
|
||||
}.length
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
class Controller<T> {
|
||||
fun yield(t: T): Boolean = true
|
||||
fun get(): T = TODO()
|
||||
}
|
||||
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
|
||||
|
||||
fun <R> foo(w: R, x: (R) -> R): R = TODO()
|
||||
|
||||
fun <Q> materialize(): Q = TODO()
|
||||
|
||||
fun bar(x: String) {}
|
||||
|
||||
fun main() {
|
||||
generate {
|
||||
// S <: String
|
||||
bar(get())
|
||||
// R <: S
|
||||
// R <: String
|
||||
// R = String
|
||||
yield(foo(materialize()) { it.length.toString() })
|
||||
}
|
||||
|
||||
generate {
|
||||
// String <: S
|
||||
yield("")
|
||||
// S <: R
|
||||
// => String <: R
|
||||
// R = CST(S, String) = String
|
||||
foo(get()) { it.length.toString() }
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
class Controller<T> {
|
||||
fun yield(t: T): Boolean = true
|
||||
fun get(): T = TODO()
|
||||
}
|
||||
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
|
||||
|
||||
fun <R> foo(w: R, x: (R) -> R): R = TODO()
|
||||
|
||||
fun <Q> materialize(): Q = TODO()
|
||||
|
||||
fun bar(x: String) {}
|
||||
|
||||
fun main() {
|
||||
generate {
|
||||
// S <: String
|
||||
bar(get())
|
||||
// R <: S
|
||||
// R <: String
|
||||
// R = String
|
||||
yield(foo(materialize()) { it.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE, DEBUG_INFO_UNRESOLVED_WITH_TARGET, UNRESOLVED_REFERENCE!>length<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>toString<!>() })
|
||||
}
|
||||
|
||||
generate {
|
||||
// String <: S
|
||||
yield("")
|
||||
// S <: R
|
||||
// => String <: R
|
||||
// R = CST(S, String) = String
|
||||
foo(<!TYPE_MISMATCH, TYPE_MISMATCH!>get()<!>) { it.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE, DEBUG_INFO_UNRESOLVED_WITH_TARGET, UNRESOLVED_REFERENCE!>length<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>toString<!>() }
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
class Controller<T> {
|
||||
fun yield(t: T): Boolean = true
|
||||
}
|
||||
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
|
||||
|
||||
fun <E4> select(x: E4, y: E4) {}
|
||||
fun <E5> selectL(x: E5, y: E5, l: (E5) -> Unit) {}
|
||||
|
||||
fun main(x: Controller<String>) {
|
||||
generate {
|
||||
// Just adding the constraints
|
||||
// Controller<String> <: E4
|
||||
// Controller<S> <: E4
|
||||
// No fixation is required
|
||||
select(x, this)
|
||||
}.length
|
||||
|
||||
generate {
|
||||
// Adding the constraints
|
||||
// Controller<String> <: E5
|
||||
// Controller<S> <: E5
|
||||
// But to analyze lambda we fix E5 to CST(Controller<String>, Controller<S>) = Controller<CST(String, S)>
|
||||
// The question is what is CST(String, S)
|
||||
// And current answer in K2 is that it's String just the same way as when while fixating some TV, it has improper lower constraits
|
||||
// See org.jetbrains.kotlin.resolve.calls.inference.components.ResultTypeResolver.prepareLowerConstraints
|
||||
selectL(x, this) { x ->
|
||||
x.yield(<!ARGUMENT_TYPE_MISMATCH!>1<!>)
|
||||
x.yield("")
|
||||
}
|
||||
}.length
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
class Controller<T> {
|
||||
fun yield(t: T): Boolean = true
|
||||
}
|
||||
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
|
||||
|
||||
fun <E4> select(x: E4, y: E4) {}
|
||||
fun <E5> selectL(x: E5, y: E5, l: (E5) -> Unit) {}
|
||||
|
||||
fun main(x: Controller<String>) {
|
||||
generate {
|
||||
// Just adding the constraints
|
||||
// Controller<String> <: E4
|
||||
// Controller<S> <: E4
|
||||
// No fixation is required
|
||||
select(x, this)
|
||||
}.length
|
||||
|
||||
generate {
|
||||
// Adding the constraints
|
||||
// Controller<String> <: E5
|
||||
// Controller<S> <: E5
|
||||
// But to analyze lambda we fix E5 to CST(Controller<String>, Controller<S>) = Controller<CST(String, S)>
|
||||
// The question is what is CST(String, S)
|
||||
// And current answer in K2 is that it's String just the same way as when while fixating some TV, it has improper lower constraits
|
||||
// See org.jetbrains.kotlin.resolve.calls.inference.components.ResultTypeResolver.prepareLowerConstraints
|
||||
selectL(x, this) { x ->
|
||||
x.yield(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>)
|
||||
x.yield(<!TYPE_MISMATCH!>""<!>)
|
||||
}
|
||||
}.length
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// FIR_IDENTICAL
|
||||
|
||||
interface Controller<F> {
|
||||
fun yield(t: F)
|
||||
}
|
||||
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
|
||||
|
||||
fun foo(
|
||||
prop: Controller<String>.() -> Unit
|
||||
) {
|
||||
generate {
|
||||
prop()
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// FIR_IDENTICAL
|
||||
|
||||
interface Controller<F> {
|
||||
fun yield(t: F)
|
||||
}
|
||||
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
|
||||
|
||||
interface Topic<F>
|
||||
|
||||
fun <E : Any> subscribe(topic: Topic<E>, handler: E) {}
|
||||
|
||||
fun <L : Any, K> messageBusFlow(
|
||||
topic: Topic<L>,
|
||||
initialValue: (suspend () -> K)? = null,
|
||||
listener: suspend Controller<K>.() -> L
|
||||
) {
|
||||
generate {
|
||||
initialValue?.let { yield(it()) }
|
||||
subscribe(topic, listener())
|
||||
}
|
||||
}
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
// ISSUE: KT-64840 (K2/PCLA difference)
|
||||
class Controller<T> {
|
||||
fun yield(t: T): Boolean = true
|
||||
}
|
||||
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
|
||||
|
||||
interface A<F> {
|
||||
val a: F?
|
||||
}
|
||||
|
||||
interface B<G> : A<G>
|
||||
|
||||
fun <X> predicate(x: X, c: Controller<in X>, p: (X) -> Boolean) {}
|
||||
|
||||
fun main(a: A<*>) {
|
||||
generate {
|
||||
predicate(a, this) { it is <!NO_TYPE_ARGUMENTS_ON_RHS!>B<!> }
|
||||
}.a
|
||||
}
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
// ISSUE: KT-64840 (K2/PCLA difference)
|
||||
class Controller<T> {
|
||||
fun yield(t: T): Boolean = true
|
||||
}
|
||||
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
|
||||
|
||||
interface A<F> {
|
||||
val a: F?
|
||||
}
|
||||
|
||||
interface B<G> : A<G>
|
||||
|
||||
fun <X> predicate(x: X, c: Controller<in X>, p: (X) -> Boolean) {}
|
||||
|
||||
fun main(a: A<*>) {
|
||||
generate {
|
||||
predicate(a, this) { it is B }
|
||||
}.a
|
||||
}
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
// FIR_IDENTICAL
|
||||
class Controller<T> {
|
||||
fun yield(t: T): Boolean = true
|
||||
}
|
||||
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
|
||||
|
||||
fun foo() {
|
||||
val t = generate {
|
||||
yield("")
|
||||
bar(this, "") { it.length }
|
||||
}
|
||||
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>t<!>
|
||||
}
|
||||
|
||||
fun <R, F : Controller<in R>> bar(f: F, x: R, b: (R) -> Unit) {}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// FIR_IDENTICAL
|
||||
class Controller<T> {
|
||||
fun yield(t: T): Boolean = true
|
||||
}
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
|
||||
|
||||
fun <E, F> myMap(x: Controller<F>, y: E, b: (E) -> F) {}
|
||||
|
||||
fun <G> myTake(t: G, predicate: (G) -> Unit): G = TODO()
|
||||
|
||||
fun foo() {
|
||||
generate {
|
||||
myMap(this, "") {
|
||||
// NB: The statement below was relevant some time ago, but just it doesn't seem so, but left it for history
|
||||
// Here, to start analysis of the lambda, we need to fix the G variable and after that,
|
||||
// when we add a subtyping constraint from the whole `myTake` call to the last statement of the `myMap` lambda,
|
||||
// the return type of the former call contains fixed variable G.
|
||||
// That is quite irregular for non-PCLA cases, because ther we don't fix TVs that belong to return types.
|
||||
myTake("") { x ->
|
||||
x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// FIR_IDENTICAL
|
||||
class Controller<T> {
|
||||
fun yield(t: T): Boolean = true
|
||||
}
|
||||
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
|
||||
|
||||
interface Base
|
||||
interface Derived : Base
|
||||
|
||||
fun foo(
|
||||
base: Base,
|
||||
derived: Derived,
|
||||
) {
|
||||
val t = generate {
|
||||
twoBooleans(yield(base), yield(derived))
|
||||
}
|
||||
|
||||
// Should be Base, not just Derived
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Base")!>t<!>
|
||||
}
|
||||
|
||||
fun twoBooleans(x: Boolean, y: Boolean) {}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
// FIR_IDENTICAL
|
||||
class Controller<T> {
|
||||
fun yield(t: T): String = "1"
|
||||
}
|
||||
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
|
||||
|
||||
class MyAsserter<E : MyAsserter<E>> {
|
||||
fun self(): E = TODO()
|
||||
fun member() {}
|
||||
}
|
||||
|
||||
fun assertThat(x: String): MyAsserter<*> = TODO()
|
||||
|
||||
fun bar(): String? = null
|
||||
|
||||
fun check(b: Boolean, l: List<String>) {
|
||||
generate {
|
||||
assertThat("")
|
||||
.self()
|
||||
.member()
|
||||
|
||||
assertThat(bar()!!)
|
||||
.self()
|
||||
.member()
|
||||
|
||||
assertThat(yield(""))
|
||||
.self()
|
||||
.member()
|
||||
}.length
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// FIR_IDENTICAL
|
||||
|
||||
class Controller<T> {
|
||||
fun yield(t: T) {}
|
||||
}
|
||||
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit) {}
|
||||
|
||||
fun main() {
|
||||
generate {
|
||||
myRun {
|
||||
yield("")
|
||||
myLet {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun myLet(x: () -> Unit) {}
|
||||
fun <E> myRun(x: () -> E) {}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// FIR_IDENTICAL
|
||||
|
||||
fun <T> myRun(runnable: () -> T): T = TODO()
|
||||
|
||||
interface Controller<F> {
|
||||
fun yield(t: F)
|
||||
}
|
||||
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
|
||||
|
||||
fun foo(x: List<String>) {
|
||||
val y = generate {
|
||||
myRun {
|
||||
yield("")
|
||||
Unit
|
||||
}
|
||||
}
|
||||
|
||||
y.length
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// FIR_IDENTICAL
|
||||
// WITH_STDLIB
|
||||
|
||||
class Controller<T> {
|
||||
fun yield(t: T): Boolean = true
|
||||
}
|
||||
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
|
||||
|
||||
fun foo(x1: List<String>, x2: List<String>) {
|
||||
generate {
|
||||
yield(
|
||||
x1.flatMap1 {
|
||||
x2.map2 { "" }
|
||||
}
|
||||
)
|
||||
}.length
|
||||
}
|
||||
|
||||
fun <T1> Iterable<T1>.flatMap1(transform: (T1) -> String): String = TODO()
|
||||
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("flatMapSequence")
|
||||
fun <T2> Iterable<T2>.flatMap1(transform: (T2) -> Int): Int = TODO()
|
||||
|
||||
fun <T3, R3> T3.map2(transform: (T3) -> R3): R3 = TODO()
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// FIR_IDENTICAL
|
||||
class Controller<T> {
|
||||
fun yield(t: T): Boolean = true
|
||||
}
|
||||
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
|
||||
|
||||
class Out<out X>
|
||||
|
||||
fun <T1> catching(body: suspend () -> T1): Out<T1> = TODO()
|
||||
fun <R2, T2 : R2> Out<T2>.getOrElse2(onFailure: () -> R2): R2 = TODO()
|
||||
|
||||
fun <T3> myEmptyList(): List<T3> = TODO()
|
||||
|
||||
fun main(x: List<String>) {
|
||||
|
||||
generate {
|
||||
val languages = catching { x }.getOrElse2 {
|
||||
myEmptyList()
|
||||
}
|
||||
|
||||
yield(languages[0].length)
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
// FIR_IDENTICAL
|
||||
// WITH_STDLIB
|
||||
// WITH_RUNTIME
|
||||
|
||||
interface A1<X1>
|
||||
interface A2<X2>
|
||||
interface A3<X2>
|
||||
interface Res1<Y>
|
||||
interface Res2<Z>
|
||||
|
||||
class Controller<T> {
|
||||
fun yield(t: T) {}
|
||||
}
|
||||
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
|
||||
|
||||
fun main(src: A1<String>, res1: Res1<Int>) {
|
||||
generate {
|
||||
foo(src) { }
|
||||
// At this stage we've got E type variable not fixed
|
||||
// And two `bar` overloads one of which we should choose depending on the return type
|
||||
// But we can't _simply_ start lambda analysis with ConstraintSystemCompletionMode.UNTIL_FIRST_LAMBDA
|
||||
// because currently it only allows lambda analysis for completely ready
|
||||
.bar { y ->
|
||||
res1
|
||||
}
|
||||
|
||||
yield("")
|
||||
}.length
|
||||
}
|
||||
|
||||
fun <E> foo(x: A1<E>, block: () -> Unit): A2<A3<E>> = TODO()
|
||||
|
||||
fun <V1> A2<V1>.bar(transform: (A2<V1>) -> Res1<Int>) {}
|
||||
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("bar1")
|
||||
fun <V2> A2<V2>.bar(transform: (A2<V2>) -> Res2<Int>) {}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// FIR_IDENTICAL
|
||||
|
||||
class Controller<T> {
|
||||
fun yield(t: T): Boolean = true
|
||||
}
|
||||
|
||||
fun <R> myRun(b: () -> R) {}
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
|
||||
|
||||
fun foo(b: Boolean) {
|
||||
generate {
|
||||
myRun {
|
||||
if (b) {
|
||||
yield("")
|
||||
}
|
||||
}
|
||||
Unit
|
||||
}
|
||||
}
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
class Controller<T2>
|
||||
|
||||
fun <T1> generate(
|
||||
block: (Controller<T1>) -> Unit
|
||||
): T1 = TODO()
|
||||
|
||||
fun <E3> foobar(
|
||||
cont: Controller<E3>
|
||||
) {}
|
||||
|
||||
fun foo() {
|
||||
generate { cont ->
|
||||
foobar(cont <!USELESS_CAST!>as Controller<String><!>)
|
||||
baz(cont)
|
||||
}
|
||||
}
|
||||
|
||||
fun baz(cont: Controller<String>) {}
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
class Controller<T2>
|
||||
|
||||
fun <T1> generate(
|
||||
block: (Controller<T1>) -> Unit
|
||||
): T1 = TODO()
|
||||
|
||||
fun <E3> foobar(
|
||||
cont: Controller<E3>
|
||||
) {}
|
||||
|
||||
fun foo() {
|
||||
generate { cont ->
|
||||
foobar(cont as Controller<String>)
|
||||
baz(cont)
|
||||
}
|
||||
}
|
||||
|
||||
fun baz(cont: Controller<String>) {}
|
||||
Vendored
+58
@@ -0,0 +1,58 @@
|
||||
fun <R1> build(block: TestInterface<R1>.() -> Unit): R1 = TODO()
|
||||
|
||||
interface TestInterface<R> {
|
||||
fun emit(r: R)
|
||||
fun get(): R
|
||||
}
|
||||
|
||||
fun <X> select(x: X, y: X): X = x
|
||||
|
||||
fun test() {
|
||||
val ret0 = build l1@{
|
||||
emit("1")
|
||||
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit")!>build l2@{
|
||||
emit(1)
|
||||
select(this@l1.get(), get())
|
||||
}<!>
|
||||
}
|
||||
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Comparable<*> & java.io.Serializable")!>ret0<!>
|
||||
|
||||
val ret1 = build l1@{
|
||||
emit("1")
|
||||
|
||||
build l2@{
|
||||
emit(1)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>select(this@l1.get(), get())<!>
|
||||
}
|
||||
}
|
||||
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Comparable<*> & java.io.Serializable")!>ret1<!>
|
||||
|
||||
val ret2 = build l1@{
|
||||
emit("1")
|
||||
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>build l2@{
|
||||
emit(1)
|
||||
select(this@l1.get(), get())
|
||||
""
|
||||
}<!>
|
||||
""
|
||||
}
|
||||
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>ret2<!>
|
||||
|
||||
val ret3 = build l1@{
|
||||
emit("1")
|
||||
|
||||
build l2@{
|
||||
emit(1)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Comparable<*> & java.io.Serializable")!>select(this@l1.get(), get())<!>
|
||||
""
|
||||
}
|
||||
""
|
||||
}
|
||||
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>ret3<!>
|
||||
}
|
||||
Vendored
+58
@@ -0,0 +1,58 @@
|
||||
fun <R1> build(block: TestInterface<R1>.() -> Unit): R1 = TODO()
|
||||
|
||||
interface TestInterface<R> {
|
||||
fun emit(r: R)
|
||||
fun get(): R
|
||||
}
|
||||
|
||||
fun <X> select(x: X, y: X): X = x
|
||||
|
||||
fun test() {
|
||||
val ret0 = build l1@{
|
||||
emit("1")
|
||||
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit")!>build l2@{
|
||||
emit(1)
|
||||
select(<!TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH!>this@l1.get()<!>, get())
|
||||
}<!>
|
||||
}
|
||||
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("{Comparable<*> & java.io.Serializable}")!>ret0<!>
|
||||
|
||||
val ret1 = build l1@{
|
||||
emit("1")
|
||||
|
||||
build l2@{
|
||||
emit(1)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit")!>select(<!TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH!>this@l1.get()<!>, get())<!>
|
||||
}
|
||||
}
|
||||
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("{Comparable<*> & java.io.Serializable}")!>ret1<!>
|
||||
|
||||
val ret2 = build l1@{
|
||||
emit("1")
|
||||
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>build l2@{
|
||||
emit(1)
|
||||
select(this@l1.get(), get())
|
||||
""
|
||||
}<!>
|
||||
""
|
||||
}
|
||||
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>ret2<!>
|
||||
|
||||
val ret3 = build l1@{
|
||||
emit("1")
|
||||
|
||||
build l2@{
|
||||
emit(1)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>select(this@l1.get(), get())<!>
|
||||
""
|
||||
}
|
||||
""
|
||||
}
|
||||
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>ret3<!>
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// FILE: GenericJava.java
|
||||
public class GenericJava<F> {
|
||||
public java.util.List<F> getFoo() {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
class Controller<T> {
|
||||
fun yield(t: T) {}
|
||||
|
||||
fun gg(): GenericJava<T> = TODO()
|
||||
}
|
||||
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit) {}
|
||||
|
||||
fun main() {
|
||||
generate {
|
||||
yield("")
|
||||
gg().foo
|
||||
}
|
||||
}
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
// FILE: GenericJava.java
|
||||
public class GenericJava<F> {
|
||||
public java.util.List<F> getFoo() {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
class Controller<T> {
|
||||
fun yield(t: T) {}
|
||||
|
||||
fun gg(): GenericJava<T> = TODO()
|
||||
}
|
||||
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit) {}
|
||||
|
||||
fun main() {
|
||||
generate {
|
||||
yield("")
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("(kotlin.collections.MutableList<(TypeVariable(S)..TypeVariable(S)?)>..kotlin.collections.List<(TypeVariable(S)..TypeVariable(S)?)>?)")!>gg().foo<!>
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// FIR_IDENTICAL
|
||||
interface Box<F> {
|
||||
fun add(f: F)
|
||||
fun get(): F
|
||||
}
|
||||
|
||||
fun <E> myBuilder(x: Box<E>.() -> Unit): Box<E> = TODO()
|
||||
|
||||
fun main() {
|
||||
myBuilder {
|
||||
add("")
|
||||
}.get().length
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// FIR_IDENTICAL
|
||||
|
||||
interface Controller<F> {
|
||||
fun yield(t: F)
|
||||
}
|
||||
|
||||
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
|
||||
|
||||
fun foo(b: Boolean, buffer: Collection<String>) {
|
||||
generate {
|
||||
if (b) {
|
||||
val x: String = myLaunch {
|
||||
myRun {
|
||||
yield(buffer.toTypedArray2())
|
||||
}
|
||||
}
|
||||
}
|
||||
}.get(0).length
|
||||
}
|
||||
|
||||
fun <E> Collection<E>.toTypedArray2(): Array<E> = TODO()
|
||||
|
||||
fun myLaunch(
|
||||
block: () -> Unit
|
||||
): String = TODO()
|
||||
|
||||
fun myRun(action: () -> Unit): Unit = TODO()
|
||||
Reference in New Issue
Block a user