Fixed loading variance from alternative signature.
This commit is contained in:
+6
-2
@@ -124,9 +124,9 @@ class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
|
||||
TypeProjection argument = arguments.get(i);
|
||||
JetType alternativeType = computeType(argumentAlternativeTypeElement, argument.getType(), originalToAltTypeParameters);
|
||||
Variance variance = argument.getProjectionKind();
|
||||
Variance altVariance;
|
||||
if (type instanceof JetUserType) {
|
||||
JetTypeProjection typeProjection = ((JetUserType) type).getTypeArguments().get(i);
|
||||
Variance altVariance = Variance.INVARIANT;
|
||||
switch (typeProjection.getProjectionKind()) {
|
||||
case IN:
|
||||
altVariance = Variance.IN_VARIANCE;
|
||||
@@ -137,12 +137,16 @@ class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
|
||||
case STAR:
|
||||
throw new AlternativeSignatureMismatchException("Star projection is not available in alternative signatures");
|
||||
default:
|
||||
altVariance = Variance.INVARIANT;
|
||||
}
|
||||
if (altVariance != variance && variance != Variance.INVARIANT) {
|
||||
throw new AlternativeSignatureMismatchException("Variance mismatch, actual: %s, in alternative signature: %s", variance, altVariance);
|
||||
}
|
||||
}
|
||||
altArguments.add(new TypeProjection(variance, alternativeType));
|
||||
else {
|
||||
altVariance = variance;
|
||||
}
|
||||
altArguments.add(new TypeProjection(altVariance, alternativeType));
|
||||
}
|
||||
|
||||
TypeConstructor typeConstructor;
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package test;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import jet.runtime.typeinfo.KotlinSignature;
|
||||
|
||||
public class CustomVariance {
|
||||
@KotlinSignature("fun foo(): MutableList<out Number>")
|
||||
public List<Number> foo() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package test
|
||||
|
||||
import java.util.*
|
||||
|
||||
public open class CustomVariance : Object() {
|
||||
public open fun foo() : MutableList<out Number> = throw UnsupportedOperationException()
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace test
|
||||
|
||||
public open class test.CustomVariance : java.lang.Object {
|
||||
public final /*constructor*/ fun <init>(): test.CustomVariance
|
||||
public open fun foo(): jet.MutableList<out jet.Number>
|
||||
}
|
||||
@@ -260,6 +260,11 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
|
||||
doTest("compiler/testData/loadJava/kotlinSignature/ConstructorWithoutParams.java");
|
||||
}
|
||||
|
||||
@TestMetadata("CustomVariance.java")
|
||||
public void testCustomVariance() throws Exception {
|
||||
doTest("compiler/testData/loadJava/kotlinSignature/CustomVariance.java");
|
||||
}
|
||||
|
||||
@TestMetadata("MethodWithFunctionTypes.java")
|
||||
public void testMethodWithFunctionTypes() throws Exception {
|
||||
doTest("compiler/testData/loadJava/kotlinSignature/MethodWithFunctionTypes.java");
|
||||
|
||||
+5
@@ -1155,6 +1155,11 @@ public class LazyResolveNamespaceComparingTestGenerated extends AbstractLazyReso
|
||||
doTestSinglePackage("compiler/testData/loadJava/kotlinSignature/ConstructorWithoutParams.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("CustomVariance.kt")
|
||||
public void testCustomVariance() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/loadJava/kotlinSignature/CustomVariance.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("MethodWithFunctionTypes.kt")
|
||||
public void testMethodWithFunctionTypes() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/loadJava/kotlinSignature/MethodWithFunctionTypes.kt");
|
||||
|
||||
Reference in New Issue
Block a user