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
@@ -208,11 +208,7 @@ public class FunctionCodegen {
getThrownExceptions(functionDescriptor, typeMapper)); getThrownExceptions(functionDescriptor, typeMapper));
if (CodegenContextUtil.isImplClassOwner(owner)) { if (CodegenContextUtil.isImplClassOwner(owner)) {
v.getSerializationBindings().put( v.getSerializationBindings().put(METHOD_FOR_FUNCTION, CodegenUtilKt.unwrapFrontendVersion(functionDescriptor), asmMethod);
METHOD_FOR_FUNCTION,
CodegenUtilKt.<FunctionDescriptor>unwrapFrontendVersion(functionDescriptor),
asmMethod
);
} }
generateMethodAnnotations(functionDescriptor, asmMethod, mv); generateMethodAnnotations(functionDescriptor, asmMethod, mv);
@@ -1031,7 +1031,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
} }
else if (constructor.hasBody() && !(constructor instanceof KtSecondaryConstructor && !((KtSecondaryConstructor) constructor).hasImplicitDelegationCall())) { else if (constructor.hasBody() && !(constructor instanceof KtSecondaryConstructor && !((KtSecondaryConstructor) constructor).hasImplicitDelegationCall())) {
KtBlockExpression bodyExpression = constructor.getBodyExpression(); KtBlockExpression bodyExpression = constructor.getBodyExpression();
List<KtExpression> statements = bodyExpression != null ? bodyExpression.getStatements() : Collections.<KtExpression>emptyList(); List<KtExpression> statements = bodyExpression != null ? bodyExpression.getStatements() : Collections.emptyList();
if (!statements.isEmpty()) { if (!statements.isEmpty()) {
codegen.markStartLineNumber(statements.iterator().next()); codegen.markStartLineNumber(statements.iterator().next());
} }
@@ -20,7 +20,6 @@ import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
import kotlin.Unit; import kotlin.Unit;
import kotlin.jvm.functions.Function0; import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.backend.common.CodegenUtil; import org.jetbrains.kotlin.backend.common.CodegenUtil;
@@ -60,7 +59,10 @@ import org.jetbrains.kotlin.storage.LockBasedStorageManager;
import org.jetbrains.kotlin.storage.NotNullLazyValue; import org.jetbrains.kotlin.storage.NotNullLazyValue;
import org.jetbrains.kotlin.types.ErrorUtils; import org.jetbrains.kotlin.types.ErrorUtils;
import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.org.objectweb.asm.*; import org.jetbrains.org.objectweb.asm.Label;
import org.jetbrains.org.objectweb.asm.MethodVisitor;
import org.jetbrains.org.objectweb.asm.Opcodes;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter; import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import org.jetbrains.org.objectweb.asm.commons.Method; import org.jetbrains.org.objectweb.asm.commons.Method;
@@ -450,8 +452,7 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
private SimpleFunctionDescriptorImpl createClInitFunctionDescriptor(@NotNull DeclarationDescriptor descriptor) { private SimpleFunctionDescriptorImpl createClInitFunctionDescriptor(@NotNull DeclarationDescriptor descriptor) {
SimpleFunctionDescriptorImpl clInit = SimpleFunctionDescriptorImpl.create(descriptor, Annotations.Companion.getEMPTY(), SimpleFunctionDescriptorImpl clInit = SimpleFunctionDescriptorImpl.create(descriptor, Annotations.Companion.getEMPTY(),
Name.special("<clinit>"), SYNTHESIZED, KotlinSourceElementKt.toSourceElement(element)); Name.special("<clinit>"), SYNTHESIZED, KotlinSourceElementKt.toSourceElement(element));
clInit.initialize(null, null, Collections.<TypeParameterDescriptor>emptyList(), clInit.initialize(null, null, Collections.emptyList(), Collections.emptyList(),
Collections.<ValueParameterDescriptor>emptyList(),
DescriptorUtilsKt.getModule(descriptor).getBuiltIns().getUnitType(), DescriptorUtilsKt.getModule(descriptor).getBuiltIns().getUnitType(),
null, Visibilities.PRIVATE); null, Visibilities.PRIVATE);
return clInit; return clInit;
@@ -60,7 +60,7 @@ public class ScriptCodegen extends MemberCodegen<KtScript> {
List<ScriptDescriptor> earlierScripts = state.getReplSpecific().getEarlierScriptsForReplInterpreter(); List<ScriptDescriptor> earlierScripts = state.getReplSpecific().getEarlierScriptsForReplInterpreter();
ScriptContext scriptContext = parentContext.intoScript( ScriptContext scriptContext = parentContext.intoScript(
scriptDescriptor, scriptDescriptor,
earlierScripts == null ? Collections.<ScriptDescriptor>emptyList() : earlierScripts, earlierScripts == null ? Collections.emptyList() : earlierScripts,
scriptDescriptor, scriptDescriptor,
state.getTypeMapper() state.getTypeMapper()
); );
@@ -106,7 +106,7 @@ public final class MutableClosure implements CalculatedClosure {
@NotNull @NotNull
@Override @Override
public Map<DeclarationDescriptor, EnclosedValueDescriptor> getCaptureVariables() { public Map<DeclarationDescriptor, EnclosedValueDescriptor> getCaptureVariables() {
return captureVariables != null ? captureVariables : Collections.<DeclarationDescriptor, EnclosedValueDescriptor>emptyMap(); return captureVariables != null ? captureVariables : Collections.emptyMap();
} }
public void setCaptureReceiverType(@NotNull KotlinType type) { public void setCaptureReceiverType(@NotNull KotlinType type) {
@@ -116,7 +116,7 @@ public final class MutableClosure implements CalculatedClosure {
@NotNull @NotNull
@Override @Override
public List<Pair<String, Type>> getRecordedFields() { public List<Pair<String, Type>> getRecordedFields() {
return recordedFields != null ? recordedFields : Collections.<Pair<String, Type>>emptyList(); return recordedFields != null ? recordedFields : Collections.emptyList();
} }
@Override @Override
@@ -590,7 +590,7 @@ public class InlineCodegen extends CallGenerator {
strategy = strategy =
new SuspendFunctionGenerationStrategy( new SuspendFunctionGenerationStrategy(
state, state,
CoroutineCodegenUtilKt.<FunctionDescriptor>unwrapInitialDescriptorForSuspendFunction(descriptor), CoroutineCodegenUtilKt.unwrapInitialDescriptorForSuspendFunction(descriptor),
(KtFunction) expression (KtFunction) expression
); );
} }
@@ -61,7 +61,7 @@ public class InliningContext {
@NotNull @NotNull
public InliningContext subInline(@NotNull NameGenerator generator) { public InliningContext subInline(@NotNull NameGenerator generator) {
return subInline(generator, Collections.<String, String>emptyMap(), isInliningLambda); return subInline(generator, Collections.emptyMap(), isInliningLambda);
} }
@NotNull @NotNull
@@ -23,7 +23,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
public class ModuleScriptData { public class ModuleScriptData {
public static final ModuleScriptData EMPTY = new ModuleScriptData(Collections.<Module>emptyList()); public static final ModuleScriptData EMPTY = new ModuleScriptData(Collections.emptyList());
private final List<Module> modules; private final List<Module> modules;
@@ -387,10 +387,7 @@ public class CheckerTestUtil {
} }
public static StringBuffer addDiagnosticMarkersToText(@NotNull PsiFile psiFile, @NotNull Collection<ActualDiagnostic> diagnostics) { public static StringBuffer addDiagnosticMarkersToText(@NotNull PsiFile psiFile, @NotNull Collection<ActualDiagnostic> diagnostics) {
return addDiagnosticMarkersToText( return addDiagnosticMarkersToText(psiFile, diagnostics, Collections.emptyMap(), PsiElement::getText);
psiFile, diagnostics, Collections.<ActualDiagnostic, TextDiagnostic>emptyMap(),
PsiElement::getText
);
} }
public static StringBuffer addDiagnosticMarkersToText( public static StringBuffer addDiagnosticMarkersToText(
@@ -59,13 +59,13 @@ public class CompilerConfiguration {
@NotNull @NotNull
public <T> List<T> getList(@NotNull CompilerConfigurationKey<List<T>> key) { public <T> List<T> getList(@NotNull CompilerConfigurationKey<List<T>> key) {
List<T> data = get(key); List<T> data = get(key);
return data == null ? Collections.<T>emptyList() : data; return data == null ? Collections.emptyList() : data;
} }
@NotNull @NotNull
public <K, V> Map<K, V> getMap(@NotNull CompilerConfigurationKey<Map<K, V>> key) { public <K, V> Map<K, V> getMap(@NotNull CompilerConfigurationKey<Map<K, V>> key) {
Map<K, V> data = get(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) { public <T> void put(@NotNull CompilerConfigurationKey<T> key, @NotNull T value) {
@@ -68,7 +68,7 @@ public class KtCallExpression extends KtExpressionImpl implements KtCallElement,
@NotNull @NotNull
public List<KtValueArgument> getValueArguments() { public List<KtValueArgument> getValueArguments() {
KtValueArgumentList list = getValueArgumentList(); 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(); List<KtLambdaArgument> functionLiteralArguments = getLambdaArguments();
if (functionLiteralArguments.isEmpty()) { if (functionLiteralArguments.isEmpty()) {
return valueArgumentsInParentheses; return valueArgumentsInParentheses;
@@ -83,6 +83,6 @@ public class KtCallExpression extends KtExpressionImpl implements KtCallElement,
@NotNull @NotNull
public List<KtTypeProjection> getTypeArguments() { public List<KtTypeProjection> getTypeArguments() {
KtTypeArgumentList list = getTypeArgumentList(); 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 @NotNull
public List<KtImportDirective> getImportDirectives() { public List<KtImportDirective> getImportDirectives() {
KtImportList importList = getImportList(); KtImportList importList = getImportList();
return importList != null ? importList.getImports() : Collections.<KtImportDirective>emptyList(); return importList != null ? importList.getImports() : Collections.emptyList();
} }
@Nullable @Nullable
@@ -41,7 +41,7 @@ public abstract class KtFunctionNotStubbed extends KtTypeParameterListOwnerNotSt
@NotNull @NotNull
public List<KtParameter> getValueParameters() { public List<KtParameter> getValueParameters() {
KtParameterList list = getValueParameterList(); KtParameterList list = getValueParameterList();
return list != null ? list.getParameters() : Collections.<KtParameter>emptyList(); return list != null ? list.getParameters() : Collections.emptyList();
} }
@Override @Override
@@ -72,7 +72,7 @@ public class KtFunctionType extends KtElementImplStub<KotlinPlaceHolderStub<KtFu
@NotNull @NotNull
public List<KtParameter> getParameters() { public List<KtParameter> getParameters() {
KtParameterList list = getParameterList(); KtParameterList list = getParameterList();
return list != null ? list.getParameters() : Collections.<KtParameter>emptyList(); return list != null ? list.getParameters() : Collections.emptyList();
} }
@Nullable @Nullable
@@ -115,7 +115,7 @@ public class KtNamedFunction extends KtTypeParameterListOwnerStub<KotlinFunction
@NotNull @NotNull
public List<KtParameter> getValueParameters() { public List<KtParameter> getValueParameters() {
KtParameterList list = getValueParameterList(); KtParameterList list = getValueParameterList();
return list != null ? list.getParameters() : Collections.<KtParameter>emptyList(); return list != null ? list.getParameters() : Collections.emptyList();
} }
@Override @Override
@@ -44,7 +44,7 @@ public class KtNullableType extends KtElementImplStub<KotlinPlaceHolderStub<KtNu
@Override @Override
public List<KtTypeReference> getTypeArgumentsAsTypes() { public List<KtTypeReference> getTypeArgumentsAsTypes() {
KtTypeElement innerType = getInnerType(); KtTypeElement innerType = getInnerType();
return innerType == null ? Collections.<KtTypeReference>emptyList() : innerType.getTypeArgumentsAsTypes(); return innerType == null ? Collections.emptyList() : innerType.getTypeArgumentsAsTypes();
} }
@Override @Override
@@ -66,7 +66,6 @@ public class KtNullableType extends KtElementImplStub<KotlinPlaceHolderStub<KtNu
@NotNull @NotNull
public List<KtAnnotationEntry> getAnnotationEntries() { public List<KtAnnotationEntry> getAnnotationEntries() {
KtModifierList modifierList = getModifierList(); KtModifierList modifierList = getModifierList();
return modifierList != null ? modifierList.getAnnotationEntries() return modifierList != null ? modifierList.getAnnotationEntries() : Collections.emptyList();
: Collections.<KtAnnotationEntry>emptyList();
} }
} }
@@ -51,7 +51,7 @@ public class KtUserType extends KtElementImplStub<KotlinUserTypeStub> implements
public List<KtTypeProjection> getTypeArguments() { public List<KtTypeProjection> getTypeArguments() {
// TODO: empty elements in PSI // TODO: empty elements in PSI
KtTypeArgumentList typeArgumentList = getTypeArgumentList(); KtTypeArgumentList typeArgumentList = getTypeArgumentList();
return typeArgumentList == null ? Collections.<KtTypeProjection>emptyList() : typeArgumentList.getArguments(); return typeArgumentList == null ? Collections.emptyList() : typeArgumentList.getArguments();
} }
@NotNull @NotNull
@@ -125,8 +125,8 @@ public class DescriptorResolver {
BindingTrace trace BindingTrace trace
) { ) {
List<KotlinType> supertypes = Lists.newArrayList(); List<KotlinType> supertypes = Lists.newArrayList();
List<KtSuperTypeListEntry> delegationSpecifiers = correspondingClassOrObject == null ? Collections.<KtSuperTypeListEntry>emptyList() : List<KtSuperTypeListEntry> delegationSpecifiers =
correspondingClassOrObject.getSuperTypeListEntries(); correspondingClassOrObject == null ? Collections.emptyList() : correspondingClassOrObject.getSuperTypeListEntries();
Collection<KotlinType> declaredSupertypes = resolveSuperTypeListEntries( Collection<KotlinType> declaredSupertypes = resolveSuperTypeListEntries(
scope, scope,
delegationSpecifiers, delegationSpecifiers,
@@ -1151,8 +1151,9 @@ public class DescriptorResolver {
false false
); );
propertyWrapper.setDescriptor(propertyDescriptor); propertyWrapper.setDescriptor(propertyDescriptor);
propertyDescriptor.setType(type, Collections.<TypeParameterDescriptor>emptyList(), propertyDescriptor.setType(
getDispatchReceiverParameterIfNeeded(classDescriptor), (ReceiverParameterDescriptor) null); type, Collections.emptyList(), getDispatchReceiverParameterIfNeeded(classDescriptor), (ReceiverParameterDescriptor) null
);
Annotations setterAnnotations = annotationSplitter.getAnnotationsForTarget(PROPERTY_SETTER); Annotations setterAnnotations = annotationSplitter.getAnnotationsForTarget(PROPERTY_SETTER);
Annotations getterAnnotations = new CompositeAnnotations(CollectionsKt.listOf( Annotations getterAnnotations = new CompositeAnnotations(CollectionsKt.listOf(
@@ -276,11 +276,11 @@ public class ArgumentTypeResolver {
} }
if (expectedTypeIsUnknown) { if (expectedTypeIsUnknown) {
return functionPlaceholders.createFunctionPlaceholderType(Collections.<KotlinType>emptyList(), false); return functionPlaceholders.createFunctionPlaceholderType(Collections.emptyList(), false);
} }
return FunctionTypesKt.createFunctionType( 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; boolean isFunctionLiteral = function instanceof KtFunctionLiteral;
if (function.getValueParameterList() == null && isFunctionLiteral) { if (function.getValueParameterList() == null && isFunctionLiteral) {
return expectedTypeIsUnknown return expectedTypeIsUnknown
? functionPlaceholders ? functionPlaceholders.createFunctionPlaceholderType(Collections.emptyList(), /* hasDeclaredArguments = */ false)
.createFunctionPlaceholderType(Collections.<KotlinType>emptyList(), /* hasDeclaredArguments = */ false)
: FunctionTypesKt.createFunctionType( : 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(); List<KtParameter> valueParameters = function.getValueParameters();
@@ -127,23 +127,17 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements MutableRe
@NotNull @NotNull
private static Map<ValueParameterDescriptor, ResolvedValueArgument> createValueArgumentsMap(CallableDescriptor descriptor) { private static Map<ValueParameterDescriptor, ResolvedValueArgument> createValueArgumentsMap(CallableDescriptor descriptor) {
return descriptor.getValueParameters().isEmpty() return descriptor.getValueParameters().isEmpty() ? Collections.emptyMap() : Maps.newLinkedHashMap();
? Collections.<ValueParameterDescriptor, ResolvedValueArgument>emptyMap()
: Maps.<ValueParameterDescriptor, ResolvedValueArgument>newLinkedHashMap();
} }
@NotNull @NotNull
private static Map<ValueArgument, ArgumentMatchImpl> createArgumentsToParameterMap(CallableDescriptor descriptor) { private static Map<ValueArgument, ArgumentMatchImpl> createArgumentsToParameterMap(CallableDescriptor descriptor) {
return descriptor.getValueParameters().isEmpty() return descriptor.getValueParameters().isEmpty() ? Collections.emptyMap() : Maps.newHashMap();
? Collections.<ValueArgument, ArgumentMatchImpl>emptyMap()
: Maps.<ValueArgument, ArgumentMatchImpl>newHashMap();
} }
@NotNull @NotNull
private static Map<TypeParameterDescriptor, KotlinType> createTypeArgumentsMap(CallableDescriptor descriptor) { private static Map<TypeParameterDescriptor, KotlinType> createTypeArgumentsMap(CallableDescriptor descriptor) {
return descriptor.getTypeParameters().isEmpty() return descriptor.getTypeParameters().isEmpty() ? Collections.emptyMap() : Maps.newLinkedHashMap();
? Collections.<TypeParameterDescriptor, KotlinType>emptyMap()
: Maps.<TypeParameterDescriptor, KotlinType>newLinkedHashMap();
} }
@Override @Override
@@ -35,7 +35,7 @@ public class OverloadResolutionResultsImpl<D extends CallableDescriptor> impleme
public static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> nameNotFound() { public static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> nameNotFound() {
OverloadResolutionResultsImpl<D> results = new OverloadResolutionResultsImpl<>( OverloadResolutionResultsImpl<D> results = new OverloadResolutionResultsImpl<>(
Code.NAME_NOT_FOUND, Collections.<MutableResolvedCall<D>>emptyList()); Code.NAME_NOT_FOUND, Collections.<MutableResolvedCall<D>>emptyList());
results.setAllCandidates(Collections.<ResolvedCall<D>>emptyList()); results.setAllCandidates(Collections.emptyList());
return results; return results;
} }
@@ -233,7 +233,7 @@ public class CallMaker {
@NotNull @NotNull
public static Call makeCall(@NotNull ReceiverValue baseAsReceiver, KtUnaryExpression expression) { 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 @NotNull
@@ -277,7 +277,7 @@ public class CallMaker {
@NotNull @NotNull
public static Call makePropertyCall(@Nullable Receiver explicitReceiver, @Nullable ASTNode callOperationNode, @NotNull KtSimpleNameExpression nameExpression) { 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 @NotNull
public static Call makeCall(@NotNull KtElement callElement, @NotNull ReceiverValue explicitReceiver) { 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.KotlinType;
import org.jetbrains.kotlin.types.TypeUtils; import org.jetbrains.kotlin.types.TypeUtils;
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker; import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext;
import java.util.Set; import java.util.Set;
@@ -40,7 +39,7 @@ import static org.jetbrains.kotlin.diagnostics.Errors.*;
public class CompileTimeConstantChecker { public class CompileTimeConstantChecker {
private static final Set<DiagnosticFactory<?>> errorsThatDependOnExpectedType = 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 KotlinBuiltIns builtIns;
private final BindingTrace trace; private final BindingTrace trace;
@@ -171,7 +171,7 @@ public class ResolveSession implements KotlinCodeAnalyzer, LazyClassContext {
@NotNull @NotNull
@Override @Override
public List<PackageFragmentDescriptor> getPackageFragments(@NotNull FqName fqName) { public List<PackageFragmentDescriptor> getPackageFragments(@NotNull FqName fqName) {
return ContainerUtil.<PackageFragmentDescriptor>createMaybeSingletonList(getPackageFragment(fqName)); return ContainerUtil.createMaybeSingletonList(getPackageFragment(fqName));
} }
@NotNull @NotNull
@@ -339,7 +339,7 @@ public class ResolveSession implements KotlinCodeAnalyzer, LazyClassContext {
LazyPackageDescriptor rootPackage = getPackageFragment(FqName.ROOT); LazyPackageDescriptor rootPackage = getPackageFragment(FqName.ROOT);
assert rootPackage != null : "Root package must be initialized"; assert rootPackage != null : "Root package must be initialized";
return collectAllPackages(Lists.<LazyPackageDescriptor>newArrayList(), rootPackage); return collectAllPackages(Lists.newArrayList(), rootPackage);
} }
@NotNull @NotNull
@@ -88,7 +88,7 @@ public abstract class KtClassOrObjectInfo<E extends KtClassOrObject> implements
@Override @Override
public List<KtAnnotationEntry> getDanglingAnnotations() { public List<KtAnnotationEntry> getDanglingAnnotations() {
KtClassBody body = element.getBody(); KtClassBody body = element.getBody();
return body == null ? Collections.<KtAnnotationEntry>emptyList() : body.getDanglingAnnotations(); return body == null ? Collections.emptyList() : body.getDanglingAnnotations();
} }
@NotNull @NotNull
@@ -26,8 +26,7 @@ import org.jetbrains.kotlin.storage.LockBasedStorageManager;
import java.util.Collections; import java.util.Collections;
public interface DeclarationProviderFactory { public interface DeclarationProviderFactory {
DeclarationProviderFactory EMPTY = DeclarationProviderFactory EMPTY = new FileBasedDeclarationProviderFactory(LockBasedStorageManager.NO_LOCKS, Collections.emptyList());
new FileBasedDeclarationProviderFactory(LockBasedStorageManager.NO_LOCKS, Collections.<KtFile>emptyList());
@NotNull @NotNull
ClassMemberDeclarationProvider getClassMemberDeclarationProvider(@NotNull KtClassLikeInfo classLikeInfo); ClassMemberDeclarationProvider getClassMemberDeclarationProvider(@NotNull KtClassLikeInfo classLikeInfo);
@@ -270,7 +270,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
CallableMemberDescriptor.Kind.SYNTHESIZED, SourceElement.NO_SOURCE 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); null, Modality.FINAL, Visibilities.PRIVATE);
} }
@@ -665,13 +665,11 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
KtClassOrObject classOrObject = declarationProvider.getOwnerInfo().getCorrespondingClassOrObject(); KtClassOrObject classOrObject = declarationProvider.getOwnerInfo().getCorrespondingClassOrObject();
if (classOrObject == null) { if (classOrObject == null) {
return Collections.<KotlinType>singleton(c.getModuleDescriptor().getBuiltIns().getAnyType()); return Collections.singleton(c.getModuleDescriptor().getBuiltIns().getAnyType());
} }
List<KotlinType> allSupertypes = List<KotlinType> allSupertypes =
c.getDescriptorResolver() c.getDescriptorResolver().resolveSupertypes(getScopeForClassHeaderResolution(), this, classOrObject, c.getTrace());
.resolveSupertypes(getScopeForClassHeaderResolution(), this, classOrObject,
c.getTrace());
return new ArrayList<>(CollectionsKt.filter(allSupertypes, VALID_SUPERTYPE)); return new ArrayList<>(CollectionsKt.filter(allSupertypes, VALID_SUPERTYPE));
} }
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.resolve.lazy.descriptors;
import kotlin.collections.CollectionsKt; import kotlin.collections.CollectionsKt;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.descriptors.SupertypeLoopChecker;
import org.jetbrains.kotlin.descriptors.impl.AbstractLazyTypeParameterDescriptor; import org.jetbrains.kotlin.descriptors.impl.AbstractLazyTypeParameterDescriptor;
import org.jetbrains.kotlin.diagnostics.Errors; import org.jetbrains.kotlin.diagnostics.Errors;
import org.jetbrains.kotlin.lexer.KtTokens; import org.jetbrains.kotlin.lexer.KtTokens;
@@ -93,7 +92,7 @@ public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescri
return CollectionsKt.plus( return CollectionsKt.plus(
typeParameter.getExtendsBound() != null typeParameter.getExtendsBound() != null
? Collections.singletonList(typeParameter.getExtendsBound()) ? Collections.singletonList(typeParameter.getExtendsBound())
: Collections.<KtTypeReference>emptyList(), : Collections.emptyList(),
getUpperBoundsFromWhereClause() getUpperBoundsFromWhereClause()
); );
} }
@@ -136,7 +136,7 @@ public class TypeIntersector {
return KotlinTypeFactory.simpleType( return KotlinTypeFactory.simpleType(
Annotations.Companion.getEMPTY(), Annotations.Companion.getEMPTY(),
constructor, constructor,
Collections.<TypeProjection>emptyList(), Collections.emptyList(),
allNullable, allNullable,
constructor.createScopeForKotlinType() constructor.createScopeForKotlinType()
); );
@@ -667,7 +667,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
KtExpression expression KtExpression expression
) { ) {
BindingTrace trace = context.trace; 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<ReceiverParameterDescriptor> resolutionCandidate =
ResolutionCandidate.create( ResolutionCandidate.create(
call, descriptor, null, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, null); call, descriptor, null, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, null);
@@ -118,7 +118,7 @@ public class ControlStructureTypingUtils {
TracingStrategy tracing = createTracingForSpecialConstruction(call, construct.getName(), context); TracingStrategy tracing = createTracingForSpecialConstruction(call, construct.getName(), context);
TypeSubstitutor knownTypeParameterSubstitutor = createKnownTypeParameterSubstitutorForSpecialCall(construct, function, context.expectedType); TypeSubstitutor knownTypeParameterSubstitutor = createKnownTypeParameterSubstitutorForSpecialCall(construct, function, context.expectedType);
ResolutionCandidate<FunctionDescriptor> resolutionCandidate = ResolutionCandidate<FunctionDescriptor> resolutionCandidate =
ResolutionCandidate.<FunctionDescriptor>create(call, function, knownTypeParameterSubstitutor); ResolutionCandidate.create(call, function, knownTypeParameterSubstitutor);
OverloadResolutionResults<FunctionDescriptor> results = callResolver.resolveCallWithKnownCandidate( OverloadResolutionResults<FunctionDescriptor> results = callResolver.resolveCallWithKnownCandidate(
call, tracing, context, resolutionCandidate, dataFlowInfoForArguments); call, tracing, context, resolutionCandidate, dataFlowInfoForArguments);
assert results.isSingleResult() : "Not single result after resolving one known candidate"; assert results.isSingleResult() : "Not single result after resolving one known candidate";
@@ -304,9 +304,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
newOuterLoops.add(loopExpression); newOuterLoops.add(loopExpression);
return super.visitLoopExpression(loopExpression, newOuterLoops); return super.visitLoopExpression(loopExpression, newOuterLoops);
} }
}, expression instanceof KtLoopExpression }, expression instanceof KtLoopExpression ? Lists.newArrayList((KtLoopExpression) expression) : Lists.newArrayList());
? Lists.newArrayList((KtLoopExpression) expression)
: Lists.<KtLoopExpression>newArrayList());
return result[0]; return result[0];
} }
@@ -60,7 +60,7 @@ public class ForLoopConventionsChecker {
// Make a fake call loopRange.iterator(), and try to resolve it // Make a fake call loopRange.iterator(), and try to resolve it
OverloadResolutionResults<FunctionDescriptor> iteratorResolutionResults = fakeCallResolver.resolveFakeCall( OverloadResolutionResults<FunctionDescriptor> iteratorResolutionResults = fakeCallResolver.resolveFakeCall(
context, loopRange, OperatorNameConventions.ITERATOR, loopRangeExpression, context, loopRange, OperatorNameConventions.ITERATOR, loopRangeExpression,
loopRangeExpression, FakeCallKind.ITERATOR, Collections.<KtExpression>emptyList() loopRangeExpression, FakeCallKind.ITERATOR, Collections.emptyList()
); );
if (!iteratorResolutionResults.isSuccess()) return null; if (!iteratorResolutionResults.isSuccess()) return null;
@@ -108,7 +108,7 @@ public class ForLoopConventionsChecker {
) { ) {
OverloadResolutionResults<FunctionDescriptor> nextResolutionResults = fakeCallResolver.resolveFakeCall( OverloadResolutionResults<FunctionDescriptor> nextResolutionResults = fakeCallResolver.resolveFakeCall(
context, new TransientReceiver(iteratorType), name, loopRangeExpression, loopRangeExpression, FakeCallKind.OTHER, context, new TransientReceiver(iteratorType), name, loopRangeExpression, loopRangeExpression, FakeCallKind.OTHER,
Collections.<KtExpression>emptyList() Collections.emptyList()
); );
if (nextResolutionResults.isAmbiguity()) { if (nextResolutionResults.isAmbiguity()) {
context.trace.report(ambiguity.on(loopRangeExpression, iteratorType)); context.trace.report(ambiguity.on(loopRangeExpression, iteratorType));
@@ -85,7 +85,7 @@ public class OperatorConventions {
ImmutableSet.of(KtTokens.EQEQEQ, KtTokens.EXCLEQEQEQ); ImmutableSet.of(KtTokens.EQEQEQ, KtTokens.EXCLEQEQEQ);
public static final ImmutableSet<KtSingleValueToken> IN_OPERATIONS = 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() public static final ImmutableBiMap<KtSingleValueToken, Name> ASSIGNMENT_OPERATIONS = ImmutableBiMap.<KtSingleValueToken, Name>builder()
.put(KtTokens.MULTEQ, TIMES_ASSIGN) .put(KtTokens.MULTEQ, TIMES_ASSIGN)
@@ -20,11 +20,10 @@ import java.io.PrintStream;
import java.util.Collections; import java.util.Collections;
public abstract class InterceptionInstrumenterAdaptor implements Instrumenter { public abstract class InterceptionInstrumenterAdaptor implements Instrumenter {
private final InterceptionInstrumenter instrumenter; private final InterceptionInstrumenter instrumenter;
public InterceptionInstrumenterAdaptor() { public InterceptionInstrumenterAdaptor() {
this.instrumenter = new InterceptionInstrumenter(Collections.<Class<?>>singletonList(getClass())); this.instrumenter = new InterceptionInstrumenter(Collections.singletonList(getClass()));
} }
@Override @Override
@@ -106,7 +106,7 @@ public abstract class AbstractCompileKotlinAgainstKotlinTest extends CodegenTest
CompilerConfiguration configuration = CompilerConfiguration configuration =
createConfiguration(ConfigurationKind.ALL, getJdkKind(files), createConfiguration(ConfigurationKind.ALL, getJdkKind(files),
Collections.singletonList(KotlinTestUtils.getAnnotationsJar()), Collections.singletonList(KotlinTestUtils.getAnnotationsJar()),
Collections.<File>emptyList(), Collections.singletonList(testFile)); Collections.emptyList(), Collections.singletonList(testFile));
KotlinCoreEnvironment environment = KotlinCoreEnvironment.createForTests( KotlinCoreEnvironment environment = KotlinCoreEnvironment.createForTests(
compileDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES); compileDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES);
@@ -119,7 +119,7 @@ public abstract class AbstractCompileKotlinAgainstKotlinTest extends CodegenTest
CompilerConfiguration configurationWithADirInClasspath = CompilerConfiguration configurationWithADirInClasspath =
createConfiguration(ConfigurationKind.ALL, getJdkKind(files), createConfiguration(ConfigurationKind.ALL, getJdkKind(files),
Lists.newArrayList(KotlinTestUtils.getAnnotationsJar(), aDir), Lists.newArrayList(KotlinTestUtils.getAnnotationsJar(), aDir),
Collections.<File>emptyList(), Collections.singletonList(testFile)); Collections.emptyList(), Collections.singletonList(testFile));
Disposable compileDisposable = createDisposable("compileB"); Disposable compileDisposable = createDisposable("compileB");
KotlinCoreEnvironment environment = KotlinCoreEnvironment.createForTests( KotlinCoreEnvironment environment = KotlinCoreEnvironment.createForTests(
@@ -52,7 +52,7 @@ public abstract class AbstractTopLevelMembersInvocationTest extends AbstractByte
File library = new File(root, LIBRARY); File library = new File(root, LIBRARY);
List<File> classPath = library.exists() ? List<File> classPath = library.exists() ?
Collections.singletonList(MockLibraryUtil.compileLibraryToJar(library.getPath(), LIBRARY, false, false)) : Collections.singletonList(MockLibraryUtil.compileLibraryToJar(library.getPath(), LIBRARY, false, false)) :
Collections.<File>emptyList(); Collections.emptyList();
assert !sourceFiles.isEmpty() : getTestName(true) + " should contain at least one .kt file"; assert !sourceFiles.isEmpty() : getTestName(true) + " should contain at least one .kt file";
Collections.sort(sourceFiles); Collections.sort(sourceFiles);
@@ -89,7 +89,7 @@ public abstract class CodegenTestCase extends KtUsefulTestCase {
@NotNull ConfigurationKind configurationKind, @NotNull ConfigurationKind configurationKind,
@Nullable File... javaSourceRoots @Nullable File... javaSourceRoots
) { ) {
createEnvironmentWithMockJdkAndIdeaAnnotations(configurationKind, Collections.<TestFile>emptyList(), javaSourceRoots); createEnvironmentWithMockJdkAndIdeaAnnotations(configurationKind, Collections.emptyList(), javaSourceRoots);
} }
@NotNull @NotNull
@@ -79,7 +79,7 @@ public class CodegenTestFiles {
@NotNull @NotNull
public static CodegenTestFiles create(@NotNull List<KtFile> ktFiles) { public static CodegenTestFiles create(@NotNull List<KtFile> ktFiles) {
assert !ktFiles.isEmpty() : "List should have at least one file"; assert !ktFiles.isEmpty() : "List should have at least one file";
return new CodegenTestFiles(ktFiles, Collections.<Pair<String, String>>emptyList(), Collections.emptyList()); return new CodegenTestFiles(ktFiles, Collections.emptyList(), Collections.emptyList());
} }
public static CodegenTestFiles create(Project project, String[] names) { public static CodegenTestFiles create(Project project, String[] names) {
@@ -57,7 +57,7 @@ public abstract class AbstractWriteFlagsTest extends CodegenTestCase {
protected void doMultiFileTest( protected void doMultiFileTest(
@NotNull File wholeFile, @NotNull List<TestFile> files, @Nullable File javaFilesDir @NotNull File wholeFile, @NotNull List<TestFile> files, @Nullable File javaFilesDir
) throws Exception { ) throws Exception {
compile(files, null, ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK, Collections.<String>emptyList()); compile(files, null, ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK, Collections.emptyList());
String fileText = FileUtil.loadFile(wholeFile, true); String fileText = FileUtil.loadFile(wholeFile, true);
@@ -42,7 +42,6 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.scopes.MemberScope; import org.jetbrains.kotlin.resolve.scopes.MemberScope;
import org.jetbrains.kotlin.test.KotlinTestUtils; import org.jetbrains.kotlin.test.KotlinTestUtils;
import org.jetbrains.kotlin.test.KotlinTestWithEnvironment; import org.jetbrains.kotlin.test.KotlinTestWithEnvironment;
import org.jetbrains.kotlin.types.TypeProjection;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@@ -173,7 +172,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends KotlinTest
@NotNull @NotNull
private static FunctionDescriptor getFunctionDescriptor(@NotNull ClassDescriptor classDescriptor, @NotNull String name) { private static FunctionDescriptor getFunctionDescriptor(@NotNull ClassDescriptor classDescriptor, @NotNull String name) {
Name functionName = Name.identifier(name); Name functionName = Name.identifier(name);
MemberScope memberScope = classDescriptor.getMemberScope(Collections.<TypeProjection>emptyList()); MemberScope memberScope = classDescriptor.getMemberScope(Collections.emptyList());
Collection<SimpleFunctionDescriptor> functions = memberScope.getContributedFunctions(functionName, NoLookupLocation.FROM_TEST); Collection<SimpleFunctionDescriptor> functions = memberScope.getContributedFunctions(functionName, NoLookupLocation.FROM_TEST);
assert functions.size() == 1 : "Failed to find function " + functionName + " in class" + "." + classDescriptor.getName(); assert functions.size() == 1 : "Failed to find function " + functionName + " in class" + "." + classDescriptor.getName();
return functions.iterator().next(); return functions.iterator().next();
@@ -187,9 +186,8 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends KotlinTest
if (properties.isEmpty()) { if (properties.isEmpty()) {
for (DeclarationDescriptor descriptor : DescriptorUtils.getAllDescriptors(memberScope)) { for (DeclarationDescriptor descriptor : DescriptorUtils.getAllDescriptors(memberScope)) {
if (descriptor instanceof ClassDescriptor) { if (descriptor instanceof ClassDescriptor) {
Collection<PropertyDescriptor> classProperties = Collection<PropertyDescriptor> classProperties = ((ClassDescriptor) descriptor).getMemberScope(Collections.emptyList())
((ClassDescriptor) descriptor).getMemberScope(Collections.<TypeProjection>emptyList()) .getContributedVariables(propertyName, NoLookupLocation.FROM_TEST);
.getContributedVariables(propertyName, NoLookupLocation.FROM_TEST);
if (!classProperties.isEmpty()) { if (!classProperties.isEmpty()) {
properties = classProperties; properties = classProperties;
break; break;
@@ -209,7 +207,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends KotlinTest
@NotNull @NotNull
private static PropertyDescriptor getPropertyDescriptor(@NotNull ClassDescriptor classDescriptor, @NotNull String name) { private static PropertyDescriptor getPropertyDescriptor(@NotNull ClassDescriptor classDescriptor, @NotNull String name) {
Name propertyName = Name.identifier(name); Name propertyName = Name.identifier(name);
MemberScope memberScope = classDescriptor.getMemberScope(Collections.<TypeProjection>emptyList()); MemberScope memberScope = classDescriptor.getMemberScope(Collections.emptyList());
Collection<PropertyDescriptor> properties = memberScope.getContributedVariables(propertyName, NoLookupLocation.FROM_TEST); Collection<PropertyDescriptor> properties = memberScope.getContributedVariables(propertyName, NoLookupLocation.FROM_TEST);
assert properties.size() == 1 : "Failed to find property " + propertyName + " in class " + classDescriptor.getName(); assert properties.size() == 1 : "Failed to find property " + propertyName + " in class " + classDescriptor.getName();
return properties.iterator().next(); return properties.iterator().next();
@@ -227,7 +225,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends KotlinTest
@NotNull @NotNull
private static ClassDescriptor getInnerClassDescriptor(@NotNull ClassDescriptor classDescriptor, @NotNull String name) { private static ClassDescriptor getInnerClassDescriptor(@NotNull ClassDescriptor classDescriptor, @NotNull String name) {
Name propertyName = Name.identifier(name); Name propertyName = Name.identifier(name);
MemberScope memberScope = classDescriptor.getMemberScope(Collections.<TypeProjection>emptyList()); MemberScope memberScope = classDescriptor.getMemberScope(Collections.emptyList());
ClassifierDescriptor innerClass = memberScope.getContributedClassifier(propertyName, NoLookupLocation.FROM_TEST); ClassifierDescriptor innerClass = memberScope.getContributedClassifier(propertyName, NoLookupLocation.FROM_TEST);
assert innerClass instanceof ClassDescriptor : "Failed to find inner class " + assert innerClass instanceof ClassDescriptor : "Failed to find inner class " +
propertyName + propertyName +
@@ -437,7 +437,7 @@ public class KotlinTestUtils {
@NotNull TestJdkKind jdkKind, @NotNull TestJdkKind jdkKind,
@NotNull File... extraClasspath @NotNull File... extraClasspath
) { ) {
return newConfiguration(configurationKind, jdkKind, Arrays.asList(extraClasspath), Collections.<File>emptyList()); return newConfiguration(configurationKind, jdkKind, Arrays.asList(extraClasspath), Collections.emptyList());
} }
@NotNull @NotNull
@@ -636,7 +636,7 @@ public class KotlinTestUtils {
} }
if (isDirectiveDefined(expectedText, "WITH_COROUTINES")) { if (isDirectiveDefined(expectedText, "WITH_COROUTINES")) {
M supportModule = hasModules ? factory.createModule("support", Collections.<String>emptyList()) : null; M supportModule = hasModules ? factory.createModule("support", Collections.emptyList()) : null;
testFiles.add(factory.createFile(supportModule, testFiles.add(factory.createFile(supportModule,
"CoroutineUtil.kt", "CoroutineUtil.kt",
"import kotlin.coroutines.experimental.*\n" + "import kotlin.coroutines.experimental.*\n" +
@@ -128,18 +128,18 @@ public class RecursiveDescriptorComparator {
if (!DescriptorUtils.getAllDescriptors(staticScope).isEmpty()) { if (!DescriptorUtils.getAllDescriptors(staticScope).isEmpty()) {
printer.println(); printer.println();
printer.println("// Static members"); printer.println("// Static members");
appendSubDescriptors(descriptor, module, staticScope, Collections.<DeclarationDescriptor>emptyList(), printer); appendSubDescriptors(descriptor, module, staticScope, Collections.emptyList(), printer);
} }
} }
else if (descriptor instanceof PackageFragmentDescriptor) { else if (descriptor instanceof PackageFragmentDescriptor) {
appendSubDescriptors(descriptor, module, appendSubDescriptors(descriptor, module,
((PackageFragmentDescriptor) descriptor).getMemberScope(), ((PackageFragmentDescriptor) descriptor).getMemberScope(),
Collections.<DeclarationDescriptor>emptyList(), printer); Collections.emptyList(), printer);
} }
else if (descriptor instanceof PackageViewDescriptor) { else if (descriptor instanceof PackageViewDescriptor) {
appendSubDescriptors(descriptor, module, appendSubDescriptors(descriptor, module,
getPackageScopeInModule((PackageViewDescriptor) descriptor, module), getPackageScopeInModule((PackageViewDescriptor) descriptor, module),
Collections.<DeclarationDescriptor>emptyList(), printer); Collections.emptyList(), printer);
} }
if (!topLevel) { if (!topLevel) {
@@ -66,8 +66,8 @@ public class GenerateNotNullAssertionsTest extends CodegenTestCase {
private File compileJava0(@NotNull String fileName) { private File compileJava0(@NotNull String fileName) {
return CodegenTestUtil.compileJava( return CodegenTestUtil.compileJava(
Collections.singletonList(KotlinTestUtils.getTestDataPathBase() + "/codegen/" + getPrefix() + "/" + fileName), Collections.singletonList(KotlinTestUtils.getTestDataPathBase() + "/codegen/" + getPrefix() + "/" + fileName),
Collections.<String>emptyList(), Collections.emptyList(),
Collections.<String>emptyList() Collections.emptyList()
); );
} }
@@ -157,8 +157,8 @@ public class OuterClassGenTest extends CodegenTestCase {
private void doTest(@NotNull String classFqName, @NotNull String javaClassName, @NotNull String testDataFile) throws Exception { private void doTest(@NotNull String classFqName, @NotNull String javaClassName, @NotNull String testDataFile) throws Exception {
File javaOut = CodegenTestUtil.compileJava( File javaOut = CodegenTestUtil.compileJava(
Collections.singletonList(KotlinTestUtils.getTestDataPathBase() + "/codegen/" + getPrefix() + "/" + testDataFile + ".java"), Collections.singletonList(KotlinTestUtils.getTestDataPathBase() + "/codegen/" + getPrefix() + "/" + testDataFile + ".java"),
Collections.<String>emptyList(), Collections.emptyList(),
Collections.<String>emptyList() Collections.emptyList()
); );
String javaClassPath = javaClassName.replace('.', File.separatorChar) + ".class"; String javaClassPath = javaClassName.replace('.', File.separatorChar) + ".class";
@@ -90,7 +90,7 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
@NotNull @NotNull
private File compileLibrary(@NotNull String sourcePath, @NotNull File... extraClassPath) { private File compileLibrary(@NotNull String sourcePath, @NotNull File... extraClassPath) {
return compileLibrary(sourcePath, Collections.<String>emptyList(), extraClassPath); return compileLibrary(sourcePath, Collections.emptyList(), extraClassPath);
} }
private File compileLibrary(@NotNull String sourcePath, List<String> additionalOptions, @NotNull File... extraClassPath) { private File compileLibrary(@NotNull String sourcePath, List<String> additionalOptions, @NotNull File... extraClassPath) {
@@ -212,7 +212,7 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
@NotNull File output, @NotNull File output,
@NotNull File... classpath @NotNull File... classpath
) { ) {
return compileKotlin(fileName, output, Collections.<String>emptyList(), classpath); return compileKotlin(fileName, output, Collections.emptyList(), classpath);
} }
@NotNull @NotNull
@@ -301,7 +301,7 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
} }
private void doTestKotlinLibraryWithWrongMetadataVersionJs(@NotNull String libraryName, @NotNull String... additionalOptions) { private void doTestKotlinLibraryWithWrongMetadataVersionJs(@NotNull String libraryName, @NotNull String... additionalOptions) {
compileLibrary(new K2JSCompiler(), libraryName, new File(tmpdir, "library.js"), Collections.<String>emptyList()); compileLibrary(new K2JSCompiler(), libraryName, new File(tmpdir, "library.js"), Collections.emptyList());
File library = new File(tmpdir, "library.meta.js"); File library = new File(tmpdir, "library.meta.js");
FilesKt.writeText(library, FilesKt.readText(library, Charsets.UTF_8).replace( FilesKt.writeText(library, FilesKt.readText(library, Charsets.UTF_8).replace(
@@ -327,7 +327,7 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
try { try {
System.setProperty(TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY, "true"); System.setProperty(TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY, "true");
compileLibrary(compiler, libraryName, destination, Collections.<String>emptyList()); compileLibrary(compiler, libraryName, destination, Collections.emptyList());
} }
finally { finally {
System.clearProperty(TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY); System.clearProperty(TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY);
@@ -139,9 +139,9 @@ public class SimpleTestClassModel implements TestClassModel {
public Collection<MethodModel> getMethods() { public Collection<MethodModel> getMethods() {
if (testMethods == null) { if (testMethods == null) {
if (!rootFile.isDirectory()) { if (!rootFile.isDirectory()) {
testMethods = Collections.<MethodModel>singletonList(new SimpleTestMethodModel(rootFile, rootFile, doTestMethodName, testMethods = Collections.singletonList(new SimpleTestMethodModel(
filenamePattern, checkFilenameStartsLowerCase, rootFile, rootFile, doTestMethodName, filenamePattern, checkFilenameStartsLowerCase, targetBackend
targetBackend)); ));
} }
else { else {
List<MethodModel> result = Lists.newArrayList(); List<MethodModel> result = Lists.newArrayList();
@@ -88,17 +88,17 @@ public class SingleClassTestModel implements TestClassModel {
ContainerUtil.sort(result, (o1, o2) -> StringUtil.compare(o1.getName(), o2.getName(), true)); ContainerUtil.sort(result, (o1, o2) -> StringUtil.compare(o1.getName(), o2.getName(), true));
methods = Lists.<MethodModel>newArrayList(result); methods = Lists.newArrayList(result);
} }
return methods; return methods;
} }
@NotNull @NotNull
protected Collection<TestMethodModel> getTestMethodsFromFile(File file) { private Collection<TestMethodModel> getTestMethodsFromFile(File file) {
return Collections.<TestMethodModel>singletonList(new SimpleTestMethodModel(rootFile, file, doTestMethodName, return Collections.singletonList(new SimpleTestMethodModel(
filenamePattern, checkFilenameStartsLowerCase, rootFile, file, doTestMethodName, filenamePattern, checkFilenameStartsLowerCase, targetBackend
targetBackend)); ));
} }
@Override @Override
@@ -125,7 +125,7 @@ public final class RhinoUtils {
@Nullable Map<String, Object> variables, @Nullable Map<String, Object> variables,
@NotNull EcmaVersion ecmaVersion) @NotNull EcmaVersion ecmaVersion)
throws Exception { throws Exception {
runRhinoTest(fileNames, checker, variables, ecmaVersion, Collections.<String>emptyList()); runRhinoTest(fileNames, checker, variables, ecmaVersion, Collections.emptyList());
} }
public static void runRhinoTest(@NotNull List<String> fileNames, public static void runRhinoTest(@NotNull List<String> fileNames,
@@ -35,12 +35,12 @@ public class CallCounter extends RecursiveJsVisitor {
@NotNull @NotNull
public static CallCounter countCalls(@NotNull JsNode node) { public static CallCounter countCalls(@NotNull JsNode node) {
return countCalls(node, Collections.<String>emptySet()); return countCalls(node, Collections.emptySet());
} }
@NotNull @NotNull
public static CallCounter countCalls(@NotNull JsNode node, @NotNull Set<String> exceptFunctionNames) { public static CallCounter countCalls(@NotNull JsNode node, @NotNull Set<String> exceptFunctionNames) {
CallCounter visitor = new CallCounter(new HashSet<>(exceptFunctionNames), Collections.<String>emptySet()); CallCounter visitor = new CallCounter(new HashSet<>(exceptFunctionNames), Collections.emptySet());
node.accept(visitor); node.accept(visitor);
return visitor; return visitor;
@@ -48,7 +48,7 @@ public class CallCounter extends RecursiveJsVisitor {
@NotNull @NotNull
public static CallCounter countCallsWithExcludedScopes(@NotNull JsNode node, @NotNull Set<String> exceptScopes) { public static CallCounter countCallsWithExcludedScopes(@NotNull JsNode node, @NotNull Set<String> exceptScopes) {
CallCounter visitor = new CallCounter(Collections.<String>emptySet(), new HashSet<>(exceptScopes)); CallCounter visitor = new CallCounter(Collections.emptySet(), new HashSet<>(exceptScopes));
node.accept(visitor); node.accept(visitor);
return visitor; return visitor;
@@ -335,7 +335,7 @@ public class DirectiveTestUtils {
public static void checkFunctionNotCalled(@NotNull JsNode node, @NotNull String functionName, @Nullable String exceptFunction) public static void checkFunctionNotCalled(@NotNull JsNode node, @NotNull String functionName, @Nullable String exceptFunction)
throws Exception { throws Exception {
Set<String> excludedScopes = exceptFunction != null ? Collections.singleton(exceptFunction) : Collections.<String>emptySet(); Set<String> excludedScopes = exceptFunction != null ? Collections.singleton(exceptFunction) : Collections.emptySet();
CallCounter counter = CallCounter.countCallsWithExcludedScopes(node, excludedScopes); CallCounter counter = CallCounter.countCallsWithExcludedScopes(node, excludedScopes);
int functionCalledCount = counter.getQualifiedCallsCount(functionName); int functionCalledCount = counter.getQualifiedCallsCount(functionName);
@@ -300,7 +300,7 @@ public final class Namer {
@Nullable JsExpression argument, @Nullable JsExpression argument,
@NotNull TypeCheck metadata @NotNull TypeCheck metadata
) { ) {
List<JsExpression> arguments = argument != null ? Collections.singletonList(argument) : Collections.<JsExpression>emptyList(); List<JsExpression> arguments = argument != null ? Collections.singletonList(argument) : Collections.emptyList();
return invokeFunctionAndSetTypeCheckMetadata(functionName, arguments, metadata); return invokeFunctionAndSetTypeCheckMetadata(functionName, arguments, metadata);
} }
@@ -173,7 +173,7 @@ public final class ClassInitializerTranslator extends AbstractTranslator {
private void mayBeAddCallToSuperMethod(JsFunction initializer) { private void mayBeAddCallToSuperMethod(JsFunction initializer) {
if (classDeclaration.hasModifier(KtTokens.ENUM_KEYWORD)) { if (classDeclaration.hasModifier(KtTokens.ENUM_KEYWORD)) {
addCallToSuperMethod(Collections.<JsExpression>emptyList(), initializer); addCallToSuperMethod(Collections.emptyList(), initializer);
} }
else if (hasAncestorClass(bindingContext(), classDeclaration)) { else if (hasAncestorClass(bindingContext(), classDeclaration)) {
ResolvedCall<FunctionDescriptor> superCall = getSuperCall(bindingContext(), classDeclaration); ResolvedCall<FunctionDescriptor> superCall = getSuperCall(bindingContext(), classDeclaration);
@@ -314,7 +314,7 @@ public enum PrimitiveBinaryOperationFIF implements FunctionIntrinsicFactory {
@NotNull @NotNull
@Override @Override
public JsExpression doApply(@NotNull JsExpression left, @NotNull JsExpression right, @NotNull TranslationContext context) { public JsExpression doApply(@NotNull JsExpression left, @NotNull JsExpression right, @NotNull TranslationContext context) {
return functionIntrinsic.doApply(left, TopLevelFIF.TO_STRING.apply(right, Collections.<JsExpression>emptyList(), context), context); return functionIntrinsic.doApply(left, TopLevelFIF.TO_STRING.apply(right, Collections.emptyList(), context), context);
} }
} }
} }
@@ -29,7 +29,6 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
import java.util.Collections; import java.util.Collections;
public final class IntrinsicIncrementTranslator extends IncrementTranslator { public final class IntrinsicIncrementTranslator extends IncrementTranslator {
@NotNull @NotNull
private final ResolvedCall<? extends FunctionDescriptor> resolvedCall; private final ResolvedCall<? extends FunctionDescriptor> resolvedCall;
@@ -44,6 +43,6 @@ public final class IntrinsicIncrementTranslator extends IncrementTranslator {
protected JsExpression operationExpression(@NotNull TranslationContext context, @NotNull JsExpression receiver) { protected JsExpression operationExpression(@NotNull TranslationContext context, @NotNull JsExpression receiver) {
FunctionIntrinsic intrinsic = context.intrinsics().getFunctionIntrinsic(resolvedCall.getResultingDescriptor()); FunctionIntrinsic intrinsic = context.intrinsics().getFunctionIntrinsic(resolvedCall.getResultingDescriptor());
CallInfo callInfo = CallInfoKt.getCallInfo(context, resolvedCall, receiver); CallInfo callInfo = CallInfoKt.getCallInfo(context, resolvedCall, receiver);
return intrinsic.apply(callInfo, Collections.<JsExpression>emptyList(), context); return intrinsic.apply(callInfo, Collections.emptyList(), context);
} }
} }
@@ -16,12 +16,12 @@
package org.jetbrains.kotlin.js.translate.test; package org.jetbrains.kotlin.js.translate.test;
import org.jetbrains.kotlin.js.backend.ast.JsExpression;
import org.jetbrains.kotlin.js.backend.ast.JsNew;
import org.jetbrains.kotlin.js.backend.ast.JsStringLiteral;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.descriptors.ClassDescriptor; import org.jetbrains.kotlin.descriptors.ClassDescriptor;
import org.jetbrains.kotlin.descriptors.FunctionDescriptor; import org.jetbrains.kotlin.descriptors.FunctionDescriptor;
import org.jetbrains.kotlin.js.backend.ast.JsExpression;
import org.jetbrains.kotlin.js.backend.ast.JsNew;
import org.jetbrains.kotlin.js.backend.ast.JsStringLiteral;
import org.jetbrains.kotlin.js.translate.callTranslator.CallTranslator; import org.jetbrains.kotlin.js.translate.callTranslator.CallTranslator;
import org.jetbrains.kotlin.js.translate.context.TranslationContext; import org.jetbrains.kotlin.js.translate.context.TranslationContext;
import org.jetbrains.kotlin.js.translate.general.JetTestFunctionDetector; import org.jetbrains.kotlin.js.translate.general.JetTestFunctionDetector;
@@ -60,8 +60,8 @@ public final class JSTestGenerator {
@NotNull ClassDescriptor classDescriptor, @NotNull JSTester tester) { @NotNull ClassDescriptor classDescriptor, @NotNull JSTester tester) {
JsExpression expression = ReferenceTranslator.translateAsValueReference(classDescriptor, context); JsExpression expression = ReferenceTranslator.translateAsValueReference(classDescriptor, context);
JsNew testClass = new JsNew(expression); JsNew testClass = new JsNew(expression);
JsExpression functionToTestCall = CallTranslator.INSTANCE.buildCall(context, functionDescriptor, JsExpression functionToTestCall =
Collections.<JsExpression>emptyList(), testClass); CallTranslator.INSTANCE.buildCall(context, functionDescriptor, Collections.emptyList(), testClass);
JsStringLiteral testName = context.program().getStringLiteral(classDescriptor.getName() + "." + functionDescriptor.getName()); JsStringLiteral testName = context.program().getStringLiteral(classDescriptor.getName() + "." + functionDescriptor.getName());
tester.constructTestMethodInvocation(functionToTestCall, testName); tester.constructTestMethodInvocation(functionToTestCall, testName);
} }