Added check for extra and missing upper bounds in alternative signatures.
This commit is contained in:
+8
-4
@@ -296,14 +296,18 @@ class AlternativeSignatureData {
|
||||
else {
|
||||
JetTypeConstraint constraint =
|
||||
findTypeParameterConstraint(altFunDeclaration, pd.getName(), upperBoundIndex);
|
||||
assert constraint != null; // TODO fail more properly
|
||||
JetTypeReference boundTypeReference = constraint.getBoundTypeReference();
|
||||
assert boundTypeReference != null;
|
||||
altTypeElement = boundTypeReference.getTypeElement();
|
||||
if (constraint == null) {
|
||||
fail("Upper bound #%d for type parameter %s is missing", upperBoundIndex, pd.getName());
|
||||
}
|
||||
//noinspection ConstantConditions
|
||||
altTypeElement = constraint.getBoundTypeReference().getTypeElement();
|
||||
}
|
||||
altParamDescriptor.addUpperBound(computeType(altTypeElement, upperBound));
|
||||
upperBoundIndex++;
|
||||
}
|
||||
if (findTypeParameterConstraint(altFunDeclaration, pd.getName(), upperBoundIndex) != null) {
|
||||
fail("Extra upper bound #%d for type parameter %s", upperBoundIndex, pd.getName());
|
||||
}
|
||||
|
||||
altParamDescriptor.setInitialized();
|
||||
altTypeParameters.add(altParamDescriptor);
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package test;
|
||||
|
||||
import jet.runtime.typeinfo.KotlinSignature;
|
||||
|
||||
public class ExtraUpperBound {
|
||||
@KotlinSignature("fun <A : Runnable> foo() : String where A : Cloneable")
|
||||
public <A extends Runnable> String foo() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package test
|
||||
|
||||
import java.util.*
|
||||
|
||||
public open class ExtraUpperBound : Object() {
|
||||
public open fun <A : Runnable?> foo() : String? {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace test
|
||||
|
||||
public open class test.ExtraUpperBound : java.lang.Object {
|
||||
public final /*constructor*/ fun <init>(): test.ExtraUpperBound
|
||||
public open fun </*0*/ A : java.lang.Runnable?>foo(): jet.String?
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package test;
|
||||
|
||||
import jet.runtime.typeinfo.KotlinSignature;
|
||||
|
||||
public class MissingUpperBound {
|
||||
@KotlinSignature("fun <A : Runnable> foo() : String")
|
||||
public <A extends Runnable & Cloneable> String foo() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package test
|
||||
|
||||
import java.util.*
|
||||
|
||||
public open class MissingUpperBound : Object() {
|
||||
public open fun <A : Runnable?> foo() : String? where A : Cloneable? {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace test
|
||||
|
||||
public open class test.MissingUpperBound : java.lang.Object {
|
||||
public final /*constructor*/ fun <init>(): test.MissingUpperBound
|
||||
public open fun </*0*/ A : java.lang.Cloneable? & java.lang.Runnable?>foo(): jet.String?
|
||||
}
|
||||
Reference in New Issue
Block a user