Skip to content

Commit 4718830

Browse files
dzharkovSpace Team
authored andcommitted
FIR2IR: Add tests for KT-82590
1 parent ede9cd8 commit 4718830

42 files changed

Lines changed: 1324 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

analysis/low-level-api-fir/tests-gen/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLBlackBoxTestGenerated.java

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

analysis/low-level-api-fir/tests-gen/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLReversedBlackBoxTestGenerated.java

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// IGNORE_BACKEND: JS_IR, JS_IR_ES6
2+
// IGNORE_IR_DESERIALIZATION_TEST: JS_IR, JS_IR_ES6
3+
// IGNORE_BACKEND_K2: ANY
4+
// ISSUE: KT-82590
5+
6+
interface MyInterface
7+
8+
fun interface SimpleRibCoroutineWorker {
9+
suspend fun onStart(scope: MyInterface)
10+
}
11+
12+
class FooWorker(val s: String) : SimpleRibCoroutineWorker, (String) -> Unit {
13+
override suspend fun onStart(scope: MyInterface) {
14+
}
15+
16+
override fun toString(): String = s
17+
18+
override fun invoke(str: String) { /* no op*/ }
19+
}
20+
21+
var result = ""
22+
23+
fun foo(x: SimpleRibCoroutineWorker) {
24+
result += x.toString()
25+
}
26+
fun bar(vararg x: SimpleRibCoroutineWorker) {
27+
result += x[0].toString()
28+
}
29+
30+
fun createNewPlugin(): SimpleRibCoroutineWorker {
31+
val x: SimpleRibCoroutineWorker = FooWorker("O")
32+
result += x.toString()
33+
34+
return FooWorker("K")
35+
}
36+
37+
fun box(): String {
38+
val t = createNewPlugin().toString()
39+
result += t
40+
foo(FooWorker("1"))
41+
bar(FooWorker("2"))
42+
43+
if (result != "OK12") return "fail: $result"
44+
return "OK"
45+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// IGNORE_BACKEND: JS_IR, JS_IR_ES6
2+
// IGNORE_IR_DESERIALIZATION_TEST: JS_IR, JS_IR_ES6
3+
// IGNORE_BACKEND_K2: ANY
4+
// ISSUE: KT-82590
5+
6+
interface MyInterface
7+
8+
fun interface SimpleRibCoroutineWorker<E> {
9+
suspend fun onStart(scope: E)
10+
}
11+
12+
class FooWorker<F>(val s: String) : SimpleRibCoroutineWorker<F>, (String) -> Unit {
13+
override suspend fun onStart(scope: F) {
14+
}
15+
16+
override fun toString(): String = s
17+
18+
override fun invoke(str: String) { /* no op*/ }
19+
}
20+
21+
var result = ""
22+
23+
fun <T1> foo(x: SimpleRibCoroutineWorker<T1>) {
24+
result += x.toString()
25+
}
26+
fun <T2> bar(vararg x: SimpleRibCoroutineWorker<T2>) {
27+
result += x[0].toString()
28+
}
29+
30+
fun createNewPlugin(): SimpleRibCoroutineWorker<MyInterface> {
31+
val x: SimpleRibCoroutineWorker<MyInterface> = FooWorker("O")
32+
result += x.toString()
33+
34+
return FooWorker("K")
35+
}
36+
37+
fun box(): String {
38+
val t = createNewPlugin().toString()
39+
result += t
40+
foo<MyInterface>(FooWorker("1"))
41+
bar<MyInterface>(FooWorker("2"))
42+
43+
if (result != "OK12") return "fail: $result"
44+
return "OK"
45+
}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
FILE fqName:<root> fileName:/noConversionForSubtype.kt
2+
CLASS CLASS name:FooWorker modality:FINAL visibility:public superTypes:[<root>.SimpleRibCoroutineWorker; kotlin.Function1<kotlin.String, kotlin.Unit>]
3+
thisReceiver: VALUE_PARAMETER INSTANCE_RECEIVER kind:DispatchReceiver name:<this> type:<root>.FooWorker
4+
CONSTRUCTOR visibility:public returnType:<root>.FooWorker [primary]
5+
BLOCK_BODY
6+
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
7+
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:FooWorker modality:FINAL visibility:public superTypes:[<root>.SimpleRibCoroutineWorker; kotlin.Function1<kotlin.String, kotlin.Unit>]' type=kotlin.Unit
8+
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN returnType:kotlin.Boolean [fake_override,operator]
9+
VALUE_PARAMETER kind:DispatchReceiver name:<this> index:0 type:kotlin.Any
10+
VALUE_PARAMETER kind:Regular name:other index:1 type:kotlin.Any?
11+
overridden:
12+
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in <root>.SimpleRibCoroutineWorker
13+
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Function1
14+
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN returnType:kotlin.Int [fake_override]
15+
VALUE_PARAMETER kind:DispatchReceiver name:<this> index:0 type:kotlin.Any
16+
overridden:
17+
public open fun hashCode (): kotlin.Int declared in <root>.SimpleRibCoroutineWorker
18+
public open fun hashCode (): kotlin.Int declared in kotlin.Function1
19+
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN returnType:kotlin.String [fake_override]
20+
VALUE_PARAMETER kind:DispatchReceiver name:<this> index:0 type:kotlin.Any
21+
overridden:
22+
public open fun toString (): kotlin.String declared in <root>.SimpleRibCoroutineWorker
23+
public open fun toString (): kotlin.String declared in kotlin.Function1
24+
FUN name:invoke visibility:public modality:OPEN returnType:kotlin.Unit [operator]
25+
VALUE_PARAMETER kind:DispatchReceiver name:<this> index:0 type:<root>.FooWorker
26+
VALUE_PARAMETER kind:Regular name:str index:1 type:kotlin.String
27+
overridden:
28+
public abstract fun invoke (p1: P1 of kotlin.Function1): R of kotlin.Function1 declared in kotlin.Function1
29+
BLOCK_BODY
30+
FUN name:onStart visibility:public modality:OPEN returnType:kotlin.Unit [suspend]
31+
VALUE_PARAMETER kind:DispatchReceiver name:<this> index:0 type:<root>.FooWorker
32+
VALUE_PARAMETER kind:Regular name:scope index:1 type:<root>.MyInterface
33+
overridden:
34+
public abstract fun onStart (scope: <root>.MyInterface): kotlin.Unit declared in <root>.SimpleRibCoroutineWorker
35+
BLOCK_BODY
36+
CLASS INTERFACE name:MyInterface modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
37+
thisReceiver: VALUE_PARAMETER INSTANCE_RECEIVER kind:DispatchReceiver name:<this> type:<root>.MyInterface
38+
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN returnType:kotlin.Boolean [fake_override,operator]
39+
VALUE_PARAMETER kind:DispatchReceiver name:<this> index:0 type:kotlin.Any
40+
VALUE_PARAMETER kind:Regular name:other index:1 type:kotlin.Any?
41+
overridden:
42+
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any
43+
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN returnType:kotlin.Int [fake_override]
44+
VALUE_PARAMETER kind:DispatchReceiver name:<this> index:0 type:kotlin.Any
45+
overridden:
46+
public open fun hashCode (): kotlin.Int declared in kotlin.Any
47+
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN returnType:kotlin.String [fake_override]
48+
VALUE_PARAMETER kind:DispatchReceiver name:<this> index:0 type:kotlin.Any
49+
overridden:
50+
public open fun toString (): kotlin.String declared in kotlin.Any
51+
CLASS INTERFACE name:SimpleRibCoroutineWorker modality:ABSTRACT visibility:public [fun] superTypes:[kotlin.Any]
52+
thisReceiver: VALUE_PARAMETER INSTANCE_RECEIVER kind:DispatchReceiver name:<this> type:<root>.SimpleRibCoroutineWorker
53+
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN returnType:kotlin.Boolean [fake_override,operator]
54+
VALUE_PARAMETER kind:DispatchReceiver name:<this> index:0 type:kotlin.Any
55+
VALUE_PARAMETER kind:Regular name:other index:1 type:kotlin.Any?
56+
overridden:
57+
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any
58+
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN returnType:kotlin.Int [fake_override]
59+
VALUE_PARAMETER kind:DispatchReceiver name:<this> index:0 type:kotlin.Any
60+
overridden:
61+
public open fun hashCode (): kotlin.Int declared in kotlin.Any
62+
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN returnType:kotlin.String [fake_override]
63+
VALUE_PARAMETER kind:DispatchReceiver name:<this> index:0 type:kotlin.Any
64+
overridden:
65+
public open fun toString (): kotlin.String declared in kotlin.Any
66+
FUN name:onStart visibility:public modality:ABSTRACT returnType:kotlin.Unit [suspend]
67+
VALUE_PARAMETER kind:DispatchReceiver name:<this> index:0 type:<root>.SimpleRibCoroutineWorker
68+
VALUE_PARAMETER kind:Regular name:scope index:1 type:<root>.MyInterface
69+
FUN name:bar visibility:public modality:FINAL returnType:kotlin.Unit
70+
VALUE_PARAMETER kind:Regular name:x index:0 type:kotlin.Array<out <root>.SimpleRibCoroutineWorker> varargElementType:<root>.SimpleRibCoroutineWorker [vararg]
71+
BLOCK_BODY
72+
FUN name:createNewPlugin visibility:public modality:FINAL returnType:<root>.SimpleRibCoroutineWorker
73+
BLOCK_BODY
74+
VAR name:x type:<root>.SimpleRibCoroutineWorker [val]
75+
BLOCK type=kotlin.coroutines.SuspendFunction1<<root>.MyInterface, kotlin.Unit> origin=SUSPEND_CONVERSION
76+
FUN ADAPTER_FOR_SUSPEND_CONVERSION name:suspendConversion0 visibility:local modality:FINAL returnType:kotlin.Unit [suspend]
77+
VALUE_PARAMETER ADAPTER_PARAMETER_FOR_SUSPEND_CONVERSION kind:ExtensionReceiver name:$callee index:0 type:<root>.FooWorker
78+
VALUE_PARAMETER ADAPTER_PARAMETER_FOR_SUSPEND_CONVERSION kind:Regular name:p0 index:1 type:<root>.MyInterface
79+
BLOCK_BODY
80+
CALL 'public open fun invoke (str: kotlin.String): kotlin.Unit declared in <root>.FooWorker' type=kotlin.Unit origin=null
81+
ARG <this>: GET_VAR '$callee: <root>.FooWorker declared in <root>.createNewPlugin.suspendConversion0' type=<root>.FooWorker origin=null
82+
ARG str: GET_VAR 'p0: <root>.MyInterface declared in <root>.createNewPlugin.suspendConversion0' type=<root>.MyInterface origin=null
83+
FUNCTION_REFERENCE 'local final fun suspendConversion0 ($callee: <root>.FooWorker, p0: <root>.MyInterface): kotlin.Unit declared in <root>.createNewPlugin' type=kotlin.coroutines.SuspendFunction1<<root>.MyInterface, kotlin.Unit> origin=SUSPEND_CONVERSION reflectionTarget=null
84+
ARG $callee: CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.FooWorker' type=<root>.FooWorker origin=null
85+
RETURN type=kotlin.Nothing from='public final fun createNewPlugin (): <root>.SimpleRibCoroutineWorker declared in <root>'
86+
BLOCK type=kotlin.coroutines.SuspendFunction1<<root>.MyInterface, kotlin.Unit> origin=SUSPEND_CONVERSION
87+
FUN ADAPTER_FOR_SUSPEND_CONVERSION name:suspendConversion1 visibility:local modality:FINAL returnType:kotlin.Unit [suspend]
88+
VALUE_PARAMETER ADAPTER_PARAMETER_FOR_SUSPEND_CONVERSION kind:ExtensionReceiver name:$callee index:0 type:<root>.FooWorker
89+
VALUE_PARAMETER ADAPTER_PARAMETER_FOR_SUSPEND_CONVERSION kind:Regular name:p0 index:1 type:<root>.MyInterface
90+
BLOCK_BODY
91+
CALL 'public open fun invoke (str: kotlin.String): kotlin.Unit declared in <root>.FooWorker' type=kotlin.Unit origin=null
92+
ARG <this>: GET_VAR '$callee: <root>.FooWorker declared in <root>.createNewPlugin.suspendConversion1' type=<root>.FooWorker origin=null
93+
ARG str: GET_VAR 'p0: <root>.MyInterface declared in <root>.createNewPlugin.suspendConversion1' type=<root>.MyInterface origin=null
94+
FUNCTION_REFERENCE 'local final fun suspendConversion1 ($callee: <root>.FooWorker, p0: <root>.MyInterface): kotlin.Unit declared in <root>.createNewPlugin' type=kotlin.coroutines.SuspendFunction1<<root>.MyInterface, kotlin.Unit> origin=SUSPEND_CONVERSION reflectionTarget=null
95+
ARG $callee: CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.FooWorker' type=<root>.FooWorker origin=null
96+
FUN name:foo visibility:public modality:FINAL returnType:kotlin.Unit
97+
VALUE_PARAMETER kind:Regular name:x index:0 type:<root>.SimpleRibCoroutineWorker
98+
BLOCK_BODY
99+
FUN name:main visibility:public modality:FINAL returnType:kotlin.Unit
100+
BLOCK_BODY
101+
CALL 'public final fun foo (x: <root>.SimpleRibCoroutineWorker): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
102+
ARG x: BLOCK type=kotlin.coroutines.SuspendFunction1<<root>.MyInterface, kotlin.Unit> origin=SUSPEND_CONVERSION
103+
FUN ADAPTER_FOR_SUSPEND_CONVERSION name:suspendConversion0 visibility:local modality:FINAL returnType:kotlin.Unit [suspend]
104+
VALUE_PARAMETER ADAPTER_PARAMETER_FOR_SUSPEND_CONVERSION kind:ExtensionReceiver name:$callee index:0 type:<root>.FooWorker
105+
VALUE_PARAMETER ADAPTER_PARAMETER_FOR_SUSPEND_CONVERSION kind:Regular name:p0 index:1 type:<root>.MyInterface
106+
BLOCK_BODY
107+
CALL 'public open fun invoke (str: kotlin.String): kotlin.Unit declared in <root>.FooWorker' type=kotlin.Unit origin=null
108+
ARG <this>: GET_VAR '$callee: <root>.FooWorker declared in <root>.main.suspendConversion0' type=<root>.FooWorker origin=null
109+
ARG str: GET_VAR 'p0: <root>.MyInterface declared in <root>.main.suspendConversion0' type=<root>.MyInterface origin=null
110+
FUNCTION_REFERENCE 'local final fun suspendConversion0 ($callee: <root>.FooWorker, p0: <root>.MyInterface): kotlin.Unit declared in <root>.main' type=kotlin.coroutines.SuspendFunction1<<root>.MyInterface, kotlin.Unit> origin=SUSPEND_CONVERSION reflectionTarget=null
111+
ARG $callee: CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.FooWorker' type=<root>.FooWorker origin=null
112+
CALL 'public final fun bar (vararg x: <root>.SimpleRibCoroutineWorker): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
113+
ARG x: VARARG type=kotlin.Array<out <root>.SimpleRibCoroutineWorker> varargElementType=<root>.SimpleRibCoroutineWorker
114+
BLOCK type=kotlin.coroutines.SuspendFunction1<<root>.MyInterface, kotlin.Unit> origin=SUSPEND_CONVERSION
115+
FUN ADAPTER_FOR_SUSPEND_CONVERSION name:suspendConversion1 visibility:local modality:FINAL returnType:kotlin.Unit [suspend]
116+
VALUE_PARAMETER ADAPTER_PARAMETER_FOR_SUSPEND_CONVERSION kind:ExtensionReceiver name:$callee index:0 type:<root>.FooWorker
117+
VALUE_PARAMETER ADAPTER_PARAMETER_FOR_SUSPEND_CONVERSION kind:Regular name:p0 index:1 type:<root>.MyInterface
118+
BLOCK_BODY
119+
CALL 'public open fun invoke (str: kotlin.String): kotlin.Unit declared in <root>.FooWorker' type=kotlin.Unit origin=null
120+
ARG <this>: GET_VAR '$callee: <root>.FooWorker declared in <root>.main.suspendConversion1' type=<root>.FooWorker origin=null
121+
ARG str: GET_VAR 'p0: <root>.MyInterface declared in <root>.main.suspendConversion1' type=<root>.MyInterface origin=null
122+
FUNCTION_REFERENCE 'local final fun suspendConversion1 ($callee: <root>.FooWorker, p0: <root>.MyInterface): kotlin.Unit declared in <root>.main' type=kotlin.coroutines.SuspendFunction1<<root>.MyInterface, kotlin.Unit> origin=SUSPEND_CONVERSION reflectionTarget=null
123+
ARG $callee: CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.FooWorker' type=<root>.FooWorker origin=null
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
class FooWorker : SimpleRibCoroutineWorker, Function1<String, Unit> {
2+
constructor() /* primary */ {
3+
super/*Any*/()
4+
/* <init>() */
5+
6+
}
7+
8+
override operator fun invoke(str: String) {
9+
}
10+
11+
override suspend fun onStart(scope: MyInterface) {
12+
}
13+
14+
}
15+
16+
interface MyInterface {
17+
}
18+
19+
fun interface SimpleRibCoroutineWorker {
20+
abstract suspend fun onStart(scope: MyInterface)
21+
22+
}
23+
24+
fun bar(vararg x: SimpleRibCoroutineWorker) {
25+
}
26+
27+
fun createNewPlugin(): SimpleRibCoroutineWorker {
28+
val x: SimpleRibCoroutineWorker = { // BLOCK
29+
local suspend fun FooWorker.suspendConversion0(p0: MyInterface) {
30+
$callee.invoke(str = p0)
31+
}
32+
33+
::suspendConversion0/*($callee = FooWorker()) */
34+
}
35+
return { // BLOCK
36+
local suspend fun FooWorker.suspendConversion1(p0: MyInterface) {
37+
$callee.invoke(str = p0)
38+
}
39+
40+
::suspendConversion1/*($callee = FooWorker()) */
41+
}
42+
}
43+
44+
fun foo(x: SimpleRibCoroutineWorker) {
45+
}
46+
47+
fun main() {
48+
foo(x = { // BLOCK
49+
local suspend fun FooWorker.suspendConversion0(p0: MyInterface) {
50+
$callee.invoke(str = p0)
51+
}
52+
53+
::suspendConversion0/*($callee = FooWorker()) */
54+
})
55+
bar(x = [{ // BLOCK
56+
local suspend fun FooWorker.suspendConversion1(p0: MyInterface) {
57+
$callee.invoke(str = p0)
58+
}
59+
60+
::suspendConversion1/*($callee = FooWorker()) */
61+
}])
62+
}
63+

0 commit comments

Comments
 (0)