[FIR] Add regression tests for number of issues fixed in K2
List of issues: KT-4113, KT-6822, KT-7389, KT-17817, KT-20223 KT-21463, KT-24503, KT-24737, KT-24779, KT-24901 KT-27261, KT-28668, KT-30497, KT-30756, KT-36958 KT-37365, KT-37490, KT-38288, KT-41038, KT-41721 KT-42136, KT-42169, KT-42449, KT-42715, KT-43553 KT-43603, KT-43846, KT-43936, KT-46288, KT-46301 KT-47373, KT-47484, KT-47490, KT-47495, KT-47750 KT-47815, KT-47870, KT-48975, KT-49024, KT-49045 KT-50134, KT-50160, KT-50550, KT-51045, KT-51143 KT-51796, KT-52262, KT-52424, KT-52860, KT-52934 KT-53086, KT-53494, KT-53671, KT-53752, KT-53819 KT-54478, KT-54518, KT-54931, KT-54990, KT-55138 KT-55379, KT-55555, KT-56243
This commit is contained in:
committed by
Space Team
parent
8ae5213155
commit
aef9b129d2
+23
@@ -0,0 +1,23 @@
|
||||
FILE: assignToBoundSmartcastedVariable.kt
|
||||
public abstract interface A : R|kotlin/Any| {
|
||||
}
|
||||
public abstract interface B : R|kotlin/Any| {
|
||||
public abstract fun fooB(x: R|kotlin/Int|): R|kotlin/String|
|
||||
|
||||
}
|
||||
public final class Foo : R|kotlin/Any| {
|
||||
public constructor(): R|Foo| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final fun test(ab: R|A|): R|kotlin/Unit| {
|
||||
when () {
|
||||
(R|<local>/ab| is R|B|) -> {
|
||||
lvar z: R|it(B & A)| = R|/id|<R|it(B & A)|>(R|<local>/ab|)
|
||||
R|<local>/z| = R|/Foo.Foo<CS errors: /Foo.Foo>#|()
|
||||
R|<local>/z|.R|/B.fooB|(Int(1))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// ISSUE: KT-53752
|
||||
// INFERENCE_HELPERS
|
||||
|
||||
interface A
|
||||
interface B {
|
||||
fun fooB(x: Int): String
|
||||
}
|
||||
|
||||
class Foo
|
||||
|
||||
fun test(ab: A) {
|
||||
if (ab is B) {
|
||||
var z = id(ab) // materialize smartcast
|
||||
z = <!ASSIGNMENT_TYPE_MISMATCH!>Foo()<!> // unsafe assignment
|
||||
z.fooB(1)
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
FILE: boundSmartcastWithProjection.kt
|
||||
public final class Inv<T> : R|kotlin/Any| {
|
||||
public constructor<T>(data: R|T|): R|Inv<T>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val data: R|T| = R|<local>/data|
|
||||
public get(): R|T|
|
||||
|
||||
}
|
||||
public final fun test1(x: R|Inv<out kotlin/String?>|): R|kotlin/Unit| {
|
||||
lval y: R|kotlin/String?| = R|<local>/x|.R|SubstitutionOverride</Inv.data: R|CapturedType(out kotlin/String?)|>|
|
||||
when (R|<local>/y|) {
|
||||
($subj$ is R|kotlin/String|) -> {
|
||||
R|<local>/x|.R|SubstitutionOverride</Inv.data: R|CapturedType(out kotlin/String?)|>|.R|kotlin/String.length|
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public final fun test2(x: R|Inv<out kotlin/Any?>|): R|kotlin/Unit| {
|
||||
lval y: R|kotlin/Any?| = R|<local>/x|.R|SubstitutionOverride</Inv.data: R|CapturedType(out kotlin/Any?)|>|
|
||||
when (R|<local>/y|) {
|
||||
($subj$ is R|kotlin/String|) -> {
|
||||
R|<local>/x|.R|SubstitutionOverride</Inv.data: R|CapturedType(out kotlin/Any?)|>|.R|kotlin/String.length|
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// ISSUE: KT-24779
|
||||
|
||||
class Inv<T>(val data: T)
|
||||
|
||||
fun test1(x: Inv<out String?>) {
|
||||
val y = x.data
|
||||
when (y) {
|
||||
is String -> x.data.length // Smart cast: x.data is String
|
||||
}
|
||||
}
|
||||
|
||||
fun test2(x: Inv<out Any?>) {
|
||||
val y = x.data
|
||||
when (y) {
|
||||
is String -> x.data.length // No smart cast, UNRESOLVED_REFERENCE: length
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
FILE: contractSafeCall.kt
|
||||
public final fun test(list: R|kotlin/collections/List<kotlin/Any>?|): R|kotlin/Unit| {
|
||||
when () {
|
||||
==(R|<local>/list|?.{ $subj$.R|kotlin/collections/isNullOrEmpty|<R|kotlin/Any|>() }, Boolean(true)) -> {
|
||||
^test Unit
|
||||
}
|
||||
}
|
||||
|
||||
R|<local>/list|.R|SubstitutionOverride<kotlin/collections/List.size: R|kotlin/Int|><Inapplicable(UNSAFE_CALL): kotlin/collections/List.size>#|
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// ISSUE: KT-51796
|
||||
// WITH_STDLIB
|
||||
|
||||
fun test(list: List<Any>?) {
|
||||
if (list?.isNullOrEmpty() == true) {
|
||||
return
|
||||
}
|
||||
list<!UNSAFE_CALL!>.<!>size // should be unsafe call
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
FILE: earlyReturnInNonExhaustiveWhen.kt
|
||||
public final fun foo(str: R|kotlin/String?|): R|kotlin/Int| {
|
||||
when () {
|
||||
==(R|<local>/str|, Null(null)) -> {
|
||||
^foo Int(-1)
|
||||
}
|
||||
}
|
||||
|
||||
when () {
|
||||
==(R|<local>/str|.R|kotlin/String.length|, Int(123)) -> {
|
||||
^foo Int(123)
|
||||
}
|
||||
}
|
||||
|
||||
^foo Int(321)
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// ISSUE: KT-24901
|
||||
|
||||
fun foo(str: String?): Int {
|
||||
when {
|
||||
str == null -> return -1
|
||||
}
|
||||
if (str.length == 123)
|
||||
return 123
|
||||
return 321
|
||||
}
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
FILE: returnFromWhen.kt
|
||||
public final fun test_1(name: R|kotlin/String?|): R|kotlin/Unit| {
|
||||
when (R|<local>/name|) {
|
||||
==($subj$, Null(null)) -> {
|
||||
^test_1 Unit
|
||||
}
|
||||
}
|
||||
|
||||
R|<local>/name|.R|kotlin/String.length|
|
||||
}
|
||||
public final fun test_2(name: R|kotlin/String?|): R|kotlin/Unit| {
|
||||
when (lval s: R|kotlin/String?| = R|<local>/name|) {
|
||||
==($subj$, Null(null)) -> {
|
||||
^test_2 Unit
|
||||
}
|
||||
}
|
||||
|
||||
R|<local>/name|.R|kotlin/String.length|
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// ISSUE: KT-52262
|
||||
|
||||
fun test_1(name: String?) {
|
||||
when (name) {
|
||||
null -> return
|
||||
}
|
||||
name.length
|
||||
}
|
||||
|
||||
fun test_2(name: String?) {
|
||||
when (val s = name) {
|
||||
null -> return
|
||||
}
|
||||
name.length
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
FILE: elvisAtTheEndOfLoop.kt
|
||||
public final fun condition(): R|kotlin/Boolean| {
|
||||
^condition Boolean(true)
|
||||
}
|
||||
public final fun test_1(x: R|kotlin/String?|): R|kotlin/Unit| {
|
||||
do {
|
||||
R|<local>/x| ?: ^test_1 Unit
|
||||
}
|
||||
while(R|/condition|())
|
||||
R|<local>/x|.R|kotlin/String.length|
|
||||
}
|
||||
public final fun test_2(x: R|kotlin/String?|): R|kotlin/Unit| {
|
||||
do {
|
||||
R|<local>/x| ?: R|<local>/x|!!
|
||||
}
|
||||
while(R|/condition|())
|
||||
R|<local>/x|.R|kotlin/String.length|
|
||||
}
|
||||
public final fun test_3(): R|kotlin/Unit| {
|
||||
lvar a: R|kotlin/String?| = Null(null)
|
||||
while(R|/condition|()) {
|
||||
R|<local>/a| ?: ^test_3 Unit
|
||||
}
|
||||
|
||||
R|<local>/a|.R|kotlin/String.length<Inapplicable(UNSAFE_CALL): kotlin/String.length>#|
|
||||
}
|
||||
public final fun test_4(): R|kotlin/Unit| {
|
||||
lvar a: R|kotlin/String?| = Null(null)
|
||||
while(Boolean(true)) {
|
||||
R|<local>/a| ?: ^test_4 Unit
|
||||
}
|
||||
|
||||
R|<local>/a|.R|kotlin/String.length<Inapplicable(UNSAFE_CALL): kotlin/String.length>#|
|
||||
}
|
||||
public final fun test_5(x: R|kotlin/String?|): R|kotlin/Unit| {
|
||||
do {
|
||||
R|<local>/x| ?: ^test_5 Unit
|
||||
Q|kotlin/Unit|
|
||||
}
|
||||
while(R|/condition|())
|
||||
R|<local>/x|.R|kotlin/String.length|
|
||||
}
|
||||
public final fun test_6(x: R|kotlin/String?|): R|kotlin/Unit| {
|
||||
do {
|
||||
R|<local>/x| ?: R|<local>/x|!!
|
||||
Q|kotlin/Unit|
|
||||
}
|
||||
while(R|/condition|())
|
||||
R|<local>/x|.R|kotlin/String.length|
|
||||
}
|
||||
public final fun test_7(): R|kotlin/Unit| {
|
||||
lvar a: R|kotlin/String?| = Null(null)
|
||||
while(R|/condition|()) {
|
||||
R|<local>/a| ?: ^test_7 Unit
|
||||
R|<local>/a|
|
||||
}
|
||||
|
||||
R|<local>/a|.R|kotlin/String.length<Inapplicable(UNSAFE_CALL): kotlin/String.length>#|
|
||||
}
|
||||
public final fun test_8(): R|kotlin/Unit| {
|
||||
lvar a: R|kotlin/String?| = Null(null)
|
||||
while(Boolean(true)) {
|
||||
R|<local>/a| ?: ^test_8 Unit
|
||||
R|<local>/a|
|
||||
}
|
||||
|
||||
R|<local>/a|.R|kotlin/String.length<Inapplicable(UNSAFE_CALL): kotlin/String.length>#|
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
// ISSUE: KT-30756
|
||||
|
||||
fun condition(): Boolean = true
|
||||
|
||||
fun test_1(x: String?) {
|
||||
do {
|
||||
x ?: return
|
||||
} while(condition())
|
||||
|
||||
x.length
|
||||
}
|
||||
|
||||
fun test_2(x: String?) {
|
||||
do {
|
||||
x ?: x!!
|
||||
} while(condition())
|
||||
|
||||
x.length
|
||||
}
|
||||
|
||||
fun test_3() {
|
||||
var a: String? = null
|
||||
|
||||
while (condition()) {
|
||||
a ?: return
|
||||
}
|
||||
|
||||
a<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
fun test_4() {
|
||||
var a: String? = null
|
||||
|
||||
while (true) {
|
||||
a ?: return
|
||||
}
|
||||
|
||||
a<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
fun test_5(x: String?) {
|
||||
do {
|
||||
x ?: return
|
||||
Unit
|
||||
} while(condition())
|
||||
|
||||
x.length
|
||||
}
|
||||
|
||||
fun test_6(x: String?) {
|
||||
do {
|
||||
x ?: x!!
|
||||
Unit
|
||||
} while(condition())
|
||||
|
||||
x.length
|
||||
}
|
||||
|
||||
fun test_7() {
|
||||
var a: String? = null
|
||||
|
||||
while (condition()) {
|
||||
a ?: return
|
||||
a
|
||||
}
|
||||
|
||||
a<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
fun test_8() {
|
||||
var a: String? = null
|
||||
|
||||
while (true) {
|
||||
a ?: return
|
||||
a
|
||||
}
|
||||
|
||||
a<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
FILE: noSmartcastToNullableNothing.kt
|
||||
public abstract interface A : R|kotlin/Any| {
|
||||
}
|
||||
public final fun foo(testFun: R|((kotlin/Int) -> kotlin/Unit)?|, anyInterface: R|A?|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun test(x: R|kotlin/Int?|): R|kotlin/Unit| {
|
||||
R|/foo<Inapplicable(INAPPLICABLE): /foo>#|(when () {
|
||||
!=(R|<local>/x|, Null(null)) -> {
|
||||
foo@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Unit| <inline=Unknown> {
|
||||
Int(0)
|
||||
}
|
||||
|
||||
}
|
||||
else -> {
|
||||
Null(null)
|
||||
}
|
||||
}
|
||||
, R|<local>/x|)
|
||||
}
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// ISSUE: KT-52424
|
||||
|
||||
interface A
|
||||
|
||||
fun foo(testFun: ((Int) -> Unit)?, anyInterface: A?) {}
|
||||
|
||||
fun test(x: Int?) {
|
||||
foo(
|
||||
if (x != null) { { 0 } } else null,
|
||||
<!ARGUMENT_TYPE_MISMATCH!>x<!> // should be no smartcast to Nothing?
|
||||
)
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
FILE: smartcastOnFunctionalType.kt
|
||||
public final class MyClass : R|kotlin/Any| {
|
||||
public constructor(provider: R|(() -> kotlin/String)?|): R|MyClass| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val provider: R|(() -> kotlin/String)?| = R|<local>/provider|
|
||||
public get(): R|(() -> kotlin/String)?|
|
||||
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
when () {
|
||||
!=(this@R|/MyClass|.R|/MyClass.provider|, Null(null)) -> {
|
||||
this@R|/MyClass|.R|/MyClass.bar|(this@R|/MyClass|.R|/MyClass.provider|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/String|>|())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final fun bar(s: R|kotlin/String|): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
}
|
||||
public final class Test : R|kotlin/Any| {
|
||||
public constructor(): R|Test| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val nullableCheckBox: R|B?| = Null(null)
|
||||
public get(): R|B?|
|
||||
|
||||
public final fun fail(): R|kotlin/Unit| {
|
||||
when () {
|
||||
!=(this@R|/Test|.R|/Test.nullableCheckBox|, Null(null)) -> {
|
||||
this@R|/Test|.R|kotlin/run|<R|Test|, R|kotlin/Unit|>(<L> = run@fun R|Test|.<anonymous>(): R|kotlin/Unit| <inline=Inline, kind=EXACTLY_ONCE> {
|
||||
this@R|/Test|.R|/Test.nullableCheckBox|.R|/invoke|()
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public final class B : R|kotlin/Any| {
|
||||
public constructor(): R|B| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final operator fun R|B|.invoke(): R|kotlin/Unit| {
|
||||
^invoke R|kotlin/TODO|()
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// ISSUE: KT-4113
|
||||
|
||||
class MyClass(val provider: (() -> String)?) {
|
||||
fun foo() {
|
||||
if (provider != null)
|
||||
// NI: [UNSAFE_CALL] Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type (() -> String)?
|
||||
// OI: [UNSAFE_IMPLICIT_INVOKE_CALL] Reference has a nullable type '(() -> String)?', use explicit '?.invoke()' to make a function-like call instead
|
||||
bar(provider())
|
||||
}
|
||||
|
||||
fun bar(s: String) {
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
val nullableCheckBox: B? = null
|
||||
fun fail() {
|
||||
if (nullableCheckBox != null) {
|
||||
run { nullableCheckBox() }
|
||||
}
|
||||
}
|
||||
}
|
||||
class B
|
||||
operator fun B.invoke(): Unit = TODO()
|
||||
Vendored
+101
@@ -0,0 +1,101 @@
|
||||
FILE: smartcastToStarProjectedType.kt
|
||||
public final data class NodePropertyDescriptor<TNode : R|Node|, TProperty : R|kotlin/Any|, TPropertyVal : R|TProperty?|> : R|kotlin/Any| {
|
||||
public constructor<TNode : R|Node|, TProperty : R|kotlin/Any|, TPropertyVal : R|TProperty?|>(description: R|kotlin/String|, propertyRef: R|NodePropertyRef<TNode, TProperty, TPropertyVal>|): R|NodePropertyDescriptor<TNode, TProperty, TPropertyVal>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val description: R|kotlin/String| = R|<local>/description|
|
||||
public get(): R|kotlin/String|
|
||||
|
||||
public final val propertyRef: R|NodePropertyRef<TNode, TProperty, TPropertyVal>| = R|<local>/propertyRef|
|
||||
public get(): R|NodePropertyRef<TNode, TProperty, TPropertyVal>|
|
||||
|
||||
public final fun test_1(other: R|kotlin/Any?|): R|kotlin/Boolean| {
|
||||
when () {
|
||||
(R|<local>/other| !is R|NodePropertyDescriptor<*, *, *>|) -> {
|
||||
^test_1 Boolean(false)
|
||||
}
|
||||
}
|
||||
|
||||
when () {
|
||||
!=(this@R|/NodePropertyDescriptor|.R|/NodePropertyDescriptor.description|, R|<local>/other|.R|SubstitutionOverride</NodePropertyDescriptor.description: R|kotlin/String|>|) -> {
|
||||
^test_1 Boolean(false)
|
||||
}
|
||||
}
|
||||
|
||||
when () {
|
||||
!=(this@R|/NodePropertyDescriptor|.R|/NodePropertyDescriptor.propertyRef|, R|<local>/other|.R|SubstitutionOverride</NodePropertyDescriptor.propertyRef: R|NodePropertyRef<CapturedType(*), CapturedType(*), CapturedType(*)>|>|) -> {
|
||||
^test_1 Boolean(false)
|
||||
}
|
||||
}
|
||||
|
||||
^test_1 Boolean(true)
|
||||
}
|
||||
|
||||
public final fun test_2(other: R|kotlin/Any?|): R|kotlin/Boolean| {
|
||||
when () {
|
||||
(R|<local>/other| !is R|NodePropertyDescriptor<*, *, *>|) -> {
|
||||
^test_2 Boolean(false)
|
||||
}
|
||||
}
|
||||
|
||||
when () {
|
||||
(R|<local>/other| is R|NodePropertyDescriptor<*, *, *>|) -> {
|
||||
when () {
|
||||
!=(this@R|/NodePropertyDescriptor|.R|/NodePropertyDescriptor.description|, R|<local>/other|.R|SubstitutionOverride</NodePropertyDescriptor.description: R|kotlin/String|>|) -> {
|
||||
^test_2 Boolean(false)
|
||||
}
|
||||
}
|
||||
|
||||
when () {
|
||||
!=(this@R|/NodePropertyDescriptor|.R|/NodePropertyDescriptor.propertyRef|, R|<local>/other|.R|SubstitutionOverride</NodePropertyDescriptor.propertyRef: R|NodePropertyRef<CapturedType(*), CapturedType(*), CapturedType(*)>|>|) -> {
|
||||
^test_2 Boolean(false)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
^test_2 Boolean(true)
|
||||
}
|
||||
|
||||
public final fun test_3(other: R|kotlin/Any?|): R|kotlin/Boolean| {
|
||||
when () {
|
||||
(R|<local>/other| is R|NodePropertyDescriptor<*, *, *>|) -> {
|
||||
when () {
|
||||
!=(this@R|/NodePropertyDescriptor|.R|/NodePropertyDescriptor.description|, R|<local>/other|.R|SubstitutionOverride</NodePropertyDescriptor.description: R|kotlin/String|>|) -> {
|
||||
^test_3 Boolean(false)
|
||||
}
|
||||
}
|
||||
|
||||
when () {
|
||||
!=(this@R|/NodePropertyDescriptor|.R|/NodePropertyDescriptor.propertyRef|, R|<local>/other|.R|SubstitutionOverride</NodePropertyDescriptor.propertyRef: R|NodePropertyRef<CapturedType(*), CapturedType(*), CapturedType(*)>|>|) -> {
|
||||
^test_3 Boolean(false)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
^test_3 Boolean(true)
|
||||
}
|
||||
|
||||
public final operator fun component1(): R|kotlin/String|
|
||||
|
||||
public final operator fun component2(): R|NodePropertyRef<TNode, TProperty, TPropertyVal>|
|
||||
|
||||
public final fun copy(description: R|kotlin/String| = this@R|/NodePropertyDescriptor|.R|/NodePropertyDescriptor.description|, propertyRef: R|NodePropertyRef<TNode, TProperty, TPropertyVal>| = this@R|/NodePropertyDescriptor|.R|/NodePropertyDescriptor.propertyRef|): R|NodePropertyDescriptor<TNode, TProperty, TPropertyVal>|
|
||||
|
||||
}
|
||||
public final class NodePropertyRef<T, U, V> : R|kotlin/Any| {
|
||||
public constructor<T, U, V>(): R|NodePropertyRef<T, U, V>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public open class Node : R|kotlin/Any| {
|
||||
public constructor(): R|Node| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
// ISSUE: KT-42449
|
||||
|
||||
data class NodePropertyDescriptor<TNode : Node, TProperty : Any, TPropertyVal : TProperty?>(
|
||||
val description: String,
|
||||
val propertyRef: NodePropertyRef<TNode, TProperty, TPropertyVal>,
|
||||
) {
|
||||
fun test_1(other: Any?): Boolean {
|
||||
if (other !is NodePropertyDescriptor<*, *, *>) return false
|
||||
if (description != other.description) return false
|
||||
if (propertyRef != other.propertyRef) return false
|
||||
return true
|
||||
}
|
||||
|
||||
fun test_2(other: Any?): Boolean {
|
||||
if (other !is NodePropertyDescriptor<*, *, *>) return false
|
||||
if (<!USELESS_IS_CHECK!>other is NodePropertyDescriptor<*, *, *><!>) {
|
||||
if (description != other.description) return false
|
||||
if (propertyRef != other.propertyRef) return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fun test_3(other: Any?): Boolean {
|
||||
if (other is NodePropertyDescriptor<*, *, *>) {
|
||||
if (description != other.description) return false
|
||||
if (propertyRef != other.propertyRef) return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class NodePropertyRef<T, U, V>
|
||||
|
||||
open class Node
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
FILE: typeOfLambdaWithSmartcast.kt
|
||||
public final fun test_1(): R|kotlin/Unit| {
|
||||
lval f: R|(kotlin/String?) -> kotlin/String| = l@fun <anonymous>(it: R|kotlin/String?|): R|kotlin/String| <inline=Unknown> {
|
||||
when () {
|
||||
!=(R|<local>/it|, Null(null)) -> {
|
||||
^@l R|<local>/it|
|
||||
}
|
||||
}
|
||||
|
||||
^ String()
|
||||
}
|
||||
|
||||
R|<local>/f|.R|SubstitutionOverride<kotlin/Function1.invoke: R|kotlin/String|>|(String()).R|kotlin/String.length|
|
||||
}
|
||||
public final fun test_2(): R|kotlin/Unit| {
|
||||
lval f: R|(kotlin/String?) -> kotlin/String| = l@fun <anonymous>(it: R|kotlin/String?|): R|kotlin/String| <inline=Unknown> {
|
||||
^ when () {
|
||||
!=(R|<local>/it|, Null(null)) -> {
|
||||
R|<local>/it|
|
||||
}
|
||||
else -> {
|
||||
String()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
R|<local>/f|.R|SubstitutionOverride<kotlin/Function1.invoke: R|kotlin/String|>|(String()).R|kotlin/String.length|
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// ISSUE: KT-6822
|
||||
|
||||
fun test_1() {
|
||||
val f = l@{ it: String? ->
|
||||
if (it != null) return@l it
|
||||
""
|
||||
}
|
||||
|
||||
f("").length
|
||||
}
|
||||
|
||||
fun test_2() {
|
||||
val f = l@ { it: String? ->
|
||||
if (it != null) it
|
||||
else ""
|
||||
}
|
||||
f("").length
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
FILE: valCapturedInLambda.kt
|
||||
public final fun test_1(x: R|kotlin/Any|): R|kotlin/String| {
|
||||
when () {
|
||||
(R|<local>/x| is R|kotlin/String|) -> {
|
||||
lval thunk: R|() -> kotlin/String| = fun <anonymous>(): R|kotlin/String| <inline=Unknown> {
|
||||
^ R|<local>/x|
|
||||
}
|
||||
|
||||
^test_1 R|<local>/thunk|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/String|>|()
|
||||
}
|
||||
}
|
||||
|
||||
^test_1 String(str)
|
||||
}
|
||||
public final fun test_2(x: R|kotlin/Any|): R|kotlin/String| {
|
||||
when () {
|
||||
(R|<local>/x| is R|kotlin/String|) -> {
|
||||
lval thunk: R|() -> kotlin/String| = fun <anonymous>(): R|kotlin/String| <inline=Unknown> {
|
||||
^ R|<local>/x|.R|kotlin/String.plus|(String(a))
|
||||
}
|
||||
|
||||
^test_2 R|<local>/thunk|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/String|>|()
|
||||
}
|
||||
}
|
||||
|
||||
^test_2 String(str)
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// ISSUE: KT-43846
|
||||
|
||||
fun test_1(x: Any): String {
|
||||
if (x is String) {
|
||||
val thunk = { x }
|
||||
return thunk()
|
||||
}
|
||||
return "str"
|
||||
}
|
||||
|
||||
fun test_2(x: Any): String {
|
||||
if (x is String) {
|
||||
val thunk = { x + "a" }
|
||||
return thunk()
|
||||
}
|
||||
return "str"
|
||||
}
|
||||
Reference in New Issue
Block a user