Uneeded usages of LazinessToken.isLazy() are removed
This commit is contained in:
@@ -106,16 +106,13 @@ public class BodyResolver {
|
|||||||
|
|
||||||
resolvePropertyDeclarationBodies(c);
|
resolvePropertyDeclarationBodies(c);
|
||||||
|
|
||||||
if (!c.getTopDownAnalysisParameters().isLazy()) {
|
|
||||||
resolveClassAnnotations(c);
|
|
||||||
}
|
|
||||||
resolveAnonymousInitializers(c);
|
resolveAnonymousInitializers(c);
|
||||||
resolvePrimaryConstructorParameters(c);
|
resolvePrimaryConstructorParameters(c);
|
||||||
|
|
||||||
resolveFunctionBodies(c);
|
resolveFunctionBodies(c);
|
||||||
|
|
||||||
// SCRIPT: resolve script bodies
|
// SCRIPT: resolve script bodies
|
||||||
scriptBodyResolverResolver.resolveScriptBodies(c, trace);
|
scriptBodyResolverResolver.resolveScriptBodies(c);
|
||||||
|
|
||||||
if (!c.getTopDownAnalysisParameters().isDeclaredLocally()) {
|
if (!c.getTopDownAnalysisParameters().isDeclaredLocally()) {
|
||||||
computeDeferredTypes();
|
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) {
|
private void resolveAnonymousInitializers(@NotNull BodiesResolveContext c) {
|
||||||
if (c.getTopDownAnalysisParameters().isLazy()) {
|
for (Map.Entry<JetClassInitializer, ClassDescriptorWithResolutionScopes> entry : c.getAnonymousInitializers().entrySet()) {
|
||||||
for (Map.Entry<JetClassInitializer, ClassDescriptorWithResolutionScopes> entry : c.getAnonymousInitializers().entrySet()) {
|
JetClassInitializer initializer = entry.getKey();
|
||||||
JetClassInitializer initializer = entry.getKey();
|
ClassDescriptorWithResolutionScopes descriptor = entry.getValue();
|
||||||
ClassDescriptorWithResolutionScopes descriptor = entry.getValue();
|
resolveAnonymousInitializer(c, initializer, descriptor);
|
||||||
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(
|
public void resolveAnonymousInitializer(
|
||||||
@@ -577,9 +554,6 @@ public class BodyResolver {
|
|||||||
JetScope declaringScope = c.getDeclaringScopes().apply(declaration);
|
JetScope declaringScope = c.getDeclaringScopes().apply(declaration);
|
||||||
assert declaringScope != null;
|
assert declaringScope != null;
|
||||||
|
|
||||||
if (!c.getTopDownAnalysisParameters().isLazy()) {
|
|
||||||
resolveAnnotationArguments(declaringScope, declaration);
|
|
||||||
}
|
|
||||||
resolveFunctionBody(c, trace, declaration, descriptor, declaringScope);
|
resolveFunctionBody(c, trace, declaration, descriptor, declaringScope);
|
||||||
|
|
||||||
assert descriptor.getReturnType() != null;
|
assert descriptor.getReturnType() != null;
|
||||||
|
|||||||
@@ -268,9 +268,8 @@ public class DeclarationsChecker {
|
|||||||
private void checkClass(BodiesResolveContext c, JetClass aClass, ClassDescriptorWithResolutionScopes classDescriptor) {
|
private void checkClass(BodiesResolveContext c, JetClass aClass, ClassDescriptorWithResolutionScopes classDescriptor) {
|
||||||
checkOpenMembers(classDescriptor);
|
checkOpenMembers(classDescriptor);
|
||||||
checkConstructorParameters(aClass);
|
checkConstructorParameters(aClass);
|
||||||
if (c.getTopDownAnalysisParameters().isLazy()) {
|
checkTypeParameters(aClass);
|
||||||
checkTypeParameters(aClass);
|
|
||||||
}
|
|
||||||
if (aClass.isTrait()) {
|
if (aClass.isTrait()) {
|
||||||
checkTraitModifiers(aClass);
|
checkTraitModifiers(aClass);
|
||||||
checkConstructorInTrait(aClass);
|
checkConstructorInTrait(aClass);
|
||||||
|
|||||||
@@ -109,7 +109,6 @@ public class DescriptorResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void resolveMutableClassDescriptor(
|
public void resolveMutableClassDescriptor(
|
||||||
@NotNull TopDownAnalysisParameters topDownAnalysisParameters,
|
|
||||||
@NotNull JetClass classElement,
|
@NotNull JetClass classElement,
|
||||||
@NotNull MutableClassDescriptor descriptor,
|
@NotNull MutableClassDescriptor descriptor,
|
||||||
BindingTrace trace
|
BindingTrace trace
|
||||||
@@ -125,11 +124,6 @@ public class DescriptorResolver {
|
|||||||
}
|
}
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (JetTypeParameter typeParameter : typeParameters) {
|
for (JetTypeParameter typeParameter : typeParameters) {
|
||||||
if (!topDownAnalysisParameters.isLazy()) {
|
|
||||||
// TODO: Support
|
|
||||||
AnnotationResolver.reportUnsupportedAnnotationForTypeParameter(typeParameter, trace);
|
|
||||||
}
|
|
||||||
|
|
||||||
TypeParameterDescriptor typeParameterDescriptor = TypeParameterDescriptorImpl.createForFurtherModification(
|
TypeParameterDescriptor typeParameterDescriptor = TypeParameterDescriptorImpl.createForFurtherModification(
|
||||||
descriptor,
|
descriptor,
|
||||||
Annotations.EMPTY,
|
Annotations.EMPTY,
|
||||||
@@ -151,16 +145,6 @@ public class DescriptorResolver {
|
|||||||
trace.record(BindingContext.CLASS, classElement, descriptor);
|
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(
|
public List<JetType> resolveSupertypes(
|
||||||
@NotNull JetScope scope,
|
@NotNull JetScope scope,
|
||||||
@NotNull ClassDescriptor classDescriptor,
|
@NotNull ClassDescriptor classDescriptor,
|
||||||
|
|||||||
@@ -123,8 +123,6 @@ public class LazyTopDownAnalyzer {
|
|||||||
@NotNull Collection<? extends PsiElement> declarations,
|
@NotNull Collection<? extends PsiElement> declarations,
|
||||||
@NotNull DataFlowInfo outerDataFlowInfo
|
@NotNull DataFlowInfo outerDataFlowInfo
|
||||||
) {
|
) {
|
||||||
assert topDownAnalysisParameters.isLazy() : "Lazy analyzer is run in non-lazy mode";
|
|
||||||
|
|
||||||
final TopDownAnalysisContext c = new TopDownAnalysisContext(topDownAnalysisParameters, outerDataFlowInfo);
|
final TopDownAnalysisContext c = new TopDownAnalysisContext(topDownAnalysisParameters, outerDataFlowInfo);
|
||||||
|
|
||||||
final Multimap<FqName, JetElement> topLevelFqNames = HashMultimap.create();
|
final Multimap<FqName, JetElement> topLevelFqNames = HashMultimap.create();
|
||||||
|
|||||||
@@ -54,8 +54,6 @@ public class LazyTopDownAnalyzerForTopLevel {
|
|||||||
@NotNull Collection<JetFile> files,
|
@NotNull Collection<JetFile> files,
|
||||||
@NotNull List<? extends PackageFragmentProvider> additionalProviders
|
@NotNull List<? extends PackageFragmentProvider> additionalProviders
|
||||||
) {
|
) {
|
||||||
assert topDownAnalysisParameters.isLazy() : "Lazy analyzer is run in non-lazy mode";
|
|
||||||
|
|
||||||
PackageFragmentProvider provider;
|
PackageFragmentProvider provider;
|
||||||
if (additionalProviders.isEmpty()) {
|
if (additionalProviders.isEmpty()) {
|
||||||
provider = resolveSession.getPackageFragmentProvider();
|
provider = resolveSession.getPackageFragmentProvider();
|
||||||
|
|||||||
@@ -17,19 +17,10 @@
|
|||||||
package org.jetbrains.kotlin.resolve;
|
package org.jetbrains.kotlin.resolve;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor;
|
|
||||||
import org.jetbrains.kotlin.descriptors.ScriptDescriptor;
|
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.psi.JetScript;
|
||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||||
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
|
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.ErrorUtils;
|
||||||
import org.jetbrains.kotlin.types.JetType;
|
import org.jetbrains.kotlin.types.JetType;
|
||||||
import org.jetbrains.kotlin.types.expressions.CoercionStrategy;
|
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 org.jetbrains.kotlin.types.expressions.ExpressionTypingServices;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE;
|
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
|
// SCRIPT: resolve symbols in scripts
|
||||||
public class ScriptBodyResolver {
|
public class ScriptBodyResolver {
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private ExpressionTypingServices expressionTypingServices;
|
private ExpressionTypingServices expressionTypingServices;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@@ -56,46 +44,10 @@ public class ScriptBodyResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void resolveScriptBodies(@NotNull BodiesResolveContext c) {
|
||||||
public void resolveScriptBodies(@NotNull BodiesResolveContext c, @NotNull BindingTrace trace) {
|
|
||||||
for (Map.Entry<JetScript, ScriptDescriptor> e : c.getScripts().entrySet()) {
|
for (Map.Entry<JetScript, ScriptDescriptor> e : c.getScripts().entrySet()) {
|
||||||
JetScript declaration = e.getKey();
|
|
||||||
ScriptDescriptor descriptor = e.getValue();
|
ScriptDescriptor descriptor = e.getValue();
|
||||||
|
ForceResolveUtil.forceResolveAllContents(descriptor);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ public class JetDefaultModalityModifiersTest extends JetLiteFixture {
|
|||||||
LockBasedStorageManager.NO_LOCKS, new ExceptionTracker(), Predicates.<PsiFile>alwaysTrue(), false, false
|
LockBasedStorageManager.NO_LOCKS, new ExceptionTracker(), Predicates.<PsiFile>alwaysTrue(), false, false
|
||||||
);
|
);
|
||||||
descriptorResolver.resolveMutableClassDescriptor(
|
descriptorResolver.resolveMutableClassDescriptor(
|
||||||
parameters, aClass, classDescriptor, JetTestUtils.DUMMY_TRACE);
|
aClass, classDescriptor, JetTestUtils.DUMMY_TRACE);
|
||||||
return classDescriptor;
|
return classDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user