[Test] Add regression tests for issues which are fixed in K2

Related issues:
KT-10879, KT-18055, KT-20617, KT-23873
KT-25668, KT-31191, KT-33108, KT-41013
KT-51827, KT-53886, KT-56624, KT-58447
KT-58458, KT-58751, KT-58814, KT-60597
KT-62806, KT-63258, KT-63444, KT-65101
KT-65408, KT-65844, KT-66186

^KT-65926 Fixed
This commit is contained in:
Dmitriy Novozhilov
2024-02-28 12:13:45 +02:00
committed by Space Team
parent b875ae774e
commit 4b5eac7816
79 changed files with 1719 additions and 0 deletions
@@ -0,0 +1,48 @@
FILE fqName:<root> fileName:/test.kt
PROPERTY name:key visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:key type:<root>.A.Key<kotlin.Boolean> visibility:private [final,static]
EXPRESSION_BODY
CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.A.Key' type=<root>.A.Key<kotlin.Boolean> origin=null
<class: T>: kotlin.Boolean
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-key> visibility:public modality:FINAL <> () returnType:<root>.A.Key<kotlin.Boolean>
correspondingProperty: PROPERTY name:key visibility:public modality:FINAL [val]
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-key> (): <root>.A.Key<kotlin.Boolean> declared in <root>'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:key type:<root>.A.Key<kotlin.Boolean> visibility:private [final,static]' type=<root>.A.Key<kotlin.Boolean> origin=null
PROPERTY name:x visibility:public modality:FINAL [delegated,val]
FIELD PROPERTY_DELEGATE name:x$delegate type:kotlin.Lazy<kotlin.Boolean> visibility:private [final,static]
EXPRESSION_BODY
CALL 'public final fun lazy <T> (initializer: kotlin.Function0<T of kotlin.lazy>): kotlin.Lazy<T of kotlin.lazy> declared in kotlin' type=kotlin.Lazy<kotlin.Boolean> origin=null
<T>: kotlin.Boolean
initializer: FUN_EXPR type=kotlin.Function0<kotlin.Boolean> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Boolean
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Boolean declared in <root>.x$delegate'
BLOCK type=kotlin.Boolean origin=ELVIS
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:@[EnhancedNullability] kotlin.Boolean? [val]
CALL 'public open fun get <T> (key: @[EnhancedNullability] <root>.A.Key<@[FlexibleNullability] T of <root>.A.get?>): @[EnhancedNullability] T of <root>.A.get? declared in <root>.A' type=@[EnhancedNullability] kotlin.Boolean? origin=null
<T>: @[FlexibleNullability] kotlin.Boolean?
$this: CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.A' type=<root>.A origin=null
key: CALL 'public final fun <get-key> (): <root>.A.Key<kotlin.Boolean> declared in <root>' type=<root>.A.Key<kotlin.Boolean> origin=GET_PROPERTY
WHEN type=kotlin.Boolean origin=null
BRANCH
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
arg0: GET_VAR 'val tmp_0: @[EnhancedNullability] kotlin.Boolean? declared in <root>.x$delegate.<anonymous>' type=@[EnhancedNullability] kotlin.Boolean? origin=null
arg1: CONST Null type=kotlin.Nothing? value=null
then: CONST Boolean type=kotlin.Boolean value=false
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val tmp_0: @[EnhancedNullability] kotlin.Boolean? declared in <root>.x$delegate.<anonymous>' type=@[EnhancedNullability] kotlin.Boolean? origin=null
FUN DELEGATED_PROPERTY_ACCESSOR name:<get-x> visibility:public modality:FINAL <> () returnType:kotlin.Boolean
correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [delegated,val]
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-x> (): kotlin.Boolean declared in <root>'
CALL 'public final fun getValue <T> (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.getValue declared in kotlin' type=kotlin.Boolean origin=null
<T>: kotlin.Boolean
$receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:x$delegate type:kotlin.Lazy<kotlin.Boolean> visibility:private [final,static]' type=kotlin.Lazy<kotlin.Boolean> origin=null
thisRef: CONST Null type=kotlin.Nothing? value=null
property: PROPERTY_REFERENCE 'public final x: kotlin.Boolean' field=null getter='public final fun <get-x> (): kotlin.Boolean declared in <root>' setter=null type=kotlin.reflect.KProperty0<kotlin.Boolean> origin=PROPERTY_REFERENCE_FOR_DELEGATE
FUN name:main visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
CALL 'public final fun println (message: kotlin.Boolean): kotlin.Unit declared in kotlin.io' type=kotlin.Unit origin=null
message: CALL 'public final fun <get-x> (): kotlin.Boolean declared in <root>' type=kotlin.Boolean origin=GET_PROPERTY
@@ -0,0 +1,22 @@
val key: Key<Boolean>
field = Key<Boolean>()
get
val x: Boolean /* by */
field = lazy<Boolean>(initializer = local fun <anonymous>(): Boolean {
return { // BLOCK
val tmp_0: @EnhancedNullability Boolean? = A().get<@FlexibleNullability Boolean?>(key = <get-key>())
when {
EQEQ(arg0 = tmp_0, arg1 = null) -> false
else -> tmp_0
}
}
}
)
get(): Boolean {
return #x$delegate.getValue<Boolean>(thisRef = null, property = ::x)
}
fun main() {
println(message = <get-x>())
}
@@ -0,0 +1,29 @@
// CHECK:
// Mangled name: {}key
// Public signature: /key|1144547298251177939[0]
// Public signature debug description: {}key
val key: Key<Boolean>
// CHECK JVM_IR:
// Mangled name: #<get-key>(){}A.Key<kotlin.Boolean>
// Public signature: /key.<get-key>|-6107443460337397211[0]
// Public signature debug description: <get-key>(){}A.Key<kotlin.Boolean>
get
// CHECK:
// Mangled name: {}x
// Public signature: /x|-8060530855978347579[0]
// Public signature debug description: {}x
val x: Boolean /* by */
// CHECK JVM_IR:
// Mangled name: #<get-x>(){}kotlin.Boolean
// Public signature: /x.<get-x>|1798055433828515329[0]
// Public signature debug description: <get-x>(){}kotlin.Boolean
get(): Boolean
// CHECK JVM_IR:
// Mangled name: #main(){}
// Mangled name for the signature by IR: main(){}
// Mangled name for the signature by Frontend: main(){}%test.kt
// Public signature: /main|-4284757841571462650[0]
// Public signature debug description: main(){}
fun main(): Unit
@@ -0,0 +1,49 @@
FILE fqName:<root> fileName:/test.kt
PROPERTY name:key visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:key type:<root>.A.Key<kotlin.Boolean> visibility:private [final,static]
EXPRESSION_BODY
CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.A.Key' type=<root>.A.Key<kotlin.Boolean> origin=null
<class: T>: @[FlexibleNullability] kotlin.Boolean?
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-key> visibility:public modality:FINAL <> () returnType:<root>.A.Key<kotlin.Boolean>
correspondingProperty: PROPERTY name:key visibility:public modality:FINAL [val]
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-key> (): <root>.A.Key<kotlin.Boolean> declared in <root>'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:key type:<root>.A.Key<kotlin.Boolean> visibility:private [final,static]' type=<root>.A.Key<kotlin.Boolean> origin=null
PROPERTY name:x visibility:public modality:FINAL [delegated,val]
FIELD PROPERTY_DELEGATE name:x$delegate type:kotlin.Lazy<@[EnhancedNullability] kotlin.Boolean> visibility:private [final,static]
EXPRESSION_BODY
CALL 'public final fun lazy <T> (initializer: kotlin.Function0<T of kotlin.lazy>): kotlin.Lazy<T of kotlin.lazy> declared in kotlin' type=kotlin.Lazy<@[EnhancedNullability] kotlin.Boolean> origin=null
<T>: @[EnhancedNullability] kotlin.Boolean
initializer: FUN_EXPR type=kotlin.Function0<@[EnhancedNullability] kotlin.Boolean> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:@[EnhancedNullability] kotlin.Boolean
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): @[EnhancedNullability] kotlin.Boolean declared in <root>.x$delegate'
BLOCK type=@[EnhancedNullability] kotlin.Boolean origin=ELVIS
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:@[EnhancedNullability] kotlin.Boolean? [val]
CALL 'public open fun get <T> (key: @[EnhancedNullability] <root>.A.Key<@[FlexibleNullability] T of <root>.A.get?>): @[EnhancedNullability] T of <root>.A.get? declared in <root>.A' type=@[EnhancedNullability] kotlin.Boolean? origin=null
<T>: @[FlexibleNullability] kotlin.Boolean?
$this: CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.A' type=<root>.A origin=null
key: CALL 'public final fun <get-key> (): <root>.A.Key<kotlin.Boolean> declared in <root>' type=<root>.A.Key<kotlin.Boolean> origin=GET_PROPERTY
WHEN type=@[EnhancedNullability] kotlin.Boolean origin=null
BRANCH
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
arg0: GET_VAR 'val tmp_0: @[EnhancedNullability] kotlin.Boolean? declared in <root>.x$delegate.<anonymous>' type=@[EnhancedNullability] kotlin.Boolean? origin=null
arg1: CONST Null type=kotlin.Nothing? value=null
then: CONST Boolean type=kotlin.Boolean value=false
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: GET_VAR 'val tmp_0: @[EnhancedNullability] kotlin.Boolean? declared in <root>.x$delegate.<anonymous>' type=@[EnhancedNullability] kotlin.Boolean? origin=null
FUN DELEGATED_PROPERTY_ACCESSOR name:<get-x> visibility:public modality:FINAL <> () returnType:@[EnhancedNullability] kotlin.Boolean
correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [delegated,val]
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-x> (): @[EnhancedNullability] kotlin.Boolean declared in <root>'
CALL 'public final fun getValue <T> (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.getValue declared in kotlin' type=@[EnhancedNullability] kotlin.Boolean origin=null
<T>: @[EnhancedNullability] kotlin.Boolean
$receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:x$delegate type:kotlin.Lazy<@[EnhancedNullability] kotlin.Boolean> visibility:private [final,static]' type=kotlin.Lazy<@[EnhancedNullability] kotlin.Boolean> origin=null
thisRef: CONST Null type=kotlin.Nothing? value=null
property: PROPERTY_REFERENCE 'public final x: @[EnhancedNullability] kotlin.Boolean' field=null getter='public final fun <get-x> (): @[EnhancedNullability] kotlin.Boolean declared in <root>' setter=null type=kotlin.reflect.KProperty0<@[EnhancedNullability] kotlin.Boolean> origin=PROPERTY_REFERENCE_FOR_DELEGATE
FUN name:main visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
CALL 'public final fun println (message: kotlin.Boolean): kotlin.Unit declared in kotlin.io' type=kotlin.Unit origin=null
message: TYPE_OP type=kotlin.Boolean origin=IMPLICIT_NOTNULL typeOperand=kotlin.Boolean
CALL 'public final fun <get-x> (): @[EnhancedNullability] kotlin.Boolean declared in <root>' type=@[EnhancedNullability] kotlin.Boolean origin=GET_PROPERTY
@@ -0,0 +1,28 @@
// TARGET_BACKEND: JVM_IR
// SEPARATE_SIGNATURE_DUMP_FOR_K2
// ISSUE: KT-53886
// WITH_STDLIB
// FILE: A.java
import org.jetbrains.annotations.*;
public class A {
@Nullable
public <T> T get(@NotNull Key<T> key) {
return null;
}
public static class Key<T> {}
}
// FILE: test.kt
val key = A.Key<Boolean>()
val x by lazy {
A().get(key) ?: false
}
fun main() {
println(x)
}
@@ -0,0 +1,22 @@
val key: Key<Boolean>
field = Key<@FlexibleNullability Boolean?>()
get
val x: @EnhancedNullability Boolean /* by */
field = lazy<@EnhancedNullability Boolean>(initializer = local fun <anonymous>(): @EnhancedNullability Boolean {
return { // BLOCK
val tmp_0: @EnhancedNullability Boolean? = A().get<@FlexibleNullability Boolean?>(key = <get-key>())
when {
EQEQ(arg0 = tmp_0, arg1 = null) -> false
else -> tmp_0
}
}
}
)
get(): @EnhancedNullability Boolean {
return #x$delegate.getValue<@EnhancedNullability Boolean>(thisRef = null, property = ::x)
}
fun main() {
println(message = <get-x>() /*!! Boolean */)
}
@@ -0,0 +1,31 @@
// CHECK:
// Mangled name: {}key
// Public signature: /key|1144547298251177939[0]
// Public signature debug description: {}key
val key: Key<Boolean>
// CHECK JVM_IR:
// Mangled name: #<get-key>(){}A.Key<kotlin.Boolean>
// Public signature: /key.<get-key>|-6107443460337397211[0]
// Public signature debug description: <get-key>(){}A.Key<kotlin.Boolean>
get
// CHECK:
// Mangled name: {}x
// Public signature: /x|-8060530855978347579[0]
// Public signature debug description: {}x
val x: @EnhancedNullability Boolean /* by */
// CHECK JVM_IR:
// Mangled name: #<get-x>(){}kotlin.Boolean{EnhancedNullability}
// Public signature: /x.<get-x>|-384063749268193272[0]
// Public signature debug description: <get-x>(){}kotlin.Boolean{EnhancedNullability}
get(): @EnhancedNullability Boolean
// CHECK JVM_IR:
// Mangled name: #main(){}
// Mangled name for the signature by IR: main(){}
// Mangled name for the signature by Frontend: main(){}%test.kt
// Public signature by IR: /main|-4284757841571462650[0]
// Public signature by IR debug description: main(){}
// Public signature by Frontend: /main|-2141841464851950582[0]
// Public signature by Frontend debug description: main(){}%test.kt
fun main(): Unit