Fix incorrect NULLABLE_TYPE_PARAMETER_AGAINST_NOT_NULL_TYPE_PARAMETER

^KT-42257 Fixed
This commit is contained in:
Denis Zharkov
2020-09-29 19:14:33 +03:00
parent d09ccdbe3c
commit fdd71c0bce
7 changed files with 63 additions and 1 deletions
@@ -156,7 +156,13 @@ class JavaNullabilityChecker : AdditionalTypeChecker {
private fun isNullableTypeAgainstNotNullTypeParameter(
subType: KotlinType,
superType: KotlinType
) = superType is NotNullTypeVariable && subType.isNullable()
): Boolean {
if (superType !is NotNullTypeVariable) return false
return !AbstractNullabilityChecker.isSubtypeOfAny(
ClassicTypeCheckerContext(errorTypeEqualsToAnything = true) as AbstractTypeCheckerContext,
subType
)
}
override fun checkReceiver(
receiverParameter: ReceiverParameterDescriptor,
@@ -10,6 +10,8 @@ public interface SLRUMap<V> {
void takeVList(@NotNull List<@NotNull V> value);
<E> void takeEList(@NotNull List<@NotNull E> value);
public <K> K id(K value) { return null; }
}
// FILE: main.kt
@@ -20,9 +22,20 @@ fun <V> SLRUMap<V>.getOrPut(value: V, l: List<V>) {
takeE(value)
takeEList(l)
takeE(id(value))
if (value != null) {
takeV(value)
takeE(value)
takeE(id(value))
}
}
fun <V : Any> SLRUMap<V>.getOrPutNN(value: V, l: List<V>) {
takeV(value)
takeVList(l)
takeE(value)
takeEList(l)
takeE(id(value))
}
@@ -10,6 +10,8 @@ public interface SLRUMap<V> {
void takeVList(@NotNull List<@NotNull V> value);
<E> void takeEList(@NotNull List<@NotNull E> value);
public <K> K id(K value) { return null; }
}
// FILE: main.kt
@@ -20,9 +22,20 @@ fun <V> SLRUMap<V>.getOrPut(value: V, l: List<V>) {
takeE(<!TYPE_MISMATCH!>value<!>)
takeEList(<!TYPE_MISMATCH!>l<!>)
takeE(<!TYPE_MISMATCH!>id(value)<!>)
if (value != null) {
takeV(<!DEBUG_INFO_SMARTCAST!>value<!>)
takeE(<!DEBUG_INFO_SMARTCAST!>value<!>)
takeE(id(value))
}
}
fun <V : Any> SLRUMap<V>.getOrPutNN(value: V, l: List<V>) {
takeV(value)
takeVList(l)
takeE(value)
takeEList(l)
takeE(id(value))
}
@@ -1,10 +1,12 @@
package
public fun </*0*/ V> SLRUMap<V>.getOrPut(/*0*/ value: V, /*1*/ l: kotlin.collections.List<V>): kotlin.Unit
public fun </*0*/ V : kotlin.Any> SLRUMap<V>.getOrPutNN(/*0*/ value: V, /*1*/ l: kotlin.collections.List<V>): kotlin.Unit
public interface SLRUMap</*0*/ V : kotlin.Any!> {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public abstract fun </*0*/ K : kotlin.Any!> id(/*0*/ value: K!): K!
public abstract fun </*0*/ E : kotlin.Any!> takeE(/*0*/ @org.jetbrains.annotations.NotNull value: E!!): kotlin.Unit
public abstract fun </*0*/ E : kotlin.Any!> takeEList(/*0*/ @org.jetbrains.annotations.NotNull value: kotlin.collections.(Mutable)List<@org.jetbrains.annotations.NotNull E!!>): kotlin.Unit
public abstract fun takeV(/*0*/ @org.jetbrains.annotations.NotNull value: V!!): kotlin.Unit
@@ -10,6 +10,8 @@ public interface SLRUMap<V> {
void takeVList(@NotNull List<@NotNull V> value);
<E> void takeEList(@NotNull List<@NotNull E> value);
public <K> K id(K value) { return null; }
}
// FILE: main.kt
@@ -20,9 +22,20 @@ fun <V> SLRUMap<V>.getOrPut(value: V, l: List<V>) {
takeE(value)
takeEList(l)
takeE(id(value))
if (value != null) {
takeV(value)
takeE(value)
takeE(id(value))
}
}
fun <V : Any> SLRUMap<V>.getOrPutNN(value: V, l: List<V>) {
takeV(value)
takeVList(l)
takeE(value)
takeEList(l)
takeE(id(value))
}
@@ -10,6 +10,8 @@ public interface SLRUMap<V> {
void takeVList(@NotNull List<@NotNull V> value);
<E> void takeEList(@NotNull List<@NotNull E> value);
public <K> K id(K value) { return null; }
}
// FILE: main.kt
@@ -20,9 +22,20 @@ fun <V> SLRUMap<V>.getOrPut(value: V, l: List<V>) {
takeE(<!NULLABLE_TYPE_PARAMETER_AGAINST_NOT_NULL_TYPE_PARAMETER!>value<!>)
takeEList(<!NULLABLE_TYPE_PARAMETER_AGAINST_NOT_NULL_TYPE_PARAMETER!>l<!>)
takeE(<!NULLABLE_TYPE_PARAMETER_AGAINST_NOT_NULL_TYPE_PARAMETER!>id(value)<!>)
if (value != null) {
takeV(value)
takeE(value)
takeE(id(value))
}
}
fun <V : Any> SLRUMap<V>.getOrPutNN(value: V, l: List<V>) {
takeV(value)
takeVList(l)
takeE(value)
takeEList(l)
takeE(id(value))
}
@@ -1,10 +1,12 @@
package
public fun </*0*/ V> SLRUMap<V>.getOrPut(/*0*/ value: V, /*1*/ l: kotlin.collections.List<V>): kotlin.Unit
public fun </*0*/ V : kotlin.Any> SLRUMap<V>.getOrPutNN(/*0*/ value: V, /*1*/ l: kotlin.collections.List<V>): kotlin.Unit
public interface SLRUMap</*0*/ V : kotlin.Any!> {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public abstract fun </*0*/ K : kotlin.Any!> id(/*0*/ value: K!): K!
public abstract fun </*0*/ E : kotlin.Any!> takeE(/*0*/ @org.jetbrains.annotations.NotNull value: E): kotlin.Unit
public abstract fun </*0*/ E : kotlin.Any!> takeEList(/*0*/ @org.jetbrains.annotations.NotNull value: kotlin.collections.(Mutable)List<@org.jetbrains.annotations.NotNull E>): kotlin.Unit
public abstract fun takeV(/*0*/ @org.jetbrains.annotations.NotNull value: V): kotlin.Unit