Prohibit local objects and enum classes
#KT-5402 Fixed
#KT-4838 Fixed
Resolve type of object inside local object as special, not supertype('Any').
Changed visibility of constructor of anonymous object to 'internal' to be able to resolve the following:
fun box(): String {
var foo = object {
val bar = object {
val baz = "ok"
}
}
return foo.bar.baz
}
The containing declaration of property initializers is constructor, so 'baz' was invisible inside private constructor.
This commit is contained in:
@@ -3194,6 +3194,11 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest("compiler/testData/diagnostics/tests/enum/kt2834.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localEnums.kt")
|
||||
public void testLocalEnums() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/enum/localEnums.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("starImportNestedClassAndEntries.kt")
|
||||
public void testStarImportNestedClassAndEntries() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/enum/starImportNestedClassAndEntries.kt");
|
||||
@@ -5921,6 +5926,11 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest("compiler/testData/diagnostics/tests/objects/localObjectInsideObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localObjects.kt")
|
||||
public void testLocalObjects() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/objects/localObjects.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectLiteralExpressionTypeMismatch.kt")
|
||||
public void testObjectLiteralExpressionTypeMismatch() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/objects/objectLiteralExpressionTypeMismatch.kt");
|
||||
|
||||
+5
-15
@@ -2114,11 +2114,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest("compiler/testData/codegen/box/enum/entrywithinner.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inFunction.kt")
|
||||
public void testInFunction() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/enum/inFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inPackage.kt")
|
||||
public void testInPackage() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/enum/inPackage.kt");
|
||||
@@ -2149,11 +2144,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest("compiler/testData/codegen/box/enum/kt2350.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt2673.kt")
|
||||
public void testKt2673() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/enum/kt2673.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("name.kt")
|
||||
public void testName() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/enum/name.kt");
|
||||
@@ -3336,11 +3326,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest("compiler/testData/codegen/box/localClasses/anonymousObjectInParameterInitializer.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("enum.kt")
|
||||
public void testEnum() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/localClasses/enum.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inExtensionFunction.kt")
|
||||
public void testInExtensionFunction() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/localClasses/inExtensionFunction.kt");
|
||||
@@ -4059,6 +4044,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest("compiler/testData/codegen/box/objects/nestedObjectWithSuperclass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectInLocalAnonymousObject.kt")
|
||||
public void testObjectInLocalAnonymousObject() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/objects/objectInLocalAnonymousObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectLiteral.kt")
|
||||
public void testObjectLiteral() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/objects/objectLiteral.kt");
|
||||
|
||||
@@ -186,6 +186,11 @@ public class ReplInterpreterTestGenerated extends AbstractReplInterpreterTest {
|
||||
doTest("compiler/testData/repl/objects/emptyObject.repl");
|
||||
}
|
||||
|
||||
@TestMetadata("localObject.repl")
|
||||
public void testLocalObject() throws Exception {
|
||||
doTest("compiler/testData/repl/objects/localObject.repl");
|
||||
}
|
||||
|
||||
@TestMetadata("simpleObjectDeclaration.repl")
|
||||
public void testSimpleObjectDeclaration() throws Exception {
|
||||
doTest("compiler/testData/repl/objects/simpleObjectDeclaration.repl");
|
||||
|
||||
@@ -134,8 +134,8 @@ public class JetDefaultModalityModifiersTest extends JetLiteFixture {
|
||||
|
||||
List<JetDeclaration> declarations = aClass.getDeclarations();
|
||||
JetProperty property = (JetProperty) declarations.get(0);
|
||||
PropertyDescriptor propertyDescriptor = descriptorResolver.resolvePropertyDescriptor(classDescriptor, scope, property,
|
||||
JetTestUtils.DUMMY_TRACE, DataFlowInfo.EMPTY);
|
||||
PropertyDescriptor propertyDescriptor = descriptorResolver.resolvePropertyDescriptor(
|
||||
classDescriptor, scope, property, JetTestUtils.DUMMY_TRACE, DataFlowInfo.EMPTY);
|
||||
|
||||
assertEquals(expectedPropertyModality, propertyDescriptor.getModality());
|
||||
}
|
||||
@@ -147,8 +147,8 @@ public class JetDefaultModalityModifiersTest extends JetLiteFixture {
|
||||
|
||||
List<JetDeclaration> declarations = aClass.getDeclarations();
|
||||
JetProperty property = (JetProperty) declarations.get(0);
|
||||
PropertyDescriptor propertyDescriptor = descriptorResolver.resolvePropertyDescriptor(classDescriptor, scope, property,
|
||||
JetTestUtils.DUMMY_TRACE, DataFlowInfo.EMPTY);
|
||||
PropertyDescriptor propertyDescriptor = descriptorResolver.resolvePropertyDescriptor(
|
||||
classDescriptor, scope, property, JetTestUtils.DUMMY_TRACE, DataFlowInfo.EMPTY);
|
||||
PropertyAccessorDescriptor propertyAccessor = isGetter
|
||||
? propertyDescriptor.getGetter()
|
||||
: propertyDescriptor.getSetter();
|
||||
|
||||
Reference in New Issue
Block a user