[LL API] Fix 'this' capturing inside property accessors
^KTIJ-26726 Fixed
This commit is contained in:
+18
@@ -160,6 +160,24 @@ public class FirIdeNormalAnalysisLibrarySourceModuleCompilerFacilityTestGenerate
|
||||
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing/extensionReceiverLabeled.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("extensionReceiverProperty.kt")
|
||||
public void testExtensionReceiverProperty() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing/extensionReceiverProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("extensionReceiverPropertyExplicit.kt")
|
||||
public void testExtensionReceiverPropertyExplicit() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing/extensionReceiverPropertyExplicit.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("extensionReceiverPropertyLabeled.kt")
|
||||
public void testExtensionReceiverPropertyLabeled() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing/extensionReceiverPropertyLabeled.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("initializer.kt")
|
||||
public void testInitializer() throws Exception {
|
||||
|
||||
+18
@@ -160,6 +160,24 @@ public class FirIdeNormalAnalysisSourceModuleCompilerFacilityTestGenerated exten
|
||||
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing/extensionReceiverLabeled.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("extensionReceiverProperty.kt")
|
||||
public void testExtensionReceiverProperty() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing/extensionReceiverProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("extensionReceiverPropertyExplicit.kt")
|
||||
public void testExtensionReceiverPropertyExplicit() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing/extensionReceiverPropertyExplicit.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("extensionReceiverPropertyLabeled.kt")
|
||||
public void testExtensionReceiverPropertyLabeled() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing/extensionReceiverPropertyLabeled.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("initializer.kt")
|
||||
public void testInitializer() throws Exception {
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
ExtensionReceiver[name: ext; isMutated: false; displayText: this@ext]
|
||||
val R|kotlin/Int|.ext: R|kotlin/String|
|
||||
get(): R|kotlin/String|
|
||||
R|kotlin/Int|
|
||||
+1
@@ -0,0 +1 @@
|
||||
dec()
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
MODULE_FRAGMENT
|
||||
FILE fqName:<root> fileName:fragment.kt
|
||||
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.CodeFragment
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
FUN name:run visibility:public modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Int
|
||||
VALUE_PARAMETER name:p0 index:0 type:kotlin.Int
|
||||
EXPRESSION_BODY
|
||||
BLOCK type=kotlin.Int origin=null
|
||||
CALL 'public final fun dec (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null
|
||||
$this: GET_VAR 'p0: kotlin.Int declared in <root>.CodeFragment.run' type=kotlin.Int origin=null
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fun test() {
|
||||
1.ext
|
||||
}
|
||||
|
||||
val Int.ext: String
|
||||
get() {
|
||||
<caret>return "foo"
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
public final class CodeFragment {
|
||||
// source: 'fragment.kt'
|
||||
public method <init>(): void
|
||||
public final static method run(p0: int): int
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
ExtensionReceiver[name: ext; isMutated: false; displayText: this@ext]
|
||||
val R|kotlin/Int|.ext: R|kotlin/String|
|
||||
get(): R|kotlin/String|
|
||||
R|kotlin/Int|
|
||||
+1
@@ -0,0 +1 @@
|
||||
this.dec()
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
MODULE_FRAGMENT
|
||||
FILE fqName:<root> fileName:fragment.kt
|
||||
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.CodeFragment
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
FUN name:run visibility:public modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Int
|
||||
VALUE_PARAMETER name:p0 index:0 type:kotlin.Int
|
||||
EXPRESSION_BODY
|
||||
BLOCK type=kotlin.Int origin=null
|
||||
CALL 'public final fun dec (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null
|
||||
$this: GET_VAR 'p0: kotlin.Int declared in <root>.CodeFragment.run' type=kotlin.Int origin=null
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fun test() {
|
||||
1.ext
|
||||
}
|
||||
|
||||
val Int.ext: String
|
||||
get() {
|
||||
<caret>return "foo"
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
public final class CodeFragment {
|
||||
// source: 'fragment.kt'
|
||||
public method <init>(): void
|
||||
public final static method run(p0: int): int
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
ExtensionReceiver[name: ext; isMutated: false; displayText: this@ext]
|
||||
val R|kotlin/Int|.ext: R|kotlin/String|
|
||||
get(): R|kotlin/String|
|
||||
R|kotlin/Int|
|
||||
+1
@@ -0,0 +1 @@
|
||||
this@ext.dec()
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
MODULE_FRAGMENT
|
||||
FILE fqName:<root> fileName:fragment.kt
|
||||
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.CodeFragment
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
FUN name:run visibility:public modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Int
|
||||
VALUE_PARAMETER name:p0 index:0 type:kotlin.Int
|
||||
EXPRESSION_BODY
|
||||
BLOCK type=kotlin.Int origin=null
|
||||
CALL 'public final fun dec (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null
|
||||
$this: GET_VAR 'p0: kotlin.Int declared in <root>.CodeFragment.run' type=kotlin.Int origin=null
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fun test() {
|
||||
1.ext
|
||||
}
|
||||
|
||||
val Int.ext: String
|
||||
get() {
|
||||
<caret>return "foo"
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
public final class CodeFragment {
|
||||
// source: 'fragment.kt'
|
||||
public method <init>(): void
|
||||
public final static method run(p0: int): int
|
||||
}
|
||||
+4
-1
@@ -139,7 +139,10 @@ private class CodeFragmentCapturedValueVisitor(
|
||||
register(CodeFragmentCapturedSymbol(capturedValue, symbol, typeRef, contextReceiverNumber))
|
||||
}
|
||||
}
|
||||
is FirFunctionSymbol<*> -> {
|
||||
is FirFunctionSymbol<*>, is FirPropertySymbol -> {
|
||||
@Suppress("USELESS_IS_CHECK") // Smart-cast is not applied from a 'when' condition in K1
|
||||
require(symbol is FirCallableSymbol<*>)
|
||||
|
||||
if (contextReceiverNumber >= 0) {
|
||||
val contextReceiver = symbol.resolvedContextReceivers[contextReceiverNumber]
|
||||
val labelName = contextReceiver.labelName
|
||||
|
||||
+18
@@ -54,6 +54,24 @@ public class CodeFragmentCapturingTestGenerated extends AbstractCodeFragmentCapt
|
||||
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing/extensionReceiverLabeled.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("extensionReceiverProperty.kt")
|
||||
public void testExtensionReceiverProperty() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing/extensionReceiverProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("extensionReceiverPropertyExplicit.kt")
|
||||
public void testExtensionReceiverPropertyExplicit() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing/extensionReceiverPropertyExplicit.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("extensionReceiverPropertyLabeled.kt")
|
||||
public void testExtensionReceiverPropertyLabeled() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/capturing/extensionReceiverPropertyLabeled.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("initializer.kt")
|
||||
public void testInitializer() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user