Import nested classes both from classes and their class objects
It seems that this incorrect behaviour was introduced in 726bcb5
This commit is contained in:
@@ -28,6 +28,7 @@ import org.jetbrains.jet.lang.resolve.scopes.FilteringScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@@ -86,20 +87,21 @@ public interface Importer {
|
||||
}
|
||||
|
||||
protected void importAllUnderDeclaration(@NotNull DeclarationDescriptor descriptor, @NotNull PlatformToKotlinClassMap platformToKotlinClassMap) {
|
||||
JetScope scopeToImport = null;
|
||||
List<JetScope> scopesToImport = new ArrayList<JetScope>(2);
|
||||
if (descriptor instanceof NamespaceDescriptor) {
|
||||
scopeToImport = ((NamespaceDescriptor) descriptor).getMemberScope();
|
||||
scopesToImport.add(((NamespaceDescriptor) descriptor).getMemberScope());
|
||||
}
|
||||
if (descriptor instanceof ClassDescriptor && ((ClassDescriptor) descriptor).getKind() != ClassKind.OBJECT) {
|
||||
else if (descriptor instanceof ClassDescriptor && ((ClassDescriptor) descriptor).getKind() != ClassKind.OBJECT) {
|
||||
ClassDescriptor classDescriptor = (ClassDescriptor) descriptor;
|
||||
scopeToImport = classDescriptor.getUnsubstitutedInnerClassesScope();
|
||||
scopesToImport.add(classDescriptor.getUnsubstitutedInnerClassesScope());
|
||||
ClassDescriptor classObjectDescriptor = classDescriptor.getClassObjectDescriptor();
|
||||
if (classObjectDescriptor != null) {
|
||||
scopeToImport = classObjectDescriptor.getUnsubstitutedInnerClassesScope();
|
||||
scopesToImport.add(classObjectDescriptor.getUnsubstitutedInnerClassesScope());
|
||||
}
|
||||
}
|
||||
if (scopeToImport != null) {
|
||||
namespaceScope.importScope(createFilteringScope(scopeToImport, descriptor, platformToKotlinClassMap));
|
||||
|
||||
for (JetScope scope : scopesToImport) {
|
||||
namespaceScope.importScope(createFilteringScope(scope, descriptor, platformToKotlinClassMap));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// FILE: E.kt
|
||||
package foo
|
||||
|
||||
enum class E {
|
||||
ENTRY
|
||||
ANOTHER
|
||||
|
||||
class Nested {
|
||||
class object {
|
||||
fun foo() = 42
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
package bar
|
||||
|
||||
import foo.E.*
|
||||
|
||||
fun f1() = ENTRY
|
||||
fun f2() = ANOTHER
|
||||
fun f3() = Nested()
|
||||
fun f4() = Nested.foo()
|
||||
fun f5() = values()
|
||||
@@ -2597,6 +2597,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
doTest("compiler/testData/diagnostics/tests/enum/kt2834.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("starImportNestedClassAndEntries.kt")
|
||||
public void testStarImportNestedClassAndEntries() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/enum/starImportNestedClassAndEntries.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/enum/inner")
|
||||
public static class Inner extends AbstractDiagnosticsTestWithEagerResolve {
|
||||
public void testAllFilesPresentInInner() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user