Fix JetType.equals(): flexible types are not equal to non-flexible ones, when we store them in a HashSet
This commit is contained in:
+6
-1
@@ -1081,7 +1081,12 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
JetType type = resolvedCall.getResultingDescriptor().getReturnType();
|
||||
if (type == null || rightType == null) return JetTypeInfo.create(null, dataFlowInfo);
|
||||
|
||||
return JetTypeInfo.create(TypeUtils.makeNullableAsSpecified(type, rightType.isNullable()), dataFlowInfo);
|
||||
// Sometimes return type for special call for elvis operator might be nullable,
|
||||
// but result is not nullable if the right type is not nullable
|
||||
if (!TypeUtils.isNullableType(rightType) && TypeUtils.isNullableType(type)) {
|
||||
type = TypeUtils.makeNotNullable(type);
|
||||
}
|
||||
return JetTypeInfo.create(type, dataFlowInfo);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// FILE: p/J.java
|
||||
package p;
|
||||
|
||||
public interface J {
|
||||
public interface Super<T> {}
|
||||
public interface Sub<T> extends Super<T> {}
|
||||
}
|
||||
|
||||
// FILE: k.kt
|
||||
|
||||
import p.J.*
|
||||
|
||||
class Foo<T>: Sub<T> {
|
||||
fun foo(): Super<T> {
|
||||
return <!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>Foo<!>()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package
|
||||
|
||||
internal final class Foo</*0*/ T> : p.J.Sub<T> {
|
||||
public constructor Foo</*0*/ T>()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
internal final fun foo(): p.J.Super<T>
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// FILE: p/J.java
|
||||
|
||||
package p;
|
||||
|
||||
public class J {
|
||||
public static J j() { return null; }
|
||||
}
|
||||
|
||||
// FILE: k.kt
|
||||
|
||||
import p.*
|
||||
|
||||
fun foo(): J? = null
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val v = foo() ?: J.j()
|
||||
if (v != null) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
internal fun foo(): p.J?
|
||||
internal fun main(/*0*/ args: kotlin.Array<kotlin.String>): kotlin.Unit
|
||||
@@ -4865,6 +4865,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("immutableArrayList.kt")
|
||||
public void testImmutableArrayList() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/immutableArrayList.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inferInFunctionLiterals.kt")
|
||||
public void testInferInFunctionLiterals() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/inferInFunctionLiterals.kt");
|
||||
@@ -7799,6 +7805,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("typeOfElvis.kt")
|
||||
public void testTypeOfElvis() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/commonSupertype/typeOfElvis.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/platformTypes/methodCall")
|
||||
|
||||
Reference in New Issue
Block a user