Use Java 7+ diamond operator in compiler modules

This commit is contained in:
Alexander Udalov
2017-04-01 02:28:36 +03:00
parent 37f435da93
commit d440f07111
187 changed files with 512 additions and 533 deletions
@@ -37,7 +37,7 @@ public abstract class AbstractClassBuilder implements ClassBuilder {
private final JvmSerializationBindings serializationBindings = new JvmSerializationBindings();
private final List<FileMapping> fileMappings = new ArrayList<FileMapping>();
private final List<FileMapping> fileMappings = new ArrayList<>();
private String sourceName;
@@ -56,7 +56,7 @@ public class AccessorForFunctionDescriptor extends AbstractAccessorForFunctionDe
setSuspend(descriptor.isSuspend());
if (descriptor.getUserData(CoroutineCodegenUtilKt.INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION) != null) {
userDataMap = new LinkedHashMap<UserDataKey<?>, Object>();
userDataMap = new LinkedHashMap<>();
userDataMap.put(
CoroutineCodegenUtilKt.INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION,
descriptor.getUserData(CoroutineCodegenUtilKt.INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION)
@@ -27,9 +27,11 @@ import org.jetbrains.kotlin.load.java.JvmAnnotationNames;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.resolve.AnnotationChecker;
import org.jetbrains.kotlin.resolve.constants.*;
import org.jetbrains.kotlin.resolve.constants.StringValue;
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
import org.jetbrains.kotlin.types.*;
import org.jetbrains.kotlin.types.FlexibleType;
import org.jetbrains.kotlin.types.FlexibleTypesKt;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.types.TypeUtils;
import org.jetbrains.org.objectweb.asm.*;
import java.lang.annotation.*;
@@ -87,7 +89,7 @@ public abstract class AnnotationCodegen {
return;
}
Set<String> annotationDescriptorsAlreadyPresent = new HashSet<String>();
Set<String> annotationDescriptorsAlreadyPresent = new HashSet<>();
Annotations annotations = annotated.getAnnotations();
@@ -200,8 +202,7 @@ public abstract class AnnotationCodegen {
generateAnnotationIfNotPresent(annotationDescriptorsAlreadyPresent, annotationClass);
}
private static final Map<KotlinTarget, ElementType> annotationTargetMap =
new EnumMap<KotlinTarget, ElementType>(KotlinTarget.class);
private static final Map<KotlinTarget, ElementType> annotationTargetMap = new EnumMap<>(KotlinTarget.class);
static {
annotationTargetMap.put(KotlinTarget.CLASS, ElementType.TYPE);
@@ -418,8 +419,7 @@ public abstract class AnnotationCodegen {
value.accept(argumentVisitor, null);
}
private static final Map<KotlinRetention, RetentionPolicy> annotationRetentionMap =
new EnumMap<KotlinRetention, RetentionPolicy>(KotlinRetention.class);
private static final Map<KotlinRetention, RetentionPolicy> annotationRetentionMap = new EnumMap<>(KotlinRetention.class);
static {
annotationRetentionMap.put(KotlinRetention.SOURCE, RetentionPolicy.SOURCE);
@@ -445,7 +445,7 @@ public class AsmUtil {
}
public static void genClosureFields(@NotNull CalculatedClosure closure, ClassBuilder v, KotlinTypeMapper typeMapper) {
List<Pair<String, Type>> allFields = new ArrayList<Pair<String, Type>>();
List<Pair<String, Type>> allFields = new ArrayList<>();
ClassifierDescriptor captureThis = closure.getCaptureThis();
if (captureThis != null) {
@@ -54,7 +54,7 @@ public abstract class ClassBodyCodegen extends MemberCodegen<KtPureClassOrObject
@Override
protected void generateBody() {
List<KtObjectDeclaration> companions = new ArrayList<KtObjectDeclaration>();
List<KtObjectDeclaration> companions = new ArrayList<>();
if (kind != OwnerKind.DEFAULT_IMPLS) {
//generate nested classes first and only then generate class body. It necessary to access to nested CodegenContexts
for (KtDeclaration declaration : myClass.getDeclarations()) {
@@ -42,12 +42,12 @@ import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.getMappingFileName;
public class ClassFileFactory implements OutputFileCollection {
private final GenerationState state;
private final ClassBuilderFactory builderFactory;
private final Map<String, OutAndSourceFileList> generators = new LinkedHashMap<String, OutAndSourceFileList>();
private final Map<String, OutAndSourceFileList> generators = new LinkedHashMap<>();
private boolean isDone = false;
private final Set<File> packagePartSourceFiles = new HashSet<File>();
private final Map<String, PackageParts> partsGroupedByPackage = new LinkedHashMap<String, PackageParts>();
private final Set<File> packagePartSourceFiles = new HashSet<>();
private final Map<String, PackageParts> partsGroupedByPackage = new LinkedHashMap<>();
public ClassFileFactory(@NotNull GenerationState state, @NotNull ClassBuilderFactory builderFactory) {
this.state = state;
@@ -153,7 +153,7 @@ public class ClassFileFactory implements OutputFileCollection {
@NotNull
@TestOnly
public Map<String, String> createTextForEachFile() {
Map<String, String> answer = new LinkedHashMap<String, String>();
Map<String, String> answer = new LinkedHashMap<>();
for (OutputFile file : asList()) {
answer.put(file.getRelativePath(), file.asText());
}
@@ -188,7 +188,7 @@ public class ClassFileFactory implements OutputFileCollection {
@NotNull
private static List<File> toIoFilesIgnoringNonPhysical(@NotNull Collection<? extends PsiFile> psiFiles) {
List<File> result = new ArrayList<File>(psiFiles.size());
List<File> result = new ArrayList<>(psiFiles.size());
for (PsiFile psiFile : psiFiles) {
VirtualFile virtualFile = psiFile.getVirtualFile();
// We ignore non-physical files here, because this code is needed to tell the make what inputs affect which outputs
@@ -100,7 +100,7 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
this.strategy = strategy;
if (samType == null) {
this.superInterfaceTypes = new ArrayList<KotlinType>();
this.superInterfaceTypes = new ArrayList<>();
KotlinType superClassType = null;
for (KotlinType supertype : classDescriptor.getTypeConstructor().getSupertypes()) {
@@ -252,7 +252,7 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
@NotNull
private static FunctionDescriptor createFreeLambdaDescriptor(@NotNull FunctionDescriptor descriptor) {
FunctionDescriptor.CopyBuilder<? extends FunctionDescriptor> builder = descriptor.newCopyBuilder();
List<TypeParameterDescriptor> typeParameters = new ArrayList<TypeParameterDescriptor>(0);
List<TypeParameterDescriptor> typeParameters = new ArrayList<>(0);
builder.setTypeParameters(typeParameters);
DeclarationDescriptor container = descriptor.getContainingDeclaration();
@@ -130,7 +130,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
private final TailRecursionCodegen tailRecursionCodegen;
public final CallGenerator defaultCallGenerator = new CallGenerator.DefaultCallGenerator(this);
private final Stack<BlockStackElement> blockStackElements = new Stack<BlockStackElement>();
private final Stack<BlockStackElement> blockStackElements = new Stack<>();
/*
* When we create a temporary variable to hold some value not to compute it many times
@@ -189,7 +189,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
}
static class FinallyBlockStackElement extends BlockStackElement {
List<Label> gaps = new ArrayList<Label>();
List<Label> gaps = new ArrayList<>();
final KtTryExpression expression;
@@ -571,7 +571,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
// We handle this case separately because otherwise such variable will be out of the frame map after the block ends
List<KtExpression> doWhileStatements = ((KtBlockExpression) body).getStatements();
List<KtExpression> statements = new ArrayList<KtExpression>(doWhileStatements.size() + 1);
List<KtExpression> statements = new ArrayList<>(doWhileStatements.size() + 1);
statements.addAll(doWhileStatements);
statements.add(condition);
@@ -1444,7 +1444,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
}
if (!shouldInlineConstVals && !takeUpConstValsAsConst && compileTimeValue.getUsesVariableAsConstant()) {
Ref<Boolean> containsNonInlinedVals = new Ref<Boolean>(false);
Ref<Boolean> containsNonInlinedVals = new Ref<>(false);
KtVisitor constantChecker = new KtVisitor() {
@Override
public Object visitSimpleNameExpression(@NotNull KtSimpleNameExpression expression, Object data) {
@@ -1648,9 +1648,9 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
.format("Incorrect number of mapped parameters vs arguments: %d < %d for %s",
superMappedTypes.size(), params, classDescriptor);
List<ResolvedValueArgument> valueArguments = new ArrayList<ResolvedValueArgument>(params);
List<ValueParameterDescriptor> valueParameters = new ArrayList<ValueParameterDescriptor>(params);
List<Type> mappedTypes = new ArrayList<Type>(params);
List<ResolvedValueArgument> valueArguments = new ArrayList<>(params);
List<ValueParameterDescriptor> valueParameters = new ArrayList<>(params);
List<Type> mappedTypes = new ArrayList<>(params);
for (ValueParameterDescriptor parameter : superValueParameters) {
ResolvedValueArgument argument = superCall.getValueArguments().get(parameter);
if (!(argument instanceof DefaultValueArgument)) {
@@ -2810,7 +2810,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
DefaultCallArgs defaultArgs =
argumentGenerator.generate(
valueArguments,
new ArrayList<ResolvedValueArgument>(resolvedCall.getValueArguments().values()),
new ArrayList<>(resolvedCall.getValueArguments().values()),
resolvedCall.getResultingDescriptor()
);
@@ -3041,9 +3041,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
TypeParameterDescriptor parameterDescriptor = TypeUtils.getTypeParameterDescriptorOrNull(type);
if (parameterDescriptor == null) return null;
return new Pair<TypeParameterDescriptor, ReificationArgument>(
parameterDescriptor,
new ReificationArgument(parameterDescriptor.getName().asString(), isNullable, arrayDepth));
return new Pair<>(parameterDescriptor, new ReificationArgument(parameterDescriptor.getName().asString(), isNullable, arrayDepth));
}
@NotNull
@@ -4542,9 +4540,9 @@ The "returned" value of try expression with no finally is either the last expres
@NotNull Label blockEnd
) {
List<Label> gapsInBlock =
finallyBlockStackElement != null ? new ArrayList<Label>(finallyBlockStackElement.gaps) : Collections.<Label>emptyList();
finallyBlockStackElement != null ? new ArrayList<>(finallyBlockStackElement.gaps) : Collections.emptyList();
assert gapsInBlock.size() % 2 == 0;
List<Label> blockRegions = new ArrayList<Label>(gapsInBlock.size() + 2);
List<Label> blockRegions = new ArrayList<>(gapsInBlock.size() + 2);
blockRegions.add(blockStart);
blockRegions.addAll(gapsInBlock);
blockRegions.add(blockEnd);
@@ -4809,7 +4807,7 @@ The "returned" value of try expression with no finally is either the last expres
}
public Stack<BlockStackElement> getBlockStackElements() {
return new Stack<BlockStackElement>(blockStackElements);
return new Stack<>(blockStackElements);
}
public void addBlockStackElementsForNonLocalReturns(@NotNull Stack<BlockStackElement> elements, int finallyDepth) {
@@ -28,8 +28,8 @@ import java.util.Comparator;
import java.util.List;
public class FrameMap {
private final TObjectIntHashMap<DeclarationDescriptor> myVarIndex = new TObjectIntHashMap<DeclarationDescriptor>();
private final TObjectIntHashMap<DeclarationDescriptor> myVarSizes = new TObjectIntHashMap<DeclarationDescriptor>();
private final TObjectIntHashMap<DeclarationDescriptor> myVarIndex = new TObjectIntHashMap<>();
private final TObjectIntHashMap<DeclarationDescriptor> myVarSizes = new TObjectIntHashMap<>();
private int myMaxIndex = 0;
public int enter(DeclarationDescriptor descriptor, Type type) {
@@ -81,7 +81,7 @@ public class FrameMap {
}
public void dropTo() {
List<DeclarationDescriptor> descriptorsToDrop = new ArrayList<DeclarationDescriptor>();
List<DeclarationDescriptor> descriptorsToDrop = new ArrayList<>();
TObjectIntIterator<DeclarationDescriptor> iterator = myVarIndex.iterator();
while (iterator.hasNext()) {
iterator.advance();
@@ -35,7 +35,10 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import java.util.*;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isObject;
@@ -88,7 +91,7 @@ public class FunctionReferenceGenerationStrategy extends FunctionGenerationStrat
private final Map<ValueParameterDescriptor, ResolvedValueArgument> argumentMap;
{
argumentMap = new LinkedHashMap<ValueParameterDescriptor, ResolvedValueArgument>(fakeArguments.size());
argumentMap = new LinkedHashMap<>(fakeArguments.size());
int index = 0;
List<ValueParameterDescriptor> parameters = functionDescriptor.getValueParameters();
for (ValueArgument argument : fakeArguments) {
@@ -112,7 +115,7 @@ public class FunctionReferenceGenerationStrategy extends FunctionGenerationStrat
@NotNull
@Override
public List<ResolvedValueArgument> getValueArgumentsByIndex() {
return new ArrayList<ResolvedValueArgument>(argumentMap.values());
return new ArrayList<>(argumentMap.values());
}
@NotNull
@@ -100,8 +100,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
private final DelegationFieldsInfo delegationFieldsInfo;
private final List<Function2<ImplementationBodyCodegen, ClassBuilder, Unit>> additionalTasks =
new ArrayList<Function2<ImplementationBodyCodegen, ClassBuilder, Unit>>();
private final List<Function2<ImplementationBodyCodegen, ClassBuilder, Unit>> additionalTasks = new ArrayList<>();
public ImplementationBodyCodegen(
@NotNull KtPureClassOrObject aClass,
@@ -255,7 +254,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
}
private static final Map<FqName, String> KOTLIN_MARKER_INTERFACES = new HashMap<FqName, String>();
private static final Map<FqName, String> KOTLIN_MARKER_INTERFACES = new HashMap<>();
static {
KOTLIN_MARKER_INTERFACES.put(FQ_NAMES.iterator, "kotlin/jvm/internal/markers/KMappedMarker");
KOTLIN_MARKER_INTERFACES.put(FQ_NAMES.iterable, "kotlin/jvm/internal/markers/KMappedMarker");
@@ -302,8 +301,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
sw.writeSuperclassEnd();
LinkedHashSet<String> superInterfaces = new LinkedHashSet<String>();
Set<String> kotlinMarkerInterfaces = new LinkedHashSet<String>();
LinkedHashSet<String> superInterfaces = new LinkedHashSet<>();
Set<String> kotlinMarkerInterfaces = new LinkedHashSet<>();
for (KotlinType supertype : descriptor.getTypeConstructor().getSupertypes()) {
if (isJvmInterface(supertype.getConstructor().getDeclarationDescriptor())) {
@@ -330,7 +329,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
superInterfaces.addAll(kotlinMarkerInterfaces);
return new JvmClassSignature(classAsmType.getInternalName(), superClassInfo.getType().getInternalName(),
new ArrayList<String>(superInterfaces), sw.makeJavaGenericSignature());
new ArrayList<>(superInterfaces), sw.makeJavaGenericSignature());
}
private void getSuperClass() {
@@ -1089,7 +1088,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
return StackValue.field(type, classAsmType, name, false, StackValue.none());
}
}
private final Map<KtDelegatedSuperTypeEntry, Field> fields = new HashMap<KtDelegatedSuperTypeEntry, Field>();
private final Map<KtDelegatedSuperTypeEntry, Field> fields = new HashMap<>();
@NotNull
public Field getInfo(KtDelegatedSuperTypeEntry specifier) {
@@ -1266,7 +1265,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
private void generateTraitMethods() {
if (isAnnotationOrJvmInterfaceWithoutDefaults(descriptor, state)) return;
List<FunctionDescriptor> restrictedInheritance = new ArrayList<FunctionDescriptor>();
List<FunctionDescriptor> restrictedInheritance = new ArrayList<>();
for (Map.Entry<FunctionDescriptor, FunctionDescriptor> entry : CodegenUtil.getNonPrivateTraitMethods(descriptor).entrySet()) {
FunctionDescriptor interfaceFun = entry.getKey();
//skip java 8 default methods
@@ -1625,7 +1624,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
public void addCompanionObjectPropertyToCopy(@NotNull PropertyDescriptor descriptor, Object defaultValue) {
if (companionObjectPropertiesToCopy == null) {
companionObjectPropertiesToCopy = new ArrayList<PropertyAndDefaultValue>();
companionObjectPropertiesToCopy = new ArrayList<>();
}
companionObjectPropertiesToCopy.add(new PropertyAndDefaultValue(descriptor, defaultValue));
}
@@ -49,8 +49,8 @@ public class KotlinCodegenFacade {
@NotNull GenerationState state,
@NotNull CompilationErrorHandler errorHandler
) {
MultiMap<FqName, KtFile> filesInPackages = new MultiMap<FqName, KtFile>();
MultiMap<FqName, KtFile> filesInMultifileClasses = new MultiMap<FqName, KtFile>();
MultiMap<FqName, KtFile> filesInPackages = new MultiMap<>();
MultiMap<FqName, KtFile> filesInMultifileClasses = new MultiMap<>();
for (KtFile file : files) {
if (file == null) throw new IllegalArgumentException("A null file given for compilation");
@@ -65,13 +65,13 @@ public class KotlinCodegenFacade {
}
}
Set<FqName> obsoleteMultifileClasses = new HashSet<FqName>(state.getObsoleteMultifileClasses());
Set<FqName> obsoleteMultifileClasses = new HashSet<>(state.getObsoleteMultifileClasses());
for (FqName multifileClassFqName : Sets.union(filesInMultifileClasses.keySet(), obsoleteMultifileClasses)) {
doCheckCancelled(state);
generateMultifileClass(state, multifileClassFqName, filesInMultifileClasses.get(multifileClassFqName), errorHandler);
}
Set<FqName> packagesWithObsoleteParts = new HashSet<FqName>(state.getPackagesWithObsoleteParts());
Set<FqName> packagesWithObsoleteParts = new HashSet<>(state.getPackagesWithObsoleteParts());
for (FqName packageFqName : Sets.union(packagesWithObsoleteParts, filesInPackages.keySet())) {
doCheckCancelled(state);
generatePackage(state, packageFqName, filesInPackages.get(packageFqName), errorHandler);
@@ -92,7 +92,7 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
private final JvmFileClassesProvider fileClassesProvider;
private final MemberCodegen<?> parentCodegen;
private final ReifiedTypeParametersUsages reifiedTypeParametersUsages = new ReifiedTypeParametersUsages();
private final Collection<ClassDescriptor> innerClasses = new LinkedHashSet<ClassDescriptor>();
private final Collection<ClassDescriptor> innerClasses = new LinkedHashSet<>();
private ExpressionCodegen clInit;
private NameGenerator inlineNameGenerator;
@@ -579,7 +579,7 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
}
protected void generatePropertyMetadataArrayFieldIfNeeded(@NotNull Type thisAsmType) {
List<KtProperty> delegatedProperties = new ArrayList<KtProperty>();
List<KtProperty> delegatedProperties = new ArrayList<>();
for (KtDeclaration declaration : ((KtDeclarationContainer) element).getDeclarations()) {
if (declaration instanceof KtProperty) {
KtProperty property = (KtProperty) declaration;
@@ -99,7 +99,7 @@ public class PackageCodegenImpl implements PackageCodegen {
boolean generatePackagePart = false;
List<KtClassOrObject> classOrObjects = new ArrayList<KtClassOrObject>();
List<KtClassOrObject> classOrObjects = new ArrayList<>();
for (KtDeclaration declaration : file.getDeclarations()) {
if (declaration.hasModifier(KtTokens.HEADER_KEYWORD)) continue;
@@ -135,7 +135,7 @@ public class PackageCodegenImpl implements PackageCodegen {
@Nullable
private PackageFragmentDescriptor getOnlyPackageFragment(@NotNull FqName expectedPackageFqName) {
SmartList<PackageFragmentDescriptor> fragments = new SmartList<PackageFragmentDescriptor>();
SmartList<PackageFragmentDescriptor> fragments = new SmartList<>();
for (KtFile file : files) {
PackageFragmentDescriptor fragment = state.getBindingContext().get(BindingContext.FILE_TO_PACKAGE_FRAGMENT, file);
assert fragment != null : "package fragment is null for " + file + "\n" + file.getText();
@@ -75,7 +75,7 @@ public class PackagePartCodegen extends MemberCodegen<KtFile> {
}
private void generateAnnotationsForPartClass() {
List<AnnotationDescriptor> fileAnnotationDescriptors = new ArrayList<AnnotationDescriptor>();
List<AnnotationDescriptor> fileAnnotationDescriptors = new ArrayList<>();
for (KtAnnotationEntry annotationEntry : element.getAnnotationEntries()) {
AnnotationDescriptor annotationDescriptor = state.getBindingContext().get(BindingContext.ANNOTATION, annotationEntry);
if (annotationDescriptor != null) {
@@ -103,7 +103,7 @@ public class PackagePartCodegen extends MemberCodegen<KtFile> {
@Override
protected void generateKotlinMetadataAnnotation() {
List<DeclarationDescriptor> members = new ArrayList<DeclarationDescriptor>();
List<DeclarationDescriptor> members = new ArrayList<>();
for (KtDeclaration declaration : element.getDeclarations()) {
if (declaration instanceof KtNamedFunction) {
SimpleFunctionDescriptor functionDescriptor = bindingContext.get(BindingContext.FUNCTION, declaration);
@@ -45,7 +45,7 @@ public abstract class TransformationMethodVisitor extends MethodVisitor {
super(Opcodes.ASM5);
this.delegate = delegate;
this.methodNode = new MethodNode(access, name, desc, signature, exceptions);
this.methodNode.localVariables = new ArrayList<LocalVariableNode>(5);
this.methodNode.localVariables = new ArrayList<>(5);
this.mv = InlineCodegenUtil.wrapWithMaxLocalCalc(methodNode);
}
@@ -70,10 +70,10 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
TokenSet.create(PLUS, MINUS, MUL, DIV, PERC, RANGE, LT, GT, LTEQ, GTEQ, IDENTIFIER)
);
private final Map<String, Integer> anonymousSubclassesCount = new HashMap<String, Integer>();
private final Map<String, Integer> anonymousSubclassesCount = new HashMap<>();
private final Stack<ClassDescriptor> classStack = new Stack<ClassDescriptor>();
private final Stack<String> nameStack = new Stack<String>();
private final Stack<ClassDescriptor> classStack = new Stack<>();
private final Stack<String> nameStack = new Stack<>();
private final BindingTrace bindingTrace;
private final BindingContext bindingContext;
@@ -638,7 +638,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
String currentClassName = getCurrentTopLevelClassOrPackagePartInternalName(expression.getContainingKtFile());
if (bindingContext.get(MAPPINGS_FOR_WHENS_BY_ENUM_IN_CLASS_FILE, currentClassName) == null) {
bindingTrace.record(MAPPINGS_FOR_WHENS_BY_ENUM_IN_CLASS_FILE, currentClassName, new ArrayList<WhenByEnumsMapping>(1));
bindingTrace.record(MAPPINGS_FOR_WHENS_BY_ENUM_IN_CLASS_FILE, currentClassName, new ArrayList<>(1));
}
List<WhenByEnumsMapping> mappings = bindingContext.get(MAPPINGS_FOR_WHENS_BY_ENUM_IN_CLASS_FILE, currentClassName);
@@ -181,7 +181,7 @@ public class CodegenBinding {
) {
Collection<ClassDescriptor> innerClasses = bindingTrace.get(INNER_CLASSES, outer);
if (innerClasses == null) {
innerClasses = new ArrayList<ClassDescriptor>(1);
innerClasses = new ArrayList<>(1);
bindingTrace.record(INNER_CLASSES, outer, innerClasses);
}
innerClasses.add(inner);
@@ -192,14 +192,14 @@ public class CodegenBinding {
// todo: we use Set and add given files but ignoring other scripts because something non-clear kept in binding
// for scripts especially in case of REPL
Set<FqName> names = new HashSet<FqName>();
Set<FqName> names = new HashSet<>();
for (KtFile file : files) {
if (!file.isScript()) {
names.add(file.getPackageFqName());
}
}
Set<KtFile> answer = new HashSet<KtFile>();
Set<KtFile> answer = new HashSet<>();
answer.addAll(files);
for (FqName name : names) {
@@ -209,7 +209,7 @@ public class CodegenBinding {
}
}
List<KtFile> sortedAnswer = new ArrayList<KtFile>(answer);
List<KtFile> sortedAnswer = new ArrayList<>(answer);
sortedAnswer.sort(Comparator.comparing((KtFile file) -> {
VirtualFile virtualFile = file.getVirtualFile();
@@ -234,9 +234,9 @@ public class CodegenBinding {
Collection<ClassDescriptor> innerClasses = bindingContext.get(INNER_CLASSES, outermostClass);
if (innerClasses == null || innerClasses.isEmpty()) return Collections.emptySet();
Set<ClassDescriptor> allInnerClasses = new HashSet<ClassDescriptor>();
Set<ClassDescriptor> allInnerClasses = new HashSet<>();
Deque<ClassDescriptor> stack = new ArrayDeque<ClassDescriptor>(innerClasses);
Deque<ClassDescriptor> stack = new ArrayDeque<>(innerClasses);
do {
ClassDescriptor currentClass = stack.pop();
if (allInnerClasses.add(currentClass)) {
@@ -247,7 +247,8 @@ public class CodegenBinding {
}
}
}
} while (!stack.isEmpty());
}
while (!stack.isEmpty());
return allInnerClasses;
}
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.codegen.binding;
import com.intellij.openapi.util.Pair;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.codegen.StackValue;
import org.jetbrains.kotlin.codegen.context.EnclosedValueDescriptor;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.types.KotlinType;
@@ -140,23 +139,23 @@ public final class MutableClosure implements CalculatedClosure {
private void recordField(String name, Type type) {
if (recordedFields == null) {
recordedFields = new LinkedList<Pair<String, Type>>();
recordedFields = new LinkedList<>();
}
recordedFields.add(new Pair<String, Type>(name, type));
recordedFields.add(new Pair<>(name, type));
}
public void captureVariable(EnclosedValueDescriptor value) {
recordField(value.getFieldName(), value.getType());
if (captureVariables == null) {
captureVariables = new LinkedHashMap<DeclarationDescriptor, EnclosedValueDescriptor>();
captureVariables = new LinkedHashMap<>();
}
captureVariables.put(value.getDescriptor(), value);
}
public void setCapturedParameterOffsetInConstructor(DeclarationDescriptor descriptor, int offset) {
if (parameterOffsetInConstructor == null) {
parameterOffsetInConstructor = new LinkedHashMap<DeclarationDescriptor, Integer>();
parameterOffsetInConstructor = new LinkedHashMap<>();
}
parameterOffsetInConstructor.put(descriptor, offset);
}
@@ -425,10 +425,10 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
boolean setterAccessorRequired
) {
if (accessors == null) {
accessors = new LinkedHashMap<AccessorKey, AccessorForCallableDescriptor<?>>();
accessors = new LinkedHashMap<>();
}
if (propertyAccessorFactories == null) {
propertyAccessorFactories = new LinkedHashMap<AccessorKey, AccessorForPropertyDescriptorFactory>();
propertyAccessorFactories = new LinkedHashMap<>();
}
D descriptor = (D) possiblySubstitutedDescriptor.getOriginal();
@@ -661,7 +661,7 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
private void addChild(@NotNull CodegenContext child) {
if (shouldAddChild(child.contextDescriptor)) {
if (childContexts == null) {
childContexts = new HashMap<DeclarationDescriptor, CodegenContext>();
childContexts = new HashMap<>();
}
DeclarationDescriptor childContextDescriptor = child.getContextDescriptor();
childContexts.put(childContextDescriptor, child);
@@ -32,7 +32,7 @@ import java.util.Map;
public abstract class FieldOwnerContext<T extends DeclarationDescriptor> extends CodegenContext<T> {
//default property name -> map<property descriptor -> bytecode name>
private final Map<String, Map<PropertyDescriptor, String>> fieldNames = new HashMap<String, Map<PropertyDescriptor, String>>();
private final Map<String, Map<PropertyDescriptor, String>> fieldNames = new HashMap<>();
public FieldOwnerContext(
@NotNull T contextDescriptor,
@@ -56,8 +56,7 @@ public abstract class FieldOwnerContext<T extends DeclarationDescriptor> extends
String defaultPropertyName = KotlinTypeMapper.mapDefaultFieldName(descriptor, isDelegated);
Map<PropertyDescriptor, String> descriptor2Name =
fieldNames.computeIfAbsent(defaultPropertyName, unused -> new HashMap<PropertyDescriptor, String>());
Map<PropertyDescriptor, String> descriptor2Name = fieldNames.computeIfAbsent(defaultPropertyName, unused -> new HashMap<>());
String actualName = descriptor2Name.get(descriptor);
if (actualName != null) return actualName;
@@ -37,7 +37,7 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
private final InliningContext inliningContext;
private final Type oldObjectType;
private final boolean isSameModule;
private final Map<String, List<String>> fieldNames = new HashMap<String, List<String>>();
private final Map<String, List<String>> fieldNames = new HashMap<>();
private MethodNode constructor;
private String sourceInfo;
@@ -58,9 +58,9 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
@Override
@NotNull
public InlineResult doTransform(@NotNull FieldRemapper parentRemapper) {
List<InnerClassNode> innerClassNodes = new ArrayList<InnerClassNode>();
List<InnerClassNode> innerClassNodes = new ArrayList<>();
ClassBuilder classBuilder = createRemappingClassBuilderViaFactory(inliningContext);
List<MethodNode> methodsToTransform = new ArrayList<MethodNode>();
List<MethodNode> methodsToTransform = new ArrayList<>();
createClassReader().accept(new ClassVisitor(InlineCodegenUtil.API, classBuilder.getVisitor()) {
@Override
@@ -139,7 +139,7 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
List<CapturedParamInfo> additionalFakeParams =
extractParametersMappingAndPatchConstructor(constructor, allCapturedParamBuilder, constructorParamBuilder,
transformationInfo, parentRemapper);
List<DeferredMethodVisitor> deferringMethods = new ArrayList<DeferredMethodVisitor>();
List<DeferredMethodVisitor> deferringMethods = new ArrayList<>();
generateConstructorAndFields(classBuilder, allCapturedParamBuilder, constructorParamBuilder, parentRemapper, additionalFakeParams);
@@ -243,7 +243,7 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
@NotNull FieldRemapper parentRemapper,
@NotNull List<CapturedParamInfo> constructorAdditionalFakeParams
) {
List<Type> descTypes = new ArrayList<Type>();
List<Type> descTypes = new ArrayList<>();
Parameters constructorParams = constructorInlineBuilder.buildParameters();
int[] capturedIndexes = new int[constructorParams.getParameters().size()];
@@ -364,10 +364,10 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
@NotNull AnonymousObjectTransformationInfo transformationInfo,
@NotNull FieldRemapper parentFieldRemapper
) {
Set<LambdaInfo> capturedLambdas = new LinkedHashSet<LambdaInfo>(); //captured var of inlined parameter
List<CapturedParamInfo> constructorAdditionalFakeParams = new ArrayList<CapturedParamInfo>();
Set<LambdaInfo> capturedLambdas = new LinkedHashSet<>(); //captured var of inlined parameter
List<CapturedParamInfo> constructorAdditionalFakeParams = new ArrayList<>();
Map<Integer, LambdaInfo> indexToLambda = transformationInfo.getLambdasToInline();
Set<Integer> capturedParams = new HashSet<Integer>();
Set<Integer> capturedParams = new HashSet<>();
//load captured parameters and patch instruction list (NB: there is also could be object fields)
AbstractInsnNode cur = constructor.instructions.getFirst();
@@ -436,12 +436,12 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
//For all inlined lambdas add their captured parameters
//TODO: some of such parameters could be skipped - we should perform additional analysis
Map<String, LambdaInfo> capturedLambdasToInline = new HashMap<String, LambdaInfo>(); //captured var of inlined parameter
List<CapturedParamDesc> allRecapturedParameters = new ArrayList<CapturedParamDesc>();
Map<String, LambdaInfo> capturedLambdasToInline = new HashMap<>(); //captured var of inlined parameter
List<CapturedParamDesc> allRecapturedParameters = new ArrayList<>();
boolean addCapturedNotAddOuter =
parentFieldRemapper.isRoot() ||
(parentFieldRemapper instanceof InlinedLambdaRemapper && parentFieldRemapper.getParent().isRoot());
Map<String, CapturedParamInfo> alreadyAdded = new HashMap<String, CapturedParamInfo>();
Map<String, CapturedParamInfo> alreadyAdded = new HashMap<>();
for (LambdaInfo info : capturedLambdas) {
if (addCapturedNotAddOuter) {
for (CapturedParamDesc desc : info.getCapturedVars()) {
@@ -524,7 +524,7 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
@NotNull
private String addUniqueField(@NotNull String name) {
List<String> existNames = fieldNames.computeIfAbsent(name, unused -> new LinkedList<String>());
List<String> existNames = fieldNames.computeIfAbsent(name, unused -> new LinkedList<>());
String suffix = existNames.isEmpty() ? "" : "$" + existNames.size();
String newName = name + suffix;
existNames.add(newName);
@@ -29,7 +29,7 @@ import static org.jetbrains.kotlin.codegen.inline.InlineCodegenUtil.getLoadStore
public class InlineAdapter extends InstructionAdapter {
private final SourceMapper sourceMapper;
private final List<CatchBlock> blocks = new ArrayList<CatchBlock>();
private final List<CatchBlock> blocks = new ArrayList<>();
private boolean isLambdaInlining = false;
private int nextLocalIndex = 0;
@@ -88,7 +88,7 @@ public class InlineCodegen extends CallGenerator {
private final boolean isSameModule;
private final ParametersBuilder invocationParamBuilder = ParametersBuilder.newBuilder();
private final Map<Integer, LambdaInfo> expressionMap = new HashMap<Integer, LambdaInfo>();
private final Map<Integer, LambdaInfo> expressionMap = new HashMap<>();
private final ReifiedTypeInliner reifiedTypeInliner;
@@ -819,7 +819,7 @@ public class InlineCodegen extends CallGenerator {
@NotNull
public static Set<String> getDeclarationLabels(@Nullable PsiElement lambdaOrFun, @NotNull DeclarationDescriptor descriptor) {
Set<String> result = new HashSet<String>();
Set<String> result = new HashSet<>();
if (lambdaOrFun != null) {
Name label = LabelResolver.INSTANCE.getLabelNameIfAny(lambdaOrFun);
@@ -944,8 +944,7 @@ public class InlineCodegen extends CallGenerator {
) {
if (!codegen.hasFinallyBlocks()) return;
Map<AbstractInsnNode, MethodInliner.PointForExternalFinallyBlocks> extensionPoints =
new HashMap<AbstractInsnNode, MethodInliner.PointForExternalFinallyBlocks>();
Map<AbstractInsnNode, MethodInliner.PointForExternalFinallyBlocks> extensionPoints = new HashMap<>();
for (MethodInliner.PointForExternalFinallyBlocks insertPoint : insertPoints) {
extensionPoints.put(insertPoint.beforeIns, insertPoint);
}
@@ -35,8 +35,7 @@ public class InliningContext {
public final ReifiedTypeInliner reifiedTypeInliner;
public final boolean isInliningLambda;
public final boolean classRegeneration;
public final Map<String, AnonymousObjectTransformationInfo> internalNameToAnonymousObjectTransformationInfo =
new HashMap<String, AnonymousObjectTransformationInfo>();
public final Map<String, AnonymousObjectTransformationInfo> internalNameToAnonymousObjectTransformationInfo = new HashMap<>();
private boolean isContinuation;
@@ -67,7 +66,7 @@ public class InliningContext {
@NotNull
public InliningContext subInlineLambda(@NotNull LambdaInfo lambdaInfo) {
Map<String, String> map = new HashMap<String, String>();
Map<String, String> map = new HashMap<>();
map.put(lambdaInfo.getLambdaClassType().getInternalName(), null); //mark lambda inlined
return subInline(nameGenerator.subGenerator("lambda"), map, true);
}
@@ -67,12 +67,12 @@ public class InternalFinallyBlockInliner extends CoveringTryCatchNodeProcessor {
public static void processInlineFunFinallyBlocks(@NotNull MethodNode inlineFun, int lambdaTryCatchBlockNodes, int finallyParamOffset) {
int index = 0;
List<TryCatchBlockNodeInfo> inlineFunTryBlockInfo = new ArrayList<TryCatchBlockNodeInfo>();
List<TryCatchBlockNodeInfo> inlineFunTryBlockInfo = new ArrayList<>();
for (TryCatchBlockNode block : inlineFun.tryCatchBlocks) {
inlineFunTryBlockInfo.add(new TryCatchBlockNodeInfo(block, index++ < lambdaTryCatchBlockNodes));
}
List<LocalVarNodeWrapper> localVars = new ArrayList<LocalVarNodeWrapper>();
List<LocalVarNodeWrapper> localVars = new ArrayList<>();
for (LocalVariableNode var : inlineFun.localVariables) {
localVars.add(new LocalVarNodeWrapper(var));
}
@@ -132,7 +132,7 @@ public class InternalFinallyBlockInliner extends CoveringTryCatchNodeProcessor {
}
List<TryCatchBlockNodeInfo> currentCoveringNodesFromInnermost =
sortTryCatchBlocks(new ArrayList<TryCatchBlockNodeInfo>(getTryBlocksMetaInfo().getCurrentIntervals()));
sortTryCatchBlocks(new ArrayList<>(getTryBlocksMetaInfo().getCurrentIntervals()));
checkCoveringBlocksInvariant(Lists.reverse(currentCoveringNodesFromInnermost));
if (currentCoveringNodesFromInnermost.isEmpty() ||
@@ -285,7 +285,7 @@ public class InternalFinallyBlockInliner extends CoveringTryCatchNodeProcessor {
@NotNull
private static Set<LabelNode> rememberOriginalLabelNodes(@NotNull FinallyBlockInfo finallyInfo) {
Set<LabelNode> labelsInsideFinally = new HashSet<LabelNode>();
Set<LabelNode> labelsInsideFinally = new HashSet<>();
for (AbstractInsnNode currentIns = finallyInfo.startIns; currentIns != finallyInfo.endInsExclusive; currentIns = currentIns.getNext()) {
if (currentIns instanceof LabelNode) {
labelsInsideFinally.add((LabelNode) currentIns);
@@ -305,7 +305,7 @@ public class InternalFinallyBlockInliner extends CoveringTryCatchNodeProcessor {
//copy tryCatchFinallies that totally in finally block
List<TryBlockCluster<TryCatchBlockNodePosition>> clusters = TryBlockClusteringKt.doClustering(tryCatchBlockPresentInFinally);
Map<LabelNode, TryBlockCluster<TryCatchBlockNodePosition>> handler2Cluster = new HashMap<LabelNode, TryBlockCluster<TryCatchBlockNodePosition>>();
Map<LabelNode, TryBlockCluster<TryCatchBlockNodePosition>> handler2Cluster = new HashMap<>();
IntervalMetaInfo<TryCatchBlockNodeInfo> tryBlocksMetaInfo = getTryBlocksMetaInfo();
for (TryBlockCluster<TryCatchBlockNodePosition> cluster : clusters) {
@@ -418,7 +418,7 @@ public class InternalFinallyBlockInliner extends CoveringTryCatchNodeProcessor {
@NotNull TryCatchBlockNodeInfo tryCatchBlock,
@ReadOnly @NotNull List<TryCatchBlockNodeInfo> tryCatchBlocks
) {
List<TryCatchBlockNodeInfo> sameDefaultHandler = new ArrayList<TryCatchBlockNodeInfo>();
List<TryCatchBlockNodeInfo> sameDefaultHandler = new ArrayList<>();
LabelNode defaultHandler = null;
boolean afterStartBlock = false;
for (TryCatchBlockNodeInfo block : tryCatchBlocks) {
@@ -486,8 +486,8 @@ public class InternalFinallyBlockInliner extends CoveringTryCatchNodeProcessor {
@NotNull
private List<TryCatchBlockNodePosition> findTryCatchBlocksInlinedInFinally(@NotNull FinallyBlockInfo finallyInfo) {
List<TryCatchBlockNodePosition> result = new ArrayList<TryCatchBlockNodePosition>();
Map<TryCatchBlockNodeInfo, TryCatchBlockNodePosition> processedBlocks = new HashMap<TryCatchBlockNodeInfo, TryCatchBlockNodePosition>();
List<TryCatchBlockNodePosition> result = new ArrayList<>();
Map<TryCatchBlockNodeInfo, TryCatchBlockNodePosition> processedBlocks = new HashMap<>();
for (AbstractInsnNode curInstr = finallyInfo.startIns; curInstr != finallyInfo.endInsExclusive; curInstr = curInstr.getNext()) {
if (!(curInstr instanceof LabelNode)) continue;
@@ -128,7 +128,7 @@ public class LambdaInfo implements LabelOwner {
public List<CapturedParamDesc> getCapturedVars() {
//lazy initialization cause it would be calculated after object creation
if (capturedVars == null) {
capturedVars = new ArrayList<CapturedParamDesc>();
capturedVars = new ArrayList<>();
if (closure.getCaptureThis() != null) {
Type type = typeMapper.mapType(closure.getCaptureThis());
@@ -104,9 +104,8 @@ public class MaxStackFrameSizeAndLocalsCalculator extends MaxLocalsCalculator {
*/
private int maxStack;
private final Collection<ExceptionHandler> exceptionHandlers = new LinkedList<ExceptionHandler>();
private final Map<Label, LabelWrapper> labelWrappersMap = new HashMap<Label, LabelWrapper>();
private final Collection<ExceptionHandler> exceptionHandlers = new LinkedList<>();
private final Map<Label, LabelWrapper> labelWrappersMap = new HashMap<>();
public MaxStackFrameSizeAndLocalsCalculator(int api, int access, String descriptor, MethodVisitor mv) {
super(api, access, descriptor, mv);
@@ -331,8 +330,8 @@ public class MaxStackFrameSizeAndLocalsCalculator extends MaxLocalsCalculator {
* stack sizes of these blocks.
*/
int max = 0;
Stack<LabelWrapper> stack = new Stack<LabelWrapper>();
Set<LabelWrapper> pushed = new HashSet<LabelWrapper>();
Stack<LabelWrapper> stack = new Stack<>();
Set<LabelWrapper> pushed = new HashSet<>();
stack.push(firstLabel);
pushed.add(firstLabel);
@@ -411,7 +410,7 @@ public class MaxStackFrameSizeAndLocalsCalculator extends MaxLocalsCalculator {
private static class LabelWrapper {
private final Label label;
private LabelWrapper nextLabel = null;
private final Collection<ControlFlowEdge> successors = new LinkedList<ControlFlowEdge>();
private final Collection<ControlFlowEdge> successors = new LinkedList<>();
private int outputStackMax = 0;
private int inputStackSize = 0;
@@ -29,7 +29,7 @@ public class NameGenerator {
private int nextLambdaIndex = 1;
private int nextWhenIndex = 1;
private final Map<String, NameGenerator> subGenerators = new HashMap<String, NameGenerator>();
private final Map<String, NameGenerator> subGenerators = new HashMap<>();
public NameGenerator(String generatorClass) {
this.generatorClass = generatorClass;
@@ -23,7 +23,7 @@ import java.util.Iterator;
import java.util.Set;
public class RedundantBoxedValuesCollection implements Iterable<BoxedValueDescriptor> {
private final Set<BoxedValueDescriptor> safeToDeleteValues = new HashSet<BoxedValueDescriptor>();
private final Set<BoxedValueDescriptor> safeToDeleteValues = new HashSet<>();
public void add(@NotNull BoxedValueDescriptor descriptor) {
safeToDeleteValues.add(descriptor);
@@ -153,7 +153,7 @@ public class RedundantBoxingMethodTransformer extends MethodTransformer {
@NotNull MethodNode node,
@NotNull Frame<BasicValue>[] frames
) {
List<BasicValue> values = new ArrayList<BasicValue>();
List<BasicValue> values = new ArrayList<>();
InsnList insnList = node.instructions;
int from = insnList.indexOf(localVariableNode.start) + 1;
int to = insnList.indexOf(localVariableNode.end) - 1;
@@ -192,7 +192,7 @@ public class RedundantBoxingMethodTransformer extends MethodTransformer {
@NotNull
private static int[] buildVariablesRemapping(@NotNull RedundantBoxedValuesCollection values, @NotNull MethodNode node) {
Set<Integer> doubleSizedVars = new HashSet<Integer>();
Set<Integer> doubleSizedVars = new HashSet<>();
for (BoxedValueDescriptor valueDescriptor : values) {
if (valueDescriptor.isDoubleSize()) {
doubleSizedVars.addAll(valueDescriptor.getVariablesIndexes());
@@ -41,7 +41,7 @@ public abstract class MethodTransformer {
@NotNull MethodNode node,
@NotNull Interpreter<V> interpreter
) {
return runAnalyzer(new Analyzer<V>(interpreter), internalClassName, node);
return runAnalyzer(new Analyzer<>(interpreter), internalClassName, node);
}
public abstract void transform(@NotNull String internalClassName, @NotNull MethodNode methodNode);
@@ -40,7 +40,7 @@ public final class JvmSerializationBindings {
@NotNull
public static <K, V> SerializationMappingSlice<K, V> create() {
return new SerializationMappingSlice<K, V>();
return new SerializationMappingSlice<>();
}
}
@@ -51,7 +51,7 @@ public final class JvmSerializationBindings {
@NotNull
public static <K> SerializationMappingSetSlice<K> create() {
return new SerializationMappingSetSlice<K>();
return new SerializationMappingSetSlice<>();
}
}
@@ -49,7 +49,7 @@ public class BothSignatureWriter extends JvmSignatureWriter {
this.signatureVisitor = new CheckSignatureAdapter(mode.asmType, signatureWriter);
}
private final Stack<SignatureVisitor> visitors = new Stack<SignatureVisitor>();
private final Stack<SignatureVisitor> visitors = new Stack<>();
private void push(SignatureVisitor visitor) {
visitors.push(visitor);
@@ -32,7 +32,7 @@ import java.util.List;
public class JvmSignatureWriter extends JvmDescriptorTypeWriter<Type> {
private final List<JvmMethodParameterSignature> kotlinParameterTypes = new ArrayList<JvmMethodParameterSignature>();
private final List<JvmMethodParameterSignature> kotlinParameterTypes = new ArrayList<>();
private Type jvmReturnType;
@@ -149,7 +149,7 @@ public class JvmSignatureWriter extends JvmDescriptorTypeWriter<Type> {
@NotNull
public JvmMethodGenericSignature makeJvmMethodSignature(@NotNull String name) {
List<Type> types = new ArrayList<Type>(kotlinParameterTypes.size());
List<Type> types = new ArrayList<>(kotlinParameterTypes.size());
for (JvmMethodParameterSignature parameter : kotlinParameterTypes) {
types.add(parameter.getAsmType());
}
@@ -28,7 +28,7 @@ import java.util.Set;
public class MappingsClassesForWhenByEnum {
private final GenerationState state;
private final Set<String> generatedMappingClasses = new HashSet<String>();
private final Set<String> generatedMappingClasses = new HashSet<>();
private final MappingClassesForWhenByEnumCodegen mappingsCodegen;
public MappingsClassesForWhenByEnum(@NotNull GenerationState state) {
@@ -55,12 +55,10 @@ public class StringSwitchCodegen extends SwitchCodegen {
if (!transitionsTable.containsKey(hashCode)) {
transitionsTable.put(hashCode, new Label());
hashCodesToStringAndEntryLabel.put(hashCode, new ArrayList<Pair<String, Label>>());
hashCodesToStringAndEntryLabel.put(hashCode, new ArrayList<>());
}
hashCodesToStringAndEntryLabel.get(hashCode).add(
new Pair<String, Label>(((StringValue) constant).getValue(), entryLabel)
);
hashCodesToStringAndEntryLabel.get(hashCode).add(new Pair<>(((StringValue) constant).getValue(), entryLabel));
}
@Override
@@ -43,8 +43,8 @@ abstract public class SwitchCodegen {
protected final Type resultType;
protected final InstructionAdapter v;
protected final NavigableMap<Integer, Label> transitionsTable = new TreeMap<Integer, Label>();
protected final List<Label> entryLabels = new ArrayList<Label>();
protected final NavigableMap<Integer, Label> transitionsTable = new TreeMap<>();
protected final List<Label> entryLabels = new ArrayList<>();
protected Label elseLabel = new Label();
protected Label endLabel = new Label();
protected Label defaultLabel;
@@ -66,7 +66,7 @@ public class SwitchCodegenUtil {
@NotNull BindingContext bindingContext,
boolean shouldInlineConstVals
) {
List<ConstantValue<?>> result = new ArrayList<ConstantValue<?>>();
List<ConstantValue<?>> result = new ArrayList<>();
for (KtWhenEntry entry : expression.getEntries()) {
addConstantsFromEntry(result, entry, bindingContext, shouldInlineConstVals);
@@ -97,7 +97,7 @@ public class SwitchCodegenUtil {
@NotNull BindingContext bindingContext,
boolean shouldInlineConstVals
) {
List<ConstantValue<?>> result = new ArrayList<ConstantValue<?>>();
List<ConstantValue<?>> result = new ArrayList<>();
addConstantsFromEntry(result, entry, bindingContext, shouldInlineConstVals);
return result;
}
@@ -27,7 +27,7 @@ public class WhenByEnumsMapping {
public static final String MAPPING_ARRAY_FIELD_PREFIX = "$EnumSwitchMapping$";
public static final String MAPPINGS_CLASS_NAME_POSTFIX = "$WhenMappings";
private final Map<EnumValue, Integer> map = new LinkedHashMap<EnumValue, Integer>();
private final Map<EnumValue, Integer> map = new LinkedHashMap<>();
private final ClassDescriptor enumClassDescriptor;
private final String outerClassInternalNameForExpression;
private final String mappingsClassInternalName;