Deprecate smartcasts on local delegated properties

^KT-22517 Fixed
This commit is contained in:
Dmitry Savvinov
2018-06-21 12:11:47 +03:00
parent 31ce992ff2
commit 70714cb71e
16 changed files with 129 additions and 17 deletions
@@ -0,0 +1,15 @@
// !LANGUAGE: -ProhibitSmartcastsOnLocalDelegatedProperty
class AlternatingDelegate {
var counter: Int = 0
operator fun getValue(thisRef: Any?, property: <!UNRESOLVED_REFERENCE!>KProperty<!><*>): Any? =
if (counter++ % 2 == 0) 42 else ""
}
fun failsWithClassCastException() {
val sometimesNotInt: Any? by AlternatingDelegate()
if (sometimesNotInt is Int) {
<!DEPRECATED_SMARTCAST, DEBUG_INFO_SMARTCAST!>sometimesNotInt<!>.inc()
}
}