Equality for flexible types
This commit is contained in:
+1
-1
@@ -18,6 +18,6 @@ public class Y extends X<String> {
|
|||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
Y().fooN() : Any
|
Y().fooN() : Any
|
||||||
Y().barN(<!NULL_FOR_NONNULL_TYPE!>null<!>);
|
Y().barN(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -18,6 +18,6 @@ public class Y extends X<A> {
|
|||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
Y().fooN() : Any
|
Y().fooN() : Any
|
||||||
Y().barN(<!NULL_FOR_NONNULL_TYPE!>null<!>);
|
Y().barN(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ public class Y extends X<String> {
|
|||||||
// FILE: test.kt
|
// FILE: test.kt
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
Y().foo()<!UNSAFE_CALL!>.<!>length
|
Y().foo().length
|
||||||
Y().bar(null)
|
Y().bar(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,5 +9,5 @@ package a
|
|||||||
|
|
||||||
fun foo() {
|
fun foo() {
|
||||||
// If this fails, it means that we have broken the rule that Java returns are always nullable
|
// If this fails, it means that we have broken the rule that Java returns are always nullable
|
||||||
a.Test<Int>().t() <!UNSAFE_INFIX_CALL!>+<!> 1
|
a.Test<Int>().t() + 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,5 +13,5 @@ package d
|
|||||||
import a.C
|
import a.C
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
C.create()<!UNSAFE_CALL!>.<!>foo()
|
C.create().foo()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,20 @@ public class TypeCheckingProcedure {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean equalTypes(@NotNull JetType type1, @NotNull JetType type2) {
|
public boolean equalTypes(@NotNull JetType type1, @NotNull JetType type2) {
|
||||||
|
if (type1 instanceof FlexibleType) {
|
||||||
|
FlexibleType flexibleType1 = (FlexibleType) type1;
|
||||||
|
if (type2 instanceof FlexibleType) {
|
||||||
|
FlexibleType flexibleType2 = (FlexibleType) type2;
|
||||||
|
return equalTypes(flexibleType1.getLowerBound(), flexibleType2.getLowerBound())
|
||||||
|
&& equalTypes(flexibleType1.getUpperBound(), flexibleType2.getUpperBound());
|
||||||
|
}
|
||||||
|
return equalTypes(flexibleType1.getLowerBound(), type2) || equalTypes(flexibleType1.getUpperBound(), type2);
|
||||||
|
}
|
||||||
|
else if (type2 instanceof FlexibleType) {
|
||||||
|
FlexibleType flexibleType2 = (FlexibleType) type2;
|
||||||
|
return equalTypes(type1, flexibleType2.getLowerBound()) || equalTypes(type1, flexibleType2.getUpperBound());
|
||||||
|
}
|
||||||
|
|
||||||
if (type1.isNullable() != type2.isNullable()) {
|
if (type1.isNullable() != type2.isNullable()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user