Added prohibiting adding of nullability in alternative signatures.
This commit is contained in:
+5
@@ -49,6 +49,11 @@ class AlternativeSignatureParsing {
|
|||||||
@Override
|
@Override
|
||||||
public JetType visitNullableType(JetNullableType nullableType, Void data) {
|
public JetType visitNullableType(JetNullableType nullableType, Void data) {
|
||||||
try {
|
try {
|
||||||
|
if (!autoType.isNullable()) {
|
||||||
|
throw new AlternativeSignatureMismatchException(String.format(
|
||||||
|
"Auto type '%s' is not-null, while type in alternative signature is nullable: '%s'",
|
||||||
|
DescriptorRenderer.TEXT.renderType(autoType), nullableType.getText()));
|
||||||
|
}
|
||||||
return TypeUtils.makeNullable(computeAlternativeTypeFromAnnotation(nullableType.getInnerType(), autoType));
|
return TypeUtils.makeNullable(computeAlternativeTypeFromAnnotation(nullableType.getInnerType(), autoType));
|
||||||
}
|
}
|
||||||
catch (AlternativeSignatureMismatchException e) {
|
catch (AlternativeSignatureMismatchException e) {
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package test;
|
||||||
|
|
||||||
|
import jet.runtime.typeinfo.KotlinSignature;
|
||||||
|
|
||||||
|
public class AddingNullability {
|
||||||
|
@KotlinSignature("fun foo() : Int?")
|
||||||
|
public int foo() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
public open class AddingNullability : Object() {
|
||||||
|
public open fun foo() : Int {
|
||||||
|
throw UnsupportedOperationException()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace test
|
||||||
|
|
||||||
|
public open class test.AddingNullability : java.lang.Object {
|
||||||
|
public final /*constructor*/ fun <init>(): test.AddingNullability
|
||||||
|
public open fun foo(): jet.Int
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user