Fix using qualified this with labeled function literals
#KT-9251 Fixed
This commit is contained in:
@@ -182,19 +182,14 @@ object LabelResolver {
|
||||
}
|
||||
else if (size == 0) {
|
||||
val element = resolveNamedLabel(labelName, targetLabel, context.trace)
|
||||
if (element is KtFunctionLiteral) {
|
||||
val declarationDescriptor = context.trace.bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element)
|
||||
if (declarationDescriptor is FunctionDescriptor) {
|
||||
val thisReceiver = declarationDescriptor.extensionReceiverParameter
|
||||
if (thisReceiver != null) {
|
||||
context.trace.record(LABEL_TARGET, targetLabel, element)
|
||||
context.trace.record(REFERENCE_TARGET, referenceExpression, declarationDescriptor)
|
||||
}
|
||||
return LabeledReceiverResolutionResult.labelResolutionSuccess(thisReceiver)
|
||||
}
|
||||
else {
|
||||
context.trace.report(UNRESOLVED_REFERENCE.on(targetLabel, targetLabel))
|
||||
val declarationDescriptor = context.trace.bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, element]
|
||||
if (declarationDescriptor is FunctionDescriptor) {
|
||||
val thisReceiver = declarationDescriptor.extensionReceiverParameter
|
||||
if (thisReceiver != null) {
|
||||
context.trace.record(LABEL_TARGET, targetLabel, element)
|
||||
context.trace.record(REFERENCE_TARGET, referenceExpression, declarationDescriptor)
|
||||
}
|
||||
return LabeledReceiverResolutionResult.labelResolutionSuccess(thisReceiver)
|
||||
}
|
||||
else {
|
||||
context.trace.report(UNRESOLVED_REFERENCE.on(targetLabel, targetLabel))
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
val funLit = lambda@ fun String.() {
|
||||
val d1 = this@lambda
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val funLit = lambda@ fun String.(): String {
|
||||
return this@lambda
|
||||
}
|
||||
}
|
||||
|
||||
fun lambda() {
|
||||
val funLit = lambda@ fun String.(): String {
|
||||
return <!NO_THIS!>this@lambda<!>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package
|
||||
|
||||
public val funLit: kotlin.String.() -> kotlin.Unit
|
||||
public fun lambda(): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
@@ -12670,6 +12670,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("labeledFunctionLiteral.kt")
|
||||
public void testLabeledFunctionLiteral() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/labels/labeledFunctionLiteral.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("labelsMustBeNamed.kt")
|
||||
public void testLabelsMustBeNamed() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/labels/labelsMustBeNamed.kt");
|
||||
|
||||
Reference in New Issue
Block a user