K2: support ForbidInferringTypeVariablesIntoEmptyIntersection on/off

This commit is contained in:
Mikhail Glukhikh
2023-02-28 09:40:19 +01:00
committed by Space Team
parent f7544aff62
commit b64cb67370
43 changed files with 86 additions and 248 deletions
@@ -1,25 +0,0 @@
// !LANGUAGE: +ForbidInferringTypeVariablesIntoEmptyIntersection
// FILE: ObjectNode.java
public interface ObjectNode {
<T extends JsonNode> T set(String fieldName, JsonNode value);
}
// FILE: JsonNode.java
public class JsonNode
// FILE: test.kt
interface JsonObject
class SomeJsonObject() : JsonObject
fun String.put(value: JsonObject?, node: ObjectNode) {
<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION!>when (value) {
null -> node.set(this, null)
is SomeJsonObject -> Unit
else -> TODO()
}<!>
}
fun TODO(): Nothing = null!!
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +ForbidInferringTypeVariablesIntoEmptyIntersection
// FILE: ObjectNode.java
@@ -1,25 +0,0 @@
// !LANGUAGE: -ForbidInferringTypeVariablesIntoEmptyIntersection
// FILE: ObjectNode.java
public interface ObjectNode {
<T extends JsonNode> T set(String fieldName, JsonNode value);
}
// FILE: JsonNode.java
public class JsonNode
// FILE: test.kt
interface JsonObject
class SomeJsonObject() : JsonObject
fun String.put(value: JsonObject?, node: ObjectNode) {
<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION!>when (value) {
null -> node.set(this, null)
is SomeJsonObject -> Unit
else -> TODO()
}<!>
}
fun TODO(): Nothing = null!!
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: -ForbidInferringTypeVariablesIntoEmptyIntersection
// FILE: ObjectNode.java