Fix access to top level delegated property from another property

#KT-5612 Fixed
This commit is contained in:
Alexander Udalov
2014-08-14 10:42:40 +04:00
parent 9e971ed2b9
commit 99d4f97aef
3 changed files with 20 additions and 5 deletions
@@ -55,6 +55,8 @@ public class PackagePartCodegen extends MemberCodegen<JetFile> {
ArrayUtil.EMPTY_STRING_ARRAY
);
v.visitSource(element.getName(), null);
generatePropertyMetadataArrayFieldIfNeeded(packagePartType);
}
@Override
@@ -75,11 +77,6 @@ public class PackagePartCodegen extends MemberCodegen<JetFile> {
}
}
@Override
protected void generateSyntheticParts() {
generatePropertyMetadataArrayFieldIfNeeded(packagePartType);
}
@Override
protected void generateKotlinAnnotation() {
writeKotlinSyntheticClassAnnotation(v, KotlinSyntheticClass.Kind.PACKAGE_PART);
@@ -0,0 +1,13 @@
// KT-5612
class Delegate {
public fun get(thisRef: Any?, prop: PropertyMetadata): String {
return "OK"
}
}
val prop by Delegate()
val a = prop
fun box() = a
@@ -1887,6 +1887,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
@TestMetadata("compiler/testData/codegen/box/delegatedProperty")
public static class DelegatedProperty extends AbstractBlackBoxCodegenTest {
@TestMetadata("accessTopLevelDelegatedPropertyInClinit.kt")
public void testAccessTopLevelDelegatedPropertyInClinit() throws Exception {
doTest("compiler/testData/codegen/box/delegatedProperty/accessTopLevelDelegatedPropertyInClinit.kt");
}
public void testAllFilesPresentInDelegatedProperty() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/box/delegatedProperty"), Pattern.compile("^(.+)\\.kt$"), true);
}