[FIR] Add FirDelegateUsesExtensionPropertyTypeParameterChecker

This commit is contained in:
Nikolay Lunyak
2021-09-29 15:20:52 +03:00
committed by TeamCityServer
parent f97e666608
commit dbfe3524ce
11 changed files with 103 additions and 44 deletions
@@ -1,22 +0,0 @@
// !LANGUAGE: +ForbidUsingExtensionPropertyTypeParameterInDelegate
class Delegate<T : Any> {
private var v: T? = null
operator fun getValue(thisRef: Any?, kp: Any?): T = v!!
operator fun setValue(thisRef: Any?, kp: Any?, newValue: T) { v = newValue }
}
var <T : Any> List<T>.foo by Delegate<T>()
class Wrapper<T>(val v: T? = null)
operator fun <T> Wrapper<T>.getValue(thisRef: Any?, kp: Any?): T = v!!
val <T : Any> List<T>.bar by Wrapper<T>()
fun useString(s: String) {}
fun main(listInt: List<Int>, listStr: List<String>) {
listInt.foo = 42
useString(listStr.foo) // CCE
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +ForbidUsingExtensionPropertyTypeParameterInDelegate
class Delegate<T : Any> {
@@ -1,22 +0,0 @@
// !LANGUAGE: -ForbidUsingExtensionPropertyTypeParameterInDelegate
class Delegate<T : Any> {
private var v: T? = null
operator fun getValue(thisRef: Any?, kp: Any?): T = v!!
operator fun setValue(thisRef: Any?, kp: Any?, newValue: T) { v = newValue }
}
var <T : Any> List<T>.foo by Delegate<T>()
class Wrapper<T>(val v: T? = null)
operator fun <T> Wrapper<T>.getValue(thisRef: Any?, kp: Any?): T = v!!
val <T : Any> List<T>.bar by Wrapper<T>()
fun useString(s: String) {}
fun main(listInt: List<Int>, listStr: List<String>) {
listInt.foo = 42
useString(listStr.foo) // CCE
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: -ForbidUsingExtensionPropertyTypeParameterInDelegate
class Delegate<T : Any> {