RawFirBuilder: fix label bounding for property initialization
#KT-58076 Fixed
This commit is contained in:
committed by
Space Team
parent
df8132b844
commit
594b044c26
Vendored
+2
-2
@@ -13,8 +13,8 @@ FILE: lambdaWithAnonymousObject.kt
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public open override val action: R|() -> kotlin/Unit| = myRun@fun <anonymous>(): R|kotlin/Unit| <inline=Unknown> {
|
||||
^@myRun Unit
|
||||
public open override val action: R|() -> kotlin/Unit| = fun <anonymous>(): R|kotlin/Unit| <inline=Unknown> {
|
||||
^ Unit
|
||||
}
|
||||
|
||||
public get(): R|() -> kotlin/Unit|
|
||||
|
||||
+5
-1
@@ -1186,7 +1186,11 @@ class DeclarationsConverter(
|
||||
accessors += it
|
||||
}
|
||||
BACKING_FIELD -> fieldDeclaration = it
|
||||
else -> if (it.isExpression()) propertyInitializer = expressionConverter.getAsFirExpression(it, "Should have initializer")
|
||||
else -> if (it.isExpression()) {
|
||||
context.calleeNamesForLambda += null
|
||||
propertyInitializer = expressionConverter.getAsFirExpression(it, "Should have initializer")
|
||||
context.calleeNamesForLambda.removeLast()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1722,9 +1722,14 @@ open class RawFirBuilder(
|
||||
|
||||
private fun KtDeclarationWithInitializer.toInitializerExpression() =
|
||||
runIf(hasInitializer()) {
|
||||
buildOrLazyExpression(null) {
|
||||
this@RawFirBuilder.context.calleeNamesForLambda += null
|
||||
|
||||
val expression = buildOrLazyExpression(null) {
|
||||
initializer.toFirExpression("Should have initializer")
|
||||
}
|
||||
|
||||
this@RawFirBuilder.context.calleeNamesForLambda.removeLast()
|
||||
expression
|
||||
}
|
||||
|
||||
private fun <T> KtProperty.toFirProperty(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// FIR_IDENTICAL
|
||||
// ISSUE: KT-57880
|
||||
// ISSUE: KT-57880, KT-58076
|
||||
// DIAGNOSTICS: -UNUSED_VARIABLE, -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE
|
||||
|
||||
fun outerLambda(action: String.() -> Unit) {}
|
||||
var lambda: Int.() -> Unit = {}
|
||||
@@ -18,4 +19,16 @@ fun main() {
|
||||
consumeInt(this@innerLambda)
|
||||
}
|
||||
}
|
||||
|
||||
lateinit var c: Int.() -> Unit
|
||||
val a = "hello".apply {
|
||||
val b: Int.() -> Unit = {
|
||||
this@apply.hello()
|
||||
}
|
||||
c = {
|
||||
this@apply.hello()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun String.hello() = this
|
||||
|
||||
Reference in New Issue
Block a user