Fix most unchecked/deprecation javac warnings in compiler modules
This commit is contained in:
@@ -28,13 +28,13 @@ abstract class AbstractNode extends HasMetadata implements JsNode {
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T extends HasMetadata & JsNode> T withMetadataFrom(T other) {
|
||||
this.copyMetadataFrom(other);
|
||||
Object otherSource = other.getSource();
|
||||
if (otherSource != null) {
|
||||
source(otherSource);
|
||||
}
|
||||
//noinspection unchecked
|
||||
return (T) this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +100,7 @@ public class JsFor extends SourceInfoAwareJsNode implements JsLoop {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void traverse(JsVisitorWithContext v, JsContext ctx) {
|
||||
if (v.visit(this, ctx)) {
|
||||
assert (!(initExpression != null && initVars != null));
|
||||
|
||||
@@ -48,10 +48,10 @@ public abstract class JsVisitorWithContext {
|
||||
doAcceptList(collection);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public final <T extends JsStatement> T acceptStatement(T statement) {
|
||||
if (statement == null) return null;
|
||||
|
||||
//noinspection unchecked
|
||||
return (T) doAcceptStatement(statement);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,6 @@ package org.jetbrains.kotlin.js.util;
|
||||
import com.intellij.util.SmartList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.js.backend.ast.JsBinaryOperation;
|
||||
import org.jetbrains.kotlin.js.backend.ast.JsBinaryOperator;
|
||||
import org.jetbrains.kotlin.js.backend.ast.JsExpression;
|
||||
import org.jetbrains.kotlin.js.backend.ast.JsNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -20,10 +17,10 @@ public final class AstUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends JsNode> T deepCopy(@Nullable T node) {
|
||||
if (node == null) return null;
|
||||
|
||||
//noinspection unchecked
|
||||
return (T) node.deepCopy();
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,8 @@ import kotlin.jvm.functions.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.backend.common.CommonCoroutineCodegenUtilKt;
|
||||
import org.jetbrains.kotlin.config.*;
|
||||
import org.jetbrains.kotlin.config.CommonConfigurationKeysKt;
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings;
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor;
|
||||
@@ -24,7 +25,6 @@ import org.jetbrains.kotlin.js.inline.context.FunctionContext;
|
||||
import org.jetbrains.kotlin.js.inline.context.InliningContext;
|
||||
import org.jetbrains.kotlin.js.inline.context.NamingContext;
|
||||
import org.jetbrains.kotlin.js.inline.util.*;
|
||||
import org.jetbrains.kotlin.js.translate.expression.InlineMetadata;
|
||||
import org.jetbrains.kotlin.resolve.inline.InlineStrategy;
|
||||
|
||||
import java.util.*;
|
||||
@@ -303,7 +303,9 @@ public class JsInliner extends JsVisitorWithContextImpl {
|
||||
@Override
|
||||
public void endVisit(@NotNull JsInvocation x, @NotNull JsContext ctx) {
|
||||
if (hasToBeInlined(x)) {
|
||||
inline(x, ctx);
|
||||
@SuppressWarnings("unchecked")
|
||||
JsContext<JsNode> context = (JsContext) ctx;
|
||||
inline(x, context);
|
||||
}
|
||||
|
||||
JsCallInfo lastCallInfo = null;
|
||||
@@ -335,7 +337,7 @@ public class JsInliner extends JsVisitorWithContextImpl {
|
||||
super.doAcceptStatementList(statements);
|
||||
}
|
||||
|
||||
private void inline(@NotNull JsInvocation call, @NotNull JsContext context) {
|
||||
private void inline(@NotNull JsInvocation call, @NotNull JsContext<JsNode> context) {
|
||||
DeclarationDescriptor callDescriptor = MetadataProperties.getDescriptor(call);
|
||||
if (isSuspendWithCurrentContinuation(callDescriptor,
|
||||
CommonConfigurationKeysKt.getLanguageVersionSettings(config.getConfiguration()))) {
|
||||
@@ -403,7 +405,7 @@ public class JsInliner extends JsVisitorWithContextImpl {
|
||||
) {
|
||||
// Apparently we should avoid this trick when we implement fair support for crossinline
|
||||
Function<JsWrapperKey, Map<JsName, JsNameRef>> replacementGen = k -> {
|
||||
JsContext ctx = k.context;
|
||||
JsContext<JsStatement> ctx = k.context;
|
||||
|
||||
Map<JsName, JsNameRef> newReplacements = new HashMap<>();
|
||||
|
||||
@@ -499,9 +501,11 @@ public class JsInliner extends JsVisitorWithContextImpl {
|
||||
replaceIfNecessary(x, ctx);
|
||||
}
|
||||
|
||||
private void replaceIfNecessary(@NotNull JsExpression expression, @NotNull JsContext context) {
|
||||
private void replaceIfNecessary(@NotNull JsExpression expression, @NotNull JsContext ctx) {
|
||||
JsName alias = MetadataProperties.getLocalAlias(expression);
|
||||
if (alias != null) {
|
||||
@SuppressWarnings("unchecked")
|
||||
JsContext<JsNode> context = (JsContext) ctx;
|
||||
context.replaceMe(alias.makeRef());
|
||||
}
|
||||
}
|
||||
@@ -519,7 +523,7 @@ public class JsInliner extends JsVisitorWithContextImpl {
|
||||
);
|
||||
}
|
||||
|
||||
private void inlineSuspendWithCurrentContinuation(@NotNull JsInvocation call, @NotNull JsContext context) {
|
||||
private void inlineSuspendWithCurrentContinuation(@NotNull JsInvocation call, @NotNull JsContext<JsNode> context) {
|
||||
JsExpression lambda = call.getArguments().get(0);
|
||||
JsExpression continuationArg = call.getArguments().get(call.getArguments().size() - 1);
|
||||
|
||||
@@ -632,10 +636,10 @@ public class JsInliner extends JsVisitorWithContextImpl {
|
||||
}
|
||||
|
||||
static class JsWrapperKey {
|
||||
final JsContext context;
|
||||
final JsContext<JsStatement> context;
|
||||
private final JsFunction function;
|
||||
|
||||
public JsWrapperKey(@NotNull JsContext context, @NotNull JsFunction function) {
|
||||
public JsWrapperKey(@NotNull JsContext<JsStatement> context, @NotNull JsFunction function) {
|
||||
this.context = context;
|
||||
this.function = function;
|
||||
}
|
||||
|
||||
@@ -210,6 +210,7 @@ public class Context {
|
||||
return (Context) threadContexts.get(t);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void setThreadContext(Context cx) {
|
||||
if (threadLocalCx != null) {
|
||||
try {
|
||||
|
||||
@@ -70,6 +70,7 @@ public class SourceMap3Builder implements SourceMapBuilder {
|
||||
|
||||
@Override
|
||||
public String build() {
|
||||
@SuppressWarnings("unchecked")
|
||||
JsonObject json = new JsonObject();
|
||||
json.getProperties().put("version", new JsonNumber(3));
|
||||
json.getProperties().put("file", new JsonString(generatedFile.getName()));
|
||||
|
||||
@@ -49,14 +49,15 @@ public final class BindingUtils {
|
||||
private BindingUtils() {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@NotNull
|
||||
static private <E extends PsiElement, D extends DeclarationDescriptor>
|
||||
D getDescriptorForExpression(@NotNull BindingContext context, @NotNull E expression, Class<D> descriptorClass) {
|
||||
private static <E extends PsiElement, D extends DeclarationDescriptor> D getDescriptorForExpression(
|
||||
@NotNull BindingContext context, @NotNull E expression, Class<D> descriptorClass
|
||||
) {
|
||||
DeclarationDescriptor descriptor = context.get(BindingContext.DECLARATION_TO_DESCRIPTOR, expression);
|
||||
assert descriptor != null;
|
||||
assert descriptorClass.isInstance(descriptor)
|
||||
: message(expression, expression.toString() + " expected to have of type" + descriptorClass.toString());
|
||||
//noinspection unchecked
|
||||
return (D) descriptor;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user