From 98f72e58bd156138739d53a2504a41c56809c07a Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 5 Sep 2019 15:16:29 +0300 Subject: [PATCH] FIR deserializer: use class type parameters in constructor directly This allows calls like Pair(...) to be resolved correctly --- .../kotlin/fir/deserialization/FirMemberDeserializer.kt | 7 +------ .../annotations/types/ClassLiteralArgument.txt | 2 +- .../testData/loadCompiledKotlin/class/ClassInParam.txt | 2 +- .../testData/loadCompiledKotlin/class/ClassOutParam.txt | 2 +- .../class/ClassParamReferencesParam2.txt | 2 +- .../testData/loadCompiledKotlin/class/ClassTwoParams2.txt | 2 +- .../loadCompiledKotlin/classFun/ClassInParamUsedInFun.txt | 2 +- .../loadCompiledKotlin/visibility/PrivateToThis.txt | 2 +- compiler/fir/resolve/testData/resolve/stdlib/problems.txt | 4 ++-- .../genericConstructorCallWithTypeArguments.fir.txt | 4 ++-- 10 files changed, 12 insertions(+), 17 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/FirMemberDeserializer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/FirMemberDeserializer.kt index fb23130dd37..5db0358e2db 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/FirMemberDeserializer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/FirMemberDeserializer.kt @@ -23,7 +23,6 @@ import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.serialization.deserialization.ProtoEnumFlags import org.jetbrains.kotlin.serialization.deserialization.getName -import org.jetbrains.kotlin.types.Variance class FirDeserializationContext( val nameResolver: NameResolver, @@ -234,11 +233,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) { val local = c.childContext(emptyList()) val isPrimary = !Flags.IS_SECONDARY.get(flags) - val typeParameters = klass.typeParameters.map { - FirTypeParameterImpl(c.session, null, FirTypeParameterSymbol(), it.name, Variance.INVARIANT, false).apply { - bounds.addAll(it.bounds) - } - } + val typeParameters = klass.typeParameters val delegatedSelfType = FirResolvedTypeRefImpl( null, diff --git a/compiler/fir/resolve/testData/loadCompiledKotlin/annotations/types/ClassLiteralArgument.txt b/compiler/fir/resolve/testData/loadCompiledKotlin/annotations/types/ClassLiteralArgument.txt index c1ce1028bb4..aec8d698534 100644 --- a/compiler/fir/resolve/testData/loadCompiledKotlin/annotations/types/ClassLiteralArgument.txt +++ b/compiler/fir/resolve/testData/loadCompiledKotlin/annotations/types/ClassLiteralArgument.txt @@ -28,7 +28,7 @@ public final class InnerGeneric : R|kotlin/Any| { public constructor(): R|test/InnerGeneric| public final inner class Inner : R|kotlin/Any| { - public constructor(): R|test/InnerGeneric.Inner| + public constructor(): R|test/InnerGeneric.Inner| } diff --git a/compiler/fir/resolve/testData/loadCompiledKotlin/class/ClassInParam.txt b/compiler/fir/resolve/testData/loadCompiledKotlin/class/ClassInParam.txt index 30a205058bf..4bafc9e5fb0 100644 --- a/compiler/fir/resolve/testData/loadCompiledKotlin/class/ClassInParam.txt +++ b/compiler/fir/resolve/testData/loadCompiledKotlin/class/ClassInParam.txt @@ -1,4 +1,4 @@ public final class Wine : R|kotlin/Any| { - public constructor(): R|test/Wine| + public constructor(): R|test/Wine| } diff --git a/compiler/fir/resolve/testData/loadCompiledKotlin/class/ClassOutParam.txt b/compiler/fir/resolve/testData/loadCompiledKotlin/class/ClassOutParam.txt index 88b09545e9d..e3cdd19d60f 100644 --- a/compiler/fir/resolve/testData/loadCompiledKotlin/class/ClassOutParam.txt +++ b/compiler/fir/resolve/testData/loadCompiledKotlin/class/ClassOutParam.txt @@ -1,4 +1,4 @@ public final class Juice : R|kotlin/Any| { - public constructor(): R|test/Juice| + public constructor(): R|test/Juice| } diff --git a/compiler/fir/resolve/testData/loadCompiledKotlin/class/ClassParamReferencesParam2.txt b/compiler/fir/resolve/testData/loadCompiledKotlin/class/ClassParamReferencesParam2.txt index 9394336c27f..3d81dcea7b9 100644 --- a/compiler/fir/resolve/testData/loadCompiledKotlin/class/ClassParamReferencesParam2.txt +++ b/compiler/fir/resolve/testData/loadCompiledKotlin/class/ClassParamReferencesParam2.txt @@ -1,4 +1,4 @@ public final class ClassParamReferencesParam : R|kotlin/Any| { - public constructor(): R|test/ClassParamReferencesParam| + public constructor(): R|test/ClassParamReferencesParam| } diff --git a/compiler/fir/resolve/testData/loadCompiledKotlin/class/ClassTwoParams2.txt b/compiler/fir/resolve/testData/loadCompiledKotlin/class/ClassTwoParams2.txt index 1de5446e1b4..7fc33f4ceff 100644 --- a/compiler/fir/resolve/testData/loadCompiledKotlin/class/ClassTwoParams2.txt +++ b/compiler/fir/resolve/testData/loadCompiledKotlin/class/ClassTwoParams2.txt @@ -1,4 +1,4 @@ public final class ClassTwoParams : R|kotlin/Any| { - public constructor(): R|test/ClassTwoParams| + public constructor(): R|test/ClassTwoParams| } diff --git a/compiler/fir/resolve/testData/loadCompiledKotlin/classFun/ClassInParamUsedInFun.txt b/compiler/fir/resolve/testData/loadCompiledKotlin/classFun/ClassInParamUsedInFun.txt index 257ff4de95e..015085e2c9e 100644 --- a/compiler/fir/resolve/testData/loadCompiledKotlin/classFun/ClassInParamUsedInFun.txt +++ b/compiler/fir/resolve/testData/loadCompiledKotlin/classFun/ClassInParamUsedInFun.txt @@ -1,6 +1,6 @@ public final class ClassParamUsedInFun : R|kotlin/Any| { public final fun f(t: R|T|): R|kotlin/Int| - public constructor(): R|test/ClassParamUsedInFun| + public constructor(): R|test/ClassParamUsedInFun| } diff --git a/compiler/fir/resolve/testData/loadCompiledKotlin/visibility/PrivateToThis.txt b/compiler/fir/resolve/testData/loadCompiledKotlin/visibility/PrivateToThis.txt index 6857efe8f4b..6b0a9f8cf18 100644 --- a/compiler/fir/resolve/testData/loadCompiledKotlin/visibility/PrivateToThis.txt +++ b/compiler/fir/resolve/testData/loadCompiledKotlin/visibility/PrivateToThis.txt @@ -15,6 +15,6 @@ public final class A : R|kotlin/Any| { private/*private to this*/ get(): R|I| private/*private to this*/ set(value: R|I|): kotlin/Unit - public constructor(): R|test/A| + public constructor(): R|test/A| } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/problems.txt b/compiler/fir/resolve/testData/resolve/stdlib/problems.txt index 9fcf50d1053..d6dd51cb6af 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/problems.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/problems.txt @@ -36,8 +36,8 @@ FILE: problems.kt } public final val t: = String().# public get(): - public final val p: = #(Int(0), String()) - public get(): + public final val p: R|kotlin/Pair| = R|kotlin/Pair.Pair|(Int(0), String()) + public get(): R|kotlin/Pair| public final class Base : R|kotlin/Any| { public constructor(x: R|T|): R|Base| { super() diff --git a/compiler/testData/ir/irText/expressions/genericConstructorCallWithTypeArguments.fir.txt b/compiler/testData/ir/irText/expressions/genericConstructorCallWithTypeArguments.fir.txt index 667955c9b0f..ee9f4d02525 100644 --- a/compiler/testData/ir/irText/expressions/genericConstructorCallWithTypeArguments.fir.txt +++ b/compiler/testData/ir/irText/expressions/genericConstructorCallWithTypeArguments.fir.txt @@ -15,8 +15,8 @@ FILE fqName: fileName:/genericConstructorCallWithTypeArguments.kt CONSTRUCTOR_CALL 'public constructor (size: kotlin.Int, init: kotlin.Function1) declared in kotlin.Array' type=kotlin.Array.testArray> origin=null : size: GET_VAR 'n: kotlin.Int declared in .testArray' type=kotlin.Int origin=null - init: FUN_EXPR type=kotlin.Function1 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:kotlin.Int) returnType:T of kotlin.Array + init: FUN_EXPR type=kotlin.Function1.testArray> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:kotlin.Int) returnType:T of .testArray VALUE_PARAMETER name:it index:0 type:kotlin.Int BLOCK_BODY CALL 'public abstract fun invoke (): T of .testArray declared in kotlin.Function0' type=T of .testArray origin=null