From 1bf6f8fc572049d36ca7a800b359d2b6ac643a02 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Wed, 19 Apr 2017 18:05:00 +0300 Subject: [PATCH] Do not generate separate type parameter declarations for constructors --- .../jetbrains/kotlin/psi2ir/generators/FunctionGenerator.kt | 3 +-- .../kotlin/psi2ir/generators/ModuleDependenciesGenerator.kt | 1 - compiler/testData/ir/irText/classes/dataClassesGeneric.txt | 1 - .../delegatingConstructorCallToTypeAliasConstructor.txt | 1 - compiler/testData/ir/irText/declarations/fakeOverrides.txt | 1 - .../testData/ir/irText/declarations/parameters/class.txt | 3 --- .../ir/irText/declarations/parameters/constructor.txt | 6 ------ .../ir/irText/declarations/parameters/dataClassMembers.txt | 1 - .../declarations/parameters/defaultPropertyAccessors.txt | 1 - .../ir/irText/declarations/parameters/delegatedMembers.txt | 1 - .../ir/irText/declarations/parameters/propertyAccessors.txt | 1 - .../testData/ir/irText/regressions/integerCoercionToT.txt | 1 - 12 files changed, 1 insertion(+), 20 deletions(-) diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/FunctionGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/FunctionGenerator.kt index 70e7b4d5b84..7386de13a2d 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/FunctionGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/FunctionGenerator.kt @@ -16,7 +16,6 @@ package org.jetbrains.kotlin.psi2ir.generators -import com.sun.org.apache.xpath.internal.operations.Mod import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.expressions.IrBlockBody @@ -204,7 +203,7 @@ class FunctionGenerator(declarationGenerator: DeclarationGenerator) : Declaratio context.symbolTable.declareConstructor( ktConstructorElement.startOffset, ktConstructorElement.endOffset, IrDeclarationOrigin.DEFINED, constructorDescriptor ).buildWithScope { irConstructor -> - generateFunctionParameterDeclarations(irConstructor, ktParametersElement, null) + generateValueParameterDeclarations(irConstructor, ktParametersElement, null) irConstructor.body = createBodyGenerator(irConstructor.symbol).generateBody() } diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ModuleDependenciesGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ModuleDependenciesGenerator.kt index e031b2bf5e4..a0ecbc42dec 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ModuleDependenciesGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ModuleDependenciesGenerator.kt @@ -23,7 +23,6 @@ import org.jetbrains.kotlin.ir.declarations.impl.IrModuleFragmentImpl import org.jetbrains.kotlin.ir.declarations.impl.IrPropertyImpl import org.jetbrains.kotlin.ir.declarations.impl.IrTypeParameterImpl import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl -import org.jetbrains.kotlin.ir.descriptors.IrDeclarationStubBuilder import org.jetbrains.kotlin.ir.symbols.IrSymbol import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.scopes.MemberScope diff --git a/compiler/testData/ir/irText/classes/dataClassesGeneric.txt b/compiler/testData/ir/irText/classes/dataClassesGeneric.txt index 90f84adc878..2a4233a0825 100644 --- a/compiler/testData/ir/irText/classes/dataClassesGeneric.txt +++ b/compiler/testData/ir/irText/classes/dataClassesGeneric.txt @@ -3,7 +3,6 @@ FILE /dataClassesGeneric.kt $new: VALUE_PARAMETER TYPE_PARAMETER CONSTRUCTOR public constructor Test1(x: T) - TYPE_PARAMETER VALUE_PARAMETER value-parameter x: T BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' diff --git a/compiler/testData/ir/irText/classes/delegatingConstructorCallToTypeAliasConstructor.txt b/compiler/testData/ir/irText/classes/delegatingConstructorCallToTypeAliasConstructor.txt index d839c2acb47..20209e25cc4 100644 --- a/compiler/testData/ir/irText/classes/delegatingConstructorCallToTypeAliasConstructor.txt +++ b/compiler/testData/ir/irText/classes/delegatingConstructorCallToTypeAliasConstructor.txt @@ -3,7 +3,6 @@ FILE /delegatingConstructorCallToTypeAliasConstructor.kt $new: VALUE_PARAMETER TYPE_PARAMETER CONSTRUCTOR public constructor Cell(value: T) - TYPE_PARAMETER VALUE_PARAMETER value-parameter value: T BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' diff --git a/compiler/testData/ir/irText/declarations/fakeOverrides.txt b/compiler/testData/ir/irText/declarations/fakeOverrides.txt index f395af8bec6..db1c34063ac 100644 --- a/compiler/testData/ir/irText/declarations/fakeOverrides.txt +++ b/compiler/testData/ir/irText/declarations/fakeOverrides.txt @@ -17,7 +17,6 @@ FILE /fakeOverrides.kt $new: VALUE_PARAMETER TYPE_PARAMETER CONSTRUCTOR public constructor CFoo() - TYPE_PARAMETER BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' INSTANCE_INITIALIZER_CALL classDescriptor='CFoo' diff --git a/compiler/testData/ir/irText/declarations/parameters/class.txt b/compiler/testData/ir/irText/declarations/parameters/class.txt index 6f23dd1f22b..d54b0f26f85 100644 --- a/compiler/testData/ir/irText/declarations/parameters/class.txt +++ b/compiler/testData/ir/irText/declarations/parameters/class.txt @@ -13,7 +13,6 @@ FILE /class.kt $new: VALUE_PARAMETER TYPE_PARAMETER CONSTRUCTOR public constructor Test() - TYPE_PARAMETER BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' INSTANCE_INITIALIZER_CALL classDescriptor='Test' @@ -21,7 +20,6 @@ FILE /class.kt $new: VALUE_PARAMETER TYPE_PARAMETER CONSTRUCTOR public constructor TestNested() - TYPE_PARAMETER BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' INSTANCE_INITIALIZER_CALL classDescriptor='TestNested' @@ -32,7 +30,6 @@ FILE /class.kt $new: VALUE_PARAMETER TYPE_PARAMETER CONSTRUCTOR public constructor TestInner() - TYPE_PARAMETER $outer: VALUE_PARAMETER BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' diff --git a/compiler/testData/ir/irText/declarations/parameters/constructor.txt b/compiler/testData/ir/irText/declarations/parameters/constructor.txt index 7712c365105..1b8c6b8115c 100644 --- a/compiler/testData/ir/irText/declarations/parameters/constructor.txt +++ b/compiler/testData/ir/irText/declarations/parameters/constructor.txt @@ -4,8 +4,6 @@ FILE /constructor.kt TYPE_PARAMETER TYPE_PARAMETER CONSTRUCTOR public constructor Test1(x: T1, y: T2) - TYPE_PARAMETER - TYPE_PARAMETER VALUE_PARAMETER value-parameter x: T1 VALUE_PARAMETER value-parameter y: T2 BLOCK_BODY @@ -56,7 +54,6 @@ FILE /constructor.kt $new: VALUE_PARAMETER TYPE_PARAMETER CONSTRUCTOR public constructor TestInner(z: Z) - TYPE_PARAMETER $outer: VALUE_PARAMETER VALUE_PARAMETER value-parameter z: Z BLOCK_BODY @@ -73,7 +70,6 @@ FILE /constructor.kt GET_FIELD 'z: Z' type=Z origin=null receiver: GET_VAR '' type=Test2.TestInner origin=null CONSTRUCTOR public constructor TestInner(z: Z, i: kotlin.Int) - TYPE_PARAMETER $outer: VALUE_PARAMETER VALUE_PARAMETER value-parameter z: Z VALUE_PARAMETER value-parameter i: kotlin.Int @@ -125,7 +121,6 @@ FILE /constructor.kt $new: VALUE_PARAMETER TYPE_PARAMETER CONSTRUCTOR public constructor Test4(x: kotlin.Int) - TYPE_PARAMETER VALUE_PARAMETER value-parameter x: kotlin.Int BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' @@ -141,7 +136,6 @@ FILE /constructor.kt GET_FIELD 'x: Int' type=kotlin.Int origin=null receiver: GET_VAR '' type=Test4 origin=null CONSTRUCTOR public constructor Test4(x: kotlin.Int, y: kotlin.Int = ...) - TYPE_PARAMETER VALUE_PARAMETER value-parameter x: kotlin.Int VALUE_PARAMETER value-parameter y: kotlin.Int = ... EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/declarations/parameters/dataClassMembers.txt b/compiler/testData/ir/irText/declarations/parameters/dataClassMembers.txt index 56aa07a0316..7f0d690bbae 100644 --- a/compiler/testData/ir/irText/declarations/parameters/dataClassMembers.txt +++ b/compiler/testData/ir/irText/declarations/parameters/dataClassMembers.txt @@ -3,7 +3,6 @@ FILE /dataClassMembers.kt $new: VALUE_PARAMETER TYPE_PARAMETER CONSTRUCTOR public constructor Test(x: T, y: kotlin.String = ...) - TYPE_PARAMETER VALUE_PARAMETER value-parameter x: T VALUE_PARAMETER value-parameter y: kotlin.String = ... EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/declarations/parameters/defaultPropertyAccessors.txt b/compiler/testData/ir/irText/declarations/parameters/defaultPropertyAccessors.txt index 8c41310fb35..84846c8f96f 100644 --- a/compiler/testData/ir/irText/declarations/parameters/defaultPropertyAccessors.txt +++ b/compiler/testData/ir/irText/declarations/parameters/defaultPropertyAccessors.txt @@ -60,7 +60,6 @@ FILE /defaultPropertyAccessors.kt $new: VALUE_PARAMETER TYPE_PARAMETER CONSTRUCTOR public constructor InPrimaryCtor(testInPrimaryCtor1: T, testInPrimaryCtor2: kotlin.Int = ...) - TYPE_PARAMETER VALUE_PARAMETER value-parameter testInPrimaryCtor1: T VALUE_PARAMETER value-parameter testInPrimaryCtor2: kotlin.Int = ... EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.txt b/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.txt index 1f59edc854d..55d53bcfc94 100644 --- a/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.txt +++ b/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.txt @@ -19,7 +19,6 @@ FILE /delegatedMembers.kt $new: VALUE_PARAMETER TYPE_PARAMETER CONSTRUCTOR public constructor Test(impl: IBase) - TYPE_PARAMETER VALUE_PARAMETER value-parameter impl: IBase BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' diff --git a/compiler/testData/ir/irText/declarations/parameters/propertyAccessors.txt b/compiler/testData/ir/irText/declarations/parameters/propertyAccessors.txt index 6dccd4877ec..99d29eeccc8 100644 --- a/compiler/testData/ir/irText/declarations/parameters/propertyAccessors.txt +++ b/compiler/testData/ir/irText/declarations/parameters/propertyAccessors.txt @@ -48,7 +48,6 @@ FILE /propertyAccessors.kt $new: VALUE_PARAMETER TYPE_PARAMETER CONSTRUCTOR public constructor Host() - TYPE_PARAMETER BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' INSTANCE_INITIALIZER_CALL classDescriptor='Host' diff --git a/compiler/testData/ir/irText/regressions/integerCoercionToT.txt b/compiler/testData/ir/irText/regressions/integerCoercionToT.txt index cfcb6a0728b..da144a1b9af 100644 --- a/compiler/testData/ir/irText/regressions/integerCoercionToT.txt +++ b/compiler/testData/ir/irText/regressions/integerCoercionToT.txt @@ -13,7 +13,6 @@ FILE /integerCoercionToT.kt $new: VALUE_PARAMETER TYPE_PARAMETER CONSTRUCTOR public constructor CInt32VarX() - TYPE_PARAMETER BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' INSTANCE_INITIALIZER_CALL classDescriptor='CInt32VarX'