Invoke "remove unnecessary final" intention in compiler modules
This commit is contained in:
@@ -42,7 +42,7 @@ import static org.jetbrains.kotlin.resolve.BindingContextUtils.variableDescripto
|
||||
|
||||
public class PseudocodeUtil {
|
||||
@NotNull
|
||||
public static Pseudocode generatePseudocode(@NotNull KtDeclaration declaration, @NotNull final BindingContext bindingContext) {
|
||||
public static Pseudocode generatePseudocode(@NotNull KtDeclaration declaration, @NotNull BindingContext bindingContext) {
|
||||
BindingTrace mockTrace = new BindingTrace() {
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
@@ -153,11 +153,11 @@ public class CheckerTestUtil {
|
||||
private static List<ActualDiagnostic> getDebugInfoDiagnostics(
|
||||
@NotNull PsiElement root,
|
||||
@NotNull BindingContext bindingContext,
|
||||
final boolean markDynamicCalls,
|
||||
@Nullable final List<DeclarationDescriptor> dynamicCallDescriptors,
|
||||
@Nullable final String platform
|
||||
boolean markDynamicCalls,
|
||||
@Nullable List<DeclarationDescriptor> dynamicCallDescriptors,
|
||||
@Nullable String platform
|
||||
) {
|
||||
final List<ActualDiagnostic> debugAnnotations = new ArrayList<ActualDiagnostic>();
|
||||
List<ActualDiagnostic> debugAnnotations = new ArrayList<ActualDiagnostic>();
|
||||
|
||||
DebugInfoUtil.markDebugAnnotations(root, bindingContext, new DebugInfoUtil.DebugInfoReporter() {
|
||||
@Override
|
||||
@@ -297,7 +297,7 @@ public class CheckerTestUtil {
|
||||
Map<ActualDiagnostic, TextDiagnostic> actualDiagnostics = currentActual.getTextDiagnosticsMap();
|
||||
List<TextDiagnostic> expectedDiagnostics = currentExpected.getDiagnostics();
|
||||
|
||||
for (final TextDiagnostic expectedDiagnostic : expectedDiagnostics) {
|
||||
for (TextDiagnostic expectedDiagnostic : expectedDiagnostics) {
|
||||
Map.Entry<ActualDiagnostic, TextDiagnostic> actualDiagnosticEntry = CollectionsKt.firstOrNull(
|
||||
actualDiagnostics.entrySet(), new Function1<Map.Entry<ActualDiagnostic, TextDiagnostic>, Boolean>() {
|
||||
@Override
|
||||
|
||||
@@ -69,10 +69,10 @@ public class DebugInfoUtil {
|
||||
|
||||
public static void markDebugAnnotations(
|
||||
@NotNull PsiElement root,
|
||||
@NotNull final BindingContext bindingContext,
|
||||
@NotNull final DebugInfoReporter debugInfoReporter
|
||||
@NotNull BindingContext bindingContext,
|
||||
@NotNull DebugInfoReporter debugInfoReporter
|
||||
) {
|
||||
final Map<KtReferenceExpression, DiagnosticFactory<?>> markedWithErrorElements = Maps.newHashMap();
|
||||
Map<KtReferenceExpression, DiagnosticFactory<?>> markedWithErrorElements = Maps.newHashMap();
|
||||
for (Diagnostic diagnostic : bindingContext.getDiagnostics()) {
|
||||
DiagnosticFactory<?> factory = diagnostic.getFactory();
|
||||
if (Errors.UNRESOLVED_REFERENCE_DIAGNOSTICS.contains(diagnostic.getFactory())) {
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.parsing;
|
||||
public abstract class AbstractTokenStreamPredicate implements TokenStreamPredicate {
|
||||
|
||||
@Override
|
||||
public TokenStreamPredicate or(final TokenStreamPredicate other) {
|
||||
public TokenStreamPredicate or(TokenStreamPredicate other) {
|
||||
return new AbstractTokenStreamPredicate() {
|
||||
@Override
|
||||
public boolean matching(boolean topLevel) {
|
||||
|
||||
@@ -64,7 +64,7 @@ public class KotlinParsing extends AbstractKotlinParsing {
|
||||
}
|
||||
|
||||
private static KotlinParsing createForByClause(SemanticWhitespaceAwarePsiBuilder builder) {
|
||||
final SemanticWhitespaceAwarePsiBuilderForByClause builderForByClause = new SemanticWhitespaceAwarePsiBuilderForByClause(builder);
|
||||
SemanticWhitespaceAwarePsiBuilderForByClause builderForByClause = new SemanticWhitespaceAwarePsiBuilderForByClause(builder);
|
||||
KotlinParsing kotlinParsing = new KotlinParsing(builderForByClause);
|
||||
kotlinParsing.myExpressionParsing = new KotlinExpressionParsing(builderForByClause, kotlinParsing) {
|
||||
@Override
|
||||
|
||||
@@ -109,7 +109,7 @@ public class KtPsiUtil {
|
||||
@NotNull
|
||||
public static Set<KtElement> findRootExpressions(@NotNull Collection<KtElement> unreachableElements) {
|
||||
Set<KtElement> rootElements = new HashSet<KtElement>();
|
||||
final Set<KtElement> shadowedElements = new HashSet<KtElement>();
|
||||
Set<KtElement> shadowedElements = new HashSet<KtElement>();
|
||||
KtVisitorVoid shadowAllChildren = new KtVisitorVoid() {
|
||||
@Override
|
||||
public void visitKtElement(@NotNull KtElement element) {
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ public abstract class KtStubElementType<StubT extends StubElement, PsiT extends
|
||||
@NotNull
|
||||
private final ArrayFactory<PsiT> arrayFactory;
|
||||
|
||||
public KtStubElementType(@NotNull @NonNls String debugName, @NotNull final Class<PsiT> psiClass, @NotNull Class<?> stubClass) {
|
||||
public KtStubElementType(@NotNull @NonNls String debugName, @NotNull Class<PsiT> psiClass, @NotNull Class<?> stubClass) {
|
||||
super(debugName, KotlinLanguage.INSTANCE);
|
||||
try {
|
||||
byNodeConstructor = psiClass.getConstructor(ASTNode.class);
|
||||
|
||||
@@ -51,7 +51,7 @@ public class AnalyzingUtils {
|
||||
}
|
||||
|
||||
public static List<PsiErrorElement> getSyntaxErrorRanges(@NotNull PsiElement root) {
|
||||
final List<PsiErrorElement> r = new ArrayList<PsiErrorElement>();
|
||||
List<PsiErrorElement> r = new ArrayList<PsiErrorElement>();
|
||||
root.acceptChildren(new PsiErrorElementVisitor() {
|
||||
@Override
|
||||
public void visitErrorElement(@NotNull PsiErrorElement element) {
|
||||
|
||||
@@ -230,7 +230,7 @@ public class BindingContextUtils {
|
||||
}
|
||||
|
||||
static void addOwnDataTo(
|
||||
@NotNull final BindingTrace trace, @Nullable final TraceEntryFilter filter, boolean commitDiagnostics,
|
||||
@NotNull BindingTrace trace, @Nullable TraceEntryFilter filter, boolean commitDiagnostics,
|
||||
@NotNull MutableSlicedMap map, MutableDiagnosticsWithSuppression diagnostics
|
||||
) {
|
||||
map.forEach(new Function3<WritableSlice, Object, Object, Void>() {
|
||||
|
||||
@@ -140,10 +140,10 @@ public class BodyResolver {
|
||||
}
|
||||
|
||||
public void resolveSecondaryConstructorBody(
|
||||
@NotNull final DataFlowInfo outerDataFlowInfo,
|
||||
@NotNull final BindingTrace trace,
|
||||
@NotNull final KtSecondaryConstructor constructor,
|
||||
@NotNull final ClassConstructorDescriptor descriptor,
|
||||
@NotNull DataFlowInfo outerDataFlowInfo,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull KtSecondaryConstructor constructor,
|
||||
@NotNull ClassConstructorDescriptor descriptor,
|
||||
@NotNull LexicalScope declaringScope
|
||||
) {
|
||||
ForceResolveUtil.forceResolveAllContents(descriptor.getAnnotations());
|
||||
@@ -266,21 +266,21 @@ public class BodyResolver {
|
||||
}
|
||||
|
||||
public void resolveSuperTypeEntryList(
|
||||
@NotNull final DataFlowInfo outerDataFlowInfo,
|
||||
@NotNull DataFlowInfo outerDataFlowInfo,
|
||||
@NotNull KtClassOrObject ktClass,
|
||||
@NotNull final ClassDescriptor descriptor,
|
||||
@Nullable final ConstructorDescriptor primaryConstructor,
|
||||
@NotNull ClassDescriptor descriptor,
|
||||
@Nullable ConstructorDescriptor primaryConstructor,
|
||||
@NotNull LexicalScope scopeForConstructorResolution,
|
||||
@NotNull final LexicalScope scopeForMemberResolution
|
||||
@NotNull LexicalScope scopeForMemberResolution
|
||||
) {
|
||||
final LexicalScope scopeForConstructor =
|
||||
LexicalScope scopeForConstructor =
|
||||
primaryConstructor == null
|
||||
? null
|
||||
: FunctionDescriptorUtil.getFunctionInnerScope(scopeForConstructorResolution, primaryConstructor, trace, overloadChecker);
|
||||
final ExpressionTypingServices typeInferrer = expressionTypingServices; // TODO : flow
|
||||
ExpressionTypingServices typeInferrer = expressionTypingServices; // TODO : flow
|
||||
|
||||
final Map<KtTypeReference, KotlinType> supertypes = Maps.newLinkedHashMap();
|
||||
final ResolvedCall<?>[] primaryConstructorDelegationCall = new ResolvedCall[1];
|
||||
Map<KtTypeReference, KotlinType> supertypes = Maps.newLinkedHashMap();
|
||||
ResolvedCall<?>[] primaryConstructorDelegationCall = new ResolvedCall[1];
|
||||
KtVisitorVoid visitor = new KtVisitorVoid() {
|
||||
private void recordSupertype(KtTypeReference typeReference, KotlinType supertype) {
|
||||
if (supertype == null) return;
|
||||
@@ -633,7 +633,7 @@ public class BodyResolver {
|
||||
|
||||
private static LexicalScope getPrimaryConstructorParametersScope(
|
||||
LexicalScope originalScope,
|
||||
final ConstructorDescriptor unsubstitutedPrimaryConstructor
|
||||
ConstructorDescriptor unsubstitutedPrimaryConstructor
|
||||
) {
|
||||
return new LexicalScopeImpl(originalScope, unsubstitutedPrimaryConstructor, false, null,
|
||||
LexicalScopeKind.DEFAULT_VALUE, LocalRedeclarationChecker.DO_NOTHING.INSTANCE,
|
||||
@@ -736,7 +736,7 @@ public class BodyResolver {
|
||||
}
|
||||
}
|
||||
|
||||
private ObservableBindingTrace createFieldTrackingTrace(final PropertyDescriptor propertyDescriptor) {
|
||||
private ObservableBindingTrace createFieldTrackingTrace(PropertyDescriptor propertyDescriptor) {
|
||||
return new ObservableBindingTrace(trace).addHandler(
|
||||
BindingContext.REFERENCE_TARGET,
|
||||
new ObservableBindingTrace.RecordHandler<KtReferenceExpression, DeclarationDescriptor>() {
|
||||
@@ -847,7 +847,7 @@ public class BodyResolver {
|
||||
if (functionDescriptor instanceof PropertyAccessorDescriptor && functionDescriptor.getExtensionReceiverParameter() == null) {
|
||||
PropertyAccessorDescriptor accessorDescriptor = (PropertyAccessorDescriptor) functionDescriptor;
|
||||
KtProperty property = (KtProperty) function.getParent();
|
||||
final SyntheticFieldDescriptor fieldDescriptor = new SyntheticFieldDescriptor(accessorDescriptor, property);
|
||||
SyntheticFieldDescriptor fieldDescriptor = new SyntheticFieldDescriptor(accessorDescriptor, property);
|
||||
innerScope = new LexicalScopeImpl(innerScope, functionDescriptor, true, null,
|
||||
LexicalScopeKind.PROPERTY_ACCESSOR_BODY,
|
||||
LocalRedeclarationChecker.DO_NOTHING.INSTANCE, new Function1<LexicalScopeImpl.InitializeHandler, Unit>() {
|
||||
@@ -913,7 +913,7 @@ public class BodyResolver {
|
||||
return;
|
||||
}
|
||||
// +1 is a work around against new Queue(0).addLast(...) bug // stepan.koltsov@ 2011-11-21
|
||||
final Queue<DeferredType> queue = new Queue<DeferredType>(deferredTypes.size() + 1);
|
||||
Queue<DeferredType> queue = new Queue<DeferredType>(deferredTypes.size() + 1);
|
||||
trace.addHandler(DEFERRED_TYPE, new ObservableBindingTrace.RecordHandler<Box<DeferredType>, Boolean>() {
|
||||
@Override
|
||||
public void handleRecord(
|
||||
|
||||
@@ -295,9 +295,12 @@ public class DescriptorResolver {
|
||||
|
||||
@NotNull
|
||||
public ValueParameterDescriptorImpl resolveValueParameterDescriptor(
|
||||
@NotNull final LexicalScope scope, @NotNull final FunctionDescriptor owner,
|
||||
@NotNull KtParameter valueParameter, int index,
|
||||
@NotNull final KotlinType type, @NotNull final BindingTrace trace
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull FunctionDescriptor owner,
|
||||
@NotNull KtParameter valueParameter,
|
||||
int index,
|
||||
@NotNull KotlinType type,
|
||||
@NotNull BindingTrace trace
|
||||
) {
|
||||
KotlinType varargElementType = null;
|
||||
KotlinType variableType = type;
|
||||
@@ -323,7 +326,7 @@ public class DescriptorResolver {
|
||||
}
|
||||
}
|
||||
|
||||
final KtDestructuringDeclaration destructuringDeclaration = valueParameter.getDestructuringDeclaration();
|
||||
KtDestructuringDeclaration destructuringDeclaration = valueParameter.getDestructuringDeclaration();
|
||||
|
||||
Function0<List<VariableDescriptor>> destructuringVariables;
|
||||
if (destructuringDeclaration != null) {
|
||||
@@ -436,11 +439,11 @@ public class DescriptorResolver {
|
||||
}
|
||||
|
||||
private TypeParameterDescriptorImpl resolveTypeParameterForDescriptor(
|
||||
final DeclarationDescriptor containingDescriptor,
|
||||
DeclarationDescriptor containingDescriptor,
|
||||
LexicalScope scopeForAnnotationsResolve,
|
||||
final KtTypeParameter typeParameter,
|
||||
KtTypeParameter typeParameter,
|
||||
int index,
|
||||
final BindingTrace trace
|
||||
BindingTrace trace
|
||||
) {
|
||||
if (typeParameter.getVariance() != Variance.INVARIANT) {
|
||||
trace.report(VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED.on(typeParameter));
|
||||
@@ -701,7 +704,7 @@ public class DescriptorResolver {
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull KtTypeAlias typeAlias,
|
||||
@NotNull final BindingTrace trace
|
||||
@NotNull BindingTrace trace
|
||||
) {
|
||||
if (!(containingDeclaration instanceof PackageFragmentDescriptor)) {
|
||||
trace.report(TOPLEVEL_TYPEALIASES_ONLY.on(typeAlias));
|
||||
@@ -711,13 +714,13 @@ public class DescriptorResolver {
|
||||
Visibility visibility = resolveVisibilityFromModifiers(typeAlias, getDefaultVisibility(typeAlias, containingDeclaration));
|
||||
|
||||
Annotations allAnnotations = annotationResolver.resolveAnnotationsWithArguments(scope, modifierList, trace);
|
||||
final Name name = KtPsiUtil.safeName(typeAlias.getName());
|
||||
Name name = KtPsiUtil.safeName(typeAlias.getName());
|
||||
SourceElement sourceElement = KotlinSourceElementKt.toSourceElement(typeAlias);
|
||||
final LazyTypeAliasDescriptor typeAliasDescriptor = LazyTypeAliasDescriptor.create(
|
||||
LazyTypeAliasDescriptor typeAliasDescriptor = LazyTypeAliasDescriptor.create(
|
||||
storageManager, trace, containingDeclaration, allAnnotations, name, sourceElement, visibility);
|
||||
|
||||
List<TypeParameterDescriptorImpl> typeParameterDescriptors;
|
||||
final LexicalScope scopeWithTypeParameters;
|
||||
LexicalScope scopeWithTypeParameters;
|
||||
{
|
||||
List<KtTypeParameter> typeParameters = typeAlias.getTypeParameters();
|
||||
if (typeParameters.isEmpty()) {
|
||||
@@ -737,7 +740,7 @@ public class DescriptorResolver {
|
||||
}
|
||||
}
|
||||
|
||||
final KtTypeReference typeReference = typeAlias.getTypeReference();
|
||||
KtTypeReference typeReference = typeAlias.getTypeReference();
|
||||
if (typeReference == null) {
|
||||
typeAliasDescriptor.initialize(
|
||||
typeParameterDescriptors,
|
||||
@@ -797,7 +800,7 @@ public class DescriptorResolver {
|
||||
@NotNull LexicalScope scopeForDeclarationResolution,
|
||||
@NotNull LexicalScope scopeForInitializerResolution,
|
||||
@NotNull KtProperty property,
|
||||
@NotNull final BindingTrace trace,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull DataFlowInfo dataFlowInfo
|
||||
) {
|
||||
KtModifierList modifierList = property.getModifierList();
|
||||
@@ -810,7 +813,7 @@ public class DescriptorResolver {
|
||||
trace.getBindingContext(), containingDeclaration)
|
||||
: Modality.FINAL;
|
||||
|
||||
final AnnotationSplitter.PropertyWrapper wrapper = new AnnotationSplitter.PropertyWrapper(property);
|
||||
AnnotationSplitter.PropertyWrapper wrapper = new AnnotationSplitter.PropertyWrapper(property);
|
||||
|
||||
Annotations allAnnotations = annotationResolver.resolveAnnotationsWithoutArguments(scopeForDeclarationResolution, modifierList, trace);
|
||||
AnnotationSplitter annotationSplitter =
|
||||
@@ -1108,11 +1111,11 @@ public class DescriptorResolver {
|
||||
|
||||
@NotNull
|
||||
/*package*/ KotlinType inferReturnTypeFromExpressionBody(
|
||||
@NotNull final BindingTrace trace,
|
||||
@NotNull final LexicalScope scope,
|
||||
@NotNull final DataFlowInfo dataFlowInfo,
|
||||
@NotNull final KtDeclarationWithBody function,
|
||||
@NotNull final FunctionDescriptor functionDescriptor
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull DataFlowInfo dataFlowInfo,
|
||||
@NotNull KtDeclarationWithBody function,
|
||||
@NotNull FunctionDescriptor functionDescriptor
|
||||
) {
|
||||
return wrappedTypeFactory.createRecursionIntolerantDeferredType(trace, new Function0<KotlinType>() {
|
||||
@Override
|
||||
@@ -1132,7 +1135,8 @@ public class DescriptorResolver {
|
||||
@NotNull ClassDescriptor classDescriptor,
|
||||
@NotNull ValueParameterDescriptor valueParameter,
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull KtParameter parameter, final BindingTrace trace
|
||||
@NotNull KtParameter parameter,
|
||||
BindingTrace trace
|
||||
) {
|
||||
KotlinType type = resolveParameterType(scope, parameter, trace);
|
||||
Name name = parameter.getNameAsSafeName();
|
||||
@@ -1145,7 +1149,7 @@ public class DescriptorResolver {
|
||||
}
|
||||
}
|
||||
|
||||
final AnnotationSplitter.PropertyWrapper propertyWrapper = new AnnotationSplitter.PropertyWrapper(parameter);
|
||||
AnnotationSplitter.PropertyWrapper propertyWrapper = new AnnotationSplitter.PropertyWrapper(parameter);
|
||||
Annotations allAnnotations = annotationResolver.resolveAnnotationsWithoutArguments(scope, parameter.getModifierList(), trace);
|
||||
AnnotationSplitter annotationSplitter =
|
||||
new AnnotationSplitter(storageManager, allAnnotations, new Function0<Set<AnnotationUseSiteTarget>>() {
|
||||
|
||||
@@ -63,7 +63,7 @@ public class FunctionDescriptorUtil {
|
||||
@NotNull
|
||||
public static LexicalScope getFunctionInnerScope(
|
||||
@NotNull LexicalScope outerScope,
|
||||
@NotNull final FunctionDescriptor descriptor,
|
||||
@NotNull FunctionDescriptor descriptor,
|
||||
@NotNull LocalRedeclarationChecker redeclarationChecker
|
||||
) {
|
||||
ReceiverParameterDescriptor receiver = descriptor.getExtensionReceiverParameter();
|
||||
|
||||
@@ -176,10 +176,10 @@ public class CallResolver {
|
||||
|
||||
@NotNull
|
||||
private <D extends CallableDescriptor> OverloadResolutionResults<D> computeTasksAndResolveCall(
|
||||
@NotNull final BasicCallResolutionContext context,
|
||||
@NotNull final Name name,
|
||||
@NotNull final TracingStrategy tracing,
|
||||
@NotNull final NewResolutionOldInference.ResolutionKind<D> kind
|
||||
@NotNull BasicCallResolutionContext context,
|
||||
@NotNull Name name,
|
||||
@NotNull TracingStrategy tracing,
|
||||
@NotNull NewResolutionOldInference.ResolutionKind<D> kind
|
||||
) {
|
||||
return callResolvePerfCounter.time(new Function0<OverloadResolutionResults<D>>() {
|
||||
@Override
|
||||
@@ -204,9 +204,9 @@ public class CallResolver {
|
||||
|
||||
@NotNull
|
||||
private <D extends CallableDescriptor> OverloadResolutionResults<D> computeTasksFromCandidatesAndResolvedCall(
|
||||
@NotNull final BasicCallResolutionContext context,
|
||||
@NotNull final Collection<ResolutionCandidate<D>> candidates,
|
||||
@NotNull final TracingStrategy tracing
|
||||
@NotNull BasicCallResolutionContext context,
|
||||
@NotNull Collection<ResolutionCandidate<D>> candidates,
|
||||
@NotNull TracingStrategy tracing
|
||||
) {
|
||||
return callResolvePerfCounter.time(new Function0<OverloadResolutionResults<D>>() {
|
||||
@Override
|
||||
@@ -492,11 +492,11 @@ public class CallResolver {
|
||||
}
|
||||
|
||||
public OverloadResolutionResults<FunctionDescriptor> resolveCallWithKnownCandidate(
|
||||
@NotNull final Call call,
|
||||
@NotNull final TracingStrategy tracing,
|
||||
@NotNull final ResolutionContext<?> context,
|
||||
@NotNull final ResolutionCandidate<FunctionDescriptor> candidate,
|
||||
@Nullable final MutableDataFlowInfoForArguments dataFlowInfoForArguments
|
||||
@NotNull Call call,
|
||||
@NotNull TracingStrategy tracing,
|
||||
@NotNull ResolutionContext<?> context,
|
||||
@NotNull ResolutionCandidate<FunctionDescriptor> candidate,
|
||||
@Nullable MutableDataFlowInfoForArguments dataFlowInfoForArguments
|
||||
) {
|
||||
return callResolvePerfCounter.time(new Function0<OverloadResolutionResults<FunctionDescriptor>>() {
|
||||
@Override
|
||||
|
||||
@@ -299,7 +299,7 @@ public class CallMaker {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Call makeConstructorCallForEnumEntryWithoutInitializer(@NotNull final KtSuperTypeCallEntry callElement) {
|
||||
public static Call makeConstructorCallForEnumEntryWithoutInitializer(@NotNull KtSuperTypeCallEntry callElement) {
|
||||
return new Call() {
|
||||
@Nullable
|
||||
@Override
|
||||
@@ -370,7 +370,7 @@ public class CallMaker {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Call makeCall(@Nullable final Receiver explicitReceiver, @Nullable final ASTNode callOperationNode, @NotNull final KtCallElement callElement) {
|
||||
public static Call makeCall(@Nullable Receiver explicitReceiver, @Nullable ASTNode callOperationNode, @NotNull KtCallElement callElement) {
|
||||
return new Call() {
|
||||
@Override
|
||||
public ASTNode getCallOperationNode() {
|
||||
|
||||
+1
-1
@@ -114,7 +114,7 @@ public class LazyDeclarationResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private DeclarationDescriptor resolveToDescriptor(@NotNull KtDeclaration declaration, final boolean track) {
|
||||
private DeclarationDescriptor resolveToDescriptor(@NotNull KtDeclaration declaration, boolean track) {
|
||||
DeclarationDescriptor result = declaration.accept(new KtVisitor<DeclarationDescriptor, Void>() {
|
||||
@NotNull
|
||||
private LookupLocation lookupLocationFor(@NotNull KtDeclaration declaration, boolean isTopLevel) {
|
||||
|
||||
@@ -261,7 +261,7 @@ public class ResolveSession implements KotlinCodeAnalyzer, LazyClassContext {
|
||||
@Override
|
||||
@NotNull
|
||||
@ReadOnly
|
||||
public Collection<ClassifierDescriptor> getTopLevelClassifierDescriptors(@NotNull FqName fqName, @NotNull final LookupLocation location) {
|
||||
public Collection<ClassifierDescriptor> getTopLevelClassifierDescriptors(@NotNull FqName fqName, @NotNull LookupLocation location) {
|
||||
if (fqName.isRoot()) return Collections.emptyList();
|
||||
|
||||
PackageMemberDeclarationProvider provider = declarationProviderFactory.getPackageMemberDeclarationProvider(fqName.parent());
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ public class FileBasedDeclarationProviderFactory extends AbstractDeclarationProv
|
||||
private final StorageManager storageManager;
|
||||
private final NotNullLazyValue<Index> index;
|
||||
|
||||
public FileBasedDeclarationProviderFactory(@NotNull StorageManager storageManager, @NotNull final Collection<KtFile> files) {
|
||||
public FileBasedDeclarationProviderFactory(@NotNull StorageManager storageManager, @NotNull Collection<KtFile> files) {
|
||||
super(storageManager);
|
||||
this.storageManager = storageManager;
|
||||
this.index = storageManager.createLazyValue(new Function0<Index>() {
|
||||
|
||||
+5
-5
@@ -110,10 +110,10 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
private final NotNullLazyValue<Collection<ClassDescriptor>> sealedSubclasses;
|
||||
|
||||
public LazyClassDescriptor(
|
||||
@NotNull final LazyClassContext c,
|
||||
@NotNull LazyClassContext c,
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull Name name,
|
||||
@NotNull final KtClassLikeInfo classLikeInfo,
|
||||
@NotNull KtClassLikeInfo classLikeInfo,
|
||||
boolean isExternal
|
||||
) {
|
||||
super(c.getStorageManager(), containingDeclaration, name,
|
||||
@@ -140,7 +140,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
|
||||
this.isCompanionObject = classLikeInfo instanceof KtObjectInfo && ((KtObjectInfo) classLikeInfo).isCompanionObject();
|
||||
|
||||
final KtModifierList modifierList = classLikeInfo.getModifierList();
|
||||
KtModifierList modifierList = classLikeInfo.getModifierList();
|
||||
if (kind.isSingleton()) {
|
||||
this.modality = storageManager.createLazyValue(new Function0<Modality>() {
|
||||
@Override
|
||||
@@ -150,7 +150,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
});
|
||||
}
|
||||
else {
|
||||
final Modality defaultModality = kind == ClassKind.INTERFACE ? Modality.ABSTRACT : Modality.FINAL;
|
||||
Modality defaultModality = kind == ClassKind.INTERFACE ? Modality.ABSTRACT : Modality.FINAL;
|
||||
this.modality = storageManager.createLazyValue(new Function0<Modality>() {
|
||||
@Override
|
||||
public Modality invoke() {
|
||||
@@ -431,7 +431,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
@NotNull
|
||||
@ReadOnly
|
||||
public List<ClassDescriptor> getDescriptorsForExtraCompanionObjects() {
|
||||
final KtObjectDeclaration allowedCompanionObject = getCompanionObjectIfAllowed();
|
||||
KtObjectDeclaration allowedCompanionObject = getCompanionObjectIfAllowed();
|
||||
|
||||
return CollectionsKt.map(
|
||||
CollectionsKt.filter(
|
||||
|
||||
@@ -75,7 +75,7 @@ public class BoundsSubstitutor {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<TypeParameterDescriptor> topologicallySortTypeParameters(@NotNull final List<TypeParameterDescriptor> typeParameters) {
|
||||
private static List<TypeParameterDescriptor> topologicallySortTypeParameters(@NotNull List<TypeParameterDescriptor> typeParameters) {
|
||||
// In the end, we want every parameter to have no references to those after it in the list
|
||||
// This gives us the reversed order: the one that refers to everybody else comes first
|
||||
List<TypeParameterDescriptor> topOrder = DFS.topologicalOrder(
|
||||
@@ -98,7 +98,7 @@ public class BoundsSubstitutor {
|
||||
@NotNull
|
||||
private static List<TypeParameterDescriptor> getTypeParametersFromUpperBounds(
|
||||
@NotNull TypeParameterDescriptor current,
|
||||
@NotNull final List<TypeParameterDescriptor> typeParameters
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters
|
||||
) {
|
||||
return DFS.dfs(
|
||||
current.getUpperBounds(),
|
||||
|
||||
@@ -67,7 +67,7 @@ public class CommonSupertypes {
|
||||
return max;
|
||||
}
|
||||
|
||||
private static int depth(@NotNull final KotlinType type) {
|
||||
private static int depth(@NotNull KotlinType type) {
|
||||
return 1 + maxDepth(CollectionsKt.map(type.getArguments(), new Function1<TypeProjection, KotlinType>() {
|
||||
@Override
|
||||
public KotlinType invoke(TypeProjection projection) {
|
||||
@@ -331,8 +331,8 @@ public class CommonSupertypes {
|
||||
@NotNull
|
||||
public static List<TypeConstructor> topologicallySortSuperclassesAndRecordAllInstances(
|
||||
@NotNull SimpleType type,
|
||||
@NotNull final Map<TypeConstructor, Set<SimpleType>> constructorToAllInstances,
|
||||
@NotNull final Set<TypeConstructor> visited
|
||||
@NotNull Map<TypeConstructor, Set<SimpleType>> constructorToAllInstances,
|
||||
@NotNull Set<TypeConstructor> visited
|
||||
) {
|
||||
return DFS.dfs(
|
||||
Collections.singletonList(type),
|
||||
|
||||
@@ -173,7 +173,7 @@ public class TypeIntersector {
|
||||
|
||||
private static boolean unify(KotlinType withParameters, KotlinType expected) {
|
||||
// T -> how T is used
|
||||
final Map<TypeParameterDescriptor, Variance> parameters = new HashMap<TypeParameterDescriptor, Variance>();
|
||||
Map<TypeParameterDescriptor, Variance> parameters = new HashMap<TypeParameterDescriptor, Variance>();
|
||||
Function1<TypeParameterUsage, Unit> processor = new Function1<TypeParameterUsage, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(TypeParameterUsage parameterUsage) {
|
||||
|
||||
+10
-9
@@ -714,10 +714,10 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
|
||||
@Override
|
||||
public KotlinTypeInfo visitObjectLiteralExpression(
|
||||
@NotNull final KtObjectLiteralExpression expression,
|
||||
final ExpressionTypingContext context
|
||||
@NotNull KtObjectLiteralExpression expression,
|
||||
ExpressionTypingContext context
|
||||
) {
|
||||
final KotlinType[] result = new KotlinType[1];
|
||||
KotlinType[] result = new KotlinType[1];
|
||||
TemporaryBindingTrace temporaryTrace = TemporaryBindingTrace.create(context.trace,
|
||||
"trace to resolve object literal expression", expression);
|
||||
ObservableBindingTrace.RecordHandler<PsiElement, ClassDescriptor> handler =
|
||||
@@ -727,7 +727,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
public void handleRecord(
|
||||
WritableSlice<PsiElement, ClassDescriptor> slice,
|
||||
PsiElement declaration,
|
||||
final ClassDescriptor descriptor
|
||||
ClassDescriptor descriptor
|
||||
) {
|
||||
if (slice == CLASS && declaration == expression.getObjectDeclaration()) {
|
||||
KotlinType defaultType = components.wrappedTypeFactory.createRecursionIntolerantDeferredType(
|
||||
@@ -1160,8 +1160,8 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
KtBinaryExpression expression,
|
||||
ExpressionTypingContext context,
|
||||
KtSimpleNameExpression operationSign,
|
||||
final KtExpression left,
|
||||
final KtExpression right
|
||||
KtExpression left,
|
||||
KtExpression right
|
||||
) {
|
||||
if (right == null || left == null) {
|
||||
ExpressionTypingUtils.getTypeInfoOrNullType(right, context, facade);
|
||||
@@ -1445,7 +1445,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void ensureNonemptyIntersectionOfOperandTypes(KtBinaryExpression expression, final ExpressionTypingContext context) {
|
||||
private void ensureNonemptyIntersectionOfOperandTypes(KtBinaryExpression expression, ExpressionTypingContext context) {
|
||||
KtExpression left = expression.getLeft();
|
||||
if (left == null) return;
|
||||
|
||||
@@ -1580,8 +1580,9 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
@NotNull KtStringTemplateExpression expression,
|
||||
ExpressionTypingContext contextWithExpectedType
|
||||
) {
|
||||
final ExpressionTypingContext context = contextWithExpectedType.replaceExpectedType(NO_EXPECTED_TYPE)
|
||||
.replaceContextDependency(INDEPENDENT);
|
||||
ExpressionTypingContext context = contextWithExpectedType
|
||||
.replaceExpectedType(NO_EXPECTED_TYPE)
|
||||
.replaceContextDependency(INDEPENDENT);
|
||||
|
||||
checkLiteralPrefixAndSuffix(expression, context);
|
||||
|
||||
|
||||
+7
-8
@@ -191,7 +191,7 @@ public class ControlStructureTypingUtils {
|
||||
|
||||
private static MutableDataFlowInfoForArguments createIndependentDataFlowInfoForArgumentsForCall(
|
||||
@NotNull DataFlowInfo initialDataFlowInfo,
|
||||
final Map<ValueArgument, DataFlowInfo> dataFlowInfoForArgumentsMap
|
||||
Map<ValueArgument, DataFlowInfo> dataFlowInfoForArgumentsMap
|
||||
) {
|
||||
return new MutableDataFlowInfoForArguments(initialDataFlowInfo) {
|
||||
|
||||
@@ -235,11 +235,11 @@ public class ControlStructureTypingUtils {
|
||||
}
|
||||
|
||||
/*package*/ static Call createCallForSpecialConstruction(
|
||||
@NotNull final KtExpression expression,
|
||||
@NotNull final KtExpression calleeExpression,
|
||||
@NotNull KtExpression expression,
|
||||
@NotNull KtExpression calleeExpression,
|
||||
@NotNull List<? extends KtExpression> arguments
|
||||
) {
|
||||
final List<ValueArgument> valueArguments = Lists.newArrayList();
|
||||
List<ValueArgument> valueArguments = Lists.newArrayList();
|
||||
for (KtExpression argument : arguments) {
|
||||
valueArguments.add(CallMaker.makeValueArgument(argument));
|
||||
}
|
||||
@@ -314,9 +314,9 @@ public class ControlStructureTypingUtils {
|
||||
|
||||
@NotNull
|
||||
private TracingStrategy createTracingForSpecialConstruction(
|
||||
final @NotNull Call call,
|
||||
@NotNull Call call,
|
||||
@NotNull String constructionName,
|
||||
final @NotNull ExpressionTypingContext context
|
||||
@NotNull ExpressionTypingContext context
|
||||
) {
|
||||
class CheckTypeContext {
|
||||
public BindingTrace trace;
|
||||
@@ -333,8 +333,7 @@ public class ControlStructureTypingUtils {
|
||||
}
|
||||
}
|
||||
|
||||
final KtVisitor<Boolean, CheckTypeContext> checkTypeVisitor = new KtVisitor<Boolean, CheckTypeContext>() {
|
||||
|
||||
KtVisitor<Boolean, CheckTypeContext> checkTypeVisitor = new KtVisitor<Boolean, CheckTypeContext>() {
|
||||
private boolean checkExpressionType(@NotNull KtExpression expression, CheckTypeContext c) {
|
||||
KotlinTypeInfo typeInfo = BindingContextUtils.getRecordedTypeInfo(expression, c.trace.getBindingContext());
|
||||
if (typeInfo == null) return false;
|
||||
|
||||
+2
-2
@@ -269,8 +269,8 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
.replaceDataFlowInfo(dataFlowInfo);
|
||||
}
|
||||
|
||||
private boolean containsJumpOutOfLoop(@NotNull final KtExpression expression, final ExpressionTypingContext context) {
|
||||
final boolean[] result = new boolean[1];
|
||||
private boolean containsJumpOutOfLoop(@NotNull KtExpression expression, ExpressionTypingContext context) {
|
||||
boolean[] result = new boolean[1];
|
||||
result[0] = false;
|
||||
//todo breaks in inline function literals
|
||||
expression.accept(new KtTreeVisitor<List<KtLoopExpression>>() {
|
||||
|
||||
@@ -119,12 +119,12 @@ public class DataFlowAnalyzer {
|
||||
|
||||
@NotNull
|
||||
public DataFlowInfo extractDataFlowInfoFromCondition(
|
||||
@Nullable final KtExpression condition,
|
||||
final boolean conditionValue,
|
||||
final ExpressionTypingContext context
|
||||
@Nullable KtExpression condition,
|
||||
boolean conditionValue,
|
||||
ExpressionTypingContext context
|
||||
) {
|
||||
if (condition == null) return context.dataFlowInfo;
|
||||
final Ref<DataFlowInfo> result = new Ref<DataFlowInfo>(null);
|
||||
Ref<DataFlowInfo> result = new Ref<DataFlowInfo>(null);
|
||||
condition.accept(new KtVisitorVoid() {
|
||||
@Override
|
||||
public void visitIsExpression(@NotNull KtIsExpression expression) {
|
||||
|
||||
+2
-2
@@ -99,12 +99,12 @@ public class ExpressionTypingServices {
|
||||
@NotNull
|
||||
public KotlinTypeInfo getTypeInfo(
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull final KtExpression expression,
|
||||
@NotNull KtExpression expression,
|
||||
@NotNull KotlinType expectedType,
|
||||
@NotNull DataFlowInfo dataFlowInfo,
|
||||
@NotNull BindingTrace trace,
|
||||
boolean isStatement,
|
||||
@NotNull final KtExpression contextExpression,
|
||||
@NotNull KtExpression contextExpression,
|
||||
@NotNull ContextDependency contextDependency
|
||||
) {
|
||||
ExpressionTypingContext context = ExpressionTypingContext.newContext(
|
||||
|
||||
+2
-2
@@ -125,8 +125,8 @@ public class ExpressionTypingUtils {
|
||||
|
||||
public static ObservableBindingTrace makeTraceInterceptingTypeMismatch(
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull final KtElement expressionToWatch,
|
||||
@NotNull final boolean[] mismatchFound
|
||||
@NotNull KtElement expressionToWatch,
|
||||
@NotNull boolean[] mismatchFound
|
||||
) {
|
||||
return new ObservableBindingTrace(trace) {
|
||||
|
||||
|
||||
+1
-1
@@ -168,7 +168,7 @@ public abstract class ExpressionTypingVisitorDispatcher extends KtVisitor<Kotlin
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private KotlinTypeInfo getTypeInfo(@NotNull final KtExpression expression, final ExpressionTypingContext context, final KtVisitor<KotlinTypeInfo, ExpressionTypingContext> visitor) {
|
||||
private KotlinTypeInfo getTypeInfo(@NotNull KtExpression expression, ExpressionTypingContext context, KtVisitor<KotlinTypeInfo, ExpressionTypingContext> visitor) {
|
||||
return typeInfoPerfCounter.time(new Function0<KotlinTypeInfo>() {
|
||||
@Override
|
||||
public KotlinTypeInfo invoke() {
|
||||
|
||||
@@ -53,7 +53,7 @@ public class TrackingSlicedMap extends SlicedMapImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEach(@NotNull final Function3<WritableSlice, Object, Object, Void> f) {
|
||||
public void forEach(@NotNull Function3<WritableSlice, Object, Object, Void> f) {
|
||||
super.forEach(new Function3<WritableSlice, Object, Object, Void>() {
|
||||
@Override
|
||||
public Void invoke(WritableSlice slice, Object key, Object value) {
|
||||
|
||||
Reference in New Issue
Block a user