Fix most unchecked/deprecation javac warnings in compiler modules
This commit is contained in:
@@ -361,7 +361,7 @@ public abstract class AnnotationCodegen {
|
||||
@NotNull ConstantValue<?> value,
|
||||
@NotNull AnnotationVisitor annotationVisitor
|
||||
) {
|
||||
AnnotationArgumentVisitor argumentVisitor = new AnnotationArgumentVisitor<Void, Void>() {
|
||||
AnnotationArgumentVisitor<Void, Void> argumentVisitor = new AnnotationArgumentVisitor<Void, Void>() {
|
||||
@Override
|
||||
public Void visitLongValue(@NotNull LongValue value, Void data) {
|
||||
return visitSimpleValue(value);
|
||||
|
||||
@@ -2069,7 +2069,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
CallableMethod callableGetter = null;
|
||||
CallableMethod callableSetter = null;
|
||||
|
||||
CodegenContext backingFieldContext = getBackingFieldContext(fieldAccessorKind, containingDeclaration);
|
||||
CodegenContext<?> backingFieldContext = getBackingFieldContext(fieldAccessorKind, containingDeclaration);
|
||||
boolean isPrivateProperty =
|
||||
fieldAccessorKind != AccessorKind.NORMAL &&
|
||||
(AsmUtil.getVisibilityForBackingField(propertyDescriptor, isDelegatedProperty) & ACC_PRIVATE) != 0;
|
||||
|
||||
@@ -73,7 +73,7 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
|
||||
public final GenerationState state;
|
||||
|
||||
protected final T element;
|
||||
protected final FieldOwnerContext context;
|
||||
protected final FieldOwnerContext<?> context;
|
||||
|
||||
public final ClassBuilder v;
|
||||
public final FunctionCodegen functionCodegen;
|
||||
|
||||
@@ -25,15 +25,16 @@ import org.jetbrains.kotlin.synthetic.SamAdapterExtensionFunctionDescriptor;
|
||||
|
||||
public class SamCodegenUtil {
|
||||
@Nullable
|
||||
@SuppressWarnings("unchecked")
|
||||
public static FunctionDescriptor getOriginalIfSamAdapter(@NotNull FunctionDescriptor fun) {
|
||||
if (fun instanceof SamAdapterDescriptor<?> || fun instanceof SamAdapterExtensionFunctionDescriptor) {
|
||||
//noinspection unchecked
|
||||
return ((SyntheticMemberDescriptor<FunctionDescriptor>) fun).getBaseDescriptorForSynthetic();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends FunctionDescriptor> T resolveSamAdapter(@NotNull T descriptor) {
|
||||
FunctionDescriptor original = getOriginalIfSamAdapter(descriptor);
|
||||
return original != null ? (T) original : descriptor;
|
||||
|
||||
@@ -413,7 +413,7 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
|
||||
return getAccessor(propertyDescriptor, AccessorKind.NORMAL, null, superCallTarget, getterAccessorRequired, setterAccessorRequired);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <D extends CallableMemberDescriptor> D getAccessorForJvmDefaultCompatibility(@NotNull D descriptor) {
|
||||
if (descriptor instanceof PropertyAccessorDescriptor) {
|
||||
PropertyDescriptor propertyAccessor = getAccessor(((PropertyAccessorDescriptor) descriptor).getCorrespondingProperty(),
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.load.java.structure.impl;
|
||||
|
||||
import com.intellij.psi.PsiEnumConstant;
|
||||
import com.intellij.psi.PsiField;
|
||||
import com.intellij.psi.impl.JavaConstantExpressionEvaluator;
|
||||
import com.intellij.psi.PsiVariable;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -51,6 +51,6 @@ public class JavaFieldImpl extends JavaMemberImpl<PsiField> implements JavaField
|
||||
public boolean getHasConstantNotNullInitializer() {
|
||||
// PsiUtil.isCompileTimeConstant returns false for null-initialized fields,
|
||||
// see com.intellij.psi.util.IsConstantExpressionVisitor.visitLiteralExpression()
|
||||
return PsiUtil.isCompileTimeConstant(getPsi());
|
||||
return PsiUtil.isCompileTimeConstant((PsiVariable) getPsi());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
+1
-1
@@ -514,7 +514,7 @@ public class InterceptionInstrumenter {
|
||||
|
||||
}
|
||||
}
|
||||
ia.invokevirtual(methodData.getDeclaringClass(), methodData.getName(), methodData.getDesc());
|
||||
ia.invokevirtual(methodData.getDeclaringClass(), methodData.getName(), methodData.getDesc(), false);
|
||||
Type type = asmMethod.getReturnType();
|
||||
if (type.getSort() != Type.VOID) {
|
||||
if (type.getSize() == 1) {
|
||||
|
||||
@@ -32,7 +32,7 @@ public class KtContainerNode extends KtElementImpl {
|
||||
}
|
||||
|
||||
@Override // for visibility
|
||||
protected PsiElement findChildByType(IElementType type) {
|
||||
protected <T extends PsiElement> T findChildByType(IElementType type) {
|
||||
return super.findChildByType(type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ public class KtElementImpl extends ASTWrapperPsiElement implements KtElement {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public final void accept(@NotNull PsiElementVisitor visitor) {
|
||||
if (visitor instanceof KtVisitor) {
|
||||
accept((KtVisitor) visitor, null);
|
||||
@@ -81,6 +82,7 @@ public class KtElementImpl extends ASTWrapperPsiElement implements KtElement {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public PsiReference getReference() {
|
||||
PsiReference[] references = getReferences();
|
||||
if (references.length == 1) return references[0];
|
||||
|
||||
@@ -54,6 +54,7 @@ public class KtElementImplStub<T extends StubElement<?>> extends StubBasedPsiEle
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public final void accept(@NotNull PsiElementVisitor visitor) {
|
||||
if (visitor instanceof KtVisitor) {
|
||||
accept((KtVisitor) visitor, null);
|
||||
@@ -98,6 +99,7 @@ public class KtElementImplStub<T extends StubElement<?>> extends StubBasedPsiEle
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public PsiReference getReference() {
|
||||
PsiReference[] references = getReferences();
|
||||
if (references.length == 1) return references[0];
|
||||
|
||||
@@ -91,6 +91,7 @@ public class KtLambdaExpression extends LazyParseablePsiElement implements KtExp
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public final void accept(@NotNull PsiElementVisitor visitor) {
|
||||
if (visitor instanceof KtVisitor) {
|
||||
accept((KtVisitor) visitor, null);
|
||||
|
||||
@@ -266,10 +266,12 @@ public class KtPsiUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@SafeVarargs
|
||||
@Contract("null, _ -> null")
|
||||
public static PsiElement getTopmostParentOfTypes(
|
||||
@Nullable PsiElement element,
|
||||
@NotNull Class<? extends PsiElement>... parentTypes) {
|
||||
@NotNull Class<? extends PsiElement>... parentTypes
|
||||
) {
|
||||
if (element instanceof PsiFile) return null;
|
||||
|
||||
PsiElement answer = PsiTreeUtil.getParentOfType(element, parentTypes);
|
||||
@@ -641,12 +643,13 @@ public class KtPsiUtil {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends PsiElement> T getLastChildByType(@NotNull PsiElement root, @NotNull Class<? extends T>... elementTypes) {
|
||||
PsiElement[] children = root.getChildren();
|
||||
|
||||
for (int i = children.length - 1; i >= 0; i--) {
|
||||
if (PsiTreeUtil.instanceOf(children[i], elementTypes)) {
|
||||
//noinspection unchecked
|
||||
return (T) children[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,13 +37,13 @@ public final class KtStubbedPsiUtil {
|
||||
|
||||
//TODO: contribute to idea PsiTreeUtil#getPsiOrStubParent
|
||||
@Nullable
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends KtElement> T getPsiOrStubParent(
|
||||
@NotNull PsiElement element,
|
||||
@NotNull Class<T> declarationClass,
|
||||
boolean strict
|
||||
) {
|
||||
if (!strict && declarationClass.isInstance(element)) {
|
||||
//noinspection unchecked
|
||||
return (T) element;
|
||||
}
|
||||
if (element instanceof KtElementImplStub) {
|
||||
|
||||
+4
-4
@@ -23,12 +23,11 @@ import com.intellij.psi.stubs.StubOutputStream;
|
||||
import com.intellij.util.io.StringRef;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.psi.KtAnnotationEntry;
|
||||
import org.jetbrains.kotlin.psi.KtPsiUtil;
|
||||
import org.jetbrains.kotlin.psi.KtValueArgumentList;
|
||||
import org.jetbrains.kotlin.psi.stubs.KotlinAnnotationEntryStub;
|
||||
import org.jetbrains.kotlin.psi.stubs.impl.KotlinAnnotationEntryStubImpl;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -38,13 +37,14 @@ public class KtAnnotationEntryElementType extends KtStubElementType<KotlinAnnota
|
||||
super(debugName, KtAnnotationEntry.class, KotlinAnnotationEntryStub.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public KotlinAnnotationEntryStub createStub(@NotNull KtAnnotationEntry psi, StubElement parentStub) {
|
||||
Name shortName = psi.getShortName();
|
||||
String resultName = shortName != null ? shortName.asString() : null;
|
||||
KtValueArgumentList valueArgumentList = psi.getValueArgumentList();
|
||||
boolean hasValueArguments = valueArgumentList != null && !valueArgumentList.getArguments().isEmpty();
|
||||
return new KotlinAnnotationEntryStubImpl(parentStub, StringRef.fromString(resultName), hasValueArguments);
|
||||
return new KotlinAnnotationEntryStubImpl((StubElement<?>) parentStub, StringRef.fromString(resultName), hasValueArguments);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -58,7 +58,7 @@ public class KtAnnotationEntryElementType extends KtStubElementType<KotlinAnnota
|
||||
public KotlinAnnotationEntryStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
|
||||
StringRef text = dataStream.readName();
|
||||
boolean hasValueArguments = dataStream.readBoolean();
|
||||
return new KotlinAnnotationEntryStubImpl(parentStub, text, hasValueArguments);
|
||||
return new KotlinAnnotationEntryStubImpl((StubElement<?>) parentStub, text, hasValueArguments);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -52,15 +52,19 @@ public class KtClassElementType extends KtStubElementType<KotlinClassStub, KtCla
|
||||
return node.getElementType() != KtStubElementTypes.ENUM_ENTRY ? new KtClass(node) : new KtEnumEntry(node);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public KotlinClassStub createStub(@NotNull KtClass psi, StubElement parentStub) {
|
||||
FqName fqName = KtPsiUtilKt.safeFqNameForLazyResolve(psi);
|
||||
boolean isEnumEntry = psi instanceof KtEnumEntry;
|
||||
List<String> superNames = KtPsiUtilKt.getSuperNames(psi);
|
||||
return new KotlinClassStubImpl(
|
||||
getStubType(isEnumEntry), parentStub, StringRef.fromString(fqName != null ? fqName.asString() : null),
|
||||
StringRef.fromString(psi.getName()), Utils.INSTANCE.wrapStrings(superNames), psi.isInterface(), isEnumEntry,
|
||||
psi.isLocal(), psi.isTopLevel());
|
||||
getStubType(isEnumEntry), (StubElement<?>) parentStub,
|
||||
StringRef.fromString(fqName != null ? fqName.asString() : null),
|
||||
StringRef.fromString(psi.getName()),
|
||||
Utils.INSTANCE.wrapStrings(superNames),
|
||||
psi.isInterface(), isEnumEntry, psi.isLocal(), psi.isTopLevel()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -96,8 +100,10 @@ public class KtClassElementType extends KtStubElementType<KotlinClassStub, KtCla
|
||||
superNames[i] = dataStream.readName();
|
||||
}
|
||||
|
||||
return new KotlinClassStubImpl(getStubType(isEnumEntry), parentStub, qualifiedName, name, superNames,
|
||||
isTrait, isEnumEntry, isLocal, isTopLevel);
|
||||
return new KotlinClassStubImpl(
|
||||
getStubType(isEnumEntry), (StubElement<?>) parentStub, qualifiedName, name, superNames,
|
||||
isTrait, isEnumEntry, isLocal, isTopLevel
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+10
-5
@@ -38,6 +38,7 @@ public class KtFunctionElementType extends KtStubElementType<KotlinFunctionStub,
|
||||
super(debugName, KtNamedFunction.class, KotlinFunctionStub.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public KotlinFunctionStub createStub(@NotNull KtNamedFunction psi, @NotNull StubElement parentStub) {
|
||||
boolean isTopLevel = psi.getParent() instanceof KtFile;
|
||||
@@ -45,9 +46,11 @@ public class KtFunctionElementType extends KtStubElementType<KotlinFunctionStub,
|
||||
FqName fqName = KtPsiUtilKt.safeFqNameForLazyResolve(psi);
|
||||
boolean hasBlockBody = psi.hasBlockBody();
|
||||
boolean hasBody = psi.hasBody();
|
||||
return new KotlinFunctionStubImpl(parentStub, StringRef.fromString(psi.getName()), isTopLevel, fqName,
|
||||
isExtension, hasBlockBody, hasBody, psi.hasTypeParameterListBeforeFunctionName(),
|
||||
psi.mayHaveContract());
|
||||
return new KotlinFunctionStubImpl(
|
||||
(StubElement<?>) parentStub, StringRef.fromString(psi.getName()), isTopLevel, fqName,
|
||||
isExtension, hasBlockBody, hasBody, psi.hasTypeParameterListBeforeFunctionName(),
|
||||
psi.mayHaveContract()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,8 +83,10 @@ public class KtFunctionElementType extends KtStubElementType<KotlinFunctionStub,
|
||||
boolean hasTypeParameterListBeforeFunctionName = dataStream.readBoolean();
|
||||
boolean mayHaveContract = dataStream.readBoolean();
|
||||
|
||||
return new KotlinFunctionStubImpl(parentStub, name, isTopLevel, fqName, isExtension, hasBlockBody, hasBody,
|
||||
hasTypeParameterListBeforeFunctionName, mayHaveContract);
|
||||
return new KotlinFunctionStubImpl(
|
||||
(StubElement<?>) parentStub, name, isTopLevel, fqName, isExtension, hasBlockBody, hasBody,
|
||||
hasTypeParameterListBeforeFunctionName, mayHaveContract
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-2
@@ -34,11 +34,12 @@ public class KtImportDirectiveElementType extends KtStubElementType<KotlinImport
|
||||
super(debugName, KtImportDirective.class, KotlinImportDirectiveStub.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public KotlinImportDirectiveStub createStub(@NotNull KtImportDirective psi, StubElement parentStub) {
|
||||
FqName importedFqName = psi.getImportedFqName();
|
||||
StringRef fqName = StringRef.fromString(importedFqName == null ? null : importedFqName.asString());
|
||||
return new KotlinImportDirectiveStubImpl(parentStub, psi.isAllUnder(), fqName, psi.isValidImport());
|
||||
return new KotlinImportDirectiveStubImpl((StubElement<?>) parentStub, psi.isAllUnder(), fqName, psi.isValidImport());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,6 +56,6 @@ public class KtImportDirectiveElementType extends KtStubElementType<KotlinImport
|
||||
boolean isAllUnder = dataStream.readBoolean();
|
||||
StringRef importedName = dataStream.readName();
|
||||
boolean isValid = dataStream.readBoolean();
|
||||
return new KotlinImportDirectiveStubImpl(parentStub, isAllUnder, importedName, isValid);
|
||||
return new KotlinImportDirectiveStubImpl((StubElement<?>) parentStub, isAllUnder, importedName, isValid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,13 +38,16 @@ public class KtObjectElementType extends KtStubElementType<KotlinObjectStub, KtO
|
||||
super(debugName, KtObjectDeclaration.class, KotlinObjectStub.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public KotlinObjectStub createStub(@NotNull KtObjectDeclaration psi, StubElement parentStub) {
|
||||
String name = psi.getName();
|
||||
FqName fqName = KtPsiUtilKt.safeFqNameForLazyResolve(psi);
|
||||
List<String> superNames = KtPsiUtilKt.getSuperNames(psi);
|
||||
return new KotlinObjectStubImpl(parentStub, StringRef.fromString(name), fqName, Utils.INSTANCE.wrapStrings(superNames),
|
||||
psi.isTopLevel(), psi.isCompanion(), psi.isLocal(), psi.isObjectLiteral());
|
||||
return new KotlinObjectStubImpl(
|
||||
(StubElement<?>) parentStub, StringRef.fromString(name), fqName, Utils.INSTANCE.wrapStrings(superNames),
|
||||
psi.isTopLevel(), psi.isCompanion(), psi.isLocal(), psi.isObjectLiteral()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -84,7 +87,9 @@ public class KtObjectElementType extends KtStubElementType<KotlinObjectStub, KtO
|
||||
superNames[i] = dataStream.readName();
|
||||
}
|
||||
|
||||
return new KotlinObjectStubImpl(parentStub, name, fqName, superNames, isTopLevel, isCompanion, isLocal, isObjectLiteral);
|
||||
return new KotlinObjectStubImpl(
|
||||
(StubElement<?>) parentStub, name, fqName, superNames, isTopLevel, isCompanion, isLocal, isObjectLiteral
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+7
-4
@@ -23,10 +23,10 @@ import com.intellij.psi.stubs.StubOutputStream;
|
||||
import com.intellij.util.io.StringRef;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.psi.KtParameter;
|
||||
import org.jetbrains.kotlin.psi.stubs.KotlinParameterStub;
|
||||
import org.jetbrains.kotlin.psi.stubs.impl.KotlinParameterStubImpl;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -35,12 +35,15 @@ public class KtParameterElementType extends KtStubElementType<KotlinParameterStu
|
||||
super(debugName, KtParameter.class, KotlinParameterStub.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public KotlinParameterStub createStub(@NotNull KtParameter psi, StubElement parentStub) {
|
||||
FqName fqName = psi.getFqName();
|
||||
StringRef fqNameRef = StringRef.fromString(fqName != null ? fqName.asString() : null);
|
||||
return new KotlinParameterStubImpl(parentStub, fqNameRef, StringRef.fromString(psi.getName()),
|
||||
psi.isMutable(), psi.hasValOrVar(), psi.hasDefaultValue());
|
||||
return new KotlinParameterStubImpl(
|
||||
(StubElement<?>) parentStub, fqNameRef, StringRef.fromString(psi.getName()),
|
||||
psi.isMutable(), psi.hasValOrVar(), psi.hasDefaultValue()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -62,7 +65,7 @@ public class KtParameterElementType extends KtStubElementType<KotlinParameterStu
|
||||
boolean hasDefaultValue = dataStream.readBoolean();
|
||||
StringRef fqName = dataStream.readName();
|
||||
|
||||
return new KotlinParameterStubImpl(parentStub, fqName, name, isMutable, hasValOrValNode, hasDefaultValue);
|
||||
return new KotlinParameterStubImpl((StubElement<?>) parentStub, fqName, name, isMutable, hasValOrValNode, hasDefaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -36,6 +36,7 @@ public class KtPropertyElementType extends KtStubElementType<KotlinPropertyStub,
|
||||
super(debugName, KtProperty.class, KotlinPropertyStub.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public KotlinPropertyStub createStub(@NotNull KtProperty psi, StubElement parentStub) {
|
||||
assert !psi.isLocal() :
|
||||
@@ -43,7 +44,7 @@ public class KtPropertyElementType extends KtStubElementType<KotlinPropertyStub,
|
||||
psi.getText(), psi.getParent() != null ? psi.getParent().getText() : "<no parent>");
|
||||
|
||||
return new KotlinPropertyStubImpl(
|
||||
parentStub, StringRef.fromString(psi.getName()),
|
||||
(StubElement<?>) parentStub, StringRef.fromString(psi.getName()),
|
||||
psi.isVar(), psi.isTopLevel(), psi.hasDelegate(),
|
||||
psi.hasDelegateExpression(), psi.hasInitializer(),
|
||||
psi.getReceiverTypeReference() != null, psi.getTypeReference() != null,
|
||||
@@ -81,9 +82,10 @@ public class KtPropertyElementType extends KtStubElementType<KotlinPropertyStub,
|
||||
StringRef fqNameAsString = dataStream.readName();
|
||||
FqName fqName = fqNameAsString != null ? new FqName(fqNameAsString.toString()) : null;
|
||||
|
||||
return new KotlinPropertyStubImpl(parentStub, name, isVar, isTopLevel, hasDelegate,
|
||||
hasDelegateExpression, hasInitializer, hasReceiverTypeRef, hasReturnTypeRef,
|
||||
fqName);
|
||||
return new KotlinPropertyStubImpl(
|
||||
(StubElement<?>) parentStub, name, isVar, isTopLevel, hasDelegate, hasDelegateExpression, hasInitializer,
|
||||
hasReceiverTypeRef, hasReturnTypeRef, fqName
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -47,6 +47,7 @@ public abstract class KtStubElementType<StubT extends StubElement, PsiT extends
|
||||
@NotNull
|
||||
private final ArrayFactory<PsiT> arrayFactory;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public KtStubElementType(@NotNull @NonNls String debugName, @NotNull Class<PsiT> psiClass, @NotNull Class<?> stubClass) {
|
||||
super(debugName, KotlinLanguage.INSTANCE);
|
||||
try {
|
||||
@@ -56,13 +57,11 @@ public abstract class KtStubElementType<StubT extends StubElement, PsiT extends
|
||||
catch (NoSuchMethodException e) {
|
||||
throw new RuntimeException("Stub element type declaration for " + psiClass.getSimpleName() + " is missing required constructors",e);
|
||||
}
|
||||
//noinspection unchecked
|
||||
emptyArray = (PsiT[]) Array.newInstance(psiClass, 0);
|
||||
arrayFactory = count -> {
|
||||
if (count == 0) {
|
||||
return emptyArray;
|
||||
}
|
||||
//noinspection unchecked
|
||||
return (PsiT[]) Array.newInstance(psiClass, count);
|
||||
};
|
||||
}
|
||||
|
||||
+6
-3
@@ -34,10 +34,13 @@ public class KtTypeParameterElementType extends KtStubElementType<KotlinTypePara
|
||||
super(debugName, KtTypeParameter.class, KotlinTypeParameterStub.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public KotlinTypeParameterStub createStub(@NotNull KtTypeParameter psi, StubElement parentStub) {
|
||||
return new KotlinTypeParameterStubImpl(parentStub, StringRef.fromString(psi.getName()),
|
||||
psi.getVariance() == Variance.IN_VARIANCE, psi.getVariance() == Variance.OUT_VARIANCE);
|
||||
return new KotlinTypeParameterStubImpl(
|
||||
(StubElement<?>) parentStub, StringRef.fromString(psi.getName()),
|
||||
psi.getVariance() == Variance.IN_VARIANCE, psi.getVariance() == Variance.OUT_VARIANCE
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,6 +57,6 @@ public class KtTypeParameterElementType extends KtStubElementType<KotlinTypePara
|
||||
boolean isInVariance = dataStream.readBoolean();
|
||||
boolean isOutVariance = dataStream.readBoolean();
|
||||
|
||||
return new KotlinTypeParameterStubImpl(parentStub, name, isInVariance, isOutVariance);
|
||||
return new KotlinTypeParameterStubImpl((StubElement<?>) parentStub, name, isInVariance, isOutVariance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,25 +25,24 @@ import org.jetbrains.kotlin.psi.KtUserType;
|
||||
import org.jetbrains.kotlin.psi.stubs.KotlinUserTypeStub;
|
||||
import org.jetbrains.kotlin.psi.stubs.impl.KotlinUserTypeStubImpl;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class KtUserTypeElementType extends KtStubElementType<KotlinUserTypeStub, KtUserType> {
|
||||
public KtUserTypeElementType(@NotNull @NonNls String debugName) {
|
||||
super(debugName, KtUserType.class, KotlinUserTypeStub.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public KotlinUserTypeStub createStub(@NotNull KtUserType psi, StubElement parentStub) {
|
||||
return new KotlinUserTypeStubImpl(parentStub);
|
||||
return new KotlinUserTypeStubImpl((StubElement<?>) parentStub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(@NotNull KotlinUserTypeStub stub, @NotNull StubOutputStream dataStream) throws IOException {
|
||||
public void serialize(@NotNull KotlinUserTypeStub stub, @NotNull StubOutputStream dataStream) {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public KotlinUserTypeStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
|
||||
return new KotlinUserTypeStubImpl(parentStub);
|
||||
public KotlinUserTypeStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) {
|
||||
return new KotlinUserTypeStubImpl((StubElement<?>) parentStub);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.psi.stubs.impl
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.stubs.StubElement
|
||||
import com.intellij.util.io.StringRef
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -25,7 +24,7 @@ import org.jetbrains.kotlin.psi.stubs.KotlinImportDirectiveStub
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes
|
||||
|
||||
class KotlinImportDirectiveStubImpl(
|
||||
parent: StubElement<PsiElement>,
|
||||
parent: StubElement<*>,
|
||||
private val isAllUnder: Boolean,
|
||||
private val importedFqName: StringRef?,
|
||||
private val isValid: Boolean
|
||||
|
||||
+7
-15
@@ -16,9 +16,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.codegen;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import kotlin.collections.CollectionsKt;
|
||||
import kotlin.io.FilesKt;
|
||||
import kotlin.sequences.SequencesKt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles;
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment;
|
||||
@@ -28,28 +29,19 @@ import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.TestJdkKind;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AbstractTopLevelMembersInvocationTest extends AbstractBytecodeTextTest {
|
||||
|
||||
private static final String LIBRARY = "library";
|
||||
|
||||
@Override
|
||||
public void doTest(@NotNull String filename) throws Exception {
|
||||
File root = new File(filename);
|
||||
List<String> sourceFiles = new ArrayList<>(2);
|
||||
List<String> sourceFiles = SequencesKt.toList(SequencesKt.map(
|
||||
SequencesKt.filter(FilesKt.walkTopDown(root).maxDepth(1), File::isFile),
|
||||
this::relativePath
|
||||
));
|
||||
|
||||
FileUtil.processFilesRecursively(root, file -> {
|
||||
if (file.getName().endsWith(".kt")) {
|
||||
sourceFiles.add(relativePath(file));
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}, file -> !LIBRARY.equals(file.getName()));
|
||||
|
||||
File library = new File(root, LIBRARY);
|
||||
File library = new File(root, "library");
|
||||
List<File> classPath =
|
||||
library.exists()
|
||||
? Collections.singletonList(CompilerTestUtil.compileJvmLibrary(library))
|
||||
|
||||
@@ -308,7 +308,7 @@ public abstract class CodegenTestCase extends KtUsefulTestCase {
|
||||
assert configurationKeyField != null : "Expected [+|-][namespace.]configurationKey, got: " + flag;
|
||||
|
||||
try {
|
||||
//noinspection unchecked
|
||||
@SuppressWarnings("unchecked")
|
||||
CompilerConfigurationKey<Boolean> configurationKey = (CompilerConfigurationKey<Boolean>) configurationKeyField.get(null);
|
||||
configuration.put(configurationKey, flagEnabled);
|
||||
}
|
||||
@@ -615,9 +615,9 @@ public abstract class CodegenTestCase extends KtUsefulTestCase {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@SuppressWarnings("unchecked")
|
||||
public Class<? extends Annotation> loadAnnotationClassQuietly(@NotNull String fqName) {
|
||||
try {
|
||||
//noinspection unchecked
|
||||
return (Class<? extends Annotation>) initializedClassLoader.loadClass(fqName);
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
|
||||
+1
-1
@@ -70,11 +70,11 @@ public abstract class KtPlatformLiteFixture extends KtUsefulTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T registerComponentInstance(MutablePicoContainer container, Class<T> key, T implementation) {
|
||||
Object old = container.getComponentInstance(key);
|
||||
container.unregisterComponent(key);
|
||||
container.registerComponentInstance(key, implementation);
|
||||
//noinspection unchecked
|
||||
return (T)old;
|
||||
}
|
||||
}
|
||||
|
||||
+7
-2
@@ -180,6 +180,7 @@ public abstract class KtUsefulTestCase extends TestCase {
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<String> files = ReflectionUtil.getStaticFieldValue(aClass, Set.class, "files");
|
||||
DELETE_ON_EXIT_HOOK_CLASS = aClass;
|
||||
DELETE_ON_EXIT_HOOK_DOT_FILES = files;
|
||||
@@ -307,7 +308,9 @@ public abstract class KtUsefulTestCase extends TestCase {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (Object o : collection) {
|
||||
if (o instanceof THashSet) {
|
||||
builder.append(new TreeSet<Object>((THashSet)o));
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<Object> set = new TreeSet<Object>((THashSet) o);
|
||||
builder.append(set);
|
||||
}
|
||||
else {
|
||||
builder.append(o);
|
||||
@@ -317,6 +320,7 @@ public abstract class KtUsefulTestCase extends TestCase {
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
private static <T> void assertOrderedEquals(String errorMsg, @NotNull Iterable<T> actual, @NotNull T... expected) {
|
||||
Assert.assertNotNull(actual);
|
||||
Assert.assertNotNull(expected);
|
||||
@@ -339,10 +343,12 @@ public abstract class KtUsefulTestCase extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public static <T> void assertSameElements(T[] collection, T... expected) {
|
||||
assertSameElements(Arrays.asList(collection), expected);
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public static <T> void assertSameElements(Collection<? extends T> collection, T... expected) {
|
||||
assertSameElements(collection, Arrays.asList(expected));
|
||||
}
|
||||
@@ -388,7 +394,6 @@ public abstract class KtUsefulTestCase extends TestCase {
|
||||
}
|
||||
|
||||
protected static <T> void assertEmpty(String errorMsg, Collection<T> collection) {
|
||||
//noinspection unchecked
|
||||
assertOrderedEquals(errorMsg, collection);
|
||||
}
|
||||
|
||||
|
||||
@@ -167,8 +167,8 @@ public class AnnotationGenTest extends CodegenTestCase {
|
||||
public void testConstructor() throws NoSuchFieldException, NoSuchMethodException {
|
||||
loadText("class A @[java.lang.Deprecated] constructor() {}");
|
||||
Class<?> aClass = generateClass("A");
|
||||
Constructor x = aClass.getDeclaredConstructor();
|
||||
Deprecated annotation = (Deprecated) x.getAnnotation(Deprecated.class);
|
||||
Constructor<?> x = aClass.getDeclaredConstructor();
|
||||
Deprecated annotation = x.getAnnotation(Deprecated.class);
|
||||
assertNotNull(annotation);
|
||||
}
|
||||
|
||||
@@ -181,8 +181,8 @@ public class AnnotationGenTest extends CodegenTestCase {
|
||||
|
||||
public void testClass() throws NoSuchFieldException, NoSuchMethodException {
|
||||
loadText("@[java.lang.Deprecated] class A () {}");
|
||||
Class aClass = generateClass("A");
|
||||
Deprecated annotation = (Deprecated) aClass.getAnnotation(Deprecated.class);
|
||||
Class<?> aClass = generateClass("A");
|
||||
Deprecated annotation = aClass.getAnnotation(Deprecated.class);
|
||||
assertNotNull(annotation);
|
||||
}
|
||||
|
||||
@@ -209,9 +209,10 @@ public class AnnotationGenTest extends CodegenTestCase {
|
||||
"@java.lang.annotation.Retention(RetentionPolicy.RUNTIME) annotation class A(val a: String)\n" +
|
||||
"" +
|
||||
"@A(\"239\") class B()");
|
||||
Class aClass = generateClass("A");
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends Annotation> aClass = (Class) generateClass("A");
|
||||
|
||||
Retention annotation = (Retention)aClass.getAnnotation(Retention.class);
|
||||
Retention annotation = aClass.getAnnotation(Retention.class);
|
||||
RetentionPolicy value = annotation.value();
|
||||
assertEquals(RetentionPolicy.RUNTIME, value);
|
||||
|
||||
@@ -243,9 +244,10 @@ public class AnnotationGenTest extends CodegenTestCase {
|
||||
"@java.lang.annotation.Retention(RetentionPolicy.RUNTIME) annotation class A(val a: C)\n" +
|
||||
"" +
|
||||
"@A(C(\"239\")) class B()");
|
||||
Class aClass = generateClass("A");
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends Annotation> aClass = (Class) generateClass("A");
|
||||
|
||||
Retention annotation = (Retention)aClass.getAnnotation(Retention.class);
|
||||
Retention annotation = aClass.getAnnotation(Retention.class);
|
||||
RetentionPolicy value = annotation.value();
|
||||
assertEquals(RetentionPolicy.RUNTIME, value);
|
||||
|
||||
@@ -280,9 +282,10 @@ public class AnnotationGenTest extends CodegenTestCase {
|
||||
"@java.lang.annotation.Retention(RetentionPolicy.RUNTIME) annotation class A(val a: Array<String>)\n" +
|
||||
"" +
|
||||
"@A(arrayOf(\"239\",\"932\")) class B()");
|
||||
Class aClass = generateClass("A");
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends Annotation> aClass = (Class) generateClass("A");
|
||||
|
||||
Retention annotation = (Retention)aClass.getAnnotation(Retention.class);
|
||||
Retention annotation = aClass.getAnnotation(Retention.class);
|
||||
RetentionPolicy value = annotation.value();
|
||||
assertEquals(RetentionPolicy.RUNTIME, value);
|
||||
|
||||
@@ -315,9 +318,10 @@ public class AnnotationGenTest extends CodegenTestCase {
|
||||
"@java.lang.annotation.Retention(RetentionPolicy.RUNTIME) annotation class A(val a: IntArray)\n" +
|
||||
"" +
|
||||
"@A(intArrayOf(239,932)) class B()");
|
||||
Class aClass = generateClass("A");
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends Annotation> aClass = (Class) generateClass("A");
|
||||
|
||||
Retention annotation = (Retention)aClass.getAnnotation(Retention.class);
|
||||
Retention annotation = aClass.getAnnotation(Retention.class);
|
||||
RetentionPolicy value = annotation.value();
|
||||
assertEquals(RetentionPolicy.RUNTIME, value);
|
||||
|
||||
@@ -348,9 +352,9 @@ public class AnnotationGenTest extends CodegenTestCase {
|
||||
loadText("import java.lang.annotation.*\n" +
|
||||
"" +
|
||||
"@java.lang.annotation.Target(ElementType.TYPE, ElementType.METHOD) annotation class A");
|
||||
Class aClass = generateClass("A");
|
||||
Class<?> aClass = generateClass("A");
|
||||
|
||||
Target annotation = (Target)aClass.getAnnotation(Target.class);
|
||||
Target annotation = aClass.getAnnotation(Target.class);
|
||||
ElementType[] value = annotation.value();
|
||||
assertEquals(2, value.length);
|
||||
|
||||
@@ -372,7 +376,8 @@ public class AnnotationGenTest extends CodegenTestCase {
|
||||
"@Retention(RetentionPolicy.RUNTIME) annotation class A(val a: Array<Retention>)\n" +
|
||||
"" +
|
||||
"@A(arrayOf(Retention(RetentionPolicy.RUNTIME),Retention(RetentionPolicy.SOURCE))) class B()");
|
||||
Class aClass = generateClass("A");
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends Annotation> aClass = (Class) generateClass("A");
|
||||
|
||||
Method[] methods = aClass.getDeclaredMethods();
|
||||
assertEquals(1, methods.length);
|
||||
|
||||
+1
-1
@@ -168,9 +168,9 @@ public class JavaPropertyDescriptor extends PropertyDescriptorImpl implements Ja
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <V> V getUserData(UserDataKey<V> key) {
|
||||
if (singleUserData != null && singleUserData.getFirst().equals(key)) {
|
||||
//noinspection unchecked
|
||||
return (V) singleUserData.getSecond();
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -261,9 +261,9 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <V> V getUserData(UserDataKey<V> key) {
|
||||
if (userDataMap == null) return null;
|
||||
//noinspection unchecked
|
||||
return (V) userDataMap.get(key);
|
||||
}
|
||||
|
||||
@@ -273,8 +273,8 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setOverriddenDescriptors(@NotNull Collection<? extends CallableMemberDescriptor> overriddenDescriptors) {
|
||||
//noinspection unchecked
|
||||
overriddenFunctions = (Collection<? extends FunctionDescriptor>) overriddenDescriptors;
|
||||
for (FunctionDescriptor function : overriddenFunctions) {
|
||||
if (function.isHiddenForResolutionEverywhereBesideSupercalls()) {
|
||||
|
||||
+1
-1
@@ -522,8 +522,8 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setOverriddenDescriptors(@NotNull Collection<? extends CallableMemberDescriptor> overriddenDescriptors) {
|
||||
//noinspection unchecked
|
||||
this.overriddenProperties = (Collection<? extends PropertyDescriptor>) overriddenDescriptors;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -126,8 +126,8 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public CopyBuilder<? extends SimpleFunctionDescriptor> newCopyBuilder() {
|
||||
//noinspection unchecked
|
||||
return (CopyBuilder<? extends SimpleFunctionDescriptor>) super.newCopyBuilder();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
package kotlin.reflect.jvm.internal;
|
||||
|
||||
/* package */ class Util {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Object getEnumConstantByName(Class<? extends Enum<?>> enumClass, String name) {
|
||||
// This is a workaround for KT-5191. Enum#valueOf cannot be called in Kotlin
|
||||
return Enum.valueOf((Class) enumClass, name);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import kotlin.reflect.KCallable;
|
||||
import kotlin.reflect.KMutableProperty1;
|
||||
import kotlin.reflect.KProperty1;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public abstract class MutablePropertyReference1 extends MutablePropertyReference implements KMutableProperty1 {
|
||||
public MutablePropertyReference1() {
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import kotlin.reflect.KCallable;
|
||||
import kotlin.reflect.KMutableProperty2;
|
||||
import kotlin.reflect.KProperty2;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public abstract class MutablePropertyReference2 extends MutablePropertyReference implements KMutableProperty2 {
|
||||
@Override
|
||||
protected KCallable computeReflected() {
|
||||
|
||||
@@ -9,6 +9,7 @@ import kotlin.SinceKotlin;
|
||||
import kotlin.reflect.KCallable;
|
||||
import kotlin.reflect.KProperty1;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public abstract class PropertyReference1 extends PropertyReference implements KProperty1 {
|
||||
public PropertyReference1() {
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import kotlin.SinceKotlin;
|
||||
import kotlin.reflect.KCallable;
|
||||
import kotlin.reflect.KProperty2;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public abstract class PropertyReference2 extends PropertyReference implements KProperty2 {
|
||||
@Override
|
||||
protected KCallable computeReflected() {
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
|
||||
package kotlin.jvm.internal;
|
||||
|
||||
import java.lang.Object;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class SpreadBuilder {
|
||||
@@ -18,6 +18,7 @@ public class SpreadBuilder {
|
||||
list = new ArrayList<Object>(size);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addSpread(Object container) {
|
||||
if (container == null) return;
|
||||
|
||||
@@ -25,9 +26,7 @@ public class SpreadBuilder {
|
||||
Object[] array = (Object[]) container;
|
||||
if (array.length > 0) {
|
||||
list.ensureCapacity(list.size() + array.length);
|
||||
for (Object element : array) {
|
||||
list.add(element);
|
||||
}
|
||||
Collections.addAll(list, array);
|
||||
}
|
||||
}
|
||||
else if (container instanceof Collection) {
|
||||
|
||||
Reference in New Issue
Block a user