FE 1.0: introduce DELEGATE_USES_EXTENSION_PROPERTY_TYPE_PARAMETER error

#KT-24643 Fixed
This commit is contained in:
Mikhail Glukhikh
2021-04-05 15:12:55 +03:00
parent d062f54360
commit fcbab45a88
12 changed files with 136 additions and 0 deletions
@@ -0,0 +1,16 @@
// !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>()
fun useString(s: String) {}
fun main(listInt: List<Int>, listStr: List<String>) {
listInt.foo = 42
useString(listStr.foo) // CCE
}
@@ -0,0 +1,16 @@
// !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 <!DELEGATE_USES_EXTENSION_PROPERTY_TYPE_PARAMETER!>by Delegate<T>()<!>
fun useString(s: String) {}
fun main(listInt: List<Int>, listStr: List<String>) {
listInt.foo = 42
useString(listStr.foo) // CCE
}
@@ -0,0 +1,15 @@
package
public var </*0*/ T : kotlin.Any> kotlin.collections.List<T>.foo: T
public fun main(/*0*/ listInt: kotlin.collections.List<kotlin.Int>, /*1*/ listStr: kotlin.collections.List<kotlin.String>): kotlin.Unit
public fun useString(/*0*/ s: kotlin.String): kotlin.Unit
public final class Delegate</*0*/ T : kotlin.Any> {
public constructor Delegate</*0*/ T : kotlin.Any>()
private final var v: T?
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final operator fun getValue(/*0*/ thisRef: kotlin.Any?, /*1*/ kp: kotlin.Any?): T
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final operator fun setValue(/*0*/ thisRef: kotlin.Any?, /*1*/ kp: kotlin.Any?, /*2*/ newValue: T): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,16 @@
// !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>()
fun useString(s: String) {}
fun main(listInt: List<Int>, listStr: List<String>) {
listInt.foo = 42
useString(listStr.foo) // CCE
}
@@ -0,0 +1,16 @@
// !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 <!DELEGATE_USES_EXTENSION_PROPERTY_TYPE_PARAMETER_WARNING!>by Delegate<T>()<!>
fun useString(s: String) {}
fun main(listInt: List<Int>, listStr: List<String>) {
listInt.foo = 42
useString(listStr.foo) // CCE
}
@@ -0,0 +1,15 @@
package
public var </*0*/ T : kotlin.Any> kotlin.collections.List<T>.foo: T
public fun main(/*0*/ listInt: kotlin.collections.List<kotlin.Int>, /*1*/ listStr: kotlin.collections.List<kotlin.String>): kotlin.Unit
public fun useString(/*0*/ s: kotlin.String): kotlin.Unit
public final class Delegate</*0*/ T : kotlin.Any> {
public constructor Delegate</*0*/ T : kotlin.Any>()
private final var v: T?
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final operator fun getValue(/*0*/ thisRef: kotlin.Any?, /*1*/ kp: kotlin.Any?): T
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final operator fun setValue(/*0*/ thisRef: kotlin.Any?, /*1*/ kp: kotlin.Any?, /*2*/ newValue: T): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}