Respect receiver-dependent visibility when selecting smart-cast type

This commit is contained in:
Denis Zharkov
2016-03-25 13:59:52 +03:00
parent d3b7eb81fa
commit 5bf336474d
16 changed files with 302 additions and 21 deletions
@@ -0,0 +1,18 @@
// !CHECK_TYPE
open class BaseOuter {
protected fun foo() = 1
protected fun bar() { }
}
class Foo(var base: BaseOuter)
fun BaseOuter.foo(): String = ""
class Derived : BaseOuter() {
fun test(foo: Foo) {
if (foo.base is Derived) {
foo.base.foo() checkType { _<String>() } // Resolved to extension
<!SMARTCAST_IMPOSSIBLE!>foo.base<!>.bar()
}
}
}