Fix most unchecked/deprecation javac warnings in compiler modules
This commit is contained in:
@@ -870,13 +870,13 @@ public class CheckerTestUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@SuppressWarnings("unchecked")
|
||||
public static TextDiagnostic asTextDiagnostic(@NotNull ActualDiagnostic actualDiagnostic) {
|
||||
Diagnostic diagnostic = actualDiagnostic.diagnostic;
|
||||
//noinspection TestOnlyProblems
|
||||
DiagnosticRenderer renderer = DefaultErrorMessages.getRendererForDiagnostic(diagnostic);
|
||||
String diagnosticName = actualDiagnostic.getName();
|
||||
if (renderer instanceof AbstractDiagnosticWithParametersRenderer) {
|
||||
//noinspection unchecked
|
||||
Object[] renderParameters = ((AbstractDiagnosticWithParametersRenderer) renderer).renderParameters(diagnostic);
|
||||
List<String> parameters = ContainerUtil.map(renderParameters, Object::toString);
|
||||
return new TextDiagnostic(diagnosticName, actualDiagnostic.platform, parameters, actualDiagnostic.inferenceCompatibility);
|
||||
|
||||
+1
@@ -111,6 +111,7 @@ public class LocalVariableDescriptor extends VariableDescriptorWithInitializerIm
|
||||
// This override is not deprecated because local variables can only come from sources,
|
||||
// and we can be sure that they won't be recompiled independently
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean isDelegated() {
|
||||
return isDelegated;
|
||||
}
|
||||
|
||||
@@ -50,16 +50,17 @@ public abstract class DiagnosticFactory<D extends Diagnostic> {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@SuppressWarnings("unchecked")
|
||||
public D cast(@NotNull Diagnostic diagnostic) {
|
||||
if (diagnostic.getFactory() != this) {
|
||||
throw new IllegalArgumentException("Factory mismatch: expected " + this + " but was " + diagnostic.getFactory());
|
||||
}
|
||||
|
||||
//noinspection unchecked
|
||||
return (D) diagnostic;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@SafeVarargs
|
||||
public static <D extends Diagnostic> D cast(@NotNull Diagnostic diagnostic, @NotNull DiagnosticFactory<? extends D>... factories) {
|
||||
return cast(diagnostic, Arrays.asList(factories));
|
||||
}
|
||||
|
||||
@@ -229,6 +229,7 @@ public class BindingContextUtils {
|
||||
return bindingContext.get(CONSTRUCTOR_RESOLVED_DELEGATION_CALL, constructorDescriptor);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static void addOwnDataTo(
|
||||
@NotNull BindingTrace trace, @Nullable TraceEntryFilter filter, boolean commitDiagnostics,
|
||||
@NotNull MutableSlicedMap map, MutableDiagnosticsWithSuppression diagnostics
|
||||
|
||||
@@ -515,12 +515,12 @@ public class BodyResolver {
|
||||
return parentEnumOrSealed;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void recordConstructorDelegationCall(
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull ConstructorDescriptor constructor,
|
||||
@NotNull ResolvedCall<?> call
|
||||
) {
|
||||
//noinspection unchecked
|
||||
trace.record(CONSTRUCTOR_RESOLVED_DELEGATION_CALL, constructor, (ResolvedCall<ConstructorDescriptor>) call);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,9 +52,10 @@ public class ObservableBindingTrace implements BindingTrace {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <K, V> void record(WritableSlice<K, V> slice, K key, V value) {
|
||||
originalTrace.record(slice, key, value);
|
||||
RecordHandler recordHandler = handlers.get(slice);
|
||||
RecordHandler<K, V> recordHandler = (RecordHandler) handlers.get(slice);
|
||||
if (recordHandler != null) {
|
||||
recordHandler.handleRecord(slice, key, value);
|
||||
}
|
||||
|
||||
@@ -303,6 +303,7 @@ public class CallResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@SuppressWarnings("unchecked")
|
||||
public OverloadResolutionResults<FunctionDescriptor> resolveFunctionCall(@NotNull BasicCallResolutionContext context) {
|
||||
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled();
|
||||
|
||||
|
||||
+1
-1
@@ -89,7 +89,7 @@ public class BasicCallResolutionContext extends CallResolutionContext<BasicCallR
|
||||
|
||||
@NotNull
|
||||
public static BasicCallResolutionContext create(
|
||||
@NotNull ResolutionContext context, @NotNull Call call, @NotNull CheckArgumentTypesMode checkArguments,
|
||||
@NotNull ResolutionContext<?> context, @NotNull Call call, @NotNull CheckArgumentTypesMode checkArguments,
|
||||
@Nullable MutableDataFlowInfoForArguments dataFlowInfoForArguments
|
||||
) {
|
||||
return new BasicCallResolutionContext(
|
||||
|
||||
+4
-3
@@ -124,8 +124,8 @@ public abstract class ResolutionContext<Context extends ResolutionContext<Contex
|
||||
);
|
||||
|
||||
@NotNull
|
||||
@SuppressWarnings("unchecked")
|
||||
private Context self() {
|
||||
//noinspection unchecked
|
||||
return (Context) this;
|
||||
}
|
||||
|
||||
@@ -220,14 +220,15 @@ public abstract class ResolutionContext<Context extends ResolutionContext<Contex
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public <T extends PsiElement> T getContextParentOfType(@NotNull KtExpression expression, @NotNull Class<? extends T>... classes) {
|
||||
@SafeVarargs
|
||||
@SuppressWarnings("unchecked")
|
||||
public final <T extends PsiElement> T getContextParentOfType(@NotNull KtExpression expression, @NotNull Class<? extends T>... classes) {
|
||||
KtExpression context = expressionContextProvider.invoke(expression);
|
||||
PsiElement current = context != null ? context : expression.getParent();
|
||||
|
||||
while (current != null) {
|
||||
for (Class<? extends T> klass : classes) {
|
||||
if (klass.isInstance(current)) {
|
||||
//noinspection unchecked
|
||||
return (T) current;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,6 +195,7 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements MutableRe
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setResultingSubstitutor(@NotNull TypeSubstitutor substitutor) {
|
||||
resultingDescriptor = (D) candidateDescriptor.substitute(substitutor);
|
||||
//noinspection ConstantConditions
|
||||
|
||||
+1
@@ -32,6 +32,7 @@ import java.util.Collection;
|
||||
|
||||
public class OverloadResolutionResultsUtil {
|
||||
@NotNull
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <D extends CallableDescriptor> OverloadResolutionResults<D> ambiguity(OverloadResolutionResults<D> results1, OverloadResolutionResults<D> results2) {
|
||||
Collection<MutableResolvedCall<D>> resultingCalls = Lists.newArrayList();
|
||||
resultingCalls.addAll((Collection<MutableResolvedCall<D>>) results1.getResultingCalls());
|
||||
|
||||
+2
-1
@@ -94,7 +94,7 @@ public class ResolutionResultsHandler {
|
||||
|
||||
@NotNull
|
||||
private <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> computeSuccessfulResult(
|
||||
@NotNull CallResolutionContext context,
|
||||
@NotNull CallResolutionContext<?> context,
|
||||
@NotNull TracingStrategy tracing,
|
||||
@NotNull Set<MutableResolvedCall<D>> successfulCandidates,
|
||||
@NotNull Set<MutableResolvedCall<D>> incompleteCandidates,
|
||||
@@ -192,6 +192,7 @@ public class ResolutionResultsHandler {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@SuppressWarnings("unchecked")
|
||||
private <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> chooseAndReportMaximallySpecific(
|
||||
@NotNull Set<MutableResolvedCall<D>> candidates,
|
||||
boolean discriminateGenerics,
|
||||
|
||||
+1
-2
@@ -13,7 +13,6 @@ import kotlin.jvm.functions.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||
import org.jetbrains.kotlin.config.LanguageFeature;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorBase;
|
||||
@@ -352,8 +351,8 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Collection<CallableMemberDescriptor> getDeclaredCallableMembers() {
|
||||
//noinspection unchecked
|
||||
return (Collection) CollectionsKt.filter(
|
||||
DescriptorUtils.getAllDescriptors(unsubstitutedMemberScope),
|
||||
descriptor -> descriptor instanceof CallableMemberDescriptor
|
||||
|
||||
+2
-2
@@ -80,7 +80,7 @@ public class ExpressionTypingContext extends ResolutionContext<ExpressionTypingC
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ExpressionTypingContext newContext(@NotNull ResolutionContext context) {
|
||||
public static ExpressionTypingContext newContext(@NotNull ResolutionContext<?> context) {
|
||||
return new ExpressionTypingContext(
|
||||
context.trace, context.scope, context.dataFlowInfo, context.expectedType,
|
||||
context.contextDependency, context.resolutionResultsCache,
|
||||
@@ -91,7 +91,7 @@ public class ExpressionTypingContext extends ResolutionContext<ExpressionTypingC
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ExpressionTypingContext newContext(@NotNull ResolutionContext context, boolean isDebuggerContext) {
|
||||
public static ExpressionTypingContext newContext(@NotNull ResolutionContext<?> context, boolean isDebuggerContext) {
|
||||
return new ExpressionTypingContext(
|
||||
context.trace, context.scope, context.dataFlowInfo, context.expectedType,
|
||||
context.contextDependency, context.resolutionResultsCache,
|
||||
|
||||
@@ -120,6 +120,7 @@ public class SlicedMapImpl implements MutableSlicedMap {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <K, V> ImmutableMap<K, V> getSliceContents(@NotNull ReadOnlySlice<K, V> slice) {
|
||||
if (map == null) return ImmutableMap.of();
|
||||
|
||||
@@ -129,7 +130,6 @@ public class SlicedMapImpl implements MutableSlicedMap {
|
||||
V value = holder.get(slice.getKey());
|
||||
|
||||
if (value != null) {
|
||||
//noinspection unchecked
|
||||
builder.put((K) key, value);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -112,7 +112,8 @@ public class Slices {
|
||||
this.rewritePolicy = rewritePolicy;
|
||||
}
|
||||
|
||||
public SliceBuilder<K, V> setFurtherLookupSlices(ReadOnlySlice<K, V>... furtherLookupSlices) {
|
||||
@SafeVarargs
|
||||
public final SliceBuilder<K, V> setFurtherLookupSlices(ReadOnlySlice<K, V>... furtherLookupSlices) {
|
||||
this.furtherLookupSlices = Arrays.asList(furtherLookupSlices);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -33,10 +33,9 @@ public class TrackingSlicedMap extends SlicedMapImpl {
|
||||
this.trackWithStackTraces = trackWithStackTraces;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <K, V> SliceWithStackTrace<K, V> wrapSlice(ReadOnlySlice<K, V> slice) {
|
||||
SliceWithStackTrace<?, ?> translated = sliceTranslationMap.computeIfAbsent(slice, k -> new SliceWithStackTrace<>(slice));
|
||||
//noinspection unchecked
|
||||
return (SliceWithStackTrace) translated;
|
||||
return (SliceWithStackTrace) sliceTranslationMap.computeIfAbsent(slice, k -> new SliceWithStackTrace<>(slice));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user