Use Java 7+ diamond operator in compiler modules
This commit is contained in:
@@ -124,7 +124,7 @@ public class CheckerTestUtil {
|
||||
@Nullable List<DeclarationDescriptor> dynamicCallDescriptors,
|
||||
@Nullable String platform
|
||||
) {
|
||||
List<ActualDiagnostic> diagnostics = new ArrayList<ActualDiagnostic>();
|
||||
List<ActualDiagnostic> diagnostics = new ArrayList<>();
|
||||
for (Diagnostic diagnostic : bindingContext.getDiagnostics().all()) {
|
||||
if (PsiTreeUtil.isAncestor(root, diagnostic.getPsiElement(), false)) {
|
||||
diagnostics.add(new ActualDiagnostic(diagnostic, platform));
|
||||
@@ -148,7 +148,7 @@ public class CheckerTestUtil {
|
||||
@Nullable List<DeclarationDescriptor> dynamicCallDescriptors,
|
||||
@Nullable String platform
|
||||
) {
|
||||
List<ActualDiagnostic> debugAnnotations = new ArrayList<ActualDiagnostic>();
|
||||
List<ActualDiagnostic> debugAnnotations = new ArrayList<>();
|
||||
|
||||
DebugInfoUtil.markDebugAnnotations(root, bindingContext, new DebugInfoUtil.DebugInfoReporter() {
|
||||
@Override
|
||||
@@ -214,7 +214,7 @@ public class CheckerTestUtil {
|
||||
Collection<ActualDiagnostic> actual,
|
||||
DiagnosticDiffCallbacks callbacks
|
||||
) {
|
||||
Map<ActualDiagnostic, TextDiagnostic> diagnosticToExpectedDiagnostic = new HashMap<ActualDiagnostic, TextDiagnostic>();
|
||||
Map<ActualDiagnostic, TextDiagnostic> diagnosticToExpectedDiagnostic = new HashMap<>();
|
||||
|
||||
assertSameFile(actual);
|
||||
|
||||
@@ -358,7 +358,7 @@ public class CheckerTestUtil {
|
||||
public static String parseDiagnosedRanges(String text, List<DiagnosedRange> result) {
|
||||
Matcher matcher = RANGE_START_OR_END_PATTERN.matcher(text);
|
||||
|
||||
Stack<DiagnosedRange> opened = new Stack<DiagnosedRange>();
|
||||
Stack<DiagnosedRange> opened = new Stack<>();
|
||||
|
||||
int offsetCompensation = 0;
|
||||
|
||||
@@ -405,7 +405,7 @@ public class CheckerTestUtil {
|
||||
if (!diagnostics.isEmpty()) {
|
||||
List<DiagnosticDescriptor> diagnosticDescriptors = getSortedDiagnosticDescriptors(diagnostics);
|
||||
|
||||
Stack<DiagnosticDescriptor> opened = new Stack<DiagnosticDescriptor>();
|
||||
Stack<DiagnosticDescriptor> opened = new Stack<>();
|
||||
ListIterator<DiagnosticDescriptor> iterator = diagnosticDescriptors.listIterator();
|
||||
DiagnosticDescriptor currentDescriptor = iterator.next();
|
||||
|
||||
@@ -623,7 +623,7 @@ public class CheckerTestUtil {
|
||||
}
|
||||
|
||||
public Map<ActualDiagnostic, TextDiagnostic> getTextDiagnosticsMap() {
|
||||
Map<ActualDiagnostic, TextDiagnostic> diagnosticMap = new HashMap<ActualDiagnostic, TextDiagnostic>();
|
||||
Map<ActualDiagnostic, TextDiagnostic> diagnosticMap = new HashMap<>();
|
||||
for (ActualDiagnostic diagnostic : diagnostics) {
|
||||
diagnosticMap.put(diagnostic, TextDiagnostic.asTextDiagnostic(diagnostic));
|
||||
}
|
||||
@@ -700,7 +700,7 @@ public class CheckerTestUtil {
|
||||
return new TextDiagnostic(name, platform, null);
|
||||
}
|
||||
|
||||
List<String> parsedParameters = new SmartList<String>();
|
||||
List<String> parsedParameters = new SmartList<>();
|
||||
Matcher parametersMatcher = INDIVIDUAL_PARAMETER_PATTERN.matcher(parameters);
|
||||
while (parametersMatcher.find())
|
||||
parsedParameters.add(unescape(parametersMatcher.group().trim()));
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.util.*;
|
||||
public class CompilerConfiguration {
|
||||
public static CompilerConfiguration EMPTY = new CompilerConfiguration();
|
||||
|
||||
private final Map<Key, Object> map = new HashMap<Key, Object>();
|
||||
private final Map<Key, Object> map = new HashMap<>();
|
||||
private boolean readOnly = false;
|
||||
|
||||
static {
|
||||
|
||||
@@ -29,7 +29,7 @@ public class CompilerConfigurationKey<T> {
|
||||
|
||||
@NotNull
|
||||
public static <T> CompilerConfigurationKey<T> create(@NotNull @NonNls String name) {
|
||||
return new CompilerConfigurationKey<T>(name);
|
||||
return new CompilerConfigurationKey<>(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,11 +30,11 @@ public class DiagnosticFactory0<E extends PsiElement> extends DiagnosticFactoryW
|
||||
}
|
||||
|
||||
public static <T extends PsiElement> DiagnosticFactory0<T> create(Severity severity, PositioningStrategy<? super T> positioningStrategy) {
|
||||
return new DiagnosticFactory0<T>(severity, positioningStrategy);
|
||||
return new DiagnosticFactory0<>(severity, positioningStrategy);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public SimpleDiagnostic<E> on(@NotNull E element) {
|
||||
return new SimpleDiagnostic<E>(element, this, getSeverity());
|
||||
return new SimpleDiagnostic<>(element, this, getSeverity());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class DiagnosticFactory1<E extends PsiElement, A> extends DiagnosticFactoryWithPsiElement<E, DiagnosticWithParameters1<E, A>> {
|
||||
@NotNull
|
||||
public ParametrizedDiagnostic<E> on(@NotNull E element, @NotNull A argument) {
|
||||
return new DiagnosticWithParameters1<E, A>(element, argument, this, getSeverity());
|
||||
return new DiagnosticWithParameters1<>(element, argument, this, getSeverity());
|
||||
}
|
||||
|
||||
protected DiagnosticFactory1(Severity severity, PositioningStrategy<? super E> positioningStrategy) {
|
||||
@@ -30,7 +30,7 @@ public class DiagnosticFactory1<E extends PsiElement, A> extends DiagnosticFacto
|
||||
}
|
||||
|
||||
public static <T extends PsiElement, A> DiagnosticFactory1<T, A> create(Severity severity, PositioningStrategy<? super T> positioningStrategy) {
|
||||
return new DiagnosticFactory1<T, A>(severity, positioningStrategy);
|
||||
return new DiagnosticFactory1<>(severity, positioningStrategy);
|
||||
}
|
||||
|
||||
public static <T extends PsiElement, A> DiagnosticFactory1<T, A> create(Severity severity) {
|
||||
|
||||
@@ -23,7 +23,7 @@ public class DiagnosticFactory2<E extends PsiElement, A, B> extends DiagnosticFa
|
||||
|
||||
@NotNull
|
||||
public ParametrizedDiagnostic<E> on(@NotNull E element, @NotNull A a, @NotNull B b) {
|
||||
return new DiagnosticWithParameters2<E, A, B>(element, a, b, this, getSeverity());
|
||||
return new DiagnosticWithParameters2<>(element, a, b, this, getSeverity());
|
||||
}
|
||||
|
||||
private DiagnosticFactory2(Severity severity, PositioningStrategy<? super E> positioningStrategy) {
|
||||
@@ -31,11 +31,11 @@ public class DiagnosticFactory2<E extends PsiElement, A, B> extends DiagnosticFa
|
||||
}
|
||||
|
||||
public static <T extends PsiElement, A, B> DiagnosticFactory2<T, A, B> create(Severity severity, PositioningStrategy<? super T> positioningStrategy) {
|
||||
return new DiagnosticFactory2<T, A, B>(severity, positioningStrategy);
|
||||
return new DiagnosticFactory2<>(severity, positioningStrategy);
|
||||
}
|
||||
|
||||
public static <T extends PsiElement, A, B> DiagnosticFactory2<T, A, B> create(Severity severity) {
|
||||
return new DiagnosticFactory2<T, A, B>(severity, PositioningStrategies.DEFAULT);
|
||||
return new DiagnosticFactory2<>(severity, PositioningStrategies.DEFAULT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,11 +30,11 @@ public class DiagnosticFactory3<E extends PsiElement, A, B, C> extends Diagnosti
|
||||
}
|
||||
|
||||
public static <T extends PsiElement, A, B, C> DiagnosticFactory3<T, A, B, C> create(Severity severity, PositioningStrategy<? super T> positioningStrategy) {
|
||||
return new DiagnosticFactory3<T, A, B, C>(severity, positioningStrategy);
|
||||
return new DiagnosticFactory3<>(severity, positioningStrategy);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ParametrizedDiagnostic<E> on(@NotNull E element, @NotNull A a, @NotNull B b, @NotNull C c) {
|
||||
return new DiagnosticWithParameters3<E, A, B, C>(element, a, b, c, this, getSeverity());
|
||||
return new DiagnosticWithParameters3<>(element, a, b, c, this, getSeverity());
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ public class DefaultErrorMessages {
|
||||
private static final MappedExtensionProvider<Extension, List<DiagnosticFactoryToRendererMap>> RENDERER_MAPS = MappedExtensionProvider.create(
|
||||
Extension.EP_NAME,
|
||||
extensions -> {
|
||||
List<DiagnosticFactoryToRendererMap> result = new ArrayList<DiagnosticFactoryToRendererMap>(extensions.size() + 1);
|
||||
List<DiagnosticFactoryToRendererMap> result = new ArrayList<>(extensions.size() + 1);
|
||||
for (Extension extension : extensions) {
|
||||
result.add(extension.getMap());
|
||||
}
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class DiagnosticFactoryToRendererMap {
|
||||
private final Map<DiagnosticFactory<?>, DiagnosticRenderer<?>> map = new HashMap<DiagnosticFactory<?>, DiagnosticRenderer<?>>();
|
||||
private final Map<DiagnosticFactory<?>, DiagnosticRenderer<?>> map = new HashMap<>();
|
||||
private boolean immutable = false;
|
||||
|
||||
// TO catch EA-75872
|
||||
|
||||
+1
-1
@@ -225,7 +225,7 @@ public class TabledDescriptorRenderer {
|
||||
|
||||
@NotNull
|
||||
protected static RenderingContext computeRenderingContext(@NotNull TableRenderer table) {
|
||||
ArrayList<Object> toRender = new ArrayList<Object>();
|
||||
ArrayList<Object> toRender = new ArrayList<>();
|
||||
for (TableRow row : table.rows) {
|
||||
if (row instanceof DescriptorRow) {
|
||||
toRender.add(((DescriptorRow) row).descriptor);
|
||||
|
||||
@@ -18,13 +18,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.lexer;
|
||||
|
||||
import java.util.*;
|
||||
import com.intellij.lexer.*;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.lexer.FlexLexer;
|
||||
import com.intellij.psi.TokenType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.containers.Stack;
|
||||
import org.jetbrains.kotlin.lexer.KotlinLexerException;
|
||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||
|
||||
|
||||
/**
|
||||
@@ -649,7 +646,7 @@ class _JetLexer implements FlexLexer {
|
||||
}
|
||||
}
|
||||
|
||||
private final Stack<State> states = new Stack<State>();
|
||||
private final Stack<State> states = new Stack<>();
|
||||
private int lBraceCount;
|
||||
|
||||
private int commentStart;
|
||||
|
||||
@@ -33,7 +33,7 @@ import java.util.Map;
|
||||
import static org.jetbrains.kotlin.lexer.KtTokens.*;
|
||||
|
||||
/*package*/ abstract class AbstractKotlinParsing {
|
||||
private static final Map<String, KtKeywordToken> SOFT_KEYWORD_TEXTS = new HashMap<String, KtKeywordToken>();
|
||||
private static final Map<String, KtKeywordToken> SOFT_KEYWORD_TEXTS = new HashMap<>();
|
||||
|
||||
static {
|
||||
for (IElementType type : KtTokens.SOFT_KEYWORDS.getTypes()) {
|
||||
@@ -302,7 +302,7 @@ import static org.jetbrains.kotlin.lexer.KtTokens.*;
|
||||
|
||||
protected int matchTokenStreamPredicate(TokenStreamPattern pattern) {
|
||||
PsiBuilder.Marker currentPosition = mark();
|
||||
Stack<IElementType> opens = new Stack<IElementType>();
|
||||
Stack<IElementType> opens = new Stack<>();
|
||||
int openAngleBrackets = 0;
|
||||
int openBraces = 0;
|
||||
int openParentheses = 0;
|
||||
|
||||
@@ -237,7 +237,7 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing {
|
||||
public static final TokenSet ALL_OPERATIONS;
|
||||
|
||||
static {
|
||||
Set<IElementType> operations = new HashSet<IElementType>();
|
||||
Set<IElementType> operations = new HashSet<>();
|
||||
Precedence[] values = Precedence.values();
|
||||
for (Precedence precedence : values) {
|
||||
operations.addAll(Arrays.asList(precedence.getOperations().getTypes()));
|
||||
@@ -247,9 +247,9 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing {
|
||||
|
||||
static {
|
||||
IElementType[] operations = OPERATIONS.getTypes();
|
||||
Set<IElementType> opSet = new HashSet<IElementType>(Arrays.asList(operations));
|
||||
Set<IElementType> opSet = new HashSet<>(Arrays.asList(operations));
|
||||
IElementType[] usedOperations = ALL_OPERATIONS.getTypes();
|
||||
Set<IElementType> usedSet = new HashSet<IElementType>(Arrays.asList(usedOperations));
|
||||
Set<IElementType> usedSet = new HashSet<>(Arrays.asList(usedOperations));
|
||||
|
||||
if (opSet.size() > usedSet.size()) {
|
||||
opSet.removeAll(usedSet);
|
||||
|
||||
+2
-2
@@ -31,9 +31,9 @@ import static org.jetbrains.kotlin.lexer.KtTokens.*;
|
||||
|
||||
public class SemanticWhitespaceAwarePsiBuilderImpl extends PsiBuilderAdapter implements SemanticWhitespaceAwarePsiBuilder {
|
||||
private final TokenSet complexTokens = TokenSet.create(SAFE_ACCESS, ELVIS, EXCLEXCL);
|
||||
private final Stack<Boolean> joinComplexTokens = new Stack<Boolean>();
|
||||
private final Stack<Boolean> joinComplexTokens = new Stack<>();
|
||||
|
||||
private final Stack<Boolean> newlinesEnabled = new Stack<Boolean>();
|
||||
private final Stack<Boolean> newlinesEnabled = new Stack<>();
|
||||
|
||||
private final PsiBuilderImpl delegateImpl;
|
||||
|
||||
|
||||
@@ -108,8 +108,8 @@ public class KtPsiUtil {
|
||||
|
||||
@NotNull
|
||||
public static Set<KtElement> findRootExpressions(@NotNull Collection<KtElement> unreachableElements) {
|
||||
Set<KtElement> rootElements = new HashSet<KtElement>();
|
||||
Set<KtElement> shadowedElements = new HashSet<KtElement>();
|
||||
Set<KtElement> rootElements = new HashSet<>();
|
||||
Set<KtElement> shadowedElements = new HashSet<>();
|
||||
KtVisitorVoid shadowAllChildren = new KtVisitorVoid() {
|
||||
@Override
|
||||
public void visitKtElement(@NotNull KtElement element) {
|
||||
|
||||
+2
-3
@@ -29,14 +29,13 @@ import java.io.IOException;
|
||||
|
||||
public class KtPlaceHolderStubElementType<T extends KtElementImplStub<? extends StubElement<?>>> extends
|
||||
KtStubElementType<KotlinPlaceHolderStub<T>, T> {
|
||||
|
||||
public KtPlaceHolderStubElementType(@NotNull @NonNls String debugName, @NotNull Class<T> psiClass) {
|
||||
super(debugName, psiClass, KotlinPlaceHolderStub.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public KotlinPlaceHolderStub<T> createStub(@NotNull T psi, StubElement parentStub) {
|
||||
return new KotlinPlaceHolderStubImpl<T>(parentStub, this);
|
||||
return new KotlinPlaceHolderStubImpl<>(parentStub, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -47,6 +46,6 @@ public class KtPlaceHolderStubElementType<T extends KtElementImplStub<? extends
|
||||
@NotNull
|
||||
@Override
|
||||
public KotlinPlaceHolderStub<T> deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
|
||||
return new KotlinPlaceHolderStubImpl<T>(parentStub, this);
|
||||
return new KotlinPlaceHolderStubImpl<>(parentStub, this);
|
||||
}
|
||||
}
|
||||
|
||||
+25
-25
@@ -31,89 +31,89 @@ public interface KtStubElementTypes {
|
||||
KtClassElementType ENUM_ENTRY = new KtClassElementType("ENUM_ENTRY");
|
||||
KtObjectElementType OBJECT_DECLARATION = new KtObjectElementType("OBJECT_DECLARATION");
|
||||
KtPlaceHolderStubElementType<KtClassInitializer> CLASS_INITIALIZER =
|
||||
new KtPlaceHolderStubElementType<KtClassInitializer>("CLASS_INITIALIZER", KtClassInitializer.class);
|
||||
new KtPlaceHolderStubElementType<>("CLASS_INITIALIZER", KtClassInitializer.class);
|
||||
KtPlaceHolderStubElementType<KtSecondaryConstructor> SECONDARY_CONSTRUCTOR =
|
||||
new KtPlaceHolderStubElementType<KtSecondaryConstructor>("SECONDARY_CONSTRUCTOR", KtSecondaryConstructor.class);
|
||||
new KtPlaceHolderStubElementType<>("SECONDARY_CONSTRUCTOR", KtSecondaryConstructor.class);
|
||||
KtPlaceHolderStubElementType<KtPrimaryConstructor> PRIMARY_CONSTRUCTOR =
|
||||
new KtPlaceHolderStubElementType<KtPrimaryConstructor>("PRIMARY_CONSTRUCTOR", KtPrimaryConstructor.class);
|
||||
new KtPlaceHolderStubElementType<>("PRIMARY_CONSTRUCTOR", KtPrimaryConstructor.class);
|
||||
|
||||
KtParameterElementType VALUE_PARAMETER = new KtParameterElementType("VALUE_PARAMETER");
|
||||
KtPlaceHolderStubElementType<KtParameterList> VALUE_PARAMETER_LIST =
|
||||
new KtPlaceHolderStubElementType<KtParameterList>("VALUE_PARAMETER_LIST", KtParameterList.class);
|
||||
new KtPlaceHolderStubElementType<>("VALUE_PARAMETER_LIST", KtParameterList.class);
|
||||
|
||||
KtTypeParameterElementType TYPE_PARAMETER = new KtTypeParameterElementType("TYPE_PARAMETER");
|
||||
KtPlaceHolderStubElementType<KtTypeParameterList> TYPE_PARAMETER_LIST =
|
||||
new KtPlaceHolderStubElementType<KtTypeParameterList>("TYPE_PARAMETER_LIST", KtTypeParameterList.class);
|
||||
new KtPlaceHolderStubElementType<>("TYPE_PARAMETER_LIST", KtTypeParameterList.class);
|
||||
|
||||
KtAnnotationEntryElementType ANNOTATION_ENTRY = new KtAnnotationEntryElementType("ANNOTATION_ENTRY");
|
||||
KtPlaceHolderStubElementType<KtAnnotation> ANNOTATION =
|
||||
new KtPlaceHolderStubElementType<KtAnnotation>("ANNOTATION", KtAnnotation.class);
|
||||
new KtPlaceHolderStubElementType<>("ANNOTATION", KtAnnotation.class);
|
||||
|
||||
KtAnnotationUseSiteTargetElementType ANNOTATION_TARGET = new KtAnnotationUseSiteTargetElementType("ANNOTATION_TARGET");
|
||||
|
||||
KtPlaceHolderStubElementType<KtClassBody> CLASS_BODY =
|
||||
new KtPlaceHolderStubElementType<KtClassBody>("CLASS_BODY", KtClassBody.class);
|
||||
new KtPlaceHolderStubElementType<>("CLASS_BODY", KtClassBody.class);
|
||||
|
||||
KtPlaceHolderStubElementType<KtImportList> IMPORT_LIST =
|
||||
new KtPlaceHolderStubElementType<KtImportList>("IMPORT_LIST", KtImportList.class);
|
||||
new KtPlaceHolderStubElementType<>("IMPORT_LIST", KtImportList.class);
|
||||
|
||||
KtPlaceHolderStubElementType<KtFileAnnotationList> FILE_ANNOTATION_LIST =
|
||||
new KtPlaceHolderStubElementType<KtFileAnnotationList>("FILE_ANNOTATION_LIST", KtFileAnnotationList.class);
|
||||
new KtPlaceHolderStubElementType<>("FILE_ANNOTATION_LIST", KtFileAnnotationList.class);
|
||||
|
||||
KtImportDirectiveElementType IMPORT_DIRECTIVE = new KtImportDirectiveElementType("IMPORT_DIRECTIVE");
|
||||
|
||||
KtPlaceHolderStubElementType<KtPackageDirective> PACKAGE_DIRECTIVE =
|
||||
new KtPlaceHolderStubElementType<KtPackageDirective>("PACKAGE_DIRECTIVE", KtPackageDirective.class);
|
||||
new KtPlaceHolderStubElementType<>("PACKAGE_DIRECTIVE", KtPackageDirective.class);
|
||||
|
||||
KtModifierListElementType<KtDeclarationModifierList> MODIFIER_LIST =
|
||||
new KtModifierListElementType<KtDeclarationModifierList>("MODIFIER_LIST", KtDeclarationModifierList.class);
|
||||
new KtModifierListElementType<>("MODIFIER_LIST", KtDeclarationModifierList.class);
|
||||
|
||||
KtPlaceHolderStubElementType<KtTypeConstraintList> TYPE_CONSTRAINT_LIST =
|
||||
new KtPlaceHolderStubElementType<KtTypeConstraintList>("TYPE_CONSTRAINT_LIST", KtTypeConstraintList.class);
|
||||
new KtPlaceHolderStubElementType<>("TYPE_CONSTRAINT_LIST", KtTypeConstraintList.class);
|
||||
|
||||
KtPlaceHolderStubElementType<KtTypeConstraint> TYPE_CONSTRAINT =
|
||||
new KtPlaceHolderStubElementType<KtTypeConstraint>("TYPE_CONSTRAINT", KtTypeConstraint.class);
|
||||
new KtPlaceHolderStubElementType<>("TYPE_CONSTRAINT", KtTypeConstraint.class);
|
||||
|
||||
KtPlaceHolderStubElementType<KtNullableType> NULLABLE_TYPE =
|
||||
new KtPlaceHolderStubElementType<KtNullableType>("NULLABLE_TYPE", KtNullableType.class);
|
||||
new KtPlaceHolderStubElementType<>("NULLABLE_TYPE", KtNullableType.class);
|
||||
|
||||
KtPlaceHolderStubElementType<KtTypeReference> TYPE_REFERENCE =
|
||||
new KtPlaceHolderStubElementType<KtTypeReference>("TYPE_REFERENCE", KtTypeReference.class);
|
||||
new KtPlaceHolderStubElementType<>("TYPE_REFERENCE", KtTypeReference.class);
|
||||
|
||||
KtUserTypeElementType USER_TYPE = new KtUserTypeElementType("USER_TYPE");
|
||||
KtPlaceHolderStubElementType<KtDynamicType> DYNAMIC_TYPE =
|
||||
new KtPlaceHolderStubElementType<KtDynamicType>("DYNAMIC_TYPE", KtDynamicType.class);
|
||||
new KtPlaceHolderStubElementType<>("DYNAMIC_TYPE", KtDynamicType.class);
|
||||
|
||||
KtPlaceHolderStubElementType<KtFunctionType> FUNCTION_TYPE =
|
||||
new KtPlaceHolderStubElementType<KtFunctionType>("FUNCTION_TYPE", KtFunctionType.class);
|
||||
new KtPlaceHolderStubElementType<>("FUNCTION_TYPE", KtFunctionType.class);
|
||||
|
||||
KtTypeProjectionElementType TYPE_PROJECTION = new KtTypeProjectionElementType("TYPE_PROJECTION");
|
||||
|
||||
KtPlaceHolderStubElementType<KtFunctionTypeReceiver> FUNCTION_TYPE_RECEIVER =
|
||||
new KtPlaceHolderStubElementType<KtFunctionTypeReceiver>("FUNCTION_TYPE_RECEIVER", KtFunctionTypeReceiver.class);
|
||||
new KtPlaceHolderStubElementType<>("FUNCTION_TYPE_RECEIVER", KtFunctionTypeReceiver.class);
|
||||
|
||||
KtNameReferenceExpressionElementType REFERENCE_EXPRESSION = new KtNameReferenceExpressionElementType("REFERENCE_EXPRESSION");
|
||||
KtDotQualifiedExpressionElementType DOT_QUALIFIED_EXPRESSION = new KtDotQualifiedExpressionElementType("DOT_QUALIFIED_EXPRESSION");
|
||||
KtEnumEntrySuperClassReferenceExpressionElementType
|
||||
ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION = new KtEnumEntrySuperClassReferenceExpressionElementType("ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION");
|
||||
KtPlaceHolderStubElementType<KtTypeArgumentList> TYPE_ARGUMENT_LIST =
|
||||
new KtPlaceHolderStubElementType<KtTypeArgumentList>("TYPE_ARGUMENT_LIST", KtTypeArgumentList.class);
|
||||
new KtPlaceHolderStubElementType<>("TYPE_ARGUMENT_LIST", KtTypeArgumentList.class);
|
||||
|
||||
KtPlaceHolderStubElementType<KtSuperTypeList> SUPER_TYPE_LIST =
|
||||
new KtPlaceHolderStubElementType<KtSuperTypeList>("SUPER_TYPE_LIST", KtSuperTypeList.class);
|
||||
new KtPlaceHolderStubElementType<>("SUPER_TYPE_LIST", KtSuperTypeList.class);
|
||||
|
||||
KtPlaceHolderStubElementType<KtInitializerList> INITIALIZER_LIST =
|
||||
new KtPlaceHolderStubElementType<KtInitializerList>("INITIALIZER_LIST", KtInitializerList.class);
|
||||
new KtPlaceHolderStubElementType<>("INITIALIZER_LIST", KtInitializerList.class);
|
||||
|
||||
KtPlaceHolderStubElementType<KtDelegatedSuperTypeEntry> DELEGATED_SUPER_TYPE_ENTRY =
|
||||
new KtPlaceHolderStubElementType<KtDelegatedSuperTypeEntry>("DELEGATED_SUPER_TYPE_ENTRY", KtDelegatedSuperTypeEntry.class);
|
||||
new KtPlaceHolderStubElementType<>("DELEGATED_SUPER_TYPE_ENTRY", KtDelegatedSuperTypeEntry.class);
|
||||
|
||||
KtPlaceHolderStubElementType<KtSuperTypeCallEntry> SUPER_TYPE_CALL_ENTRY =
|
||||
new KtPlaceHolderStubElementType<KtSuperTypeCallEntry>("SUPER_TYPE_CALL_ENTRY", KtSuperTypeCallEntry.class);
|
||||
new KtPlaceHolderStubElementType<>("SUPER_TYPE_CALL_ENTRY", KtSuperTypeCallEntry.class);
|
||||
KtPlaceHolderStubElementType<KtSuperTypeEntry> SUPER_TYPE_ENTRY =
|
||||
new KtPlaceHolderStubElementType<KtSuperTypeEntry>("SUPER_TYPE_ENTRY", KtSuperTypeEntry.class);
|
||||
new KtPlaceHolderStubElementType<>("SUPER_TYPE_ENTRY", KtSuperTypeEntry.class);
|
||||
KtPlaceHolderStubElementType<KtConstructorCalleeExpression> CONSTRUCTOR_CALLEE =
|
||||
new KtPlaceHolderStubElementType<KtConstructorCalleeExpression>("CONSTRUCTOR_CALLEE", KtConstructorCalleeExpression.class);
|
||||
new KtPlaceHolderStubElementType<>("CONSTRUCTOR_CALLEE", KtConstructorCalleeExpression.class);
|
||||
|
||||
KtScriptElementType SCRIPT = new KtScriptElementType("SCRIPT");
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public class AnalyzingUtils {
|
||||
}
|
||||
|
||||
public static List<PsiErrorElement> getSyntaxErrorRanges(@NotNull PsiElement root) {
|
||||
List<PsiErrorElement> r = new ArrayList<PsiErrorElement>();
|
||||
List<PsiErrorElement> r = new ArrayList<>();
|
||||
root.acceptChildren(new PsiErrorElementVisitor() {
|
||||
@Override
|
||||
public void visitErrorElement(@NotNull PsiErrorElement element) {
|
||||
|
||||
@@ -79,7 +79,7 @@ public class AnnotationResolverImpl extends AnnotationResolver {
|
||||
boolean shouldResolveArguments
|
||||
) {
|
||||
if (annotationEntryElements.isEmpty()) return Annotations.Companion.getEMPTY();
|
||||
List<AnnotationWithTarget> result = new ArrayList<AnnotationWithTarget>(0);
|
||||
List<AnnotationWithTarget> result = new ArrayList<>(0);
|
||||
|
||||
for (KtAnnotationEntry entryElement : annotationEntryElements) {
|
||||
AnnotationDescriptor descriptor = trace.get(BindingContext.ANNOTATION, entryElement);
|
||||
|
||||
@@ -97,10 +97,10 @@ public interface BindingContext {
|
||||
|
||||
WritableSlice<KtTypeReference, KotlinType> TYPE = Slices.createSimpleSlice();
|
||||
WritableSlice<KtTypeReference, KotlinType> ABBREVIATED_TYPE = Slices.createSimpleSlice();
|
||||
WritableSlice<KtExpression, KotlinTypeInfo> EXPRESSION_TYPE_INFO = new BasicWritableSlice<KtExpression, KotlinTypeInfo>(DO_NOTHING);
|
||||
WritableSlice<KtExpression, DataFlowInfo> DATA_FLOW_INFO_BEFORE = new BasicWritableSlice<KtExpression, DataFlowInfo>(DO_NOTHING);
|
||||
WritableSlice<KtExpression, KotlinType> EXPECTED_EXPRESSION_TYPE = new BasicWritableSlice<KtExpression, KotlinType>(DO_NOTHING);
|
||||
WritableSlice<KtFunction, KotlinType> EXPECTED_RETURN_TYPE = new BasicWritableSlice<KtFunction, KotlinType>(DO_NOTHING);
|
||||
WritableSlice<KtExpression, KotlinTypeInfo> EXPRESSION_TYPE_INFO = new BasicWritableSlice<>(DO_NOTHING);
|
||||
WritableSlice<KtExpression, DataFlowInfo> DATA_FLOW_INFO_BEFORE = new BasicWritableSlice<>(DO_NOTHING);
|
||||
WritableSlice<KtExpression, KotlinType> EXPECTED_EXPRESSION_TYPE = new BasicWritableSlice<>(DO_NOTHING);
|
||||
WritableSlice<KtFunction, KotlinType> EXPECTED_RETURN_TYPE = new BasicWritableSlice<>(DO_NOTHING);
|
||||
WritableSlice<KtExpression, DataFlowInfo> DATAFLOW_INFO_AFTER_CONDITION = Slices.createSimpleSlice();
|
||||
WritableSlice<VariableDescriptor, DataFlowValue> BOUND_INITIALIZER_VALUE = Slices.createSimpleSlice();
|
||||
WritableSlice<KtExpression, LeakingThisDescriptor> LEAKING_THIS = Slices.createSimpleSlice();
|
||||
@@ -108,26 +108,24 @@ public interface BindingContext {
|
||||
/**
|
||||
* A qualifier corresponds to a receiver expression (if any). For 'A.B' qualifier is recorded for 'A'.
|
||||
*/
|
||||
WritableSlice<KtExpression, Qualifier> QUALIFIER = new BasicWritableSlice<KtExpression, Qualifier>(DO_NOTHING);
|
||||
WritableSlice<KtExpression, Qualifier> QUALIFIER = new BasicWritableSlice<>(DO_NOTHING);
|
||||
|
||||
WritableSlice<KtExpression, DoubleColonLHS> DOUBLE_COLON_LHS = new BasicWritableSlice<KtExpression, DoubleColonLHS>(DO_NOTHING);
|
||||
WritableSlice<KtExpression, DoubleColonLHS> DOUBLE_COLON_LHS = new BasicWritableSlice<>(DO_NOTHING);
|
||||
|
||||
WritableSlice<KtSuperExpression, KotlinType> THIS_TYPE_FOR_SUPER_EXPRESSION =
|
||||
new BasicWritableSlice<KtSuperExpression, KotlinType>(DO_NOTHING);
|
||||
WritableSlice<KtSuperExpression, KotlinType> THIS_TYPE_FOR_SUPER_EXPRESSION = new BasicWritableSlice<>(DO_NOTHING);
|
||||
|
||||
WritableSlice<KtReferenceExpression, DeclarationDescriptor> REFERENCE_TARGET =
|
||||
new BasicWritableSlice<KtReferenceExpression, DeclarationDescriptor>(DO_NOTHING);
|
||||
WritableSlice<KtReferenceExpression, DeclarationDescriptor> REFERENCE_TARGET = new BasicWritableSlice<>(DO_NOTHING);
|
||||
// if 'A' really means 'A.Companion' then this slice stores class descriptor for A, REFERENCE_TARGET stores descriptor Companion in this case
|
||||
WritableSlice<KtReferenceExpression, ClassifierDescriptorWithTypeParameters> SHORT_REFERENCE_TO_COMPANION_OBJECT =
|
||||
new BasicWritableSlice<KtReferenceExpression, ClassifierDescriptorWithTypeParameters>(DO_NOTHING);
|
||||
new BasicWritableSlice<>(DO_NOTHING);
|
||||
|
||||
WritableSlice<Call, ResolvedCall<?>> RESOLVED_CALL = new BasicWritableSlice<Call, ResolvedCall<?>>(DO_NOTHING);
|
||||
WritableSlice<Call, ResolvedCall<?>> RESOLVED_CALL = new BasicWritableSlice<>(DO_NOTHING);
|
||||
WritableSlice<Call, TailRecursionKind> TAIL_RECURSION_CALL = Slices.createSimpleSlice();
|
||||
WritableSlice<KtElement, ConstraintSystemCompleter> CONSTRAINT_SYSTEM_COMPLETER = new BasicWritableSlice<KtElement, ConstraintSystemCompleter>(DO_NOTHING);
|
||||
WritableSlice<KtElement, Call> CALL = new BasicWritableSlice<KtElement, Call>(DO_NOTHING);
|
||||
WritableSlice<KtElement, ConstraintSystemCompleter> CONSTRAINT_SYSTEM_COMPLETER = new BasicWritableSlice<>(DO_NOTHING);
|
||||
WritableSlice<KtElement, Call> CALL = new BasicWritableSlice<>(DO_NOTHING);
|
||||
|
||||
WritableSlice<KtExpression, Collection<? extends DeclarationDescriptor>> AMBIGUOUS_REFERENCE_TARGET =
|
||||
new BasicWritableSlice<KtExpression, Collection<? extends DeclarationDescriptor>>(DO_NOTHING);
|
||||
new BasicWritableSlice<>(DO_NOTHING);
|
||||
|
||||
WritableSlice<KtExpression, ResolvedCall<FunctionDescriptor>> LOOP_RANGE_ITERATOR_RESOLVED_CALL = Slices.createSimpleSlice();
|
||||
|
||||
@@ -151,9 +149,9 @@ public interface BindingContext {
|
||||
|
||||
WritableSlice<KtCollectionLiteralExpression, ResolvedCall<FunctionDescriptor>> COLLECTION_LITERAL_CALL = Slices.createSimpleSlice();
|
||||
|
||||
WritableSlice<KtExpression, ExplicitSmartCasts> SMARTCAST = new BasicWritableSlice<KtExpression, ExplicitSmartCasts>(DO_NOTHING);
|
||||
WritableSlice<KtExpression, ExplicitSmartCasts> SMARTCAST = new BasicWritableSlice<>(DO_NOTHING);
|
||||
WritableSlice<KtExpression, Boolean> SMARTCAST_NULL = Slices.createSimpleSlice();
|
||||
WritableSlice<KtExpression, ImplicitSmartCasts> IMPLICIT_RECEIVER_SMARTCAST = new BasicWritableSlice<KtExpression, ImplicitSmartCasts>(DO_NOTHING);
|
||||
WritableSlice<KtExpression, ImplicitSmartCasts> IMPLICIT_RECEIVER_SMARTCAST = new BasicWritableSlice<>(DO_NOTHING);
|
||||
|
||||
WritableSlice<KtWhenExpression, Boolean> EXHAUSTIVE_WHEN = Slices.createSimpleSlice();
|
||||
WritableSlice<KtWhenExpression, Boolean> IMPLICIT_EXHAUSTIVE_WHEN = Slices.createSimpleSlice();
|
||||
@@ -173,8 +171,8 @@ public interface BindingContext {
|
||||
WritableSlice<KtElement, Boolean> USED_AS_RESULT_OF_LAMBDA = Slices.createSimpleSetSlice();
|
||||
WritableSlice<KtElement, Boolean> UNREACHABLE_CODE = Slices.createSimpleSetSlice();
|
||||
|
||||
WritableSlice<VariableDescriptor, CaptureKind> CAPTURED_IN_CLOSURE = new BasicWritableSlice<VariableDescriptor, CaptureKind>(DO_NOTHING);
|
||||
WritableSlice<KtDeclaration, PreliminaryDeclarationVisitor> PRELIMINARY_VISITOR = new BasicWritableSlice<KtDeclaration, PreliminaryDeclarationVisitor>(DO_NOTHING);
|
||||
WritableSlice<VariableDescriptor, CaptureKind> CAPTURED_IN_CLOSURE = new BasicWritableSlice<>(DO_NOTHING);
|
||||
WritableSlice<KtDeclaration, PreliminaryDeclarationVisitor> PRELIMINARY_VISITOR = new BasicWritableSlice<>(DO_NOTHING);
|
||||
|
||||
WritableSlice<Box<DeferredType>, Boolean> DEFERRED_TYPE = Slices.createCollectiveSetSlice();
|
||||
|
||||
@@ -255,8 +253,7 @@ public interface BindingContext {
|
||||
WritableSlice<ValueParameterDescriptor, FunctionDescriptor> DATA_CLASS_COMPONENT_FUNCTION = Slices.createSimpleSlice();
|
||||
WritableSlice<ClassDescriptor, FunctionDescriptor> DATA_CLASS_COPY_FUNCTION = Slices.createSimpleSlice();
|
||||
|
||||
WritableSlice<FqNameUnsafe, ClassDescriptor> FQNAME_TO_CLASS_DESCRIPTOR =
|
||||
new BasicWritableSlice<FqNameUnsafe, ClassDescriptor>(DO_NOTHING, true);
|
||||
WritableSlice<FqNameUnsafe, ClassDescriptor> FQNAME_TO_CLASS_DESCRIPTOR = new BasicWritableSlice<>(DO_NOTHING, true);
|
||||
WritableSlice<KtFile, PackageFragmentDescriptor> FILE_TO_PACKAGE_FRAGMENT = Slices.createSimpleSlice();
|
||||
WritableSlice<FqName, Collection<KtFile>> PACKAGE_TO_FILES = Slices.createSimpleSlice();
|
||||
|
||||
|
||||
@@ -218,7 +218,7 @@ public class BindingContextUtils {
|
||||
.getSourceFromDescriptor(containingFunctionDescriptor) : null;
|
||||
}
|
||||
|
||||
return new Pair<FunctionDescriptor, PsiElement>(containingFunctionDescriptor, containingFunction);
|
||||
return new Pair<>(containingFunctionDescriptor, containingFunction);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -447,7 +447,7 @@ public class BodyResolver {
|
||||
currentDescriptor = (ClassDescriptor) currentDescriptor.getContainingDeclaration();
|
||||
if (DescriptorUtils.isSealedClass(currentDescriptor)) {
|
||||
if (parentEnumOrSealed.isEmpty()) {
|
||||
parentEnumOrSealed = new HashSet<TypeConstructor>();
|
||||
parentEnumOrSealed = new HashSet<>();
|
||||
}
|
||||
parentEnumOrSealed.add(currentDescriptor.getTypeConstructor());
|
||||
}
|
||||
@@ -891,7 +891,7 @@ public class BodyResolver {
|
||||
return;
|
||||
}
|
||||
// +1 is a work around against new Queue(0).addLast(...) bug // stepan.koltsov@ 2011-11-21
|
||||
Queue<DeferredType> queue = new Queue<DeferredType>(deferredTypes.size() + 1);
|
||||
Queue<DeferredType> queue = new Queue<>(deferredTypes.size() + 1);
|
||||
trace.addHandler(DEFERRED_TYPE, (deferredTypeKeyDeferredTypeWritableSlice, key, value) -> queue.addLast(key.getData()));
|
||||
for (Box<DeferredType> deferredType : deferredTypes) {
|
||||
queue.addLast(deferredType.getData());
|
||||
|
||||
@@ -425,7 +425,7 @@ public class DescriptorResolver {
|
||||
containingDescriptor instanceof TypeAliasDescriptor
|
||||
: "This method should be called for functions, properties, or type aliases, got " + containingDescriptor;
|
||||
|
||||
List<TypeParameterDescriptorImpl> result = new ArrayList<TypeParameterDescriptorImpl>();
|
||||
List<TypeParameterDescriptorImpl> result = new ArrayList<>();
|
||||
for (int i = 0, typeParametersSize = typeParameters.size(); i < typeParametersSize; i++) {
|
||||
KtTypeParameter typeParameter = typeParameters.get(i);
|
||||
result.add(resolveTypeParameterForDescriptor(containingDescriptor, scopeForAnnotationsResolve, typeParameter, i, trace));
|
||||
@@ -558,8 +558,8 @@ public class DescriptorResolver {
|
||||
public static void checkUpperBoundTypes(@NotNull BindingTrace trace, @NotNull List<UpperBoundCheckRequest> requests) {
|
||||
if (requests.isEmpty()) return;
|
||||
|
||||
Set<Name> classBoundEncountered = new HashSet<Name>();
|
||||
Set<Pair<Name, TypeConstructor>> allBounds = new HashSet<Pair<Name, TypeConstructor>>();
|
||||
Set<Name> classBoundEncountered = new HashSet<>();
|
||||
Set<Pair<Name, TypeConstructor>> allBounds = new HashSet<>();
|
||||
|
||||
for (UpperBoundCheckRequest request : requests) {
|
||||
Name typeParameterName = request.typeParameterName;
|
||||
@@ -567,7 +567,7 @@ public class DescriptorResolver {
|
||||
KtTypeReference upperBoundElement = request.upperBound;
|
||||
|
||||
if (!upperBound.isError()) {
|
||||
if (!allBounds.add(new Pair<Name, TypeConstructor>(typeParameterName, upperBound.getConstructor()))) {
|
||||
if (!allBounds.add(new Pair<>(typeParameterName, upperBound.getConstructor()))) {
|
||||
trace.report(REPEATED_BOUND.on(upperBoundElement));
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -39,7 +39,7 @@ public class TopDownAnalysisContext implements BodiesResolveContext {
|
||||
|
||||
private final Map<KtClassOrObject, ClassDescriptorWithResolutionScopes> classes = Maps.newLinkedHashMap();
|
||||
private final Map<KtAnonymousInitializer, ClassDescriptorWithResolutionScopes> anonymousInitializers = Maps.newLinkedHashMap();
|
||||
private final Set<KtFile> files = new LinkedHashSet<KtFile>();
|
||||
private final Set<KtFile> files = new LinkedHashSet<>();
|
||||
private final Map<KtSecondaryConstructor, ClassConstructorDescriptor> secondaryConstructors = Maps.newLinkedHashMap();
|
||||
|
||||
private final Map<KtNamedFunction, SimpleFunctionDescriptor> functions = Maps.newLinkedHashMap();
|
||||
|
||||
@@ -317,8 +317,8 @@ public class ArgumentTypeResolver {
|
||||
List<KtParameter> valueParameters = function.getValueParameters();
|
||||
TemporaryBindingTrace temporaryTrace = TemporaryBindingTrace.create(
|
||||
trace, "trace to resolve function literal parameter types");
|
||||
List<KotlinType> parameterTypes = new ArrayList<KotlinType>(valueParameters.size());
|
||||
List<Name> parameterNames = new ArrayList<Name>(valueParameters.size());
|
||||
List<KotlinType> parameterTypes = new ArrayList<>(valueParameters.size());
|
||||
List<Name> parameterNames = new ArrayList<>(valueParameters.size());
|
||||
for (KtParameter parameter : valueParameters) {
|
||||
parameterTypes.add(resolveTypeRefWithDefault(parameter.getTypeReference(), scope, temporaryTrace, DONT_CARE));
|
||||
Name name = parameter.getNameAsName();
|
||||
|
||||
@@ -295,7 +295,7 @@ public class CallResolver {
|
||||
KotlinType expectedType = NO_EXPECTED_TYPE;
|
||||
if (calleeExpression instanceof KtLambdaExpression) {
|
||||
int parameterNumber = ((KtLambdaExpression) calleeExpression).getValueParameters().size();
|
||||
List<KotlinType> parameterTypes = new ArrayList<KotlinType>(parameterNumber);
|
||||
List<KotlinType> parameterTypes = new ArrayList<>(parameterNumber);
|
||||
for (int i = 0; i < parameterNumber; i++) {
|
||||
parameterTypes.add(NO_EXPECTED_TYPE);
|
||||
}
|
||||
@@ -452,8 +452,7 @@ public class CallResolver {
|
||||
@NotNull BasicCallResolutionContext context
|
||||
) {
|
||||
if (!(superType.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor)) {
|
||||
return new Pair<Collection<ResolutionCandidate<ConstructorDescriptor>>, BasicCallResolutionContext>(
|
||||
Collections.<ResolutionCandidate<ConstructorDescriptor>>emptyList(), context);
|
||||
return new Pair<>(Collections.<ResolutionCandidate<ConstructorDescriptor>>emptyList(), context);
|
||||
}
|
||||
|
||||
// If any constructor has type parameter (currently it only can be true for ones from Java), try to infer arguments for them
|
||||
@@ -470,7 +469,7 @@ public class CallResolver {
|
||||
context.scope, context.call, superType, !anyConstructorHasDeclaredTypeParameters
|
||||
);
|
||||
|
||||
return new Pair<Collection<ResolutionCandidate<ConstructorDescriptor>>, BasicCallResolutionContext>(candidates, context);
|
||||
return new Pair<>(candidates, context);
|
||||
}
|
||||
|
||||
private static boolean anyConstructorHasDeclaredTypeParameters(@Nullable ClassifierDescriptor classDescriptor) {
|
||||
@@ -495,10 +494,9 @@ public class CallResolver {
|
||||
|
||||
Set<ResolutionCandidate<FunctionDescriptor>> candidates = Collections.singleton(candidate);
|
||||
|
||||
ResolutionTask<FunctionDescriptor> resolutionTask =
|
||||
new ResolutionTask<FunctionDescriptor>(
|
||||
new NewResolutionOldInference.ResolutionKind.GivenCandidates<FunctionDescriptor>(), null, candidates
|
||||
);
|
||||
ResolutionTask<FunctionDescriptor> resolutionTask = new ResolutionTask<>(
|
||||
new NewResolutionOldInference.ResolutionKind.GivenCandidates<>(), null, candidates
|
||||
);
|
||||
|
||||
return doResolveCallOrGetCachedResults(basicCallResolutionContext, resolutionTask, tracing);
|
||||
});
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ public class ValueArgumentsToParametersMapper {
|
||||
@NotNull MutableResolvedCall<D> candidateCall
|
||||
) {
|
||||
//return new ValueArgumentsToParametersMapper().process(call, tracing, candidateCall, unmappedArguments);
|
||||
Processor<D> processor = new Processor<D>(call, candidateCall, tracing);
|
||||
Processor<D> processor = new Processor<>(call, candidateCall, tracing);
|
||||
processor.process();
|
||||
return processor.status;
|
||||
}
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ import static org.jetbrains.kotlin.resolve.inline.InlineUtil.checkNonLocalReturn
|
||||
|
||||
class InlineChecker implements CallChecker {
|
||||
private final FunctionDescriptor descriptor;
|
||||
private final Set<CallableDescriptor> inlinableParameters = new LinkedHashSet<CallableDescriptor>();
|
||||
private final Set<CallableDescriptor> inlinableParameters = new LinkedHashSet<>();
|
||||
private final EffectiveVisibility inlineFunEffectiveVisibility;
|
||||
private final boolean isEffectivelyPrivateApiFunction;
|
||||
|
||||
|
||||
+3
-3
@@ -72,7 +72,7 @@ public final class CallCandidateResolutionContext<D extends CallableDescriptor>
|
||||
@NotNull TracingStrategy tracing, @NotNull Call call,
|
||||
@NotNull CandidateResolveMode candidateResolveMode
|
||||
) {
|
||||
return new CallCandidateResolutionContext<D>(
|
||||
return new CallCandidateResolutionContext<>(
|
||||
candidateCall, tracing, trace, context.scope, call, context.expectedType,
|
||||
context.dataFlowInfo, context.contextDependency, context.checkArguments,
|
||||
context.resolutionResultsCache, context.dataFlowInfoForArguments,
|
||||
@@ -85,7 +85,7 @@ public final class CallCandidateResolutionContext<D extends CallableDescriptor>
|
||||
public static <D extends CallableDescriptor> CallCandidateResolutionContext<D> createForCallBeingAnalyzed(
|
||||
@NotNull MutableResolvedCall<D> candidateCall, @NotNull BasicCallResolutionContext context, @NotNull TracingStrategy tracing
|
||||
) {
|
||||
return new CallCandidateResolutionContext<D>(
|
||||
return new CallCandidateResolutionContext<>(
|
||||
candidateCall, tracing, context.trace, context.scope, context.call, context.expectedType,
|
||||
context.dataFlowInfo, context.contextDependency, context.checkArguments, context.resolutionResultsCache,
|
||||
context.dataFlowInfoForArguments, context.statementFilter,
|
||||
@@ -106,7 +106,7 @@ public final class CallCandidateResolutionContext<D extends CallableDescriptor>
|
||||
@NotNull CallPosition callPosition,
|
||||
@NotNull Function1<KtExpression, KtExpression> expressionContextProvider
|
||||
) {
|
||||
return new CallCandidateResolutionContext<D>(
|
||||
return new CallCandidateResolutionContext<>(
|
||||
candidateCall, tracing, trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments,
|
||||
resolutionResultsCache, dataFlowInfoForArguments, statementFilter,
|
||||
candidateResolveMode, isAnnotationContext, isDebuggerContext, collectAllCandidates, callPosition, expressionContextProvider);
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ public class ConstraintsUtil {
|
||||
context.put(typeVariable.getOriginalTypeParameter().getTypeConstructor(), typeProjection);
|
||||
}
|
||||
}
|
||||
Collection<TypeSubstitutor> typeSubstitutors = new ArrayList<TypeSubstitutor>(substitutionContexts.size());
|
||||
Collection<TypeSubstitutor> typeSubstitutors = new ArrayList<>(substitutionContexts.size());
|
||||
for (Map<TypeConstructor, TypeProjection> context : substitutionContexts) {
|
||||
typeSubstitutors.add(TypeSubstitutor.create(context));
|
||||
}
|
||||
|
||||
+2
-2
@@ -44,7 +44,7 @@ public class DataFlowInfoForArgumentsImpl extends MutableDataFlowInfoForArgument
|
||||
ValueArgument argument = iterator.next();
|
||||
if (prev != null) {
|
||||
if (nextArgument == null) {
|
||||
nextArgument = new HashMap<ValueArgument, ValueArgument>();
|
||||
nextArgument = new HashMap<>();
|
||||
}
|
||||
nextArgument.put(prev, argument);
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public class DataFlowInfoForArgumentsImpl extends MutableDataFlowInfoForArgument
|
||||
ValueArgument next = nextArgument == null ? null : nextArgument.get(valueArgument);
|
||||
if (next != null) {
|
||||
if (infoMap == null) {
|
||||
infoMap = new HashMap<ValueArgument, DataFlowInfo>();
|
||||
infoMap = new HashMap<>();
|
||||
}
|
||||
infoMap.put(next, dataFlowInfo);
|
||||
return;
|
||||
|
||||
+4
-4
@@ -53,7 +53,7 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements MutableRe
|
||||
@NotNull TracingStrategy tracing,
|
||||
@NotNull MutableDataFlowInfoForArguments dataFlowInfoForArguments
|
||||
) {
|
||||
return new ResolvedCallImpl<D>(candidate, trace, tracing, dataFlowInfoForArguments);
|
||||
return new ResolvedCallImpl<>(candidate, trace, tracing, dataFlowInfoForArguments);
|
||||
}
|
||||
|
||||
private final Call call;
|
||||
@@ -212,7 +212,7 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements MutableRe
|
||||
List<ValueParameterDescriptor> substitutedParameters = resultingDescriptor.getValueParameters();
|
||||
|
||||
Collection<Map.Entry<ValueParameterDescriptor, ResolvedValueArgument>> valueArgumentsBeforeSubstitution =
|
||||
new SmartList<Map.Entry<ValueParameterDescriptor, ResolvedValueArgument>>(valueArguments.entrySet());
|
||||
new SmartList<>(valueArguments.entrySet());
|
||||
|
||||
valueArguments.clear();
|
||||
|
||||
@@ -223,7 +223,7 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements MutableRe
|
||||
}
|
||||
|
||||
Collection<Map.Entry<ValueArgument, ArgumentMatchImpl>> unsubstitutedArgumentMappings =
|
||||
new SmartList<Map.Entry<ValueArgument, ArgumentMatchImpl>>(argumentToParameterMap.entrySet());
|
||||
new SmartList<>(argumentToParameterMap.entrySet());
|
||||
|
||||
argumentToParameterMap.clear();
|
||||
for (Map.Entry<ValueArgument, ArgumentMatchImpl> entry : unsubstitutedArgumentMappings) {
|
||||
@@ -283,7 +283,7 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements MutableRe
|
||||
@Nullable
|
||||
@Override
|
||||
public List<ResolvedValueArgument> getValueArgumentsByIndex() {
|
||||
List<ResolvedValueArgument> arguments = new ArrayList<ResolvedValueArgument>(candidateDescriptor.getValueParameters().size());
|
||||
List<ResolvedValueArgument> arguments = new ArrayList<>(candidateDescriptor.getValueParameters().size());
|
||||
for (int i = 0; i < candidateDescriptor.getValueParameters().size(); ++i) {
|
||||
arguments.add(null);
|
||||
}
|
||||
|
||||
+8
-8
@@ -29,33 +29,33 @@ import java.util.Collections;
|
||||
public class OverloadResolutionResultsImpl<D extends CallableDescriptor> implements OverloadResolutionResults<D> {
|
||||
|
||||
public static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> success(@NotNull MutableResolvedCall<D> candidate) {
|
||||
return new OverloadResolutionResultsImpl<D>(Code.SUCCESS, Collections.singleton(candidate));
|
||||
return new OverloadResolutionResultsImpl<>(Code.SUCCESS, Collections.singleton(candidate));
|
||||
}
|
||||
|
||||
public static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> nameNotFound() {
|
||||
OverloadResolutionResultsImpl<D> results = new OverloadResolutionResultsImpl<D>(
|
||||
OverloadResolutionResultsImpl<D> results = new OverloadResolutionResultsImpl<>(
|
||||
Code.NAME_NOT_FOUND, Collections.<MutableResolvedCall<D>>emptyList());
|
||||
results.setAllCandidates(Collections.<ResolvedCall<D>>emptyList());
|
||||
return results;
|
||||
}
|
||||
|
||||
public static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> singleFailedCandidate(MutableResolvedCall<D> candidate) {
|
||||
return new OverloadResolutionResultsImpl<D>(Code.SINGLE_CANDIDATE_ARGUMENT_MISMATCH, Collections.singleton(candidate));
|
||||
return new OverloadResolutionResultsImpl<>(Code.SINGLE_CANDIDATE_ARGUMENT_MISMATCH, Collections.singleton(candidate));
|
||||
}
|
||||
public static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> manyFailedCandidates(Collection<MutableResolvedCall<D>> failedCandidates) {
|
||||
return new OverloadResolutionResultsImpl<D>(Code.MANY_FAILED_CANDIDATES, failedCandidates);
|
||||
return new OverloadResolutionResultsImpl<>(Code.MANY_FAILED_CANDIDATES, failedCandidates);
|
||||
}
|
||||
|
||||
public static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> candidatesWithWrongReceiver(Collection<MutableResolvedCall<D>> failedCandidates) {
|
||||
return new OverloadResolutionResultsImpl<D>(Code.CANDIDATES_WITH_WRONG_RECEIVER, failedCandidates);
|
||||
return new OverloadResolutionResultsImpl<>(Code.CANDIDATES_WITH_WRONG_RECEIVER, failedCandidates);
|
||||
}
|
||||
|
||||
public static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> ambiguity(Collection<MutableResolvedCall<D>> candidates) {
|
||||
return new OverloadResolutionResultsImpl<D>(Code.AMBIGUITY, candidates);
|
||||
return new OverloadResolutionResultsImpl<>(Code.AMBIGUITY, candidates);
|
||||
}
|
||||
|
||||
public static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> incompleteTypeInference(Collection<MutableResolvedCall<D>> candidates) {
|
||||
return new OverloadResolutionResultsImpl<D>(Code.INCOMPLETE_TYPE_INFERENCE, candidates);
|
||||
return new OverloadResolutionResultsImpl<>(Code.INCOMPLETE_TYPE_INFERENCE, candidates);
|
||||
}
|
||||
|
||||
public static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> incompleteTypeInference(MutableResolvedCall<D> candidate) {
|
||||
@@ -148,7 +148,7 @@ public class OverloadResolutionResultsImpl<D extends CallableDescriptor> impleme
|
||||
assert isSingleResult() && getResultCode() == Code.INCOMPLETE_TYPE_INFERENCE :
|
||||
"Only incomplete type inference status with one candidate can be changed to success: " +
|
||||
getResultCode() + "\n" + getResultingCalls();
|
||||
OverloadResolutionResultsImpl<D> newResults = new OverloadResolutionResultsImpl<D>(Code.SUCCESS, getResultingCalls());
|
||||
OverloadResolutionResultsImpl<D> newResults = new OverloadResolutionResultsImpl<>(Code.SUCCESS, getResultingCalls());
|
||||
newResults.setAllCandidates(getAllCandidates());
|
||||
return newResults;
|
||||
}
|
||||
|
||||
+2
-2
@@ -154,7 +154,7 @@ public class ResolutionResultsHandler {
|
||||
if (severityLevel.contains(ARGUMENTS_MAPPING_ERROR)) {
|
||||
@SuppressWarnings("unchecked")
|
||||
OverloadingConflictResolver<MutableResolvedCall<D>> myResolver = (OverloadingConflictResolver) overloadingConflictResolver;
|
||||
return recordFailedInfo(tracing, trace, myResolver.filterOutEquivalentCalls(new LinkedHashSet<MutableResolvedCall<D>>(thisLevel)));
|
||||
return recordFailedInfo(tracing, trace, myResolver.filterOutEquivalentCalls(new LinkedHashSet<>(thisLevel)));
|
||||
}
|
||||
OverloadResolutionResultsImpl<D> results = chooseAndReportMaximallySpecific(
|
||||
thisLevel, false, false, checkArgumentsMode, languageVersionSettings);
|
||||
@@ -200,7 +200,7 @@ public class ResolutionResultsHandler {
|
||||
|
||||
Set<MutableResolvedCall<D>> refinedCandidates = candidates;
|
||||
if (!languageVersionSettings.supportsFeature(LanguageFeature.RefinedSamAdaptersPriority)) {
|
||||
Set<MutableResolvedCall<D>> nonSynthesized = new HashSet<MutableResolvedCall<D>>();
|
||||
Set<MutableResolvedCall<D>> nonSynthesized = new HashSet<>();
|
||||
for (MutableResolvedCall<D> candidate : candidates) {
|
||||
if (!TowerUtilsKt.isSynthesized(candidate.getCandidateDescriptor())) {
|
||||
nonSynthesized.add(candidate);
|
||||
|
||||
+4
-6
@@ -45,15 +45,14 @@ public class ResolutionCandidate<D extends CallableDescriptor> {
|
||||
public static <D extends CallableDescriptor> ResolutionCandidate<D> create(
|
||||
@NotNull Call call, @NotNull D descriptor
|
||||
) {
|
||||
return new ResolutionCandidate<D>(call, descriptor, null, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, null);
|
||||
return new ResolutionCandidate<>(call, descriptor, null, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, null);
|
||||
}
|
||||
|
||||
public static <D extends CallableDescriptor> ResolutionCandidate<D> create(
|
||||
@NotNull Call call, @NotNull D descriptor, @Nullable TypeSubstitutor knownTypeParametersResultingSubstitutor
|
||||
) {
|
||||
return new ResolutionCandidate<D>(call, descriptor,
|
||||
null, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER,
|
||||
knownTypeParametersResultingSubstitutor);
|
||||
return new ResolutionCandidate<>(call, descriptor, null, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER,
|
||||
knownTypeParametersResultingSubstitutor);
|
||||
}
|
||||
|
||||
public static <D extends CallableDescriptor> ResolutionCandidate<D> create(
|
||||
@@ -61,8 +60,7 @@ public class ResolutionCandidate<D extends CallableDescriptor> {
|
||||
@NotNull ExplicitReceiverKind explicitReceiverKind,
|
||||
@Nullable TypeSubstitutor knownTypeParametersResultingSubstitutor
|
||||
) {
|
||||
return new ResolutionCandidate<D>(call, descriptor, dispatchReceiver, explicitReceiverKind,
|
||||
knownTypeParametersResultingSubstitutor);
|
||||
return new ResolutionCandidate<>(call, descriptor, dispatchReceiver, explicitReceiverKind, knownTypeParametersResultingSubstitutor);
|
||||
}
|
||||
|
||||
public void setDispatchReceiver(@Nullable ReceiverValue dispatchReceiver) {
|
||||
|
||||
@@ -206,7 +206,7 @@ public class CallMaker {
|
||||
arguments = Collections.emptyList();
|
||||
}
|
||||
else {
|
||||
arguments = new ArrayList<ValueArgument>(argumentExpressions.size());
|
||||
arguments = new ArrayList<>(argumentExpressions.size());
|
||||
for (KtExpression argumentExpression : argumentExpressions) {
|
||||
arguments.add(makeValueArgument(argumentExpression, calleeExpression));
|
||||
}
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ public class DiagnosticsElementsCache {
|
||||
}
|
||||
|
||||
private static MultiMap<PsiElement, Diagnostic> buildElementToDiagnosticCache(Diagnostics diagnostics, Function1<Diagnostic, Boolean> filter) {
|
||||
MultiMap<PsiElement, Diagnostic> elementToDiagnostic = new ConcurrentMultiMap<PsiElement, Diagnostic>();
|
||||
MultiMap<PsiElement, Diagnostic> elementToDiagnostic = new ConcurrentMultiMap<>();
|
||||
for (Diagnostic diagnostic : diagnostics) {
|
||||
if (filter.invoke(diagnostic)) {
|
||||
elementToDiagnostic.putValue(diagnostic.getPsiElement(), diagnostic);
|
||||
|
||||
+1
-2
@@ -48,8 +48,7 @@ public class DiagnosticsWithSuppression implements Diagnostics {
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterator<Diagnostic> iterator() {
|
||||
return new FilteringIterator<Diagnostic, Diagnostic>(diagnostics.iterator(),
|
||||
diagnostic -> kotlinSuppressCache.getFilter().invoke(diagnostic));
|
||||
return new FilteringIterator<>(diagnostics.iterator(), kotlinSuppressCache.getFilter()::invoke);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -248,7 +248,7 @@ public class ResolveSession implements KotlinCodeAnalyzer, LazyClassContext {
|
||||
PackageMemberDeclarationProvider provider = declarationProviderFactory.getPackageMemberDeclarationProvider(fqName.parent());
|
||||
if (provider == null) return Collections.emptyList();
|
||||
|
||||
Collection<ClassifierDescriptor> result = new SmartList<ClassifierDescriptor>();
|
||||
Collection<ClassifierDescriptor> result = new SmartList<>();
|
||||
|
||||
result.addAll(ContainerUtil.mapNotNull(
|
||||
provider.getClassOrObjectDeclarations(fqName.shortName()),
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ResolveSessionUtils {
|
||||
) {
|
||||
if (fqName.isRoot()) return Collections.emptyList();
|
||||
|
||||
Collection<ClassDescriptor> result = new ArrayList<ClassDescriptor>(1);
|
||||
Collection<ClassDescriptor> result = new ArrayList<>(1);
|
||||
|
||||
FqName packageFqName = fqName.parent();
|
||||
while (true) {
|
||||
|
||||
+2
-2
@@ -166,7 +166,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
this.isImpl = modifierList != null && modifierList.hasModifier(KtTokens.IMPL_KEYWORD);
|
||||
|
||||
// Annotation entries are taken from both own annotations (if any) and object literal annotations (if any)
|
||||
List<KtAnnotationEntry> annotationEntries = new ArrayList<KtAnnotationEntry>();
|
||||
List<KtAnnotationEntry> annotationEntries = new ArrayList<>();
|
||||
if (classOrObject != null && classOrObject.getParent() instanceof KtObjectLiteralExpression) {
|
||||
// TODO: it would be better to have separate ObjectLiteralDescriptor without so much magic
|
||||
annotationEntries.addAll(KtPsiUtilKt.getAnnotationEntries((KtObjectLiteralExpression) classOrObject.getParent()));
|
||||
@@ -241,7 +241,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
List<KtTypeParameter> typeParameters = typeParameterList.getParameters();
|
||||
if (typeParameters.isEmpty()) return Collections.emptyList();
|
||||
|
||||
List<TypeParameterDescriptor> parameters = new ArrayList<TypeParameterDescriptor>(typeParameters.size());
|
||||
List<TypeParameterDescriptor> parameters = new ArrayList<>(typeParameters.size());
|
||||
|
||||
for (int i = 0; i < typeParameters.size(); i++) {
|
||||
parameters.add(new LazyTypeParameterDescriptor(c, this, typeParameters.get(i), i));
|
||||
|
||||
+2
-2
@@ -73,7 +73,7 @@ public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescri
|
||||
@NotNull
|
||||
@Override
|
||||
protected List<KotlinType> resolveUpperBounds() {
|
||||
List<KotlinType> upperBounds = new ArrayList<KotlinType>(1);
|
||||
List<KotlinType> upperBounds = new ArrayList<>(1);
|
||||
|
||||
for (KtTypeReference typeReference : getAllUpperBounds()) {
|
||||
KotlinType resolvedType = resolveBoundType(typeReference);
|
||||
@@ -99,7 +99,7 @@ public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescri
|
||||
}
|
||||
|
||||
private Collection<KtTypeReference> getUpperBoundsFromWhereClause() {
|
||||
Collection<KtTypeReference> result = new ArrayList<KtTypeReference>();
|
||||
Collection<KtTypeReference> result = new ArrayList<>();
|
||||
|
||||
KtClassOrObject classOrObject = KtStubbedPsiUtil.getPsiOrStubParent(typeParameter, KtClassOrObject.class, true);
|
||||
if (classOrObject instanceof KtClass) {
|
||||
|
||||
@@ -52,7 +52,7 @@ public class BoundsSubstitutor {
|
||||
|
||||
@NotNull
|
||||
private static TypeSubstitutor createUpperBoundsSubstitutor(@NotNull List<TypeParameterDescriptor> typeParameters) {
|
||||
Map<TypeConstructor, TypeProjection> mutableSubstitution = new HashMap<TypeConstructor, TypeProjection>();
|
||||
Map<TypeConstructor, TypeProjection> mutableSubstitution = new HashMap<>();
|
||||
TypeSubstitutor substitutor = TypeSubstitutor.create(mutableSubstitution);
|
||||
|
||||
// todo assert: no loops
|
||||
|
||||
@@ -80,8 +80,8 @@ public class CommonSupertypes {
|
||||
private static KotlinType findCommonSupertype(@NotNull Collection<KotlinType> types, int recursionDepth, int maxDepth) {
|
||||
assert recursionDepth <= maxDepth : "Recursion depth exceeded: " + recursionDepth + " > " + maxDepth + " for types " + types;
|
||||
boolean hasFlexible = false;
|
||||
List<SimpleType> upper = new ArrayList<SimpleType>(types.size());
|
||||
List<SimpleType> lower = new ArrayList<SimpleType>(types.size());
|
||||
List<SimpleType> upper = new ArrayList<>(types.size());
|
||||
List<SimpleType> lower = new ArrayList<>(types.size());
|
||||
for (KotlinType type : types) {
|
||||
UnwrappedType unwrappedType = type.unwrap();
|
||||
if (unwrappedType instanceof FlexibleType) {
|
||||
@@ -110,7 +110,7 @@ public class CommonSupertypes {
|
||||
@NotNull
|
||||
private static SimpleType commonSuperTypeForInflexible(@NotNull Collection<SimpleType> types, int recursionDepth, int maxDepth) {
|
||||
assert !types.isEmpty();
|
||||
Collection<SimpleType> typeSet = new HashSet<SimpleType>(types);
|
||||
Collection<SimpleType> typeSet = new HashSet<>(types);
|
||||
|
||||
// If any of the types is nullable, the result must be nullable
|
||||
// This also removed Nothing and Nothing? because they are subtypes of everything else
|
||||
@@ -142,7 +142,7 @@ public class CommonSupertypes {
|
||||
// constructor of the supertype -> all of its instantiations occurring as supertypes
|
||||
Map<TypeConstructor, Set<SimpleType>> commonSupertypes = computeCommonRawSupertypes(typeSet);
|
||||
while (commonSupertypes.size() > 1) {
|
||||
Set<SimpleType> merge = new HashSet<SimpleType>();
|
||||
Set<SimpleType> merge = new HashSet<>();
|
||||
for (Set<SimpleType> supertypes : commonSupertypes.values()) {
|
||||
merge.addAll(supertypes);
|
||||
}
|
||||
@@ -164,12 +164,12 @@ public class CommonSupertypes {
|
||||
private static Map<TypeConstructor, Set<SimpleType>> computeCommonRawSupertypes(@NotNull Collection<SimpleType> types) {
|
||||
assert !types.isEmpty();
|
||||
|
||||
Map<TypeConstructor, Set<SimpleType>> constructorToAllInstances = new HashMap<TypeConstructor, Set<SimpleType>>();
|
||||
Map<TypeConstructor, Set<SimpleType>> constructorToAllInstances = new HashMap<>();
|
||||
Set<TypeConstructor> commonSuperclasses = null;
|
||||
|
||||
List<TypeConstructor> order = null;
|
||||
for (SimpleType type : types) {
|
||||
Set<TypeConstructor> visited = new HashSet<TypeConstructor>();
|
||||
Set<TypeConstructor> visited = new HashSet<>();
|
||||
order = topologicallySortSuperclassesAndRecordAllInstances(type, constructorToAllInstances, visited);
|
||||
|
||||
if (commonSuperclasses == null) {
|
||||
@@ -181,8 +181,8 @@ public class CommonSupertypes {
|
||||
}
|
||||
assert order != null;
|
||||
|
||||
Set<TypeConstructor> notSource = new HashSet<TypeConstructor>();
|
||||
Map<TypeConstructor, Set<SimpleType>> result = new HashMap<TypeConstructor, Set<SimpleType>>();
|
||||
Set<TypeConstructor> notSource = new HashSet<>();
|
||||
Map<TypeConstructor, Set<SimpleType>> result = new HashMap<>();
|
||||
for (TypeConstructor superConstructor : order) {
|
||||
if (!commonSuperclasses.contains(superConstructor)) {
|
||||
continue;
|
||||
@@ -210,9 +210,9 @@ public class CommonSupertypes {
|
||||
}
|
||||
|
||||
List<TypeParameterDescriptor> parameters = constructor.getParameters();
|
||||
List<TypeProjection> newProjections = new ArrayList<TypeProjection>(parameters.size());
|
||||
List<TypeProjection> newProjections = new ArrayList<>(parameters.size());
|
||||
for (TypeParameterDescriptor parameterDescriptor : parameters) {
|
||||
Set<TypeProjection> typeProjections = new HashSet<TypeProjection>();
|
||||
Set<TypeProjection> typeProjections = new HashSet<>();
|
||||
for (KotlinType type : types) {
|
||||
typeProjections.add(type.getArguments().get(parameterDescriptor.getIndex()));
|
||||
}
|
||||
@@ -255,8 +255,8 @@ public class CommonSupertypes {
|
||||
return TypeUtils.makeStarProjection(parameterDescriptor);
|
||||
}
|
||||
|
||||
Set<KotlinType> ins = new HashSet<KotlinType>();
|
||||
Set<KotlinType> outs = new HashSet<KotlinType>();
|
||||
Set<KotlinType> ins = new HashSet<>();
|
||||
Set<KotlinType> outs = new HashSet<>();
|
||||
|
||||
Variance variance = parameterDescriptor.getVariance();
|
||||
switch (variance) {
|
||||
@@ -335,7 +335,7 @@ public class CommonSupertypes {
|
||||
current -> {
|
||||
TypeSubstitutor substitutor = TypeSubstitutor.create(current);
|
||||
Collection<KotlinType> supertypes = current.getConstructor().getSupertypes();
|
||||
List<SimpleType> result = new ArrayList<SimpleType>(supertypes.size());
|
||||
List<SimpleType> result = new ArrayList<>(supertypes.size());
|
||||
for (KotlinType supertype : supertypes) {
|
||||
if (visited.contains(supertype.getConstructor())) {
|
||||
continue;
|
||||
@@ -348,9 +348,8 @@ public class CommonSupertypes {
|
||||
new DFS.NodeHandlerWithListResult<SimpleType, TypeConstructor>() {
|
||||
@Override
|
||||
public boolean beforeChildren(SimpleType current) {
|
||||
Set<SimpleType> instances = constructorToAllInstances.computeIfAbsent(
|
||||
current.getConstructor(), k -> new HashSet<SimpleType>()
|
||||
);
|
||||
Set<SimpleType> instances =
|
||||
constructorToAllInstances.computeIfAbsent(current.getConstructor(), k -> new HashSet<>());
|
||||
instances.add(current);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -40,7 +40,7 @@ public class DeferredType extends WrappedType {
|
||||
@NotNull Function0<KotlinType> compute
|
||||
) {
|
||||
DeferredType deferredType = new DeferredType(storageManager.createLazyValue(compute));
|
||||
trace.record(DEFERRED_TYPE, new Box<DeferredType>(deferredType));
|
||||
trace.record(DEFERRED_TYPE, new Box<>(deferredType));
|
||||
return deferredType;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class DeferredType extends WrappedType {
|
||||
//noinspection unchecked
|
||||
DeferredType deferredType =
|
||||
new DeferredType(storageManager.createLazyValueWithPostCompute(compute, RECURSION_PREVENTER, t -> null));
|
||||
trace.record(DEFERRED_TYPE, new Box<DeferredType>(deferredType));
|
||||
trace.record(DEFERRED_TYPE, new Box<>(deferredType));
|
||||
return deferredType;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ import static org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt.getB
|
||||
public class TypeIntersector {
|
||||
|
||||
public static boolean isIntersectionEmpty(@NotNull KotlinType typeA, @NotNull KotlinType typeB) {
|
||||
return intersectTypes(KotlinTypeChecker.DEFAULT, new LinkedHashSet<KotlinType>(Arrays.asList(typeA, typeB))) == null;
|
||||
return intersectTypes(KotlinTypeChecker.DEFAULT, new LinkedHashSet<>(Arrays.asList(typeA, typeB))) == null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -52,7 +52,7 @@ public class TypeIntersector {
|
||||
// made nullable is they all were nullable
|
||||
KotlinType nothingOrNullableNothing = null;
|
||||
boolean allNullable = true;
|
||||
List<KotlinType> nullabilityStripped = new ArrayList<KotlinType>(types.size());
|
||||
List<KotlinType> nullabilityStripped = new ArrayList<>(types.size());
|
||||
for (KotlinType type : types) {
|
||||
if (type.isError()) continue;
|
||||
|
||||
@@ -73,7 +73,7 @@ public class TypeIntersector {
|
||||
}
|
||||
|
||||
// Now we remove types that have subtypes in the list
|
||||
List<KotlinType> resultingTypes = new ArrayList<KotlinType>();
|
||||
List<KotlinType> resultingTypes = new ArrayList<>();
|
||||
outer:
|
||||
for (KotlinType type : nullabilityStripped) {
|
||||
if (!TypeUtils.canHaveSubtypes(typeChecker, type)) {
|
||||
@@ -172,7 +172,7 @@ public class TypeIntersector {
|
||||
|
||||
private static boolean unify(KotlinType withParameters, KotlinType expected) {
|
||||
// T -> how T is used
|
||||
Map<TypeParameterDescriptor, Variance> parameters = new HashMap<TypeParameterDescriptor, Variance>();
|
||||
Map<TypeParameterDescriptor, Variance> parameters = new HashMap<>();
|
||||
Function1<TypeParameterUsage, Unit> processor = parameterUsage -> {
|
||||
Variance howTheTypeIsUsedBefore = parameters.get(parameterUsage.typeParameterDescriptor);
|
||||
if (howTheTypeIsUsedBefore == null) {
|
||||
|
||||
+1
-1
@@ -251,7 +251,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
}
|
||||
else {
|
||||
Matcher matcher = FP_LITERAL_PARTS.matcher(text);
|
||||
parts = new ArrayList<String>();
|
||||
parts = new ArrayList<>();
|
||||
if (matcher.matches()) {
|
||||
for (int i = 0; i < matcher.groupCount(); i++) {
|
||||
parts.add(matcher.group(i + 1));
|
||||
|
||||
+1
-1
@@ -163,7 +163,7 @@ public class ControlStructureTypingUtils {
|
||||
KotlinType type = typeParameter.getDefaultType();
|
||||
KotlinType nullableType = TypeUtils.makeNullable(type);
|
||||
|
||||
List<ValueParameterDescriptor> valueParameters = new ArrayList<ValueParameterDescriptor>(argumentNames.size());
|
||||
List<ValueParameterDescriptor> valueParameters = new ArrayList<>(argumentNames.size());
|
||||
for (int i = 0; i < argumentNames.size(); i++) {
|
||||
KotlinType argumentType = isArgumentNullable.get(i) ? nullableType : type;
|
||||
ValueParameterDescriptorImpl valueParameter = new ValueParameterDescriptorImpl(
|
||||
|
||||
+1
-1
@@ -481,7 +481,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
KtExpression tryBlock = expression.getTryBlock();
|
||||
List<KtCatchClause> catchClauses = expression.getCatchClauses();
|
||||
KtFinallySection finallyBlock = expression.getFinallyBlock();
|
||||
List<KotlinType> types = new ArrayList<KotlinType>();
|
||||
List<KotlinType> types = new ArrayList<>();
|
||||
boolean nothingInAllCatchBranches = true;
|
||||
for (KtCatchClause catchClause : catchClauses) {
|
||||
KtParameter catchParameter = catchClause.getCatchParameter();
|
||||
|
||||
@@ -124,7 +124,7 @@ public class DataFlowAnalyzer {
|
||||
ExpressionTypingContext context
|
||||
) {
|
||||
if (condition == null) return context.dataFlowInfo;
|
||||
Ref<DataFlowInfo> result = new Ref<DataFlowInfo>(null);
|
||||
Ref<DataFlowInfo> result = new Ref<>(null);
|
||||
condition.accept(new KtVisitorVoid() {
|
||||
@Override
|
||||
public void visitIsExpression(@NotNull KtIsExpression expression) {
|
||||
|
||||
+1
-1
@@ -174,7 +174,7 @@ public class ExpressionTypingUtils {
|
||||
|
||||
@NotNull
|
||||
public static List<KotlinType> getValueParametersTypes(@NotNull List<ValueParameterDescriptor> valueParameters) {
|
||||
List<KotlinType> parameterTypes = new ArrayList<KotlinType>(valueParameters.size());
|
||||
List<KotlinType> parameterTypes = new ArrayList<>(valueParameters.size());
|
||||
for (ValueParameterDescriptor parameter : valueParameters) {
|
||||
parameterTypes.add(parameter.getType());
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class SlicedMapImpl implements MutableSlicedMap {
|
||||
return new SlicedMapImpl();
|
||||
}
|
||||
|
||||
private final Map<Object, KeyFMap> map = new THashMap<Object, KeyFMap>(0);
|
||||
private final Map<Object, KeyFMap> map = new THashMap<>(0);
|
||||
private Multimap<WritableSlice<?, ?>, Object> collectiveSliceKeys = null;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -51,23 +51,23 @@ public class Slices {
|
||||
}
|
||||
|
||||
public static <K, V> SliceBuilder<K, V> sliceBuilder() {
|
||||
return new SliceBuilder<K, V>(ONLY_REWRITE_TO_EQUAL);
|
||||
return new SliceBuilder<>(ONLY_REWRITE_TO_EQUAL);
|
||||
}
|
||||
|
||||
public static <K, V> WritableSlice<K, V> createSimpleSlice() {
|
||||
return new BasicWritableSlice<K, V>(ONLY_REWRITE_TO_EQUAL);
|
||||
return new BasicWritableSlice<>(ONLY_REWRITE_TO_EQUAL);
|
||||
}
|
||||
|
||||
public static <K, V> WritableSlice<K, V> createCollectiveSlice() {
|
||||
return new BasicWritableSlice<K, V>(ONLY_REWRITE_TO_EQUAL, true);
|
||||
return new BasicWritableSlice<>(ONLY_REWRITE_TO_EQUAL, true);
|
||||
}
|
||||
|
||||
public static <K> WritableSlice<K, Boolean> createSimpleSetSlice() {
|
||||
return new SetSlice<K>(RewritePolicy.DO_NOTHING);
|
||||
return new SetSlice<>(RewritePolicy.DO_NOTHING);
|
||||
}
|
||||
|
||||
public static <K> WritableSlice<K, Boolean> createCollectiveSetSlice() {
|
||||
return new SetSlice<K>(RewritePolicy.DO_NOTHING, true);
|
||||
return new SetSlice<>(RewritePolicy.DO_NOTHING, true);
|
||||
}
|
||||
|
||||
public static class SliceBuilder<K, V> {
|
||||
@@ -115,7 +115,7 @@ public class Slices {
|
||||
}
|
||||
};
|
||||
}
|
||||
return new BasicWritableSlice<K, V>(rewritePolicy);
|
||||
return new BasicWritableSlice<>(rewritePolicy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class TrackingSlicedMap extends SlicedMapImpl {
|
||||
}
|
||||
|
||||
private <K, V> SliceWithStackTrace<K, V> wrapSlice(ReadOnlySlice<K, V> slice) {
|
||||
SliceWithStackTrace<?, ?> translated = sliceTranslationMap.computeIfAbsent(slice, k -> new SliceWithStackTrace<K, V>(slice));
|
||||
SliceWithStackTrace<?, ?> translated = sliceTranslationMap.computeIfAbsent(slice, k -> new SliceWithStackTrace<>(slice));
|
||||
//noinspection unchecked
|
||||
return (SliceWithStackTrace) translated;
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public class TrackingSlicedMap extends SlicedMapImpl {
|
||||
|
||||
@Override
|
||||
public <K, V> void put(WritableSlice<K, V> slice, K key, V value) {
|
||||
super.put(wrapSlice(slice), key, new TrackableValue<V>(value, trackWithStackTraces));
|
||||
super.put(wrapSlice(slice), key, new TrackableValue<>(value, trackWithStackTraces));
|
||||
}
|
||||
|
||||
private static class TrackableValue<V> {
|
||||
@@ -125,7 +125,7 @@ public class TrackingSlicedMap extends SlicedMapImpl {
|
||||
|
||||
@Override
|
||||
public TrackableValue<V> computeValue(SlicedMap map, K key, TrackableValue<V> value, boolean valueNotFound) {
|
||||
return new TrackableValue<V>(delegate.computeValue(map, key, value == null ? null : value.value, valueNotFound), trackWithStackTraces);
|
||||
return new TrackableValue<>(delegate.computeValue(map, key, value == null ? null : value.value, valueNotFound), trackWithStackTraces);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user