[FE] Do not change original semantics in LabelResolver

This commit is contained in:
Anastasiya Shadrina
2021-11-22 15:00:25 +07:00
committed by TeamCityServer
parent 5d76f979cf
commit 2b30c1eb5d
8 changed files with 95 additions and 3 deletions
@@ -10660,6 +10660,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/noExplicitReceiver.kt");
}
@Test
@TestMetadata("noLabelsByClassName.kt")
public void testNoLabelsByClassName() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/noLabelsByClassName.kt");
}
@Test
@TestMetadata("outerClass.kt")
public void testOuterClass() throws Exception {
@@ -10660,6 +10660,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/noExplicitReceiver.kt");
}
@Test
@TestMetadata("noLabelsByClassName.kt")
public void testNoLabelsByClassName() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/noLabelsByClassName.kt");
}
@Test
@TestMetadata("outerClass.kt")
public void testOuterClass() throws Exception {
@@ -10660,6 +10660,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/noExplicitReceiver.kt");
}
@Test
@TestMetadata("noLabelsByClassName.kt")
public void testNoLabelsByClassName() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/noLabelsByClassName.kt");
}
@Test
@TestMetadata("outerClass.kt")
public void testOuterClass() throws Exception {
@@ -57,7 +57,10 @@ object LabelResolver {
is KtLambdaExpression -> result.addIfNotNull(getLabelForFunctionalExpression(element))
}
val functionOrProperty = when (element) {
is KtNamedFunction -> element
is KtNamedFunction -> {
result.addIfNotNull(element.nameAsName ?: getLabelForFunctionalExpression(element))
element
}
is KtPropertyAccessor -> element.property
else -> return result
}
@@ -66,8 +69,6 @@ object LabelResolver {
functionOrProperty.contextReceivers
.mapNotNullTo(result) { it.name()?.let { s -> Name.identifier(s) } }
}
val name = functionOrProperty.nameAsName ?: getLabelForFunctionalExpression(functionOrProperty)
result.addIfNotNull(name)
return result
}
@@ -0,0 +1,27 @@
fun Int.f() {
this<!UNRESOLVED_LABEL!>@Int<!>
}
var Int.p: Int
get() {
this<!UNRESOLVED_LABEL!>@Int<!>
<!RETURN_NOT_ALLOWED!>return@p<!> 42
}
set(value) {
this<!UNRESOLVED_LABEL!>@Int<!>
}
class X {
var Int.p: Int
get() {
this<!UNRESOLVED_LABEL!>@Int<!>
<!RETURN_NOT_ALLOWED!>return@p<!> 42
}
set(value) {
this<!UNRESOLVED_LABEL!>@Int<!>
}
fun Int.f() {
this<!UNRESOLVED_LABEL!>@Int<!>
}
}
@@ -0,0 +1,27 @@
fun Int.f() {
this<!UNRESOLVED_REFERENCE!>@Int<!>
}
var Int.p: Int
get() {
this<!UNRESOLVED_REFERENCE!>@Int<!>
return<!UNRESOLVED_REFERENCE!>@p<!> 42
}
set(value) {
this<!UNRESOLVED_REFERENCE!>@Int<!>
}
class X {
var Int.p: Int
get() {
this<!UNRESOLVED_REFERENCE!>@Int<!>
return<!UNRESOLVED_REFERENCE!>@p<!> 42
}
set(value) {
this<!UNRESOLVED_REFERENCE!>@Int<!>
}
fun Int.f() {
this<!UNRESOLVED_REFERENCE!>@Int<!>
}
}
@@ -0,0 +1,13 @@
package
public var kotlin.Int.p: kotlin.Int
public fun kotlin.Int.f(): kotlin.Unit
public final class X {
public constructor X()
public final var kotlin.Int.p: kotlin.Int
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
public final fun kotlin.Int.f(): kotlin.Unit
}
@@ -10666,6 +10666,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/noExplicitReceiver.kt");
}
@Test
@TestMetadata("noLabelsByClassName.kt")
public void testNoLabelsByClassName() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/noLabelsByClassName.kt");
}
@Test
@TestMetadata("outerClass.kt")
public void testOuterClass() throws Exception {