Remove redundant type arguments for Java 8+ in compiler modules

This commit is contained in:
Alexander Udalov
2017-04-01 02:39:10 +03:00
parent d440f07111
commit 78e278ec4c
56 changed files with 104 additions and 128 deletions
@@ -387,10 +387,7 @@ public class CheckerTestUtil {
}
public static StringBuffer addDiagnosticMarkersToText(@NotNull PsiFile psiFile, @NotNull Collection<ActualDiagnostic> diagnostics) {
return addDiagnosticMarkersToText(
psiFile, diagnostics, Collections.<ActualDiagnostic, TextDiagnostic>emptyMap(),
PsiElement::getText
);
return addDiagnosticMarkersToText(psiFile, diagnostics, Collections.emptyMap(), PsiElement::getText);
}
public static StringBuffer addDiagnosticMarkersToText(
@@ -59,13 +59,13 @@ public class CompilerConfiguration {
@NotNull
public <T> List<T> getList(@NotNull CompilerConfigurationKey<List<T>> key) {
List<T> data = get(key);
return data == null ? Collections.<T>emptyList() : data;
return data == null ? Collections.emptyList() : data;
}
@NotNull
public <K, V> Map<K, V> getMap(@NotNull CompilerConfigurationKey<Map<K, V>> key) {
Map<K, V> data = get(key);
return data == null ? Collections.<K, V>emptyMap() : data;
return data == null ? Collections.emptyMap() : data;
}
public <T> void put(@NotNull CompilerConfigurationKey<T> key, @NotNull T value) {
@@ -68,7 +68,7 @@ public class KtCallExpression extends KtExpressionImpl implements KtCallElement,
@NotNull
public List<KtValueArgument> getValueArguments() {
KtValueArgumentList list = getValueArgumentList();
List<KtValueArgument> valueArgumentsInParentheses = list != null ? list.getArguments() : Collections.<KtValueArgument>emptyList();
List<KtValueArgument> valueArgumentsInParentheses = list != null ? list.getArguments() : Collections.emptyList();
List<KtLambdaArgument> functionLiteralArguments = getLambdaArguments();
if (functionLiteralArguments.isEmpty()) {
return valueArgumentsInParentheses;
@@ -83,6 +83,6 @@ public class KtCallExpression extends KtExpressionImpl implements KtCallElement,
@NotNull
public List<KtTypeProjection> getTypeArguments() {
KtTypeArgumentList list = getTypeArgumentList();
return list != null ? list.getArguments() : Collections.<KtTypeProjection>emptyList();
return list != null ? list.getArguments() : Collections.emptyList();
}
}
@@ -108,7 +108,7 @@ public class KtFile extends PsiFileBase implements KtDeclarationContainer, KtAnn
@NotNull
public List<KtImportDirective> getImportDirectives() {
KtImportList importList = getImportList();
return importList != null ? importList.getImports() : Collections.<KtImportDirective>emptyList();
return importList != null ? importList.getImports() : Collections.emptyList();
}
@Nullable
@@ -41,7 +41,7 @@ public abstract class KtFunctionNotStubbed extends KtTypeParameterListOwnerNotSt
@NotNull
public List<KtParameter> getValueParameters() {
KtParameterList list = getValueParameterList();
return list != null ? list.getParameters() : Collections.<KtParameter>emptyList();
return list != null ? list.getParameters() : Collections.emptyList();
}
@Override
@@ -72,7 +72,7 @@ public class KtFunctionType extends KtElementImplStub<KotlinPlaceHolderStub<KtFu
@NotNull
public List<KtParameter> getParameters() {
KtParameterList list = getParameterList();
return list != null ? list.getParameters() : Collections.<KtParameter>emptyList();
return list != null ? list.getParameters() : Collections.emptyList();
}
@Nullable
@@ -115,7 +115,7 @@ public class KtNamedFunction extends KtTypeParameterListOwnerStub<KotlinFunction
@NotNull
public List<KtParameter> getValueParameters() {
KtParameterList list = getValueParameterList();
return list != null ? list.getParameters() : Collections.<KtParameter>emptyList();
return list != null ? list.getParameters() : Collections.emptyList();
}
@Override
@@ -44,7 +44,7 @@ public class KtNullableType extends KtElementImplStub<KotlinPlaceHolderStub<KtNu
@Override
public List<KtTypeReference> getTypeArgumentsAsTypes() {
KtTypeElement innerType = getInnerType();
return innerType == null ? Collections.<KtTypeReference>emptyList() : innerType.getTypeArgumentsAsTypes();
return innerType == null ? Collections.emptyList() : innerType.getTypeArgumentsAsTypes();
}
@Override
@@ -66,7 +66,6 @@ public class KtNullableType extends KtElementImplStub<KotlinPlaceHolderStub<KtNu
@NotNull
public List<KtAnnotationEntry> getAnnotationEntries() {
KtModifierList modifierList = getModifierList();
return modifierList != null ? modifierList.getAnnotationEntries()
: Collections.<KtAnnotationEntry>emptyList();
return modifierList != null ? modifierList.getAnnotationEntries() : Collections.emptyList();
}
}
@@ -51,7 +51,7 @@ public class KtUserType extends KtElementImplStub<KotlinUserTypeStub> implements
public List<KtTypeProjection> getTypeArguments() {
// TODO: empty elements in PSI
KtTypeArgumentList typeArgumentList = getTypeArgumentList();
return typeArgumentList == null ? Collections.<KtTypeProjection>emptyList() : typeArgumentList.getArguments();
return typeArgumentList == null ? Collections.emptyList() : typeArgumentList.getArguments();
}
@NotNull
@@ -125,8 +125,8 @@ public class DescriptorResolver {
BindingTrace trace
) {
List<KotlinType> supertypes = Lists.newArrayList();
List<KtSuperTypeListEntry> delegationSpecifiers = correspondingClassOrObject == null ? Collections.<KtSuperTypeListEntry>emptyList() :
correspondingClassOrObject.getSuperTypeListEntries();
List<KtSuperTypeListEntry> delegationSpecifiers =
correspondingClassOrObject == null ? Collections.emptyList() : correspondingClassOrObject.getSuperTypeListEntries();
Collection<KotlinType> declaredSupertypes = resolveSuperTypeListEntries(
scope,
delegationSpecifiers,
@@ -1151,8 +1151,9 @@ public class DescriptorResolver {
false
);
propertyWrapper.setDescriptor(propertyDescriptor);
propertyDescriptor.setType(type, Collections.<TypeParameterDescriptor>emptyList(),
getDispatchReceiverParameterIfNeeded(classDescriptor), (ReceiverParameterDescriptor) null);
propertyDescriptor.setType(
type, Collections.emptyList(), getDispatchReceiverParameterIfNeeded(classDescriptor), (ReceiverParameterDescriptor) null
);
Annotations setterAnnotations = annotationSplitter.getAnnotationsForTarget(PROPERTY_SETTER);
Annotations getterAnnotations = new CompositeAnnotations(CollectionsKt.listOf(
@@ -276,11 +276,11 @@ public class ArgumentTypeResolver {
}
if (expectedTypeIsUnknown) {
return functionPlaceholders.createFunctionPlaceholderType(Collections.<KotlinType>emptyList(), false);
return functionPlaceholders.createFunctionPlaceholderType(Collections.emptyList(), false);
}
return FunctionTypesKt.createFunctionType(
builtIns, Annotations.Companion.getEMPTY(), null, Collections.<KotlinType>emptyList(), null, TypeUtils.DONT_CARE
builtIns, Annotations.Companion.getEMPTY(), null, Collections.emptyList(), null, TypeUtils.DONT_CARE
);
}
@@ -308,10 +308,9 @@ public class ArgumentTypeResolver {
boolean isFunctionLiteral = function instanceof KtFunctionLiteral;
if (function.getValueParameterList() == null && isFunctionLiteral) {
return expectedTypeIsUnknown
? functionPlaceholders
.createFunctionPlaceholderType(Collections.<KotlinType>emptyList(), /* hasDeclaredArguments = */ false)
? functionPlaceholders.createFunctionPlaceholderType(Collections.emptyList(), /* hasDeclaredArguments = */ false)
: FunctionTypesKt.createFunctionType(
builtIns, Annotations.Companion.getEMPTY(), null, Collections.<KotlinType>emptyList(), null, DONT_CARE
builtIns, Annotations.Companion.getEMPTY(), null, Collections.emptyList(), null, DONT_CARE
);
}
List<KtParameter> valueParameters = function.getValueParameters();
@@ -127,23 +127,17 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements MutableRe
@NotNull
private static Map<ValueParameterDescriptor, ResolvedValueArgument> createValueArgumentsMap(CallableDescriptor descriptor) {
return descriptor.getValueParameters().isEmpty()
? Collections.<ValueParameterDescriptor, ResolvedValueArgument>emptyMap()
: Maps.<ValueParameterDescriptor, ResolvedValueArgument>newLinkedHashMap();
return descriptor.getValueParameters().isEmpty() ? Collections.emptyMap() : Maps.newLinkedHashMap();
}
@NotNull
private static Map<ValueArgument, ArgumentMatchImpl> createArgumentsToParameterMap(CallableDescriptor descriptor) {
return descriptor.getValueParameters().isEmpty()
? Collections.<ValueArgument, ArgumentMatchImpl>emptyMap()
: Maps.<ValueArgument, ArgumentMatchImpl>newHashMap();
return descriptor.getValueParameters().isEmpty() ? Collections.emptyMap() : Maps.newHashMap();
}
@NotNull
private static Map<TypeParameterDescriptor, KotlinType> createTypeArgumentsMap(CallableDescriptor descriptor) {
return descriptor.getTypeParameters().isEmpty()
? Collections.<TypeParameterDescriptor, KotlinType>emptyMap()
: Maps.<TypeParameterDescriptor, KotlinType>newLinkedHashMap();
return descriptor.getTypeParameters().isEmpty() ? Collections.emptyMap() : Maps.newLinkedHashMap();
}
@Override
@@ -35,7 +35,7 @@ public class OverloadResolutionResultsImpl<D extends CallableDescriptor> impleme
public static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> nameNotFound() {
OverloadResolutionResultsImpl<D> results = new OverloadResolutionResultsImpl<>(
Code.NAME_NOT_FOUND, Collections.<MutableResolvedCall<D>>emptyList());
results.setAllCandidates(Collections.<ResolvedCall<D>>emptyList());
results.setAllCandidates(Collections.emptyList());
return results;
}
@@ -233,7 +233,7 @@ public class CallMaker {
@NotNull
public static Call makeCall(@NotNull ReceiverValue baseAsReceiver, KtUnaryExpression expression) {
return makeCall(expression, baseAsReceiver, null, expression.getOperationReference(), Collections.<ValueArgument>emptyList());
return makeCall(expression, baseAsReceiver, null, expression.getOperationReference(), Collections.emptyList());
}
@NotNull
@@ -277,7 +277,7 @@ public class CallMaker {
@NotNull
public static Call makePropertyCall(@Nullable Receiver explicitReceiver, @Nullable ASTNode callOperationNode, @NotNull KtSimpleNameExpression nameExpression) {
return makeCallWithExpressions(nameExpression, explicitReceiver, callOperationNode, nameExpression, Collections.<KtExpression>emptyList());
return makeCallWithExpressions(nameExpression, explicitReceiver, callOperationNode, nameExpression, Collections.emptyList());
}
@@ -446,6 +446,6 @@ public class CallMaker {
@NotNull
public static Call makeCall(@NotNull KtElement callElement, @NotNull ReceiverValue explicitReceiver) {
return new CallImpl(callElement, explicitReceiver, null, null, Collections.<ValueArgument>emptyList());
return new CallImpl(callElement, explicitReceiver, null, null, Collections.emptyList());
}
}
@@ -32,7 +32,6 @@ import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.types.TypeUtils;
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext;
import java.util.Set;
@@ -40,7 +39,7 @@ import static org.jetbrains.kotlin.diagnostics.Errors.*;
public class CompileTimeConstantChecker {
private static final Set<DiagnosticFactory<?>> errorsThatDependOnExpectedType =
Sets.<DiagnosticFactory<?>>newHashSet(CONSTANT_EXPECTED_TYPE_MISMATCH, NULL_FOR_NONNULL_TYPE);
Sets.newHashSet(CONSTANT_EXPECTED_TYPE_MISMATCH, NULL_FOR_NONNULL_TYPE);
private final KotlinBuiltIns builtIns;
private final BindingTrace trace;
@@ -171,7 +171,7 @@ public class ResolveSession implements KotlinCodeAnalyzer, LazyClassContext {
@NotNull
@Override
public List<PackageFragmentDescriptor> getPackageFragments(@NotNull FqName fqName) {
return ContainerUtil.<PackageFragmentDescriptor>createMaybeSingletonList(getPackageFragment(fqName));
return ContainerUtil.createMaybeSingletonList(getPackageFragment(fqName));
}
@NotNull
@@ -339,7 +339,7 @@ public class ResolveSession implements KotlinCodeAnalyzer, LazyClassContext {
LazyPackageDescriptor rootPackage = getPackageFragment(FqName.ROOT);
assert rootPackage != null : "Root package must be initialized";
return collectAllPackages(Lists.<LazyPackageDescriptor>newArrayList(), rootPackage);
return collectAllPackages(Lists.newArrayList(), rootPackage);
}
@NotNull
@@ -88,7 +88,7 @@ public abstract class KtClassOrObjectInfo<E extends KtClassOrObject> implements
@Override
public List<KtAnnotationEntry> getDanglingAnnotations() {
KtClassBody body = element.getBody();
return body == null ? Collections.<KtAnnotationEntry>emptyList() : body.getDanglingAnnotations();
return body == null ? Collections.emptyList() : body.getDanglingAnnotations();
}
@NotNull
@@ -26,8 +26,7 @@ import org.jetbrains.kotlin.storage.LockBasedStorageManager;
import java.util.Collections;
public interface DeclarationProviderFactory {
DeclarationProviderFactory EMPTY =
new FileBasedDeclarationProviderFactory(LockBasedStorageManager.NO_LOCKS, Collections.<KtFile>emptyList());
DeclarationProviderFactory EMPTY = new FileBasedDeclarationProviderFactory(LockBasedStorageManager.NO_LOCKS, Collections.emptyList());
@NotNull
ClassMemberDeclarationProvider getClassMemberDeclarationProvider(@NotNull KtClassLikeInfo classLikeInfo);
@@ -270,7 +270,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
CallableMemberDescriptor.Kind.SYNTHESIZED, SourceElement.NO_SOURCE
) {
{
initialize(null, null, Collections.<TypeParameterDescriptor>emptyList(), Collections.<ValueParameterDescriptor>emptyList(),
initialize(null, null, Collections.emptyList(), Collections.emptyList(),
null, Modality.FINAL, Visibilities.PRIVATE);
}
@@ -665,13 +665,11 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
KtClassOrObject classOrObject = declarationProvider.getOwnerInfo().getCorrespondingClassOrObject();
if (classOrObject == null) {
return Collections.<KotlinType>singleton(c.getModuleDescriptor().getBuiltIns().getAnyType());
return Collections.singleton(c.getModuleDescriptor().getBuiltIns().getAnyType());
}
List<KotlinType> allSupertypes =
c.getDescriptorResolver()
.resolveSupertypes(getScopeForClassHeaderResolution(), this, classOrObject,
c.getTrace());
c.getDescriptorResolver().resolveSupertypes(getScopeForClassHeaderResolution(), this, classOrObject, c.getTrace());
return new ArrayList<>(CollectionsKt.filter(allSupertypes, VALID_SUPERTYPE));
}
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.resolve.lazy.descriptors;
import kotlin.collections.CollectionsKt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.descriptors.SupertypeLoopChecker;
import org.jetbrains.kotlin.descriptors.impl.AbstractLazyTypeParameterDescriptor;
import org.jetbrains.kotlin.diagnostics.Errors;
import org.jetbrains.kotlin.lexer.KtTokens;
@@ -93,7 +92,7 @@ public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescri
return CollectionsKt.plus(
typeParameter.getExtendsBound() != null
? Collections.singletonList(typeParameter.getExtendsBound())
: Collections.<KtTypeReference>emptyList(),
: Collections.emptyList(),
getUpperBoundsFromWhereClause()
);
}
@@ -136,7 +136,7 @@ public class TypeIntersector {
return KotlinTypeFactory.simpleType(
Annotations.Companion.getEMPTY(),
constructor,
Collections.<TypeProjection>emptyList(),
Collections.emptyList(),
allNullable,
constructor.createScopeForKotlinType()
);
@@ -667,7 +667,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
KtExpression expression
) {
BindingTrace trace = context.trace;
Call call = CallMaker.makeCall(expression, null, null, expression, Collections.<ValueArgument>emptyList());
Call call = CallMaker.makeCall(expression, null, null, expression, Collections.emptyList());
ResolutionCandidate<ReceiverParameterDescriptor> resolutionCandidate =
ResolutionCandidate.create(
call, descriptor, null, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, null);
@@ -118,7 +118,7 @@ public class ControlStructureTypingUtils {
TracingStrategy tracing = createTracingForSpecialConstruction(call, construct.getName(), context);
TypeSubstitutor knownTypeParameterSubstitutor = createKnownTypeParameterSubstitutorForSpecialCall(construct, function, context.expectedType);
ResolutionCandidate<FunctionDescriptor> resolutionCandidate =
ResolutionCandidate.<FunctionDescriptor>create(call, function, knownTypeParameterSubstitutor);
ResolutionCandidate.create(call, function, knownTypeParameterSubstitutor);
OverloadResolutionResults<FunctionDescriptor> results = callResolver.resolveCallWithKnownCandidate(
call, tracing, context, resolutionCandidate, dataFlowInfoForArguments);
assert results.isSingleResult() : "Not single result after resolving one known candidate";
@@ -304,9 +304,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
newOuterLoops.add(loopExpression);
return super.visitLoopExpression(loopExpression, newOuterLoops);
}
}, expression instanceof KtLoopExpression
? Lists.newArrayList((KtLoopExpression) expression)
: Lists.<KtLoopExpression>newArrayList());
}, expression instanceof KtLoopExpression ? Lists.newArrayList((KtLoopExpression) expression) : Lists.newArrayList());
return result[0];
}
@@ -60,7 +60,7 @@ public class ForLoopConventionsChecker {
// Make a fake call loopRange.iterator(), and try to resolve it
OverloadResolutionResults<FunctionDescriptor> iteratorResolutionResults = fakeCallResolver.resolveFakeCall(
context, loopRange, OperatorNameConventions.ITERATOR, loopRangeExpression,
loopRangeExpression, FakeCallKind.ITERATOR, Collections.<KtExpression>emptyList()
loopRangeExpression, FakeCallKind.ITERATOR, Collections.emptyList()
);
if (!iteratorResolutionResults.isSuccess()) return null;
@@ -108,7 +108,7 @@ public class ForLoopConventionsChecker {
) {
OverloadResolutionResults<FunctionDescriptor> nextResolutionResults = fakeCallResolver.resolveFakeCall(
context, new TransientReceiver(iteratorType), name, loopRangeExpression, loopRangeExpression, FakeCallKind.OTHER,
Collections.<KtExpression>emptyList()
Collections.emptyList()
);
if (nextResolutionResults.isAmbiguity()) {
context.trace.report(ambiguity.on(loopRangeExpression, iteratorType));
@@ -85,7 +85,7 @@ public class OperatorConventions {
ImmutableSet.of(KtTokens.EQEQEQ, KtTokens.EXCLEQEQEQ);
public static final ImmutableSet<KtSingleValueToken> IN_OPERATIONS =
ImmutableSet.<KtSingleValueToken>of(KtTokens.IN_KEYWORD, KtTokens.NOT_IN);
ImmutableSet.of(KtTokens.IN_KEYWORD, KtTokens.NOT_IN);
public static final ImmutableBiMap<KtSingleValueToken, Name> ASSIGNMENT_OPERATIONS = ImmutableBiMap.<KtSingleValueToken, Name>builder()
.put(KtTokens.MULTEQ, TIMES_ASSIGN)