Passing DataFlowInfo to local classes/objects
#KT-2835 In Progress #KT-2225 In Progress #KT-338 In Progress
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
open class Base(x: String, y: Int)
|
||||
|
||||
fun test(x: Any, y: Int?) {
|
||||
if (x !is String) return
|
||||
if (y == null) return
|
||||
|
||||
class Local: Base(x, y) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fun test(x: Any) {
|
||||
if (x !is String) return
|
||||
|
||||
class Local(s: String = x) {
|
||||
fun foo(s: String = x): String = s
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
class Del {
|
||||
fun get(<!UNUSED_PARAMETER!>_this<!>: Any?, <!UNUSED_PARAMETER!>p<!>: PropertyMetadata): Int = 0
|
||||
}
|
||||
|
||||
fun df(del: Del): Del = del
|
||||
|
||||
|
||||
fun test(del: Any?) {
|
||||
if (del !is Del) return
|
||||
|
||||
class Local {
|
||||
val delegatedVal by df(del)
|
||||
val delegatedVal1: Int by df(del)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
trait D {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
fun test(d: Any?) {
|
||||
if (d !is D) return
|
||||
|
||||
class Local : D by d {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
trait D {
|
||||
fun foo(): String = ""
|
||||
}
|
||||
|
||||
fun test(d: Any?) {
|
||||
if (d !is D) return
|
||||
|
||||
class Local {
|
||||
fun f() {
|
||||
d.foo()
|
||||
}
|
||||
|
||||
fun f1() = d.foo()
|
||||
|
||||
fun f2(): String = d.foo()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
fun test(x: Any) {
|
||||
if (x !is String) return
|
||||
|
||||
class LocalOuter {
|
||||
fun foo(y: Any) {
|
||||
if (y !is String) return
|
||||
class Local {
|
||||
{
|
||||
x.length
|
||||
y.length
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-3
@@ -1,9 +1,12 @@
|
||||
fun test(x: Any?) {
|
||||
if (x !is String) return
|
||||
|
||||
class C {
|
||||
val v = x.length
|
||||
}
|
||||
object {
|
||||
val v = x.length
|
||||
|
||||
val vGet: Int
|
||||
get() = x.length
|
||||
|
||||
val s: String = x
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fun test(x: Any) {
|
||||
if (x !is String) return
|
||||
|
||||
class LocalOuter {
|
||||
inner class Local {
|
||||
{
|
||||
x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user