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:
Denis.Zharkov
2023-12-19 17:13:35 +01:00
committed by Space Team
parent 90feeab076
commit 7e4d9d9f64
87 changed files with 2776 additions and 60 deletions
@@ -0,0 +1,67 @@
FILE fqName:<root> fileName:/noErrorTypeAfterCaptureApproximation.kt
CLASS CLASS name:Inv1 modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Inv1<X of <root>.Inv1>
TYPE_PARAMETER name:X index:0 variance: superTypes:[kotlin.Any?] reified:false
CONSTRUCTOR visibility:public <> () returnType:<root>.Inv1<X of <root>.Inv1> [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Inv1 modality:FINAL visibility:public superTypes:[kotlin.Any]'
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:Inv2 modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Inv2<Y of <root>.Inv2>
TYPE_PARAMETER name:Y index:0 variance: superTypes:[kotlin.Any?] reified:false
CONSTRUCTOR visibility:public <> () returnType:<root>.Inv2<Y of <root>.Inv2> [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Inv2 modality:FINAL visibility:public superTypes:[kotlin.Any]'
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:useSelectOptions visibility:internal modality:FINAL <F> (options:<root>.Inv1<out F of <root>.useSelectOptions>) returnType:<root>.Inv1<out <root>.Inv2<F of <root>.useSelectOptions>>
TYPE_PARAMETER name:F index:0 variance: superTypes:[kotlin.Any?] reified:false
VALUE_PARAMETER name:options index:0 type:<root>.Inv1<out F of <root>.useSelectOptions>
BLOCK_BODY
RETURN type=kotlin.Nothing from='internal final fun useSelectOptions <F> (options: <root>.Inv1<out F of <root>.useSelectOptions>): <root>.Inv1<out <root>.Inv2<F of <root>.useSelectOptions>> declared in <root>'
CALL 'public final fun myRun <T> (callback: kotlin.Function0<T of <root>.myRun>): T of <root>.myRun declared in <root>' type=<root>.Inv1<out <root>.Inv2<F of <root>.useSelectOptions>> origin=null
<T>: <root>.Inv1<out <root>.Inv2<F of <root>.useSelectOptions>>
callback: FUN_EXPR type=kotlin.Function0<<root>.Inv1<out <root>.Inv2<F of <root>.useSelectOptions>>> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:<root>.Inv1<out <root>.Inv2<F of <root>.useSelectOptions>>
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): <root>.Inv1<out <root>.Inv2<F of <root>.useSelectOptions>> declared in <root>.useSelectOptions'
CALL 'private final fun getSelectOptions <G> (options: <root>.Inv1<out G of <root>.getSelectOptions>): <root>.Inv1<out <root>.Inv2<G of <root>.getSelectOptions>> declared in <root>' type=<root>.Inv1<out <root>.Inv2<F of <root>.useSelectOptions>> origin=null
<G>: F of <root>.useSelectOptions
options: GET_VAR 'options: <root>.Inv1<out F of <root>.useSelectOptions> declared in <root>.useSelectOptions' type=<root>.Inv1<out F of <root>.useSelectOptions> origin=null
FUN name:getSelectOptions visibility:private modality:FINAL <G> (options:<root>.Inv1<out G of <root>.getSelectOptions>) returnType:<root>.Inv1<out <root>.Inv2<G of <root>.getSelectOptions>>
TYPE_PARAMETER name:G index:0 variance: superTypes:[kotlin.Any?] reified:false
VALUE_PARAMETER name:options index:0 type:<root>.Inv1<out G of <root>.getSelectOptions>
BLOCK_BODY
RETURN type=kotlin.Nothing from='private final fun getSelectOptions <G> (options: <root>.Inv1<out G of <root>.getSelectOptions>): <root>.Inv1<out <root>.Inv2<G of <root>.getSelectOptions>> declared in <root>'
CALL 'public final fun TODO (): kotlin.Nothing declared in kotlin' type=kotlin.Nothing origin=null
FUN name:myRun visibility:public modality:FINAL <T> (callback:kotlin.Function0<T of <root>.myRun>) returnType:T of <root>.myRun
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false
VALUE_PARAMETER name:callback index:0 type:kotlin.Function0<T of <root>.myRun>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun myRun <T> (callback: kotlin.Function0<T of <root>.myRun>): T of <root>.myRun declared in <root>'
CALL 'public final fun TODO (): kotlin.Nothing declared in kotlin' type=kotlin.Nothing origin=null
@@ -0,0 +1,18 @@
// FIR_IDENTICAL
class Inv1<X>
class Inv2<Y>
internal fun <F> useSelectOptions(
options: Inv1<out F>,
): Inv1<out Inv2<F>> =
myRun {
getSelectOptions(options)
}
private fun <G> getSelectOptions(
options: Inv1<out G>,
): Inv1<out Inv2<G>> = TODO()
fun <T> myRun(
callback: () -> T,
): T = TODO()
@@ -0,0 +1,32 @@
class Inv1<X : Any?> {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
}
class Inv2<Y : Any?> {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
}
internal fun <F : Any?> useSelectOptions(options: Inv1<out F>): Inv1<out Inv2<F>> {
return myRun<Inv1<out Inv2<F>>>(callback = local fun <anonymous>(): Inv1<out Inv2<F>> {
return getSelectOptions<F>(options = options)
}
)
}
private fun <G : Any?> getSelectOptions(options: Inv1<out G>): Inv1<out Inv2<G>> {
return TODO()
}
fun <T : Any?> myRun(callback: Function0<T>): T {
return TODO()
}
@@ -0,0 +1,51 @@
// CHECK:
// Mangled name: Inv1
// Public signature: /Inv1|null[0]
class Inv1<X : Any?> {
// CHECK:
// Mangled name: Inv1#<init>(){}
// Public signature: /Inv1.<init>|-5645683436151566731[0]
// Public signature debug description: <init>(){}
constructor() /* primary */
}
// CHECK:
// Mangled name: Inv2
// Public signature: /Inv2|null[0]
class Inv2<Y : Any?> {
// CHECK:
// Mangled name: Inv2#<init>(){}
// Public signature: /Inv2.<init>|-5645683436151566731[0]
// Public signature debug description: <init>(){}
constructor() /* primary */
}
// CHECK JVM_IR:
// Mangled name: #getSelectOptions(Inv1<out|0:0>){0§<kotlin.Any?>}Inv1<out|Inv2<0:0>>
// Public signature: [ File '/noErrorTypeAfterCaptureApproximation.kt' <- /getSelectOptions|-2121566878546647451[0] ]
// CHECK JS_IR NATIVE:
// Mangled name: #getSelectOptions(Inv1<out|0:0>){0§<kotlin.Any?>}
// Public signature: [ File '/noErrorTypeAfterCaptureApproximation.kt' <- /getSelectOptions|-4741332616265873823[0] ]
private fun <G : Any?> getSelectOptions(options: Inv1<out G>): Inv1<out Inv2<G>>
// CHECK JVM_IR:
// Mangled name: #myRun(kotlin.Function0<0:0>){0§<kotlin.Any?>}0:0
// Public signature: /myRun|-4555774550754215835[0]
// Public signature debug description: myRun(kotlin.Function0<0:0>){0§<kotlin.Any?>}0:0
// CHECK JS_IR NATIVE:
// Mangled name: #myRun(kotlin.Function0<0:0>){0§<kotlin.Any?>}
// Public signature: /myRun|1886570319999512118[0]
// Public signature debug description: myRun(kotlin.Function0<0:0>){0§<kotlin.Any?>}
fun <T : Any?> myRun(callback: Function0<T>): T
// CHECK JVM_IR:
// Mangled name: #useSelectOptions(Inv1<out|0:0>){0§<kotlin.Any?>}Inv1<out|Inv2<0:0>>
// Public signature: /useSelectOptions|-100409295329799165[0]
// Public signature debug description: useSelectOptions(Inv1<out|0:0>){0§<kotlin.Any?>}Inv1<out|Inv2<0:0>>
// CHECK JS_IR NATIVE:
// Mangled name: #useSelectOptions(Inv1<out|0:0>){0§<kotlin.Any?>}
// Public signature: /useSelectOptions|3229886791495085251[0]
// Public signature debug description: useSelectOptions(Inv1<out|0:0>){0§<kotlin.Any?>}
internal fun <F : Any?> useSelectOptions(options: Inv1<out F>): Inv1<out Inv2<F>>
@@ -0,0 +1,94 @@
FILE fqName:<root> fileName:/noSyntheticTypeParameterLeftAfterPCLA.kt
FUN name:box visibility:public modality:FINAL <> (b:kotlin.Boolean) returnType:kotlin.Unit
VALUE_PARAMETER name:b index:0 type:kotlin.Boolean
BLOCK_BODY
CALL 'public final fun generate <S> (g: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<<root>.Controller<S of <root>.generate>, kotlin.Unit>): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
<S>: kotlin.Unit
g: FUN_EXPR type=@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<<root>.Controller<kotlin.Unit>, kotlin.Unit> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.Controller<kotlin.Unit>) returnType:kotlin.Unit [suspend]
$receiver: VALUE_PARAMETER name:$this$generate type:<root>.Controller<kotlin.Unit>
BLOCK_BODY
CALL 'public final fun expectIntf (intf: <root>.Intf): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
intf: BLOCK type=<root>.box.<anonymous>.<no name provided> origin=OBJECT_LITERAL
CLASS CLASS name:<no name provided> modality:FINAL visibility:local superTypes:[<root>.Intf]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.box.<anonymous>.<no name provided>
CONSTRUCTOR visibility:public <> () returnType:<root>.box.<anonymous>.<no name provided> [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:<no name provided> modality:FINAL visibility:local superTypes:[<root>.Intf]'
FUN name:foo visibility:public modality:OPEN <> ($this:<root>.box.<anonymous>.<no name provided>) returnType:kotlin.Unit
overridden:
public abstract fun foo (): kotlin.Unit declared in <root>.Intf
$this: VALUE_PARAMETER name:<this> type:<root>.box.<anonymous>.<no name provided>
BLOCK_BODY
WHEN type=kotlin.Unit origin=IF
BRANCH
if: GET_VAR 'b: kotlin.Boolean declared in <root>.box' type=kotlin.Boolean origin=null
then: BLOCK type=kotlin.Unit origin=null
CALL 'public final fun someUnit (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: BLOCK type=kotlin.Unit origin=null
CALL 'public abstract fun yield (t: F of <root>.Controller): kotlin.Unit declared in <root>.Controller' type=kotlin.Unit origin=null
$this: GET_VAR '$this$generate: <root>.Controller<kotlin.Unit> declared in <root>.box.<anonymous>' type=<root>.Controller<kotlin.Unit> origin=null
t: GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in <root>.Intf
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in <root>.Intf
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in <root>.Intf
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.box.<anonymous>.<no name provided>' type=<root>.box.<anonymous>.<no name provided> origin=OBJECT_LITERAL
CALL 'public final fun someUnit (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
FUN name:expectIntf visibility:public modality:FINAL <> (intf:<root>.Intf) returnType:kotlin.Unit
VALUE_PARAMETER name:intf index:0 type:<root>.Intf
BLOCK_BODY
FUN name:someUnit visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
CLASS INTERFACE name:Intf modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Intf
FUN name:foo visibility:public modality:ABSTRACT <> ($this:<root>.Intf) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.Intf
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS INTERFACE name:Controller modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Controller<F of <root>.Controller>
TYPE_PARAMETER name:F index:0 variance: superTypes:[kotlin.Any?] reified:false
FUN name:yield visibility:public modality:ABSTRACT <> ($this:<root>.Controller<F of <root>.Controller>, t:F of <root>.Controller) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.Controller<F of <root>.Controller>
VALUE_PARAMETER name:t index:0 type:F of <root>.Controller
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:generate visibility:public modality:FINAL <S> (g:@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<<root>.Controller<S of <root>.generate>, kotlin.Unit>) returnType:kotlin.Unit
TYPE_PARAMETER name:S index:0 variance: superTypes:[kotlin.Any?] reified:false
VALUE_PARAMETER name:g index:0 type:@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<<root>.Controller<S of <root>.generate>, kotlin.Unit>
BLOCK_BODY
@@ -0,0 +1,34 @@
// FIR_IDENTICAL
fun box(b: Boolean) {
generate {
expectIntf(object : Intf {
override fun foo() {
if (b) {
// Do not debounce regex toggle event.
someUnit()
}
else {
yield(Unit)
}
}
})
someUnit()
}
}
fun expectIntf(intf: Intf) {}
fun someUnit() {}
interface Intf {
fun foo()
}
interface Controller<F> {
fun yield(t: F)
}
fun <S> generate(g: suspend Controller<S>.() -> Unit) {}
@@ -0,0 +1,48 @@
fun box(b: Boolean) {
generate<Unit>(g = local suspend fun Controller<Unit>.<anonymous>() {
expectIntf(intf = { // BLOCK
local class <no name provided> : Intf {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
override fun foo() {
when {
b -> { // BLOCK
someUnit()
}
else -> { // BLOCK
$this$generate.yield(t = Unit)
}
}
}
}
<no name provided>()
})
someUnit()
}
)
}
fun expectIntf(intf: Intf) {
}
fun someUnit() {
}
interface Intf {
abstract fun foo()
}
interface Controller<F : Any?> {
abstract fun yield(t: F)
}
fun <S : Any?> generate(g: @ExtensionFunctionType SuspendFunction1<Controller<S>, Unit>) {
}
@@ -0,0 +1,47 @@
// CHECK:
// Mangled name: Controller
// Public signature: /Controller|null[0]
interface Controller<F : Any?> {
// CHECK:
// Mangled name: Controller#yield(1:0){}
// Public signature: /Controller.yield|3567278141085588417[0]
// Public signature debug description: yield(1:0){}
abstract fun yield(t: F): Unit
}
// CHECK:
// Mangled name: Intf
// Public signature: /Intf|null[0]
interface Intf {
// CHECK:
// Mangled name: Intf#foo(){}
// Public signature: /Intf.foo|-1041209573719867811[0]
// Public signature debug description: foo(){}
abstract fun foo(): Unit
}
// CHECK:
// Mangled name: #box(kotlin.Boolean){}
// Public signature: /box|3724984511501944637[0]
// Public signature debug description: box(kotlin.Boolean){}
fun box(b: Boolean): Unit
// CHECK:
// Mangled name: #expectIntf(Intf){}
// Public signature: /expectIntf|-7688726594904654744[0]
// Public signature debug description: expectIntf(Intf){}
fun expectIntf(intf: Intf): Unit
// CHECK:
// Mangled name: #generate(kotlin.coroutines.SuspendFunction1<Controller<0:0>,kotlin.Unit>){0§<kotlin.Any?>}
// Public signature: /generate|-3399873670227373031[0]
// Public signature debug description: generate(kotlin.coroutines.SuspendFunction1<Controller<0:0>,kotlin.Unit>){0§<kotlin.Any?>}
fun <S : Any?> generate(g: @ExtensionFunctionType SuspendFunction1<Controller<S>, Unit>): Unit
// CHECK:
// Mangled name: #someUnit(){}
// Public signature: /someUnit|-6636253765775113966[0]
// Public signature debug description: someUnit(){}
fun someUnit(): Unit