[FIR] Elvis operator: flexible rhs type implies flexible type of whole elvis
It's required for further removing of enhancement of final static fields Also, it's k2-potential feature ^KT-62467 Fixed
This commit is contained in:
committed by
Space Team
parent
648330da50
commit
2d61b9a477
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
FILE: main.kt
|
||||
public final fun testWithStatic1(x1: R|kotlin/String?|): R|kotlin/String| {
|
||||
lval x: R|kotlin/String?|
|
||||
R|<local>/x| = R|<local>/x1| ?: Q|JavaClass|.R|/JavaClass.X*s|
|
||||
^testWithStatic1 R|<local>/x|
|
||||
}
|
||||
public final fun testWithStatic2(x1: R|kotlin/String?|): R|kotlin/String| {
|
||||
lvar x: R|kotlin/String?| = Null(null)
|
||||
R|<local>/x| = R|<local>/x1| ?: Q|JavaClass|.R|/JavaClass.f*s|()
|
||||
^testWithStatic2 R|<local>/x|
|
||||
}
|
||||
public final fun testWithStatic3(x1: R|kotlin/String?|): R|kotlin/String| {
|
||||
lval x: R|kotlin/String?| = R|<local>/x1| ?: Q|JavaClass|.R|/JavaClass.X*s|
|
||||
^testWithStatic3 R|<local>/x|
|
||||
}
|
||||
public final fun testWithStatic4(x1: R|kotlin/String?|, w: R|kotlin/Int|): R|kotlin/String| {
|
||||
lvar x: R|kotlin/String?|
|
||||
R|<local>/x| = R|<local>/x1| ?: when (R|<local>/w|) {
|
||||
==($subj$, Int(42)) -> {
|
||||
Q|JavaClass|.R|/JavaClass.X*s|
|
||||
}
|
||||
else -> {
|
||||
Q|JavaClass|.R|/JavaClass.f*s|()
|
||||
}
|
||||
}
|
||||
|
||||
^testWithStatic4 R|<local>/x|
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
// ISSUE: KT-62467
|
||||
|
||||
// FILE: JavaClass.java
|
||||
|
||||
public class JavaClass {
|
||||
public static String X = null;
|
||||
public static String f() { return null; }
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun testWithStatic1(x1: String?): String {
|
||||
val x: String?
|
||||
x = x1 ?: JavaClass.X
|
||||
return x
|
||||
}
|
||||
|
||||
fun testWithStatic2(x1: String?): String {
|
||||
var x: String? = null
|
||||
x = x1 ?: JavaClass.f()
|
||||
return x
|
||||
}
|
||||
|
||||
fun testWithStatic3(x1: String?): String {
|
||||
val x: String? = x1 ?: JavaClass.X
|
||||
return <!RETURN_TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
|
||||
fun testWithStatic4(x1: String?, w: Int): String {
|
||||
var x: String?
|
||||
x = x1 ?: when (w) {
|
||||
42 -> JavaClass.X
|
||||
else -> JavaClass.f()
|
||||
}
|
||||
return x
|
||||
}
|
||||
Reference in New Issue
Block a user