Uneeded usages of LazinessToken.isLazy() are removed
This commit is contained in:
@@ -106,16 +106,13 @@ public class BodyResolver {
|
||||
|
||||
resolvePropertyDeclarationBodies(c);
|
||||
|
||||
if (!c.getTopDownAnalysisParameters().isLazy()) {
|
||||
resolveClassAnnotations(c);
|
||||
}
|
||||
resolveAnonymousInitializers(c);
|
||||
resolvePrimaryConstructorParameters(c);
|
||||
|
||||
resolveFunctionBodies(c);
|
||||
|
||||
// SCRIPT: resolve script bodies
|
||||
scriptBodyResolverResolver.resolveScriptBodies(c, trace);
|
||||
scriptBodyResolverResolver.resolveScriptBodies(c);
|
||||
|
||||
if (!c.getTopDownAnalysisParameters().isDeclaredLocally()) {
|
||||
computeDeferredTypes();
|
||||
@@ -306,32 +303,12 @@ public class BodyResolver {
|
||||
}
|
||||
}
|
||||
|
||||
private void resolveClassAnnotations(@NotNull BodiesResolveContext c) {
|
||||
for (Map.Entry<JetClassOrObject, ClassDescriptorWithResolutionScopes> entry : c.getDeclaredClasses().entrySet()) {
|
||||
resolveAnnotationArguments(entry.getValue().getScopeForClassHeaderResolution(), entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
private void resolveAnonymousInitializers(@NotNull BodiesResolveContext c) {
|
||||
if (c.getTopDownAnalysisParameters().isLazy()) {
|
||||
for (Map.Entry<JetClassInitializer, ClassDescriptorWithResolutionScopes> entry : c.getAnonymousInitializers().entrySet()) {
|
||||
JetClassInitializer initializer = entry.getKey();
|
||||
ClassDescriptorWithResolutionScopes descriptor = entry.getValue();
|
||||
resolveAnonymousInitializer(c, initializer, descriptor);
|
||||
}
|
||||
for (Map.Entry<JetClassInitializer, ClassDescriptorWithResolutionScopes> entry : c.getAnonymousInitializers().entrySet()) {
|
||||
JetClassInitializer initializer = entry.getKey();
|
||||
ClassDescriptorWithResolutionScopes descriptor = entry.getValue();
|
||||
resolveAnonymousInitializer(c, initializer, descriptor);
|
||||
}
|
||||
else {
|
||||
for (Map.Entry<JetClassOrObject, ClassDescriptorWithResolutionScopes> entry : c.getDeclaredClasses().entrySet()) {
|
||||
JetClassOrObject classOrObject = entry.getKey();
|
||||
ClassDescriptorWithResolutionScopes descriptor = entry.getValue();
|
||||
|
||||
if (!c.completeAnalysisNeeded(classOrObject)) return;
|
||||
for (JetClassInitializer initializer : classOrObject.getAnonymousInitializers()) {
|
||||
resolveAnonymousInitializer(c, initializer, descriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void resolveAnonymousInitializer(
|
||||
@@ -577,9 +554,6 @@ public class BodyResolver {
|
||||
JetScope declaringScope = c.getDeclaringScopes().apply(declaration);
|
||||
assert declaringScope != null;
|
||||
|
||||
if (!c.getTopDownAnalysisParameters().isLazy()) {
|
||||
resolveAnnotationArguments(declaringScope, declaration);
|
||||
}
|
||||
resolveFunctionBody(c, trace, declaration, descriptor, declaringScope);
|
||||
|
||||
assert descriptor.getReturnType() != null;
|
||||
|
||||
@@ -268,9 +268,8 @@ public class DeclarationsChecker {
|
||||
private void checkClass(BodiesResolveContext c, JetClass aClass, ClassDescriptorWithResolutionScopes classDescriptor) {
|
||||
checkOpenMembers(classDescriptor);
|
||||
checkConstructorParameters(aClass);
|
||||
if (c.getTopDownAnalysisParameters().isLazy()) {
|
||||
checkTypeParameters(aClass);
|
||||
}
|
||||
checkTypeParameters(aClass);
|
||||
|
||||
if (aClass.isTrait()) {
|
||||
checkTraitModifiers(aClass);
|
||||
checkConstructorInTrait(aClass);
|
||||
|
||||
@@ -109,7 +109,6 @@ public class DescriptorResolver {
|
||||
}
|
||||
|
||||
public void resolveMutableClassDescriptor(
|
||||
@NotNull TopDownAnalysisParameters topDownAnalysisParameters,
|
||||
@NotNull JetClass classElement,
|
||||
@NotNull MutableClassDescriptor descriptor,
|
||||
BindingTrace trace
|
||||
@@ -125,11 +124,6 @@ public class DescriptorResolver {
|
||||
}
|
||||
int index = 0;
|
||||
for (JetTypeParameter typeParameter : typeParameters) {
|
||||
if (!topDownAnalysisParameters.isLazy()) {
|
||||
// TODO: Support
|
||||
AnnotationResolver.reportUnsupportedAnnotationForTypeParameter(typeParameter, trace);
|
||||
}
|
||||
|
||||
TypeParameterDescriptor typeParameterDescriptor = TypeParameterDescriptorImpl.createForFurtherModification(
|
||||
descriptor,
|
||||
Annotations.EMPTY,
|
||||
@@ -151,16 +145,6 @@ public class DescriptorResolver {
|
||||
trace.record(BindingContext.CLASS, classElement, descriptor);
|
||||
}
|
||||
|
||||
public void resolveSupertypesForMutableClassDescriptor(
|
||||
@NotNull JetClassOrObject jetClass,
|
||||
@NotNull MutableClassDescriptor descriptor,
|
||||
BindingTrace trace
|
||||
) {
|
||||
for (JetType supertype : resolveSupertypes(descriptor.getScopeForClassHeaderResolution(), descriptor, jetClass, trace)) {
|
||||
descriptor.addSupertype(supertype);
|
||||
}
|
||||
}
|
||||
|
||||
public List<JetType> resolveSupertypes(
|
||||
@NotNull JetScope scope,
|
||||
@NotNull ClassDescriptor classDescriptor,
|
||||
|
||||
@@ -123,8 +123,6 @@ public class LazyTopDownAnalyzer {
|
||||
@NotNull Collection<? extends PsiElement> declarations,
|
||||
@NotNull DataFlowInfo outerDataFlowInfo
|
||||
) {
|
||||
assert topDownAnalysisParameters.isLazy() : "Lazy analyzer is run in non-lazy mode";
|
||||
|
||||
final TopDownAnalysisContext c = new TopDownAnalysisContext(topDownAnalysisParameters, outerDataFlowInfo);
|
||||
|
||||
final Multimap<FqName, JetElement> topLevelFqNames = HashMultimap.create();
|
||||
|
||||
@@ -54,8 +54,6 @@ public class LazyTopDownAnalyzerForTopLevel {
|
||||
@NotNull Collection<JetFile> files,
|
||||
@NotNull List<? extends PackageFragmentProvider> additionalProviders
|
||||
) {
|
||||
assert topDownAnalysisParameters.isLazy() : "Lazy analyzer is run in non-lazy mode";
|
||||
|
||||
PackageFragmentProvider provider;
|
||||
if (additionalProviders.isEmpty()) {
|
||||
provider = resolveSession.getPackageFragmentProvider();
|
||||
|
||||
@@ -17,19 +17,10 @@
|
||||
package org.jetbrains.kotlin.resolve;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.ScriptDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.impl.PropertyDescriptorImpl;
|
||||
import org.jetbrains.kotlin.descriptors.impl.ScriptDescriptorImpl;
|
||||
import org.jetbrains.kotlin.psi.JetDeclaration;
|
||||
import org.jetbrains.kotlin.psi.JetNamedFunction;
|
||||
import org.jetbrains.kotlin.psi.JetProperty;
|
||||
import org.jetbrains.kotlin.psi.JetScript;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
|
||||
import org.jetbrains.kotlin.resolve.lazy.data.DataPackage;
|
||||
import org.jetbrains.kotlin.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.expressions.CoercionStrategy;
|
||||
@@ -37,8 +28,6 @@ import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext;
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE;
|
||||
@@ -47,7 +36,6 @@ import static org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE;
|
||||
// SCRIPT: resolve symbols in scripts
|
||||
public class ScriptBodyResolver {
|
||||
|
||||
@NotNull
|
||||
private ExpressionTypingServices expressionTypingServices;
|
||||
|
||||
@Inject
|
||||
@@ -56,46 +44,10 @@ public class ScriptBodyResolver {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void resolveScriptBodies(@NotNull BodiesResolveContext c, @NotNull BindingTrace trace) {
|
||||
public void resolveScriptBodies(@NotNull BodiesResolveContext c) {
|
||||
for (Map.Entry<JetScript, ScriptDescriptor> e : c.getScripts().entrySet()) {
|
||||
JetScript declaration = e.getKey();
|
||||
ScriptDescriptor descriptor = e.getValue();
|
||||
|
||||
if (c.getTopDownAnalysisParameters().isLazy()) {
|
||||
ForceResolveUtil.forceResolveAllContents(descriptor);
|
||||
continue;
|
||||
}
|
||||
|
||||
ScriptDescriptorImpl descriptorImpl = (ScriptDescriptorImpl) descriptor;
|
||||
|
||||
// TODO: lock in resolveScriptDeclarations
|
||||
descriptorImpl.getScopeForBodyResolution().changeLockLevel(WritableScope.LockLevel.READING);
|
||||
|
||||
JetType returnType = resolveScriptReturnType(declaration, descriptor, trace);
|
||||
|
||||
List<PropertyDescriptorImpl> properties = new ArrayList<PropertyDescriptorImpl>();
|
||||
List<SimpleFunctionDescriptor> functions = new ArrayList<SimpleFunctionDescriptor>();
|
||||
|
||||
BindingContext bindingContext = trace.getBindingContext();
|
||||
for (JetDeclaration jetDeclaration : declaration.getDeclarations()) {
|
||||
if (jetDeclaration instanceof JetProperty) {
|
||||
if (!DataPackage.shouldBeScriptClassMember(jetDeclaration)) continue;
|
||||
|
||||
PropertyDescriptorImpl propertyDescriptor = (PropertyDescriptorImpl) bindingContext.get(BindingContext.VARIABLE, jetDeclaration);
|
||||
properties.add(propertyDescriptor);
|
||||
}
|
||||
else if (jetDeclaration instanceof JetNamedFunction) {
|
||||
if (!DataPackage.shouldBeScriptClassMember(jetDeclaration)) continue;
|
||||
|
||||
SimpleFunctionDescriptor function = bindingContext.get(BindingContext.FUNCTION, jetDeclaration);
|
||||
assert function != null;
|
||||
functions.add(function.copy(descriptor.getClassDescriptor(), function.getModality(), function.getVisibility(),
|
||||
CallableMemberDescriptor.Kind.DECLARATION, false));
|
||||
}
|
||||
}
|
||||
|
||||
descriptorImpl.initialize(returnType, properties, functions);
|
||||
ForceResolveUtil.forceResolveAllContents(descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ public class JetDefaultModalityModifiersTest extends JetLiteFixture {
|
||||
LockBasedStorageManager.NO_LOCKS, new ExceptionTracker(), Predicates.<PsiFile>alwaysTrue(), false, false
|
||||
);
|
||||
descriptorResolver.resolveMutableClassDescriptor(
|
||||
parameters, aClass, classDescriptor, JetTestUtils.DUMMY_TRACE);
|
||||
aClass, classDescriptor, JetTestUtils.DUMMY_TRACE);
|
||||
return classDescriptor;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user