Special classes (for Any and Nothing) introduced to Lazy Resolve

This commit is contained in:
Andrey Breslav
2012-06-26 19:23:17 +02:00
parent ac06825f08
commit f0e0411847
2 changed files with 34 additions and 7 deletions
@@ -24,6 +24,7 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.AnnotationResolver; import org.jetbrains.jet.lang.resolve.AnnotationResolver;
import org.jetbrains.jet.lang.resolve.DescriptorResolver; import org.jetbrains.jet.lang.resolve.DescriptorResolver;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.lazy.data.FilteringClassLikeInfo; import org.jetbrains.jet.lang.resolve.lazy.data.FilteringClassLikeInfo;
import org.jetbrains.jet.lang.resolve.lazy.data.JetClassInfoUtil; import org.jetbrains.jet.lang.resolve.lazy.data.JetClassInfoUtil;
import org.jetbrains.jet.lang.resolve.lazy.data.JetClassLikeInfo; import org.jetbrains.jet.lang.resolve.lazy.data.JetClassLikeInfo;
@@ -275,6 +276,10 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
@Override @Override
public Collection<? extends JetType> getSupertypes() { public Collection<? extends JetType> getSupertypes() {
if (supertypes == null) { if (supertypes == null) {
if (resolveSession.isClassSpecial(DescriptorUtils.getFQName(LazyClassDescriptor.this))) {
this.supertypes = Collections.emptyList();
}
else {
JetClassOrObject classOrObject = declarationProvider.getOwnerInfo().getCorrespondingClassOrObject(); JetClassOrObject classOrObject = declarationProvider.getOwnerInfo().getCorrespondingClassOrObject();
if (classOrObject == null) { if (classOrObject == null) {
this.supertypes = Collections.emptyList(); this.supertypes = Collections.emptyList();
@@ -286,6 +291,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
resolveSession.getTrace()); resolveSession.getTrace());
} }
} }
}
return supertypes; return supertypes;
} }
@@ -16,6 +16,8 @@
package org.jetbrains.jet.lang.resolve.lazy; package org.jetbrains.jet.lang.resolve.lazy;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.intellij.openapi.project.Project; import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
@@ -49,6 +51,9 @@ public class ResolveSession {
private final BindingTrace trace = new BindingTraceContext(); private final BindingTrace trace = new BindingTraceContext();
private final DeclarationProviderFactory declarationProviderFactory; private final DeclarationProviderFactory declarationProviderFactory;
private final Predicate<FqNameUnsafe> specialClasses;
private final InjectorForLazyResolve injector; private final InjectorForLazyResolve injector;
private final ModuleConfiguration moduleConfiguration; private final ModuleConfiguration moduleConfiguration;
@@ -60,6 +65,18 @@ public class ResolveSession {
@NotNull ModuleConfiguration moduleConfiguration, @NotNull ModuleConfiguration moduleConfiguration,
@NotNull DeclarationProviderFactory declarationProviderFactory @NotNull DeclarationProviderFactory declarationProviderFactory
) { ) {
this(project, rootDescriptor, moduleConfiguration, declarationProviderFactory, Predicates.<FqNameUnsafe>alwaysFalse());
}
@Deprecated // Internal use only
public ResolveSession(
@NotNull Project project,
@NotNull ModuleDescriptor rootDescriptor,
@NotNull ModuleConfiguration moduleConfiguration,
@NotNull DeclarationProviderFactory declarationProviderFactory,
@NotNull Predicate<FqNameUnsafe> specialClasses
) {
this.specialClasses = specialClasses;
this.injector = new InjectorForLazyResolve(project, this, trace); this.injector = new InjectorForLazyResolve(project, this, trace);
this.module = rootDescriptor; this.module = rootDescriptor;
this.moduleConfiguration = moduleConfiguration; this.moduleConfiguration = moduleConfiguration;
@@ -76,6 +93,10 @@ public class ResolveSession {
return injector; return injector;
} }
/*package*/ boolean isClassSpecial(@NotNull FqNameUnsafe fqName) {
return specialClasses.apply(fqName);
}
@NotNull @NotNull
public ModuleConfiguration getModuleConfiguration() { public ModuleConfiguration getModuleConfiguration() {
return moduleConfiguration; return moduleConfiguration;