diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/AnnotationCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/AnnotationCodegen.java index 04887664bb4..44b7ccc1ee3 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/AnnotationCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/AnnotationCodegen.java @@ -20,6 +20,8 @@ import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.codegen.state.JetTypeMapper; +import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedCallableMemberDescriptor; +import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedPropertyDescriptor; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.annotations.Annotated; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor; @@ -112,24 +114,33 @@ public abstract class AnnotationCodegen { modifierList = ((JetModifierListOwner) psiElement).getModifierList(); } - if (modifierList == null) { - generateAdditionalAnnotations(annotated, returnType, Collections.emptySet()); - return; - } - Set annotationDescriptorsAlreadyPresent = new HashSet(); - List annotationEntries = modifierList.getAnnotationEntries(); - for (JetAnnotationEntry annotationEntry : annotationEntries) { - ResolvedCall resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, annotationEntry.getCalleeExpression()); - if (resolvedCall == null) continue; // Skipping annotations if they are not resolved. Needed for JetLightClass generation + if (modifierList == null) { + if (annotated instanceof DeserializedCallableMemberDescriptor || + annotated instanceof PropertyAccessorDescriptor && + ((PropertyAccessorDescriptor) annotated).getCorrespondingProperty() instanceof DeserializedPropertyDescriptor) { + for (AnnotationDescriptor annotation : annotated.getAnnotations()) { + String descriptor = genAnnotation(annotation); + if (descriptor != null) { + annotationDescriptorsAlreadyPresent.add(descriptor); + } + } + } + } + else { + List annotationEntries = modifierList.getAnnotationEntries(); + for (JetAnnotationEntry annotationEntry : annotationEntries) { + ResolvedCall resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, annotationEntry.getCalleeExpression()); + if (resolvedCall == null) continue; // Skipping annotations if they are not resolved. Needed for JetLightClass generation - AnnotationDescriptor annotationDescriptor = bindingContext.get(BindingContext.ANNOTATION, annotationEntry); - if (annotationDescriptor == null) continue; // Skipping annotations if they are not resolved. Needed for JetLightClass generation + AnnotationDescriptor annotationDescriptor = bindingContext.get(BindingContext.ANNOTATION, annotationEntry); + if (annotationDescriptor == null) continue; // Skipping annotations if they are not resolved. Needed for JetLightClass generation - String descriptor = genAnnotation(annotationDescriptor); - if (descriptor != null) { - annotationDescriptorsAlreadyPresent.add(descriptor); + String descriptor = genAnnotation(annotationDescriptor); + if (descriptor != null) { + annotationDescriptorsAlreadyPresent.add(descriptor); + } } } diff --git a/jps-plugin/test/org/jetbrains/jet/jps/build/IncrementalJpsTestGenerated.java b/jps-plugin/test/org/jetbrains/jet/jps/build/IncrementalJpsTestGenerated.java index 9ccc3cd59a1..bb8c3735440 100644 --- a/jps-plugin/test/org/jetbrains/jet/jps/build/IncrementalJpsTestGenerated.java +++ b/jps-plugin/test/org/jetbrains/jet/jps/build/IncrementalJpsTestGenerated.java @@ -51,6 +51,11 @@ public class IncrementalJpsTestGenerated extends AbstractIncrementalJpsTest { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("jps-plugin/testData/incremental"), Pattern.compile("^([^\\.]+)$"), false); } + @TestMetadata("annotations") + public void testAnnotations() throws Exception { + doTest("jps-plugin/testData/incremental/annotations/"); + } + @TestMetadata("classInlineFunctionChanged") public void testClassInlineFunctionChanged() throws Exception { doTest("jps-plugin/testData/incremental/classInlineFunctionChanged/"); diff --git a/jps-plugin/testData/incremental/annotations/annotations.kt b/jps-plugin/testData/incremental/annotations/annotations.kt new file mode 100644 index 00000000000..b3ba1990abf --- /dev/null +++ b/jps-plugin/testData/incremental/annotations/annotations.kt @@ -0,0 +1,13 @@ +package test + +annotation class Anno + +[Anno] fun f() { +} + +[Anno] val v1 = "" + +var v2: String + get() = "" + [Anno] set(value) { + } diff --git a/jps-plugin/testData/incremental/annotations/build.log b/jps-plugin/testData/incremental/annotations/build.log new file mode 100644 index 00000000000..3e90e7f7e51 --- /dev/null +++ b/jps-plugin/testData/incremental/annotations/build.log @@ -0,0 +1,7 @@ +Cleaning output files: +out/production/module/test/TestPackage-other-*.class +out/production/module/test/TestPackage.class +End of files +Compiling files: +src/other.kt +End of files diff --git a/jps-plugin/testData/incremental/annotations/other.kt b/jps-plugin/testData/incremental/annotations/other.kt new file mode 100644 index 00000000000..092462c70e0 --- /dev/null +++ b/jps-plugin/testData/incremental/annotations/other.kt @@ -0,0 +1,4 @@ +package test + +fun dummyFunction() { +} \ No newline at end of file diff --git a/jps-plugin/testData/incremental/annotations/other.kt.new b/jps-plugin/testData/incremental/annotations/other.kt.new new file mode 100644 index 00000000000..092462c70e0 --- /dev/null +++ b/jps-plugin/testData/incremental/annotations/other.kt.new @@ -0,0 +1,4 @@ +package test + +fun dummyFunction() { +} \ No newline at end of file