[FIR] Forbid typeRef-named labels without +ContextReceivers

^KT-63068 Fixed
This commit is contained in:
Nikolay Lunyak
2023-11-16 12:23:50 +02:00
committed by Space Team
parent e7a3cd638e
commit 427c067cd8
4 changed files with 15 additions and 13 deletions
@@ -680,7 +680,7 @@ class BodyResolveContext(
}
val receiverTypeRef = function.receiverParameter?.typeRef
val type = receiverTypeRef?.coneType
val additionalLabelName = type?.labelName()
val additionalLabelName = type?.labelName(holder.session)
withLabelAndReceiverType(function.name, function, type, holder, additionalLabelName, f)
} else {
f()
@@ -688,8 +688,11 @@ class BodyResolveContext(
}
}
private fun ConeKotlinType.labelName(): Name? {
return (this as? ConeLookupTagBasedType)?.lookupTag?.name
private fun ConeKotlinType.labelName(session: FirSession): Name? {
return when {
!session.languageVersionSettings.supportsFeature(LanguageFeature.ContextReceivers) -> null
else -> (this as? ConeLookupTagBasedType)?.lookupTag?.name
}
}
@OptIn(PrivateForInline::class)
@@ -841,7 +844,7 @@ class BodyResolveContext(
}
withContainer(accessor) {
val type = receiverTypeRef?.coneType
val additionalLabelName = type?.labelName()
val additionalLabelName = type?.labelName(holder.session)
withLabelAndReceiverType(property.name, property, type, holder, additionalLabelName, f)
}
}
@@ -1,12 +1,12 @@
// ISSUE: KT-63068
fun List<Int>.f() {
this@List.size
this<!UNRESOLVED_LABEL!>@List<!>.size
}
<!UNSUPPORTED_FEATURE!>context(String)<!>
fun Int.f() {
this@String.length
this@Int.toDouble()
this<!UNRESOLVED_LABEL!>@Int<!>.toDouble()
}
<!UNSUPPORTED_FEATURE!>context(String)<!>
@@ -1,28 +1,28 @@
// ISSUE: KT-63068
fun Int.f() {
this@Int
this<!UNRESOLVED_LABEL!>@Int<!>
}
var Int.p: Int
get() {
this@Int
this<!UNRESOLVED_LABEL!>@Int<!>
<!RETURN_NOT_ALLOWED!>return@p<!> 42
}
set(value) {
this@Int
this<!UNRESOLVED_LABEL!>@Int<!>
}
class X {
var Int.p: Int
get() {
this@Int
this<!UNRESOLVED_LABEL!>@Int<!>
<!RETURN_NOT_ALLOWED!>return@p<!> 42
}
set(value) {
this@Int
this<!UNRESOLVED_LABEL!>@Int<!>
}
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
package foo