[FIR] Generate annotations to data class copy method parameters
#KT-57003 Fixed
This commit is contained in:
committed by
Space Team
parent
5ae3a93084
commit
0ac02be534
+15
-12
@@ -164,18 +164,21 @@ internal fun deserializeClassToSymbol(
|
||||
|
||||
if (classOrObject.isData() && firPrimaryConstructor != null) {
|
||||
val zippedParameters =
|
||||
classOrObject.primaryConstructorParameters.filter { it.hasValOrVar() } zip declarations.filterIsInstance<FirProperty>()
|
||||
addDeclaration(createDataClassCopyFunction(classId, classOrObject, context.dispatchReceiver, zippedParameters,
|
||||
createClassTypeRefWithSourceKind = {
|
||||
firPrimaryConstructor.returnTypeRef.copyWithNewSourceKind(
|
||||
it
|
||||
)
|
||||
},
|
||||
createParameterTypeRefWithSourceKind = { property, newKind ->
|
||||
property.returnTypeRef.copyWithNewSourceKind(newKind)
|
||||
}) { src, kind ->
|
||||
KtFakeSourceElement(src as PsiElement, kind)
|
||||
})
|
||||
classOrObject.primaryConstructorParameters zip declarations.filterIsInstance<FirProperty>()
|
||||
addDeclaration(
|
||||
createDataClassCopyFunction(
|
||||
classId,
|
||||
classOrObject,
|
||||
context.dispatchReceiver,
|
||||
zippedParameters,
|
||||
createClassTypeRefWithSourceKind = { firPrimaryConstructor.returnTypeRef.copyWithNewSourceKind(it) },
|
||||
createParameterTypeRefWithSourceKind = { property, newKind ->
|
||||
property.returnTypeRef.copyWithNewSourceKind(newKind)
|
||||
},
|
||||
toFirSource = { src, kind -> KtFakeSourceElement(src as PsiElement, kind) },
|
||||
addValueParameterAnnotations = { annotations += context.annotationDeserializer.loadAnnotations(it) },
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
addCloneForArrayIfNeeded(classId, context.dispatchReceiver)
|
||||
|
||||
+6
@@ -1446,6 +1446,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/AnnotationsForPropertyTypeParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotationsOnDataClassCopy.kt")
|
||||
public void testAnnotationsOnDataClassCopy() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/annotationsOnDataClassCopy.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotationsOnLambdaAsCallArgument.kt")
|
||||
public void testAnnotationsOnLambdaAsCallArgument() throws Exception {
|
||||
|
||||
+6
@@ -1446,6 +1446,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/AnnotationsForPropertyTypeParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotationsOnDataClassCopy.kt")
|
||||
public void testAnnotationsOnDataClassCopy() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/annotationsOnDataClassCopy.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotationsOnLambdaAsCallArgument.kt")
|
||||
public void testAnnotationsOnLambdaAsCallArgument() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user