[FIR] Add FirDelegateUsesExtensionPropertyTypeParameterChecker
This commit is contained in:
committed by
TeamCityServer
parent
f97e666608
commit
dbfe3524ce
Vendored
-22
@@ -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
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +ForbidUsingExtensionPropertyTypeParameterInDelegate
|
||||
|
||||
class Delegate<T : Any> {
|
||||
|
||||
-22
@@ -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
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: -ForbidUsingExtensionPropertyTypeParameterInDelegate
|
||||
|
||||
class Delegate<T : Any> {
|
||||
|
||||
Reference in New Issue
Block a user