Fixed direction of substitution when checking bounds of type parameters.

This commit is contained in:
Evgeny Gerashchenko
2012-12-04 18:10:07 +04:00
parent d7624aa7b6
commit 95c9c4c0c4
6 changed files with 52 additions and 2 deletions
@@ -116,10 +116,10 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
for (TypeParameterDescriptor parameter : methodTypeParameters) {
int index = parameter.getIndex();
JetType substituted = substitutor.substitute(altTypeParameters.get(index).getUpperBoundsAsType(), Variance.INVARIANT);
JetType substituted = substitutor.substitute(parameter.getUpperBoundsAsType(), Variance.INVARIANT);
assert substituted != null;
if (!TypeUtils.equalTypes(substituted, parameter.getUpperBoundsAsType())) {
if (!TypeUtils.equalTypes(substituted, altTypeParameters.get(index).getUpperBoundsAsType())) {
throw new AlternativeSignatureMismatchException(
"Type parameter's upper bound changed for method which overrides another: "
+ altTypeParameters.get(index).getUpperBoundsAsType() + ", was: " + parameter.getUpperBoundsAsType());
@@ -0,0 +1,18 @@
package test;
import java.util.List;
import org.jetbrains.annotations.NotNull;
import jet.runtime.typeinfo.KotlinSignature;
public interface UseParameterInUpperBoundWithKotlinSignature {
public interface Super {
@KotlinSignature("fun <A, B: List<A>> foo(a: A, b: B)")
<A, B extends List<A>> void foo(A a, B b);
}
public interface Sub extends Super {
@KotlinSignature("fun <B, A: List<B>> foo(b: B, a: A)")
<B, A extends List<B>> void foo(B b, A a);
}
}
@@ -0,0 +1,12 @@
package test
public trait UseParameterInUpperBoundWithKotlinSignature: Object {
public trait Super: Object {
public fun <A, B: List<A>> foo(p0: A, p1: B)
}
public trait Sub: Super {
override fun <B, A: List<B>> foo(p0: B, p1: A)
}
}
@@ -0,0 +1,10 @@
namespace test
public abstract trait test.UseParameterInUpperBoundWithKotlinSignature : java.lang.Object {
public abstract trait test.UseParameterInUpperBoundWithKotlinSignature.Sub : test.UseParameterInUpperBoundWithKotlinSignature.Super {
public abstract override /*1*/ fun </*0*/ B : jet.Any?, /*1*/ A : jet.List<B>>foo(/*0*/ p0: B, /*1*/ p1: A): jet.Tuple0
}
public abstract trait test.UseParameterInUpperBoundWithKotlinSignature.Super : java.lang.Object {
public abstract fun </*0*/ A : jet.Any?, /*1*/ B : jet.List<A>>foo(/*0*/ p0: A, /*1*/ p1: B): jet.Tuple0
}
}
@@ -762,6 +762,11 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
doTest("compiler/testData/loadJava/kotlinSignature/propagation/typeParameter/UseParameterInUpperBound.java");
}
@TestMetadata("UseParameterInUpperBoundWithKotlinSignature.java")
public void testUseParameterInUpperBoundWithKotlinSignature() throws Exception {
doTest("compiler/testData/loadJava/kotlinSignature/propagation/typeParameter/UseParameterInUpperBoundWithKotlinSignature.java");
}
}
public static Test innerSuite() {
@@ -1652,6 +1652,11 @@ public class LazyResolveNamespaceComparingTestGenerated extends AbstractLazyReso
doTestSinglePackage("compiler/testData/loadJava/kotlinSignature/propagation/typeParameter/UseParameterInUpperBound.kt");
}
@TestMetadata("UseParameterInUpperBoundWithKotlinSignature.kt")
public void testUseParameterInUpperBoundWithKotlinSignature() throws Exception {
doTestSinglePackage("compiler/testData/loadJava/kotlinSignature/propagation/typeParameter/UseParameterInUpperBoundWithKotlinSignature.kt");
}
}
public static Test innerSuite() {