[FIR] Forbid typeRef-named labels without +ContextReceivers
^KT-63068 Fixed
This commit is contained in:
committed by
Space Team
parent
e7a3cd638e
commit
427c067cd8
+7
-4
@@ -680,7 +680,7 @@ class BodyResolveContext(
|
|||||||
}
|
}
|
||||||
val receiverTypeRef = function.receiverParameter?.typeRef
|
val receiverTypeRef = function.receiverParameter?.typeRef
|
||||||
val type = receiverTypeRef?.coneType
|
val type = receiverTypeRef?.coneType
|
||||||
val additionalLabelName = type?.labelName()
|
val additionalLabelName = type?.labelName(holder.session)
|
||||||
withLabelAndReceiverType(function.name, function, type, holder, additionalLabelName, f)
|
withLabelAndReceiverType(function.name, function, type, holder, additionalLabelName, f)
|
||||||
} else {
|
} else {
|
||||||
f()
|
f()
|
||||||
@@ -688,8 +688,11 @@ class BodyResolveContext(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ConeKotlinType.labelName(): Name? {
|
private fun ConeKotlinType.labelName(session: FirSession): Name? {
|
||||||
return (this as? ConeLookupTagBasedType)?.lookupTag?.name
|
return when {
|
||||||
|
!session.languageVersionSettings.supportsFeature(LanguageFeature.ContextReceivers) -> null
|
||||||
|
else -> (this as? ConeLookupTagBasedType)?.lookupTag?.name
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(PrivateForInline::class)
|
@OptIn(PrivateForInline::class)
|
||||||
@@ -841,7 +844,7 @@ class BodyResolveContext(
|
|||||||
}
|
}
|
||||||
withContainer(accessor) {
|
withContainer(accessor) {
|
||||||
val type = receiverTypeRef?.coneType
|
val type = receiverTypeRef?.coneType
|
||||||
val additionalLabelName = type?.labelName()
|
val additionalLabelName = type?.labelName(holder.session)
|
||||||
withLabelAndReceiverType(property.name, property, type, holder, additionalLabelName, f)
|
withLabelAndReceiverType(property.name, property, type, holder, additionalLabelName, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
// ISSUE: KT-63068
|
// ISSUE: KT-63068
|
||||||
fun List<Int>.f() {
|
fun List<Int>.f() {
|
||||||
this@List.size
|
this<!UNRESOLVED_LABEL!>@List<!>.size
|
||||||
}
|
}
|
||||||
|
|
||||||
<!UNSUPPORTED_FEATURE!>context(String)<!>
|
<!UNSUPPORTED_FEATURE!>context(String)<!>
|
||||||
fun Int.f() {
|
fun Int.f() {
|
||||||
this@String.length
|
this@String.length
|
||||||
this@Int.toDouble()
|
this<!UNRESOLVED_LABEL!>@Int<!>.toDouble()
|
||||||
}
|
}
|
||||||
|
|
||||||
<!UNSUPPORTED_FEATURE!>context(String)<!>
|
<!UNSUPPORTED_FEATURE!>context(String)<!>
|
||||||
|
|||||||
+6
-6
@@ -1,28 +1,28 @@
|
|||||||
// ISSUE: KT-63068
|
// ISSUE: KT-63068
|
||||||
fun Int.f() {
|
fun Int.f() {
|
||||||
this@Int
|
this<!UNRESOLVED_LABEL!>@Int<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
var Int.p: Int
|
var Int.p: Int
|
||||||
get() {
|
get() {
|
||||||
this@Int
|
this<!UNRESOLVED_LABEL!>@Int<!>
|
||||||
<!RETURN_NOT_ALLOWED!>return@p<!> 42
|
<!RETURN_NOT_ALLOWED!>return@p<!> 42
|
||||||
}
|
}
|
||||||
set(value) {
|
set(value) {
|
||||||
this@Int
|
this<!UNRESOLVED_LABEL!>@Int<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
class X {
|
class X {
|
||||||
var Int.p: Int
|
var Int.p: Int
|
||||||
get() {
|
get() {
|
||||||
this@Int
|
this<!UNRESOLVED_LABEL!>@Int<!>
|
||||||
<!RETURN_NOT_ALLOWED!>return@p<!> 42
|
<!RETURN_NOT_ALLOWED!>return@p<!> 42
|
||||||
}
|
}
|
||||||
set(value) {
|
set(value) {
|
||||||
this@Int
|
this<!UNRESOLVED_LABEL!>@Int<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Int.f() {
|
fun Int.f() {
|
||||||
this@Int
|
this<!UNRESOLVED_LABEL!>@Int<!>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6
|
|
||||||
// EXPECTED_REACHABLE_NODES: 1292
|
// EXPECTED_REACHABLE_NODES: 1292
|
||||||
package foo
|
package foo
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user