[FIR] Fix deserializing nullability of type parameters
This commit is contained in:
+1
-1
@@ -116,7 +116,7 @@ class FirTypeDeserializer(
|
||||
fun simpleType(proto: ProtoBuf.Type): ConeLookupTagBasedType? {
|
||||
|
||||
val constructor = typeSymbol(proto) ?: return null
|
||||
if (constructor is ConeTypeParameterLookupTag) return ConeTypeParameterTypeImpl(constructor, isNullable = false)
|
||||
if (constructor is ConeTypeParameterLookupTag) return ConeTypeParameterTypeImpl(constructor, isNullable = proto.nullable)
|
||||
if (constructor !is ConeClassLikeLookupTag) return null
|
||||
|
||||
fun ProtoBuf.Type.collectAllArguments(): List<ProtoBuf.Type.Argument> =
|
||||
|
||||
@@ -133,7 +133,7 @@ public abstract interface Map<K, out V> : R|kotlin/Any| {
|
||||
|
||||
public abstract fun containsValue(value: R|V|): R|kotlin/Boolean|
|
||||
|
||||
public abstract operator fun get(key: R|K|): R|V|
|
||||
public abstract operator fun get(key: R|K|): R|V?|
|
||||
|
||||
@R|kotlin/SinceKotlin|(version = String(1.1)) @R|kotlin/internal/PlatformDependent|() public open fun getOrDefault(key: R|K|, defaultValue: R|V|): R|V|
|
||||
|
||||
@@ -234,11 +234,11 @@ public abstract interface MutableListIterator<T> : R|kotlin/collections/ListIter
|
||||
public abstract interface MutableMap<K, V> : R|kotlin/collections/Map<K, V>| {
|
||||
public abstract fun clear(): R|kotlin/Unit|
|
||||
|
||||
public abstract fun put(key: R|K|, value: R|V|): R|V|
|
||||
public abstract fun put(key: R|K|, value: R|V|): R|V?|
|
||||
|
||||
public abstract fun putAll(from: R|kotlin/collections/Map<out K, V>|): R|kotlin/Unit|
|
||||
|
||||
public abstract fun remove(key: R|K|): R|V|
|
||||
public abstract fun remove(key: R|K|): R|V?|
|
||||
|
||||
@R|kotlin/SinceKotlin|(version = String(1.1)) @R|kotlin/internal/PlatformDependent|() public open fun remove(key: R|K|, value: R|V|): R|kotlin/Boolean|
|
||||
|
||||
@@ -297,3 +297,4 @@ public abstract class ShortIterator : R|kotlin/collections/Iterator<kotlin/Short
|
||||
public constructor(): R|kotlin/collections/ShortIterator|
|
||||
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -1,6 +1,6 @@
|
||||
public final inline fun <reified T> arrayOf(vararg elements: R|kotlin/Array<out T>|): R|kotlin/Array<T>|
|
||||
|
||||
public final fun <reified T> arrayOfNulls(size: R|kotlin/Int|): R|kotlin/Array<T>|
|
||||
public final fun <reified T> arrayOfNulls(size: R|kotlin/Int|): R|kotlin/Array<T?>|
|
||||
|
||||
public final fun booleanArrayOf(vararg elements: R|kotlin/BooleanArray|): R|kotlin/BooleanArray|
|
||||
|
||||
@@ -1306,3 +1306,4 @@ public final object Unit : R|kotlin/Any| {
|
||||
public constructor(): R|kotlin/UnsafeVariance|
|
||||
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -15,8 +15,8 @@ public final class ConstructorTypeParamClassObjectConflict<test> : R|kotlin/Any|
|
||||
}
|
||||
|
||||
public final class ConstructorTypeParamClassObjectTypeConflict<test> : R|kotlin/Any| {
|
||||
public final val some: R|test|
|
||||
public get(): R|test|
|
||||
public final val some: R|test?|
|
||||
public get(): R|test?|
|
||||
|
||||
public constructor<test>(): R|test/ConstructorTypeParamClassObjectTypeConflict<test>|
|
||||
|
||||
|
||||
+4
-4
@@ -5,16 +5,16 @@ public final class InheritMethodsDifferentReturnTypesGeneric : R|kotlin/Any| {
|
||||
}
|
||||
|
||||
public abstract interface Super1<F, B> : R|kotlin/Any| {
|
||||
public abstract fun bar(): R|B|
|
||||
public abstract fun bar(): R|B?|
|
||||
|
||||
public abstract fun foo(): R|F|
|
||||
public abstract fun foo(): R|F?|
|
||||
|
||||
}
|
||||
|
||||
public abstract interface Super2<FF, BB> : R|kotlin/Any| {
|
||||
public abstract fun bar(): R|BB|
|
||||
public abstract fun bar(): R|BB?|
|
||||
|
||||
public abstract fun foo(): R|FF|
|
||||
public abstract fun foo(): R|FF?|
|
||||
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
public final class MethosWithPRefTP : R|kotlin/Any| {
|
||||
public final fun <P> f(p0: R|P|): R|kotlin/Unit|
|
||||
public final fun <P> f(p0: R|P?|): R|kotlin/Unit|
|
||||
|
||||
public constructor(): R|test/MethosWithPRefTP|
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
public open class WrongTypeParameterBoundStructure1 : R|kotlin/Any| {
|
||||
public open fun <A, B : R|java/lang/Runnable?|, R|kotlin/collections/List<kotlin/Cloneable>?|> foo(p0: R|A|, p1: R|kotlin/collections/List<B>?|): R|kotlin/Unit|
|
||||
public open fun <A, B : R|java/lang/Runnable?|, R|kotlin/collections/List<kotlin/Cloneable>?|> foo(p0: R|A?|, p1: R|kotlin/collections/List<B>?|): R|kotlin/Unit|
|
||||
|
||||
public constructor(): R|test/WrongTypeParameterBoundStructure1|
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
public open class WrongTypeParameterBoundStructure2 : R|kotlin/Any| {
|
||||
public open fun <A, B : R|java/lang/Runnable?|, R|kotlin/collections/List<kotlin/Cloneable>?|> foo(p0: R|A|, p1: R|kotlin/collections/List<B>?|): R|kotlin/Unit|
|
||||
public open fun <A, B : R|java/lang/Runnable?|, R|kotlin/collections/List<kotlin/Cloneable>?|> foo(p0: R|A?|, p1: R|kotlin/collections/List<B>?|): R|kotlin/Unit|
|
||||
|
||||
public constructor(): R|test/WrongTypeParameterBoundStructure2|
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
public open class WrongTypeParametersCount : R|kotlin/Any| {
|
||||
public open fun <A, B> foo(p0: R|A|, p1: R|kotlin/collections/List<B>?|): R|kotlin/Unit|
|
||||
public open fun <A, B> foo(p0: R|A?|, p1: R|kotlin/collections/List<B>?|): R|kotlin/Unit|
|
||||
|
||||
public constructor(): R|test/WrongTypeParametersCount|
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ public abstract interface Kt3302 : R|kotlin/Any| {
|
||||
public abstract interface LinkedHashMap<K, V> : R|kotlin/Any| {
|
||||
public abstract fun dummy(): R|kotlin/Unit|
|
||||
|
||||
public abstract fun put(key: R|K|, value: R|V|): R|V|
|
||||
public abstract fun put(key: R|K|, value: R|V|): R|V?|
|
||||
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,13 +1,13 @@
|
||||
public abstract interface OverrideWithErasedParameter : R|kotlin/Any| {
|
||||
public abstract interface Sub<T> : R|test/OverrideWithErasedParameter.Super<T>| {
|
||||
public abstract fun foo(p0: R|T|): R|kotlin/Unit|
|
||||
public abstract fun foo(p0: R|T?|): R|kotlin/Unit|
|
||||
|
||||
}
|
||||
|
||||
public abstract interface Super<T> : R|kotlin/Any| {
|
||||
public abstract fun dummy(): R|kotlin/Unit|
|
||||
|
||||
public abstract fun foo(p0: R|T|): R|kotlin/Unit|
|
||||
public abstract fun foo(p0: R|T?|): R|kotlin/Unit|
|
||||
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
public open class Max : R|kotlin/Any| {
|
||||
public open fun <T : R|kotlin/Comparable<T>?|> max(p0: R|kotlin/collections/Collection<T>?|): R|T|
|
||||
public open fun <T : R|kotlin/Comparable<T>?|> max(p0: R|kotlin/collections/Collection<T>?|): R|T?|
|
||||
|
||||
public constructor(): R|test/Max|
|
||||
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
public final class ExtValInClass<P> : R|kotlin/Any| {
|
||||
public final val R|kotlin/Int|.asas: R|P|
|
||||
public get(): R|P|
|
||||
public final val R|kotlin/Int|.asas: R|P?|
|
||||
public get(): R|P?|
|
||||
|
||||
public constructor<P>(): R|test/ExtValInClass<P>|
|
||||
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
public final class ExtValInClass<P> : R|kotlin/Any| {
|
||||
public final var R|kotlin/Int|.asas: R|P|
|
||||
public get(): R|P|
|
||||
public set(value: R|P|): R|kotlin/Unit|
|
||||
public final var R|kotlin/Int|.asas: R|P?|
|
||||
public get(): R|P?|
|
||||
public set(value: R|P?|): R|kotlin/Unit|
|
||||
|
||||
public constructor<P>(): R|test/ExtValInClass<P>|
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
public final class ExtValPIntInClass<P> : R|kotlin/Any| {
|
||||
public final var R|P|.asas: R|kotlin/Int|
|
||||
public final var R|P?|.asas: R|kotlin/Int|
|
||||
public get(): R|kotlin/Int|
|
||||
public set(value: R|kotlin/Int|): R|kotlin/Unit|
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fun test(set: Set<String?>) {
|
||||
val filtered = set.filterNotNull()
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
FILE: nullableTypeParameter.kt
|
||||
public final fun test(set: R|kotlin/collections/Set<kotlin/String?>|): R|kotlin/Unit| {
|
||||
lval filtered: R|kotlin/collections/List<kotlin/String>| = R|<local>/set|.R|kotlin/collections/filterNotNull|<R|kotlin/String|>()
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
FILE: typeParameterDerived.kt
|
||||
public final inline fun <K, V, VA : R|V|> R|kotlin/collections/MutableMap<K, V>|.getOrPut(key: R|K|, defaultValue: R|(K) -> VA|, postCompute: R|(VA) -> kotlin/Unit|): R|V| {
|
||||
lval value: R|V| = this@R|kotlin/collections/Map|.R|FakeOverride<kotlin/collections/Map.get: R|V|>|(R|<local>/key|)
|
||||
lval value: R|V?| = this@R|kotlin/collections/Map|.R|FakeOverride<kotlin/collections/Map.get: R|V?|>|(R|<local>/key|)
|
||||
^getOrPut when () {
|
||||
==(R|<local>/value|, Null(null)) -> {
|
||||
lval answer: R|VA| = R|<local>/defaultValue|.R|FakeOverride<kotlin/Function1.invoke: R|VA|>|(R|<local>/key|)
|
||||
this@R|kotlin/collections/MutableMap|.R|FakeOverride<kotlin/collections/MutableMap.put: R|V|>|(R|<local>/key|, R|<local>/answer|)
|
||||
this@R|kotlin/collections/MutableMap|.R|FakeOverride<kotlin/collections/MutableMap.put: R|V?|>|(R|<local>/key|, R|<local>/answer|)
|
||||
R|<local>/postCompute|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|(R|<local>/answer|)
|
||||
R|<local>/answer|
|
||||
}
|
||||
|
||||
Generated
+5
@@ -118,6 +118,11 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic
|
||||
runTest("compiler/fir/resolve/testData/resolve/stdlib/multipleImplicitReceivers.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullableTypeParameter.kt")
|
||||
public void testNullableTypeParameter() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/stdlib/nullableTypeParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("problems.kt")
|
||||
public void testProblems() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/stdlib/problems.kt");
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ FILE fqName:<root> fileName:/builtinMap.kt
|
||||
block: FUN_EXPR type=kotlin.Function1<java.util.LinkedHashMap<K1 of <root>.plus, V1 of <root>.plus>, kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
CALL 'public open fun put (p0: K1 of <root>.plus, p1: V1 of <root>.plus): V1 of <root>.plus declared in java.util.HashMap' type=V1 of <root>.plus origin=null
|
||||
CALL 'public open fun put (p0: K1 of <root>.plus, p1: V1 of <root>.plus): V1 of <root>.plus? declared in java.util.HashMap' type=V1 of <root>.plus? origin=null
|
||||
$this: GET_VAR '<this>: java.util.HashMap declared in java.util.HashMap' type=java.util.HashMap<*, *> origin=null
|
||||
p0: CALL 'public final fun <get-first> (): K1 of <root>.plus declared in kotlin.Pair' type=K1 of <root>.plus origin=null
|
||||
$this: GET_VAR 'pair: kotlin.Pair<K1 of <root>.plus, V1 of <root>.plus> declared in <root>.plus' type=kotlin.Pair<K1 of <root>.plus, V1 of <root>.plus> origin=null
|
||||
|
||||
Reference in New Issue
Block a user