[FIR] Fix generating data class if there is non-property in primary constructor
#KT-44554 Fixed
This commit is contained in:
committed by
TeamCityServer
parent
30b5bfe767
commit
2b088f1147
+5
@@ -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");
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
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|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// ISSUE: KT-44554
|
||||||
|
|
||||||
|
data class Foo(a: Int, val b: Int) {
|
||||||
|
val c = 4
|
||||||
|
}
|
||||||
+6
@@ -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 {
|
||||||
|
|||||||
+6
@@ -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(
|
|||||||
}
|
}
|
||||||
|
|
||||||
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(
|
|||||||
// 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()
|
||||||
|
|||||||
Reference in New Issue
Block a user