Rewrite Java resolve to use static class scope instead of synthesized packages

#KT-4149 Fixed
 #KT-4839 Fixed
This commit is contained in:
Alexander Udalov
2014-09-03 14:42:03 +04:00
parent 75df4a9ad8
commit bcfb5f3b09
41 changed files with 217 additions and 419 deletions
@@ -6151,6 +6151,11 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("privateNestedClassStaticMember.kt")
public void testPrivateNestedClassStaticMember() throws Exception {
doTest("compiler/testData/diagnostics/tests/j+k/privateNestedClassStaticMember.kt");
}
@TestMetadata("protectedStaticSamePackage.kt")
public void testProtectedStaticSamePackage() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/protectedStaticSamePackage.kt");
@@ -20,8 +20,6 @@ import com.google.common.collect.Lists;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.resolve.java.descriptor.JavaClassDescriptor;
import org.jetbrains.jet.lang.resolve.java.descriptor.JavaClassStaticsPackageFragmentDescriptor;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
@@ -170,13 +168,6 @@ public class DescriptorValidator {
public Boolean visitPackageFragmentDescriptor(
PackageFragmentDescriptor descriptor, DiagnosticCollector collector
) {
if (descriptor instanceof JavaClassStaticsPackageFragmentDescriptor) {
JavaClassDescriptor correspondingClass = ((JavaClassStaticsPackageFragmentDescriptor) descriptor).getCorrespondingClass();
JavaClassStaticsPackageFragmentDescriptor correspondingPackageFragment = correspondingClass.getCorrespondingPackageFragment();
if (correspondingPackageFragment != descriptor) {
report(collector, descriptor, "Corresponding class bound to another descriptor: " + correspondingPackageFragment);
}
}
validateScope(descriptor.getMemberScope(), collector);
return true;
}
@@ -251,17 +242,6 @@ public class DescriptorValidator {
}
}
if (descriptor instanceof JavaClassDescriptor) {
JavaClassStaticsPackageFragmentDescriptor
correspondingPackageFragment = ((JavaClassDescriptor) descriptor).getCorrespondingPackageFragment();
if (correspondingPackageFragment != null) {
JavaClassDescriptor correspondingClass = correspondingPackageFragment.getCorrespondingClass();
if (correspondingClass != descriptor) {
report(collector, descriptor, "Corresponding package bound to another descriptor: " + correspondingClass);
}
}
}
return true;
}
@@ -95,6 +95,12 @@ public class RecursiveDescriptorComparator {
if (descriptor instanceof ClassDescriptor) {
ClassDescriptor klass = (ClassDescriptor) descriptor;
appendSubDescriptors(klass.getDefaultType().getMemberScope(), getConstructorsAndClassObject(klass), printer);
JetScope staticScope = klass.getStaticScope();
if (!staticScope.getAllDescriptors().isEmpty()) {
printer.println();
printer.println("// Static members");
appendSubDescriptors(staticScope, Collections.<DeclarationDescriptor>emptyList(), printer);
}
}
else if (descriptor instanceof PackageFragmentDescriptor) {
appendSubDescriptors(((PackageFragmentDescriptor) descriptor).getMemberScope(),