Resolve property initializer if there is no primary constructor

This commit is contained in:
Denis Zharkov
2015-02-18 17:43:14 +03:00
parent a872a51a19
commit 4c26d037d9
4 changed files with 20 additions and 4 deletions
@@ -530,10 +530,7 @@ public class BodyResolver {
JetExpression initializer = property.getInitializer();
JetScope propertyScope = getScopeForProperty(c, property);
if (initializer != null) {
ConstructorDescriptor primaryConstructor = classDescriptor.getUnsubstitutedPrimaryConstructor();
if (primaryConstructor != null) {
resolvePropertyInitializer(c, property, propertyDescriptor, initializer, propertyScope);
}
resolvePropertyInitializer(c, property, propertyDescriptor, initializer, propertyScope);
}
JetExpression delegateExpression = property.getDelegateExpression();
@@ -0,0 +1,4 @@
class A {
val prop: Int = <!TYPE_MISMATCH!>""<!>
constructor() {}
}
@@ -0,0 +1,9 @@
package
internal final class A {
public constructor A()
internal final val prop: kotlin.Int = ""
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
}
@@ -10535,6 +10535,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("resolvePropertyInitializerWithoutPrimary.kt")
public void testResolvePropertyInitializerWithoutPrimary() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/secondaryConstructors/resolvePropertyInitializerWithoutPrimary.kt");
doTest(fileName);
}
@TestMetadata("return.kt")
public void testReturn() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/secondaryConstructors/return.kt");