Forbid using ext.property type parameter also for delegate ext.receiver
This commit is contained in:
@@ -715,8 +715,10 @@ class DeclarationsChecker(
|
|||||||
} else if (property.receiverTypeReference != null) {
|
} else if (property.receiverTypeReference != null) {
|
||||||
val delegatedPropertyResolvedCall = trace.get(DELEGATED_PROPERTY_RESOLVED_CALL, propertyDescriptor.getter)
|
val delegatedPropertyResolvedCall = trace.get(DELEGATED_PROPERTY_RESOLVED_CALL, propertyDescriptor.getter)
|
||||||
val dispatchReceiverType = delegatedPropertyResolvedCall?.dispatchReceiver?.type
|
val dispatchReceiverType = delegatedPropertyResolvedCall?.dispatchReceiver?.type
|
||||||
|
val extensionReceiverType = delegatedPropertyResolvedCall?.extensionReceiver?.type
|
||||||
val usedParameter = propertyDescriptor.typeParameters.find { typeParameter ->
|
val usedParameter = propertyDescriptor.typeParameters.find { typeParameter ->
|
||||||
dispatchReceiverType?.contains { it.constructor == typeParameter.typeConstructor } == true
|
dispatchReceiverType?.contains { it.constructor == typeParameter.typeConstructor } == true ||
|
||||||
|
extensionReceiverType?.contains { it.constructor == typeParameter.typeConstructor } == true
|
||||||
}
|
}
|
||||||
if (usedParameter != null) {
|
if (usedParameter != null) {
|
||||||
if (languageVersionSettings.supportsFeature(LanguageFeature.ForbidUsingExtensionPropertyTypeParameterInDelegate)) {
|
if (languageVersionSettings.supportsFeature(LanguageFeature.ForbidUsingExtensionPropertyTypeParameterInDelegate)) {
|
||||||
|
|||||||
Vendored
+6
@@ -8,6 +8,12 @@ class Delegate<T : Any> {
|
|||||||
|
|
||||||
var <T : Any> List<T>.foo by Delegate<T>()
|
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 useString(s: String) {}
|
||||||
|
|
||||||
fun main(listInt: List<Int>, listStr: List<String>) {
|
fun main(listInt: List<Int>, listStr: List<String>) {
|
||||||
|
|||||||
Vendored
+6
@@ -8,6 +8,12 @@ class Delegate<T : Any> {
|
|||||||
|
|
||||||
var <T : Any> List<T>.foo <!DELEGATE_USES_EXTENSION_PROPERTY_TYPE_PARAMETER!>by Delegate<T>()<!>
|
var <T : Any> List<T>.foo <!DELEGATE_USES_EXTENSION_PROPERTY_TYPE_PARAMETER!>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 <!DELEGATE_USES_EXTENSION_PROPERTY_TYPE_PARAMETER!>by Wrapper<T>()<!>
|
||||||
|
|
||||||
fun useString(s: String) {}
|
fun useString(s: String) {}
|
||||||
|
|
||||||
fun main(listInt: List<Int>, listStr: List<String>) {
|
fun main(listInt: List<Int>, listStr: List<String>) {
|
||||||
|
|||||||
Vendored
+11
@@ -1,8 +1,10 @@
|
|||||||
package
|
package
|
||||||
|
|
||||||
|
public val </*0*/ T : kotlin.Any> kotlin.collections.List<T>.bar: T
|
||||||
public var </*0*/ T : kotlin.Any> kotlin.collections.List<T>.foo: T
|
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 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 fun useString(/*0*/ s: kotlin.String): kotlin.Unit
|
||||||
|
public operator fun </*0*/ T> Wrapper<T>.getValue(/*0*/ thisRef: kotlin.Any?, /*1*/ kp: kotlin.Any?): T
|
||||||
|
|
||||||
public final class Delegate</*0*/ T : kotlin.Any> {
|
public final class Delegate</*0*/ T : kotlin.Any> {
|
||||||
public constructor Delegate</*0*/ T : kotlin.Any>()
|
public constructor Delegate</*0*/ T : kotlin.Any>()
|
||||||
@@ -13,3 +15,12 @@ public final class Delegate</*0*/ T : kotlin.Any> {
|
|||||||
public final operator fun setValue(/*0*/ thisRef: kotlin.Any?, /*1*/ kp: kotlin.Any?, /*2*/ newValue: T): kotlin.Unit
|
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
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final class Wrapper</*0*/ T> {
|
||||||
|
public constructor Wrapper</*0*/ T>(/*0*/ v: T? = ...)
|
||||||
|
public final val v: T?
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
+6
@@ -8,6 +8,12 @@ class Delegate<T : Any> {
|
|||||||
|
|
||||||
var <T : Any> List<T>.foo by Delegate<T>()
|
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 useString(s: String) {}
|
||||||
|
|
||||||
fun main(listInt: List<Int>, listStr: List<String>) {
|
fun main(listInt: List<Int>, listStr: List<String>) {
|
||||||
|
|||||||
+6
@@ -8,6 +8,12 @@ class Delegate<T : Any> {
|
|||||||
|
|
||||||
var <T : Any> List<T>.foo <!DELEGATE_USES_EXTENSION_PROPERTY_TYPE_PARAMETER_WARNING!>by Delegate<T>()<!>
|
var <T : Any> List<T>.foo <!DELEGATE_USES_EXTENSION_PROPERTY_TYPE_PARAMETER_WARNING!>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 <!DELEGATE_USES_EXTENSION_PROPERTY_TYPE_PARAMETER_WARNING!>by Wrapper<T>()<!>
|
||||||
|
|
||||||
fun useString(s: String) {}
|
fun useString(s: String) {}
|
||||||
|
|
||||||
fun main(listInt: List<Int>, listStr: List<String>) {
|
fun main(listInt: List<Int>, listStr: List<String>) {
|
||||||
|
|||||||
+11
@@ -1,8 +1,10 @@
|
|||||||
package
|
package
|
||||||
|
|
||||||
|
public val </*0*/ T : kotlin.Any> kotlin.collections.List<T>.bar: T
|
||||||
public var </*0*/ T : kotlin.Any> kotlin.collections.List<T>.foo: T
|
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 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 fun useString(/*0*/ s: kotlin.String): kotlin.Unit
|
||||||
|
public operator fun </*0*/ T> Wrapper<T>.getValue(/*0*/ thisRef: kotlin.Any?, /*1*/ kp: kotlin.Any?): T
|
||||||
|
|
||||||
public final class Delegate</*0*/ T : kotlin.Any> {
|
public final class Delegate</*0*/ T : kotlin.Any> {
|
||||||
public constructor Delegate</*0*/ T : kotlin.Any>()
|
public constructor Delegate</*0*/ T : kotlin.Any>()
|
||||||
@@ -13,3 +15,12 @@ public final class Delegate</*0*/ T : kotlin.Any> {
|
|||||||
public final operator fun setValue(/*0*/ thisRef: kotlin.Any?, /*1*/ kp: kotlin.Any?, /*2*/ newValue: T): kotlin.Unit
|
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
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final class Wrapper</*0*/ T> {
|
||||||
|
public constructor Wrapper</*0*/ T>(/*0*/ v: T? = ...)
|
||||||
|
public final val v: T?
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user