CreateExpect: should save receiver annotations
#KT-32694 Fixed
This commit is contained in:
@@ -299,10 +299,22 @@ private fun KtCallableDeclaration.repairOverride(descriptor: CallableDescriptor,
|
|||||||
private fun KtCallableDeclaration.repairAnnotationEntries(descriptor: CallableDescriptor, checker: TypeAccessibilityChecker) {
|
private fun KtCallableDeclaration.repairAnnotationEntries(descriptor: CallableDescriptor, checker: TypeAccessibilityChecker) {
|
||||||
for (annotation in descriptor.annotations) {
|
for (annotation in descriptor.annotations) {
|
||||||
if (annotation.isValidInModule(checker)) {
|
if (annotation.isValidInModule(checker)) {
|
||||||
val entry = annotation.source.safeAs<KotlinSourceElement>()?.psi.safeAs<KtAnnotationEntry>() ?: continue
|
checkAndAdd(annotation, checker, this)
|
||||||
addAnnotationEntry(entry)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val extension = descriptor.extensionReceiverParameter ?: return
|
||||||
|
val receiver = receiverTypeReference ?: return
|
||||||
|
for (annotation in extension.annotations) {
|
||||||
|
checkAndAdd(annotation, checker, receiver)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun checkAndAdd(annotationDescriptor: AnnotationDescriptor, checker: TypeAccessibilityChecker, target: KtModifierListOwner) {
|
||||||
|
if (annotationDescriptor.isValidInModule(checker)) {
|
||||||
|
val entry = annotationDescriptor.source.safeAs<KotlinSourceElement>()?.psi.safeAs<KtAnnotationEntry>() ?: return
|
||||||
|
target.addAnnotationEntry(entry)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun AnnotationDescriptor.isValidInModule(checker: TypeAccessibilityChecker): Boolean {
|
private fun AnnotationDescriptor.isValidInModule(checker: TypeAccessibilityChecker): Boolean {
|
||||||
|
|||||||
Vendored
+1
@@ -0,0 +1 @@
|
|||||||
|
annotation class SimpleA
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
expect fun @receiver:SimpleA String.myExtension()
|
||||||
Vendored
+4
@@ -0,0 +1,4 @@
|
|||||||
|
// "Create expected function in common module testModule_Common" "true"
|
||||||
|
// DISABLE-ERRORS
|
||||||
|
|
||||||
|
actual fun @receiver:SimpleA String.<caret>myExtension() { println(this) }
|
||||||
Vendored
+4
@@ -0,0 +1,4 @@
|
|||||||
|
// "Create expected function in common module testModule_Common" "true"
|
||||||
|
// DISABLE-ERRORS
|
||||||
|
|
||||||
|
actual fun @receiver:SimpleA String.<caret>myExtension() { println(this) }
|
||||||
+5
@@ -477,6 +477,11 @@ public class QuickFixMultiModuleTestGenerated extends AbstractQuickFixMultiModul
|
|||||||
runTest("idea/testData/multiModuleQuickFix/createExpect/sealedClass/");
|
runTest("idea/testData/multiModuleQuickFix/createExpect/sealedClass/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("topLevelFunctionWithAnnotations")
|
||||||
|
public void testTopLevelFunctionWithAnnotations() throws Exception {
|
||||||
|
runTest("idea/testData/multiModuleQuickFix/createExpect/topLevelFunctionWithAnnotations/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("topLevelPropertyWithTypeParam")
|
@TestMetadata("topLevelPropertyWithTypeParam")
|
||||||
public void testTopLevelPropertyWithTypeParam() throws Exception {
|
public void testTopLevelPropertyWithTypeParam() throws Exception {
|
||||||
runTest("idea/testData/multiModuleQuickFix/createExpect/topLevelPropertyWithTypeParam/");
|
runTest("idea/testData/multiModuleQuickFix/createExpect/topLevelPropertyWithTypeParam/");
|
||||||
|
|||||||
Reference in New Issue
Block a user