Changing default nullability for type arguments to NotNull
This commit is contained in:
+13
-5
@@ -148,7 +148,7 @@ public class JavaTypeTransformer {
|
||||
}
|
||||
else {
|
||||
// 'L extends List<T>' in Java is a List<T> in Kotlin, not a List<T?>
|
||||
boolean nullable = !EnumSet.of(SUPERTYPE_ARGUMENT, SUPERTYPE).contains(howThisTypeIsUsed);
|
||||
boolean nullable = !EnumSet.of(TYPE_ARGUMENT, SUPERTYPE_ARGUMENT, SUPERTYPE).contains(howThisTypeIsUsed);
|
||||
|
||||
ClassDescriptor classData = JavaToKotlinClassMap.getInstance().mapKotlinClass(new FqName(psiClass.getQualifiedName()),
|
||||
howThisTypeIsUsed);
|
||||
@@ -228,16 +228,24 @@ public class JavaTypeTransformer {
|
||||
return TypeUtils.makeNullable(jetType);
|
||||
}
|
||||
|
||||
boolean vararg = arrayType instanceof PsiEllipsisType;
|
||||
|
||||
Variance projectionKind = arrayElementTypeProjectionKind(vararg);
|
||||
TypeUsage howArgumentTypeIsUsed = vararg ? MEMBER_SIGNATURE_CONTRAVARIANT : TYPE_ARGUMENT;
|
||||
|
||||
JetType type = transformToType(componentType, howArgumentTypeIsUsed, typeVariableResolver);
|
||||
return TypeUtils.makeNullable(KotlinBuiltIns.getInstance().getArrayType(projectionKind, type));
|
||||
}
|
||||
|
||||
private Variance arrayElementTypeProjectionKind(boolean vararg) {
|
||||
Variance variance;
|
||||
if (howThisTypeIsUsed == MEMBER_SIGNATURE_CONTRAVARIANT && !(arrayType instanceof PsiEllipsisType)) {
|
||||
if (howThisTypeIsUsed == MEMBER_SIGNATURE_CONTRAVARIANT && !vararg) {
|
||||
variance = Variance.OUT_VARIANCE;
|
||||
}
|
||||
else {
|
||||
variance = Variance.INVARIANT;
|
||||
}
|
||||
|
||||
JetType type = transformToType(componentType, typeVariableResolver);
|
||||
return TypeUtils.makeNullable(KotlinBuiltIns.getInstance().getArrayType(variance, type));
|
||||
return variance;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+10
-4
@@ -29,7 +29,10 @@ import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.wrapper.PsiMethodWrapper;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||
import org.jetbrains.jet.lang.types.Variance;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
@@ -37,6 +40,9 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.java.JavaTypeTransformer.TypeUsage.MEMBER_SIGNATURE_CONTRAVARIANT;
|
||||
import static org.jetbrains.jet.lang.resolve.java.JavaTypeTransformer.TypeUsage.UPPER_BOUND;
|
||||
|
||||
/**
|
||||
* @author Evgeny Gerashchenko
|
||||
* @since 6/5/12
|
||||
@@ -181,7 +187,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
throw new AlternativeSignatureMismatchException("Parameter in method signature is not vararg, but in alternative signature it is vararg");
|
||||
}
|
||||
|
||||
alternativeType = TypeTransformingVisitor.computeType(alternativeTypeElement, originalParameterDescriptor.getType(), originalToAltTypeParameters);
|
||||
alternativeType = TypeTransformingVisitor.computeType(alternativeTypeElement, originalParameterDescriptor.getType(), originalToAltTypeParameters, MEMBER_SIGNATURE_CONTRAVARIANT);
|
||||
alternativeVarargElementType = null;
|
||||
}
|
||||
else {
|
||||
@@ -190,7 +196,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
}
|
||||
|
||||
alternativeVarargElementType = TypeTransformingVisitor.computeType(alternativeTypeElement, originalParamVarargElementType,
|
||||
originalToAltTypeParameters);
|
||||
originalToAltTypeParameters, MEMBER_SIGNATURE_CONTRAVARIANT);
|
||||
alternativeType = KotlinBuiltIns.getInstance().getArrayType(alternativeVarargElementType);
|
||||
}
|
||||
|
||||
@@ -255,7 +261,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
assert (altTypeElement != null);
|
||||
|
||||
altParamDescriptor.addUpperBound(TypeTransformingVisitor.computeType(altTypeElement, upperBound,
|
||||
originalToAltTypeParameters));
|
||||
originalToAltTypeParameters, UPPER_BOUND));
|
||||
upperBoundIndex++;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -32,6 +32,8 @@ import org.jetbrains.jet.resolve.DescriptorRenderer;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.java.JavaTypeTransformer.TypeUsage.MEMBER_SIGNATURE_COVARIANT;
|
||||
|
||||
public abstract class ElementAlternativeSignatureData {
|
||||
private String error;
|
||||
private boolean isAnnotated;
|
||||
@@ -102,6 +104,6 @@ public abstract class ElementAlternativeSignatureData {
|
||||
JetTypeElement typeElement = altReturnTypeReference.getTypeElement();
|
||||
assert (typeElement != null);
|
||||
|
||||
return TypeTransformingVisitor.computeType(typeElement, originalType, originalToAltTypeParameters);
|
||||
return TypeTransformingVisitor.computeType(typeElement, originalType, originalToAltTypeParameters, MEMBER_SIGNATURE_COVARIANT);
|
||||
}
|
||||
}
|
||||
|
||||
+14
-6
@@ -26,6 +26,7 @@ import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaToKotlinClassMap;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaTypeTransformer;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
import org.jetbrains.jet.lang.resolve.java.KotlinToJavaTypesMap;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
@@ -35,15 +36,21 @@ import org.jetbrains.jet.resolve.DescriptorRenderer;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.java.JavaTypeTransformer.TypeUsage.*;
|
||||
|
||||
class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
|
||||
private final JetType originalType;
|
||||
private final Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters;
|
||||
|
||||
private final JavaTypeTransformer.TypeUsage typeUsage;
|
||||
|
||||
private TypeTransformingVisitor(
|
||||
JetType originalType,
|
||||
Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters
|
||||
Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters,
|
||||
JavaTypeTransformer.TypeUsage typeUsage
|
||||
) {
|
||||
this.originalType = originalType;
|
||||
this.typeUsage = typeUsage;
|
||||
this.originalToAltTypeParameters = Collections.unmodifiableMap(originalToAltTypeParameters);
|
||||
}
|
||||
|
||||
@@ -51,20 +58,21 @@ class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
|
||||
public static JetType computeType(
|
||||
@NotNull JetTypeElement alternativeTypeElement,
|
||||
@NotNull JetType originalType,
|
||||
@NotNull Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters
|
||||
@NotNull Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters,
|
||||
@NotNull JavaTypeTransformer.TypeUsage typeUsage
|
||||
) {
|
||||
JetType computedType = alternativeTypeElement.accept(new TypeTransformingVisitor(originalType, originalToAltTypeParameters), null);
|
||||
JetType computedType = alternativeTypeElement.accept(new TypeTransformingVisitor(originalType, originalToAltTypeParameters, typeUsage), null);
|
||||
assert (computedType != null);
|
||||
return computedType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetType visitNullableType(JetNullableType nullableType, Void aVoid) {
|
||||
if (!originalType.isNullable()) {
|
||||
if (!originalType.isNullable() && typeUsage != TYPE_ARGUMENT) {
|
||||
throw new AlternativeSignatureMismatchException("Auto type '%s' is not-null, while type in alternative signature is nullable: '%s'",
|
||||
DescriptorRenderer.TEXT.renderType(originalType), nullableType.getText());
|
||||
}
|
||||
return TypeUtils.makeNullable(computeType(nullableType.getInnerType(), originalType, originalToAltTypeParameters));
|
||||
return TypeUtils.makeNullable(computeType(nullableType.getInnerType(), originalType, originalToAltTypeParameters, typeUsage));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -134,7 +142,7 @@ class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
|
||||
assert argumentAlternativeTypeElement != null;
|
||||
|
||||
TypeProjection argument = arguments.get(i);
|
||||
JetType alternativeArgumentType = computeType(argumentAlternativeTypeElement, argument.getType(), originalToAltTypeParameters);
|
||||
JetType alternativeArgumentType = computeType(argumentAlternativeTypeElement, argument.getType(), originalToAltTypeParameters, TYPE_ARGUMENT);
|
||||
Variance projectionKind = argument.getProjectionKind();
|
||||
Variance altProjectionKind;
|
||||
if (type instanceof JetUserType) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package test
|
||||
|
||||
public class ArrayTypeVariance : java.lang.Object() {
|
||||
public fun toArray(p0: Array<out Any?>?): Array<Any?>? {
|
||||
public fun toArray(p0: Array<out Any>?): Array<Any>? {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@ namespace test
|
||||
|
||||
public final class test.ArrayTypeVariance : java.lang.Object {
|
||||
public final /*constructor*/ fun <init>(): test.ArrayTypeVariance
|
||||
public final fun toArray(/*0*/ p0: jet.Array<out jet.Any?>?): jet.Array<jet.Any?>?
|
||||
public final fun toArray(/*0*/ p0: jet.Array<out jet.Any>?): jet.Array<jet.Any>?
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package test
|
||||
|
||||
public open class FieldOfArrayType() : java.lang.Object() {
|
||||
public var files: Array<java.io.File?>? = null
|
||||
public var files: Array<java.io.File>? = null
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@ namespace test
|
||||
|
||||
public open class test.FieldOfArrayType : java.lang.Object {
|
||||
public final /*constructor*/ fun <init>(): test.FieldOfArrayType
|
||||
public final var files: jet.Array<java.io.File?>?
|
||||
public final var files: jet.Array<java.io.File>?
|
||||
}
|
||||
|
||||
@@ -3,5 +3,5 @@ package test
|
||||
import java.util.*
|
||||
|
||||
public open class WrongReturnTypeStructure : Object() {
|
||||
public open fun foo(p0 : String?, p1 : List<Map.Entry<String?, String?>?>?) : String? = ""
|
||||
public open fun foo(p0 : String?, p1 : List<Map.Entry<String, String>>?) : String? = ""
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@ namespace test
|
||||
|
||||
public open class test.WrongReturnTypeStructure : java.lang.Object {
|
||||
public final /*constructor*/ fun <init>(): test.WrongReturnTypeStructure
|
||||
public open fun foo(/*0*/ p0: jet.String?, /*1*/ p1: jet.List<jet.Map.Entry<jet.String?, jet.String?>?>?): jet.String?
|
||||
public open fun foo(/*0*/ p0: jet.String?, /*1*/ p1: jet.List<jet.Map.Entry<jet.String, jet.String>>?): jet.String?
|
||||
}
|
||||
|
||||
+1
-1
@@ -3,6 +3,6 @@ package test
|
||||
import java.util.*
|
||||
|
||||
public open class WrongTypeParameterBoundStructure1 : Object() {
|
||||
public open fun <erased A, erased B : Runnable?> foo(p0 : A?, p1 : List<B>?) where B : List<Cloneable?>? {
|
||||
public open fun <erased A, erased B : Runnable?> foo(p0 : A?, p1 : List<B>?) where B : List<Cloneable>? {
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,5 +2,5 @@ namespace test
|
||||
|
||||
public open class test.WrongTypeParameterBoundStructure1 : java.lang.Object {
|
||||
public final /*constructor*/ fun <init>(): test.WrongTypeParameterBoundStructure1
|
||||
public open fun </*0*/ A : jet.Any?, /*1*/ B : java.lang.Runnable? & jet.List<java.lang.Cloneable?>?>foo(/*0*/ p0: A?, /*1*/ p1: jet.List<B>?): jet.Tuple0
|
||||
public open fun </*0*/ A : jet.Any?, /*1*/ B : java.lang.Runnable? & jet.List<java.lang.Cloneable>?>foo(/*0*/ p0: A?, /*1*/ p1: jet.List<B>?): jet.Tuple0
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import jet.runtime.typeinfo.KotlinSignature;
|
||||
import org.jetbrains.jet.jvm.compiler.annotation.ExpectLoadError;
|
||||
|
||||
public class WrongTypeParameterBoundStructure2 {
|
||||
@ExpectLoadError("'jet.List<java.lang.Cloneable?>?' type in method signature has 1 type arguments, while 'List' in alternative signature has 0 of them")
|
||||
@ExpectLoadError("'jet.List<java.lang.Cloneable>?' type in method signature has 1 type arguments, while 'List' in alternative signature has 0 of them")
|
||||
@KotlinSignature("fun <A, B : Runnable> foo(a : A, b : List<B>) where B : List")
|
||||
public <A, B extends Runnable & List<Cloneable>> void foo(A a, List<? extends B> b) {
|
||||
}
|
||||
|
||||
+1
-1
@@ -3,6 +3,6 @@ package test
|
||||
import java.util.*
|
||||
|
||||
public open class WrongTypeParameterBoundStructure2 : Object() {
|
||||
public open fun <erased A, erased B : Runnable?> foo(p0 : A?, p1 : List<B>?) where B : List<Cloneable?>? {
|
||||
public open fun <erased A, erased B : Runnable?> foo(p0 : A?, p1 : List<B>?) where B : List<Cloneable>? {
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,5 +2,5 @@ namespace test
|
||||
|
||||
public open class test.WrongTypeParameterBoundStructure2 : java.lang.Object {
|
||||
public final /*constructor*/ fun <init>(): test.WrongTypeParameterBoundStructure2
|
||||
public open fun </*0*/ A : jet.Any?, /*1*/ B : java.lang.Runnable? & jet.List<java.lang.Cloneable?>?>foo(/*0*/ p0: A?, /*1*/ p1: jet.List<B>?): jet.Tuple0
|
||||
public open fun </*0*/ A : jet.Any?, /*1*/ B : java.lang.Runnable? & jet.List<java.lang.Cloneable>?>foo(/*0*/ p0: A?, /*1*/ p1: jet.List<B>?): jet.Tuple0
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package test
|
||||
import java.util.*
|
||||
|
||||
public open class WrongTypeVariance : Object() {
|
||||
public open fun copy(p0 : Array<out Number?>?, p1 : Array<out Number?>?) : MutableList<Number?>? {
|
||||
public open fun copy(p0 : Array<out Number>?, p1 : Array<out Number>?) : MutableList<Number>? {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@ namespace test
|
||||
|
||||
public open class test.WrongTypeVariance : java.lang.Object {
|
||||
public final /*constructor*/ fun <init>(): test.WrongTypeVariance
|
||||
public open fun copy(/*0*/ p0: jet.Array<out jet.Number?>?, /*1*/ p1: jet.Array<out jet.Number?>?): jet.MutableList<jet.Number?>?
|
||||
public open fun copy(/*0*/ p0: jet.Array<out jet.Number>?, /*1*/ p1: jet.Array<out jet.Number>?): jet.MutableList<jet.Number>?
|
||||
}
|
||||
|
||||
@@ -3,5 +3,5 @@ package test
|
||||
import java.util.*
|
||||
|
||||
public open class WrongValueParameterStructure1 : Object() {
|
||||
public open fun foo(p0 : String?, p1 : List<Map.Entry<String?, String?>?>?) : String? = ""
|
||||
public open fun foo(p0 : String?, p1 : List<Map.Entry<String, String>>?) : String? = ""
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@ namespace test
|
||||
|
||||
public open class test.WrongValueParameterStructure1 : java.lang.Object {
|
||||
public final /*constructor*/ fun <init>(): test.WrongValueParameterStructure1
|
||||
public open fun foo(/*0*/ p0: jet.String?, /*1*/ p1: jet.List<jet.Map.Entry<jet.String?, jet.String?>?>?): jet.String?
|
||||
public open fun foo(/*0*/ p0: jet.String?, /*1*/ p1: jet.List<jet.Map.Entry<jet.String, jet.String>>?): jet.String?
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import jet.runtime.typeinfo.KotlinSignature;
|
||||
import org.jetbrains.jet.jvm.compiler.annotation.ExpectLoadError;
|
||||
|
||||
public class WrongValueParameterStructure2 {
|
||||
@ExpectLoadError("'jet.Map.Entry<jet.String?, jet.String?>?' type in method signature has 2 type arguments, while 'Map.Entry<String?>' in alternative signature has 1 of them")
|
||||
@ExpectLoadError("'jet.Map.Entry<jet.String, jet.String>' type in method signature has 2 type arguments, while 'Map.Entry<String?>' in alternative signature has 1 of them")
|
||||
@KotlinSignature("fun foo(a : String, b : List<Map.Entry<String?>?>) : String")
|
||||
public String foo(String a, List<Map.Entry<String, String>> b) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
@@ -3,5 +3,5 @@ package test
|
||||
import java.util.*
|
||||
|
||||
public open class WrongValueParameterStructure2 : Object() {
|
||||
public open fun foo(p0 : String?, p1 : List<Map.Entry<String?, String?>?>?) : String? = ""
|
||||
public open fun foo(p0 : String?, p1 : List<Map.Entry<String, String>>?) : String? = ""
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@ namespace test
|
||||
|
||||
public open class test.WrongValueParameterStructure2 : java.lang.Object {
|
||||
public final /*constructor*/ fun <init>(): test.WrongValueParameterStructure2
|
||||
public open fun foo(/*0*/ p0: jet.String?, /*1*/ p1: jet.List<jet.Map.Entry<jet.String?, jet.String?>?>?): jet.String?
|
||||
public open fun foo(/*0*/ p0: jet.String?, /*1*/ p1: jet.List<jet.Map.Entry<jet.String, jet.String>>?): jet.String?
|
||||
}
|
||||
|
||||
+2
-2
@@ -3,10 +3,10 @@ package test
|
||||
public trait InheritNotVararg: Object {
|
||||
|
||||
public trait Super: Object {
|
||||
public fun foo(p0: Array<out String?>?)
|
||||
public fun foo(p0: Array<out String>?)
|
||||
}
|
||||
|
||||
public trait Sub: Super {
|
||||
override fun foo(p0: Array<out String?>?)
|
||||
override fun foo(p0: Array<out String>?)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -2,9 +2,9 @@ namespace test
|
||||
|
||||
public abstract trait test.InheritNotVararg : java.lang.Object {
|
||||
public abstract trait test.InheritNotVararg.Sub : test.InheritNotVararg.Super {
|
||||
public abstract override /*1*/ fun foo(/*0*/ p0: jet.Array<out jet.String?>?): jet.Tuple0
|
||||
public abstract override /*1*/ fun foo(/*0*/ p0: jet.Array<out jet.String>?): jet.Tuple0
|
||||
}
|
||||
public abstract trait test.InheritNotVararg.Super : java.lang.Object {
|
||||
public abstract fun foo(/*0*/ p0: jet.Array<out jet.String?>?): jet.Tuple0
|
||||
public abstract fun foo(/*0*/ p0: jet.Array<out jet.String>?): jet.Tuple0
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -3,10 +3,10 @@ package test
|
||||
public trait InheritNotVarargInteger: Object {
|
||||
|
||||
public trait Super: Object {
|
||||
public fun foo(p0: Array<out Int?>?)
|
||||
public fun foo(p0: Array<out Int>?)
|
||||
}
|
||||
|
||||
public trait Sub: Super {
|
||||
override fun foo(p0: Array<out Int?>?)
|
||||
override fun foo(p0: Array<out Int>?)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -2,9 +2,9 @@ namespace test
|
||||
|
||||
public abstract trait test.InheritNotVarargInteger : java.lang.Object {
|
||||
public abstract trait test.InheritNotVarargInteger.Sub : test.InheritNotVarargInteger.Super {
|
||||
public abstract override /*1*/ fun foo(/*0*/ p0: jet.Array<out jet.Int?>?): jet.Tuple0
|
||||
public abstract override /*1*/ fun foo(/*0*/ p0: jet.Array<out jet.Int>?): jet.Tuple0
|
||||
}
|
||||
public abstract trait test.InheritNotVarargInteger.Super : java.lang.Object {
|
||||
public abstract fun foo(/*0*/ p0: jet.Array<out jet.Int?>?): jet.Tuple0
|
||||
public abstract fun foo(/*0*/ p0: jet.Array<out jet.Int>?): jet.Tuple0
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ public interface AddNullabilitySameGenericType1 {
|
||||
}
|
||||
|
||||
public interface Sub extends Super {
|
||||
@ExpectLoadError("Auto type 'jet.String' is not-null, while type in alternative signature is nullable: 'String?'")
|
||||
@ExpectLoadError("Return type is changed to not subtype for method which overrides another: MutableList<String?>, was: MutableList<String>")
|
||||
@KotlinSignature("fun foo(): MutableList<String?>")
|
||||
List<String> foo();
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ public interface HalfSubstitutedTypeParameters {
|
||||
public interface TrickyList<X, E> extends List<E> {}
|
||||
|
||||
public interface Super {
|
||||
@KotlinSignature("fun foo(): MutableList<String>")
|
||||
@KotlinSignature("fun foo(): MutableList<String?>")
|
||||
List<String> foo();
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -5,10 +5,10 @@ public trait HalfSubstitutedTypeParameters: Object {
|
||||
public trait TrickyList<X, E>: MutableList<E> {}
|
||||
|
||||
public trait Super: Object {
|
||||
public fun foo(): MutableList<String>
|
||||
public fun foo(): MutableList<String?>
|
||||
}
|
||||
|
||||
public trait Sub: Super {
|
||||
override fun foo(): TrickyList<Int?, String>
|
||||
override fun foo(): TrickyList<Int, String?>
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -2,10 +2,10 @@ namespace test
|
||||
|
||||
public abstract trait test.HalfSubstitutedTypeParameters : java.lang.Object {
|
||||
public abstract trait test.HalfSubstitutedTypeParameters.Sub : test.HalfSubstitutedTypeParameters.Super {
|
||||
public abstract override /*1*/ fun foo(): test.HalfSubstitutedTypeParameters.TrickyList<jet.Int?, jet.String>
|
||||
public abstract override /*1*/ fun foo(): test.HalfSubstitutedTypeParameters.TrickyList<jet.Int, jet.String?>
|
||||
}
|
||||
public abstract trait test.HalfSubstitutedTypeParameters.Super : java.lang.Object {
|
||||
public abstract fun foo(): jet.MutableList<jet.String>
|
||||
public abstract fun foo(): jet.MutableList<jet.String?>
|
||||
}
|
||||
public abstract trait test.HalfSubstitutedTypeParameters.TrickyList</*0*/ X : jet.Any?, /*1*/ E : jet.Any?> : jet.MutableList<E> {
|
||||
public abstract override /*1*/ /*fake_override*/ fun add(/*0*/ e: E): jet.Boolean
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.jet.jvm.compiler;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import junit.framework.ComparisonFailure;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.ConfigurationKind;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
@@ -51,8 +52,25 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
||||
tmpdir, myTestRootDisposable, ConfigurationKind.JDK_AND_ANNOTATIONS);
|
||||
NamespaceDescriptor nsb = nsbAndBindingContext.first;
|
||||
|
||||
boolean fail = false;
|
||||
try {
|
||||
ExpectedLoadErrorsUtil.checkForLoadErrors(nsb, nsbAndBindingContext.second);
|
||||
}
|
||||
catch (ComparisonFailure e) {
|
||||
// to let the next check run even if this one failed
|
||||
System.err.println("Expected: " + e.getExpected());
|
||||
System.err.println("Actual : " + e.getActual());
|
||||
e.printStackTrace();
|
||||
fail = true;
|
||||
}
|
||||
catch (AssertionError e) {
|
||||
e.printStackTrace();
|
||||
fail = true;
|
||||
}
|
||||
|
||||
compareNamespaces(nsa, nsb, DONT_INCLUDE_METHODS_OF_OBJECT, txtFile);
|
||||
ExpectedLoadErrorsUtil.checkForLoadErrors(nsb, nsbAndBindingContext.second);
|
||||
if (fail) {
|
||||
fail("See error above");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,9 @@ class AnnotationsPathBuilder(val parent: ModuleBuilder) {
|
||||
|
||||
open class ModuleBuilder(val name: String): Module {
|
||||
// http://youtrack.jetbrains.net/issue/KT-904
|
||||
private val sourceFiles0: ArrayList<String?> = ArrayList<String?>()
|
||||
private val classpathRoots0: ArrayList<String?> = ArrayList<String?>()
|
||||
private val annotationsRoots0: ArrayList<String?> = ArrayList<String?>()
|
||||
private val sourceFiles0 = ArrayList<String>()
|
||||
private val classpathRoots0 = ArrayList<String>()
|
||||
private val annotationsRoots0 = ArrayList<String>()
|
||||
|
||||
val sources: SourcesBuilder
|
||||
get() = SourcesBuilder(this)
|
||||
@@ -54,9 +54,9 @@ open class ModuleBuilder(val name: String): Module {
|
||||
annotationsRoots0.add(name)
|
||||
}
|
||||
|
||||
public override fun getSourceFiles(): MutableList<String?>? = sourceFiles0
|
||||
public override fun getClasspathRoots(): MutableList<String?>? = classpathRoots0
|
||||
public override fun getAnnotationsRoots(): MutableList<String?>? = annotationsRoots0
|
||||
public override fun getModuleName(): String? = name
|
||||
public override fun getSourceFiles(): List<String> = sourceFiles0
|
||||
public override fun getClasspathRoots(): List<String> = classpathRoots0
|
||||
public override fun getAnnotationsRoots(): List<String> = annotationsRoots0
|
||||
public override fun getModuleName(): String = name
|
||||
}
|
||||
|
||||
|
||||
@@ -16,14 +16,23 @@
|
||||
|
||||
package jet.modules;
|
||||
|
||||
import jet.runtime.typeinfo.KotlinSignature;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public interface Module {
|
||||
@KotlinSignature("fun getModuleName(): String")
|
||||
String getModuleName();
|
||||
|
||||
@KotlinSignature("fun getSourceFiles(): List<String>")
|
||||
List<String> getSourceFiles();
|
||||
|
||||
@KotlinSignature("fun getClasspathRoots(): List<String>")
|
||||
List<String> getClasspathRoots();
|
||||
|
||||
@KotlinSignature("fun getAnnotationsRoots(): List<String>")
|
||||
List<String> getAnnotationsRoots();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user