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) {
<!SMARTCAST_IMPOSSIBLE!>sometimesNotInt<!>.inc()
}
}
@@ -0,0 +1,12 @@
package
public fun failsWithClassCastException(): kotlin.Unit
public final class AlternatingDelegate {
public constructor AlternatingDelegate()
public final var counter: kotlin.Int
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final operator fun getValue(/*0*/ thisRef: kotlin.Any?, /*1*/ property: [ERROR : KProperty<*>]<out [ERROR : *]>): kotlin.Any?
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -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()
}
}
@@ -0,0 +1,12 @@
package
public fun failsWithClassCastException(): kotlin.Unit
public final class AlternatingDelegate {
public constructor AlternatingDelegate()
public final var counter: kotlin.Int
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final operator fun getValue(/*0*/ thisRef: kotlin.Any?, /*1*/ property: [ERROR : KProperty<*>]<out [ERROR : *]>): kotlin.Any?
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}