Generic type with Nothing in arguments compiles to raw type
This commit is contained in:
@@ -18,6 +18,8 @@ package org.jetbrains.kotlin.codegen.state;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import kotlin.CollectionsKt;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.builtins.BuiltinsPackageFragment;
|
||||
@@ -595,6 +597,11 @@ public class JetTypeMapper {
|
||||
boolean projectionsAllowed
|
||||
) {
|
||||
if (signatureVisitor != null) {
|
||||
if (hasNothingInArguments(jetType)) {
|
||||
signatureVisitor.writeAsmType(asmType);
|
||||
return;
|
||||
}
|
||||
|
||||
signatureVisitor.writeClassBegin(asmType);
|
||||
|
||||
List<TypeProjection> arguments = jetType.getArguments();
|
||||
@@ -622,6 +629,24 @@ public class JetTypeMapper {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hasNothingInArguments(JetType jetType) {
|
||||
boolean hasNothingInArguments = CollectionsKt.any(jetType.getArguments(), new Function1<TypeProjection, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(TypeProjection projection) {
|
||||
return KotlinBuiltIns.isNothingOrNullableNothing(projection.getType());
|
||||
}
|
||||
});
|
||||
|
||||
if (hasNothingInArguments) return true;
|
||||
|
||||
return CollectionsKt.any(jetType.getArguments(), new Function1<TypeProjection, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(TypeProjection projection) {
|
||||
return !projection.isStarProjection() && hasNothingInArguments(projection.getType());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static Variance getEffectiveVariance(Variance parameterVariance, Variance projectionKind, Variance howThisTypeIsUsed) {
|
||||
// Return type must not contain wildcards
|
||||
if (howThisTypeIsUsed == Variance.OUT_VARIANCE) return projectionKind;
|
||||
|
||||
Reference in New Issue
Block a user