From 5ade831665a0af3206a16228694800ae21193a7f Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Thu, 27 May 2021 18:41:36 +0300 Subject: [PATCH] FIR: Fix INFERENCE_NO_INFORMATION_FOR_PARAMETER on type alias with generic expansion ^KT-46996 Fixed --- .../kotlin/fir/resolve/calls/ConstructorProcessing.kt | 8 +++----- .../codegen/box/arrays/nonLocalReturnArrayConstructor.kt | 2 -- .../codegen/box/typealias/typeAliasConstructorForArray.kt | 2 -- .../tests/deprecated/typealiasConstructor.fir.kt | 2 +- .../testData/diagnostics/tests/typealias/inGenerics.kt | 2 +- .../typealias/typeAliasConstructorForProjection.fir.kt | 6 +++--- .../tests/typealias/typeAliasConstructorReturnType.kt | 4 ++-- .../specializedTypeAliasConstructorCall.fir.kt.txt | 2 +- .../specializedTypeAliasConstructorCall.fir.txt | 2 +- .../expressions/specializedTypeAliasConstructorCall.kt | 3 --- 10 files changed, 12 insertions(+), 21 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ConstructorProcessing.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ConstructorProcessing.kt index d2a31b0744d..e0cbccab7c3 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ConstructorProcessing.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ConstructorProcessing.kt @@ -178,7 +178,9 @@ private fun processConstructors( val outerType = bodyResolveComponents.outerClassManager.outerType(type) - if (basicScope != null && (matchedSymbol.fir.typeParameters.isNotEmpty() || outerType != null)) { + if (basicScope != null && + (matchedSymbol.fir.typeParameters.isNotEmpty() || outerType != null || type.typeArguments.isNotEmpty()) + ) { TypeAliasConstructorsSubstitutingScope( matchedSymbol, basicScope, @@ -213,10 +215,6 @@ private class TypeAliasConstructorsSubstitutingScope( private val outerType: ConeClassLikeType?, ) : FirScope() { - init { - require(outerType != null || typeAliasSymbol.fir.typeParameters.isNotEmpty()) - } - override fun processDeclaredConstructors(processor: (FirConstructorSymbol) -> Unit) { delegatingScope.processDeclaredConstructors wrapper@{ originalConstructorSymbol -> val typeParameters = typeAliasSymbol.fir.typeParameters diff --git a/compiler/testData/codegen/box/arrays/nonLocalReturnArrayConstructor.kt b/compiler/testData/codegen/box/arrays/nonLocalReturnArrayConstructor.kt index c1d80b86807..d981f577025 100644 --- a/compiler/testData/codegen/box/arrays/nonLocalReturnArrayConstructor.kt +++ b/compiler/testData/codegen/box/arrays/nonLocalReturnArrayConstructor.kt @@ -1,5 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR -// See KT-46996 // DONT_TARGET_EXACT_BACKEND: WASM // WASM_MUTE_REASON: UNIT_ISSUES typealias ArrayS = Array diff --git a/compiler/testData/codegen/box/typealias/typeAliasConstructorForArray.kt b/compiler/testData/codegen/box/typealias/typeAliasConstructorForArray.kt index c7be3d753df..c01734198ea 100644 --- a/compiler/testData/codegen/box/typealias/typeAliasConstructorForArray.kt +++ b/compiler/testData/codegen/box/typealias/typeAliasConstructorForArray.kt @@ -1,5 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR -// See KT-46996 typealias BoolArray = Array typealias IArray = IntArray typealias MyArray = Array diff --git a/compiler/testData/diagnostics/tests/deprecated/typealiasConstructor.fir.kt b/compiler/testData/diagnostics/tests/deprecated/typealiasConstructor.fir.kt index d40e3109d56..77f1063af51 100644 --- a/compiler/testData/diagnostics/tests/deprecated/typealiasConstructor.fir.kt +++ b/compiler/testData/diagnostics/tests/deprecated/typealiasConstructor.fir.kt @@ -14,4 +14,4 @@ class Test1 : DeprecatedClassAlias() class Test2 : WithDeprecatedCtorAlias() -val test3 = ArrayListOfDeprecatedClass() +val test3 = ArrayListOfDeprecatedClass() diff --git a/compiler/testData/diagnostics/tests/typealias/inGenerics.kt b/compiler/testData/diagnostics/tests/typealias/inGenerics.kt index b57099ff472..f07ddec9ba3 100644 --- a/compiler/testData/diagnostics/tests/typealias/inGenerics.kt +++ b/compiler/testData/diagnostics/tests/typealias/inGenerics.kt @@ -10,4 +10,4 @@ val ms: MyString = "MyString" val msn: MyString? = null val msc: MyStringContainer = Container(ms) -val msc1 = MyStringContainer(null) +val msc1 = MyStringContainer(null) diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorForProjection.fir.kt b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorForProjection.fir.kt index 0143bd4c4dd..2a132cb3675 100644 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorForProjection.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorForProjection.fir.kt @@ -7,8 +7,8 @@ typealias CIn = C typealias COut = C typealias CT = C -val test1 = CStar() -val test2 = CIn() -val test3 = COut() +val test1 = CStar() +val test2 = CIn() +val test3 = COut() val test4 = CT<*>() val test5 = CT>() diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorReturnType.kt b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorReturnType.kt index feb5791551f..78d88ce75c9 100644 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorReturnType.kt +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorReturnType.kt @@ -8,10 +8,10 @@ typealias PIntIntA = Pair typealias PA = Pair typealias P2A = Pair -val test1 = CIntA(10) +val test1 = CIntA(10) val test2 = CA(10) val test3 = CA(10) -val test4 = PIntIntA(10, 20) +val test4 = PIntIntA(10, 20) val test5 = PA(10, 20) val test6 = PA(10, 20) val test7 = P2A(10, 20) diff --git a/compiler/testData/ir/irText/expressions/specializedTypeAliasConstructorCall.fir.kt.txt b/compiler/testData/ir/irText/expressions/specializedTypeAliasConstructorCall.fir.kt.txt index 1fea8c4a1aa..28be079f516 100644 --- a/compiler/testData/ir/irText/expressions/specializedTypeAliasConstructorCall.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/specializedTypeAliasConstructorCall.fir.kt.txt @@ -13,5 +13,5 @@ class Cell { } fun test(): Cell { - return Cell(value = 42) + return Cell(value = 42) } diff --git a/compiler/testData/ir/irText/expressions/specializedTypeAliasConstructorCall.fir.txt b/compiler/testData/ir/irText/expressions/specializedTypeAliasConstructorCall.fir.txt index adff1df82bd..60e81a24bed 100644 --- a/compiler/testData/ir/irText/expressions/specializedTypeAliasConstructorCall.fir.txt +++ b/compiler/testData/ir/irText/expressions/specializedTypeAliasConstructorCall.fir.txt @@ -36,5 +36,5 @@ FILE fqName: fileName:/specializedTypeAliasConstructorCall.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test (): .Cell declared in ' CONSTRUCTOR_CALL 'public constructor (value: T of .Cell) [primary] declared in .Cell' type=.Cell origin=null - : kotlin.Any? + : value: CONST Int type=kotlin.Int value=42 diff --git a/compiler/testData/ir/irText/expressions/specializedTypeAliasConstructorCall.kt b/compiler/testData/ir/irText/expressions/specializedTypeAliasConstructorCall.kt index 0d491f00a68..57c0329224f 100644 --- a/compiler/testData/ir/irText/expressions/specializedTypeAliasConstructorCall.kt +++ b/compiler/testData/ir/irText/expressions/specializedTypeAliasConstructorCall.kt @@ -1,6 +1,3 @@ -// IGNORE_BACKEND_FIR: ANY -// See KT-46996 - class Cell(val value: T) typealias IntAlias = Cell