When in debugger context, access private companion object directly
This commit is contained in:
@@ -2651,12 +2651,9 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
"Containing declaration of the companion object " + companionObjectDescriptor +
|
"Containing declaration of the companion object " + companionObjectDescriptor +
|
||||||
": expected a class, actual: " + hostClassDescriptor;
|
": expected a class, actual: " + hostClassDescriptor;
|
||||||
|
|
||||||
CodegenContext hostClassContext = context;
|
CodegenContext hostClassContext = context.findParentContextWithDescriptor(hostClassDescriptor);
|
||||||
while (hostClassContext.getContextDescriptor() != hostClassDescriptor) {
|
assert hostClassContext != null :
|
||||||
hostClassContext = hostClassContext.getParentContext();
|
"Host class context for " + hostClassDescriptor + " not found in context hierarchy for " + context;
|
||||||
assert hostClassContext != null :
|
|
||||||
"Host class context for " + hostClassDescriptor + " not found in context hierarchy for " + context;
|
|
||||||
}
|
|
||||||
|
|
||||||
hostClassContext.markCompanionObjectDescriptorWithAccessorRequired(companionObjectDescriptor);
|
hostClassContext.markCompanionObjectDescriptorWithAccessorRequired(companionObjectDescriptor);
|
||||||
|
|
||||||
|
|||||||
@@ -159,6 +159,10 @@ public class JvmCodegenUtil {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isDebuggerContext(contextBeforeInline)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
CodegenContext context = contextBeforeInline.getFirstCrossInlineOrNonInlineContext();
|
CodegenContext context = contextBeforeInline.getFirstCrossInlineOrNonInlineContext();
|
||||||
if (context.isInlineMethodContext()) {
|
if (context.isInlineMethodContext()) {
|
||||||
// Inline method can be called from a nested class.
|
// Inline method can be called from a nested class.
|
||||||
|
|||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
// !LANGUAGE: +ProperVisibilityForCompanionObjectInstanceField
|
||||||
|
|
||||||
|
class Outer {
|
||||||
|
private companion object {
|
||||||
|
val result = "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
val test: String
|
||||||
|
|
||||||
|
init {
|
||||||
|
test = result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box() = Outer().test
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
// !LANGUAGE: +ProperVisibilityForCompanionObjectInstanceField
|
||||||
|
|
||||||
|
class Outer {
|
||||||
|
private companion object {
|
||||||
|
val result = "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
class Nested {
|
||||||
|
val test: String
|
||||||
|
|
||||||
|
init {
|
||||||
|
test = result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box() = Outer.Nested().test
|
||||||
Generated
+10
@@ -14039,6 +14039,16 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromAnonymousObjectInNestedClass.kt");
|
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromAnonymousObjectInNestedClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("privateCompanionObjectAccessedFromInitBlock.kt")
|
||||||
|
public void testPrivateCompanionObjectAccessedFromInitBlock() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromInitBlock.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("privateCompanionObjectAccessedFromInitBlockOfNestedClass.kt")
|
||||||
|
public void testPrivateCompanionObjectAccessedFromInitBlockOfNestedClass() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromInitBlockOfNestedClass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("privateCompanionObjectAccessedFromInlineLambdaInNestedClass.kt")
|
@TestMetadata("privateCompanionObjectAccessedFromInlineLambdaInNestedClass.kt")
|
||||||
public void testPrivateCompanionObjectAccessedFromInlineLambdaInNestedClass() throws Exception {
|
public void testPrivateCompanionObjectAccessedFromInlineLambdaInNestedClass() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromInlineLambdaInNestedClass.kt");
|
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromInlineLambdaInNestedClass.kt");
|
||||||
|
|||||||
+10
@@ -14039,6 +14039,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromAnonymousObjectInNestedClass.kt");
|
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromAnonymousObjectInNestedClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("privateCompanionObjectAccessedFromInitBlock.kt")
|
||||||
|
public void testPrivateCompanionObjectAccessedFromInitBlock() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromInitBlock.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("privateCompanionObjectAccessedFromInitBlockOfNestedClass.kt")
|
||||||
|
public void testPrivateCompanionObjectAccessedFromInitBlockOfNestedClass() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromInitBlockOfNestedClass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("privateCompanionObjectAccessedFromInlineLambdaInNestedClass.kt")
|
@TestMetadata("privateCompanionObjectAccessedFromInlineLambdaInNestedClass.kt")
|
||||||
public void testPrivateCompanionObjectAccessedFromInlineLambdaInNestedClass() throws Exception {
|
public void testPrivateCompanionObjectAccessedFromInlineLambdaInNestedClass() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromInlineLambdaInNestedClass.kt");
|
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromInlineLambdaInNestedClass.kt");
|
||||||
|
|||||||
+10
@@ -14039,6 +14039,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromAnonymousObjectInNestedClass.kt");
|
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromAnonymousObjectInNestedClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("privateCompanionObjectAccessedFromInitBlock.kt")
|
||||||
|
public void testPrivateCompanionObjectAccessedFromInitBlock() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromInitBlock.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("privateCompanionObjectAccessedFromInitBlockOfNestedClass.kt")
|
||||||
|
public void testPrivateCompanionObjectAccessedFromInitBlockOfNestedClass() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromInitBlockOfNestedClass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("privateCompanionObjectAccessedFromInlineLambdaInNestedClass.kt")
|
@TestMetadata("privateCompanionObjectAccessedFromInlineLambdaInNestedClass.kt")
|
||||||
public void testPrivateCompanionObjectAccessedFromInlineLambdaInNestedClass() throws Exception {
|
public void testPrivateCompanionObjectAccessedFromInlineLambdaInNestedClass() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromInlineLambdaInNestedClass.kt");
|
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromInlineLambdaInNestedClass.kt");
|
||||||
|
|||||||
+10
@@ -13369,6 +13369,16 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromAnonymousObjectInNestedClass.kt");
|
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromAnonymousObjectInNestedClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("privateCompanionObjectAccessedFromInitBlock.kt")
|
||||||
|
public void testPrivateCompanionObjectAccessedFromInitBlock() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromInitBlock.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("privateCompanionObjectAccessedFromInitBlockOfNestedClass.kt")
|
||||||
|
public void testPrivateCompanionObjectAccessedFromInitBlockOfNestedClass() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromInitBlockOfNestedClass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("privateCompanionObjectAccessedFromInlineLambdaInNestedClass.kt")
|
@TestMetadata("privateCompanionObjectAccessedFromInlineLambdaInNestedClass.kt")
|
||||||
public void testPrivateCompanionObjectAccessedFromInlineLambdaInNestedClass() throws Exception {
|
public void testPrivateCompanionObjectAccessedFromInlineLambdaInNestedClass() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromInlineLambdaInNestedClass.kt");
|
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromInlineLambdaInNestedClass.kt");
|
||||||
|
|||||||
+10
@@ -12241,6 +12241,16 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromAnonymousObjectInNestedClass.kt");
|
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromAnonymousObjectInNestedClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("privateCompanionObjectAccessedFromInitBlock.kt")
|
||||||
|
public void testPrivateCompanionObjectAccessedFromInitBlock() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromInitBlock.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("privateCompanionObjectAccessedFromInitBlockOfNestedClass.kt")
|
||||||
|
public void testPrivateCompanionObjectAccessedFromInitBlockOfNestedClass() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromInitBlockOfNestedClass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("privateCompanionObjectAccessedFromInlineLambdaInNestedClass.kt")
|
@TestMetadata("privateCompanionObjectAccessedFromInlineLambdaInNestedClass.kt")
|
||||||
public void testPrivateCompanionObjectAccessedFromInlineLambdaInNestedClass() throws Exception {
|
public void testPrivateCompanionObjectAccessedFromInlineLambdaInNestedClass() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromInlineLambdaInNestedClass.kt");
|
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromInlineLambdaInNestedClass.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user