提交 2b088f11 编写于 作者: D Dmitriy Novozhilov 提交者: TeamCityServer

[FIR] Fix generating data class if there is non-property in primary constructor

#KT-44554 Fixed
上级 30b5bfe7
...@@ -244,6 +244,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract ...@@ -244,6 +244,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
runTest("compiler/fir/analysis-tests/testData/resolve/implicitTypeInFakeOverride.kt"); runTest("compiler/fir/analysis-tests/testData/resolve/implicitTypeInFakeOverride.kt");
} }
@TestMetadata("incorrectDataClass.kt")
public void testIncorrectDataClass() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/incorrectDataClass.kt");
}
@TestMetadata("incorrectSuperCall.kt") @TestMetadata("incorrectSuperCall.kt")
public void testIncorrectSuperCall() throws Exception { public void testIncorrectSuperCall() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/incorrectSuperCall.kt"); runTest("compiler/fir/analysis-tests/testData/resolve/incorrectSuperCall.kt");
......
FILE: incorrectDataClass.kt
public final data class Foo : R|kotlin/Any| {
public constructor(a: R|kotlin/Int|, b: R|kotlin/Int|): R|Foo| {
super<R|kotlin/Any|>()
}
public final val b: R|kotlin/Int| = R|<local>/b|
public get(): R|kotlin/Int|
public final val c: R|kotlin/Int| = Int(4)
public get(): R|kotlin/Int|
public final operator fun component1(): R|kotlin/Int|
public final fun copy(b: R|kotlin/Int| = this@R|/Foo|.R|/Foo.b|): R|Foo|
}
// ISSUE: KT-44554
data class Foo(a: Int, val b: Int) {
val c = 4
}
...@@ -284,6 +284,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { ...@@ -284,6 +284,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
runTest("compiler/fir/analysis-tests/testData/resolve/implicitTypeInFakeOverride.kt"); runTest("compiler/fir/analysis-tests/testData/resolve/implicitTypeInFakeOverride.kt");
} }
@Test
@TestMetadata("incorrectDataClass.kt")
public void testIncorrectDataClass() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/incorrectDataClass.kt");
}
@Test @Test
@TestMetadata("incorrectSuperCall.kt") @TestMetadata("incorrectSuperCall.kt")
public void testIncorrectSuperCall() throws Exception { public void testIncorrectSuperCall() throws Exception {
......
...@@ -287,6 +287,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos ...@@ -287,6 +287,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
runTest("compiler/fir/analysis-tests/testData/resolve/implicitTypeInFakeOverride.kt"); runTest("compiler/fir/analysis-tests/testData/resolve/implicitTypeInFakeOverride.kt");
} }
@Test
@TestMetadata("incorrectDataClass.kt")
public void testIncorrectDataClass() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/incorrectDataClass.kt");
}
@Test @Test
@TestMetadata("incorrectSuperCall.kt") @TestMetadata("incorrectSuperCall.kt")
public void testIncorrectSuperCall() throws Exception { public void testIncorrectSuperCall() throws Exception {
......
...@@ -862,9 +862,7 @@ class RawFirBuilder( ...@@ -862,9 +862,7 @@ class RawFirBuilder(
} }
if (classOrObject.hasModifier(DATA_KEYWORD) && firPrimaryConstructor != null) { if (classOrObject.hasModifier(DATA_KEYWORD) && firPrimaryConstructor != null) {
val zippedParameters = classOrObject.primaryConstructorParameters.zip( val zippedParameters = classOrObject.primaryConstructorParameters.filter { it.hasValOrVar() } zip declarations.filterIsInstance<FirProperty>()
declarations.filterIsInstance<FirProperty>(),
)
DataClassMembersGenerator( DataClassMembersGenerator(
baseSession, baseSession,
classOrObject, classOrObject,
...@@ -877,7 +875,7 @@ class RawFirBuilder( ...@@ -877,7 +875,7 @@ class RawFirBuilder(
// just making a shallow copy isn't enough type ref may be a function type ref // just making a shallow copy isn't enough type ref may be a function type ref
// and contain value parameters inside // and contain value parameters inside
withDefaultSourceElementKind(newKind) { withDefaultSourceElementKind(newKind) {
(property.returnTypeRef.psi as KtTypeReference).toFirOrImplicitType() (property.returnTypeRef.psi as KtTypeReference?).toFirOrImplicitType()
} }
}, },
).generate() ).generate()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册