Fix access to top-level declarations inside anonymous initializer

#KT-16583 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2017-03-02 13:52:19 +03:00
parent 0e5603f644
commit e2dcec62d3
5 changed files with 55 additions and 2 deletions
@@ -0,0 +1,20 @@
private const val A = 0L
private val B = 0L
private fun sample() = 0L
private class PrivateClass
class Foo {
var bar: Long = 0
private var other: PrivateClass? = null
init {
bar = A
bar = B
bar = sample()
other = PrivateClass()
}
constructor()
}
@@ -0,0 +1,21 @@
package
private const val A: kotlin.Long = 0.toLong()
private val B: kotlin.Long = 0.toLong()
private fun sample(): kotlin.Long
public final class Foo {
public constructor Foo()
public final var bar: kotlin.Long
private final var other: PrivateClass?
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
}
private final class PrivateClass {
public constructor PrivateClass()
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
}
@@ -3406,6 +3406,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("initializerWithSecondaryConstructor.kt")
public void testInitializerWithSecondaryConstructor() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/constructorConsistency/initializerWithSecondaryConstructor.kt");
doTest(fileName);
}
@TestMetadata("initwithgetter.kt")
public void testInitwithgetter() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/constructorConsistency/initwithgetter.kt");