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,16 @@
|
||||
// KT-338 Support autocasts in nested declarations
|
||||
|
||||
fun f(a: Any?) {
|
||||
if (a is B) {
|
||||
class C : X(a) {
|
||||
{
|
||||
a.foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trait B {
|
||||
fun foo() {}
|
||||
}
|
||||
open class X(b: B)
|
||||
@@ -0,0 +1,9 @@
|
||||
fun foo(x: Any?) {
|
||||
if (x is String) {
|
||||
object : Base(x) {
|
||||
fun bar() = x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open class Base(s: String)
|
||||
@@ -0,0 +1,15 @@
|
||||
// KT-2225 Object expression delegation parameter should be checked with data flow info
|
||||
|
||||
trait A {
|
||||
fun foo() : Int
|
||||
}
|
||||
|
||||
class B : A {
|
||||
override fun foo() = 10
|
||||
}
|
||||
fun foo(b: B?) : Int {
|
||||
if (b == null) return 0
|
||||
val o = object : A by b { //no info about b not null check
|
||||
}
|
||||
return o.foo()
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
open class X(val s: String)
|
||||
|
||||
fun f(a: String?) {
|
||||
if (a != null) {
|
||||
object : X(a) { // Type mismatch: inferred type is jet.String? but jet.String was expected
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user