Unwrap property imported from object on property access

#KT-18982 Fixed Target versions 1.1.5
This commit is contained in:
Dmitry Petrov
2017-07-28 10:12:29 +03:00
parent 05919244bd
commit 9e6b706a03
6 changed files with 38 additions and 4 deletions
@@ -65,10 +65,7 @@ import org.jetbrains.kotlin.load.kotlin.TypeSignatureMappingKt;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilsKt;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.BindingContextUtils;
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.*;
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.CallResolverUtilKt;
import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
import org.jetbrains.kotlin.resolve.calls.model.*;
@@ -1893,6 +1890,10 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
return intermediateValueForSyntheticExtensionProperty((SyntheticJavaPropertyDescriptor) propertyDescriptor, receiver);
}
if (propertyDescriptor instanceof PropertyImportedFromObject) {
propertyDescriptor = ((PropertyImportedFromObject) propertyDescriptor).getCallableFromObject();
}
DeclarationDescriptor containingDeclaration = propertyDescriptor.getContainingDeclaration();
FieldAccessorKind fieldAccessorKind = FieldAccessorKind.NORMAL;
+9
View File
@@ -0,0 +1,9 @@
import Foo.bar0 as bar
object Foo {
val bar0 = "OK"
fun test() = bar0
}
fun box() = Foo.test()
@@ -11603,6 +11603,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
doTest(fileName);
}
@TestMetadata("kt18982.kt")
public void testKt18982() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/kt18982.kt");
doTest(fileName);
}
@TestMetadata("kt2398.kt")
public void testKt2398() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/kt2398.kt");
@@ -11603,6 +11603,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest(fileName);
}
@TestMetadata("kt18982.kt")
public void testKt18982() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/kt18982.kt");
doTest(fileName);
}
@TestMetadata("kt2398.kt")
public void testKt2398() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/kt2398.kt");
@@ -11603,6 +11603,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
doTest(fileName);
}
@TestMetadata("kt18982.kt")
public void testKt18982() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/kt18982.kt");
doTest(fileName);
}
@TestMetadata("kt2398.kt")
public void testKt2398() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/kt2398.kt");
@@ -12959,6 +12959,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
}
@TestMetadata("kt18982.kt")
public void testKt18982() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/kt18982.kt");
doTest(fileName);
}
@TestMetadata("kt2398.kt")
public void testKt2398() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/kt2398.kt");