Skip to content

Fix KSAnnotationResolvedImpl.origin#2429

Merged
ting-yuan merged 1 commit into
google:mainfrom
ting-yuan:annotation-origin
Apr 30, 2025
Merged

Fix KSAnnotationResolvedImpl.origin#2429
ting-yuan merged 1 commit into
google:mainfrom
ting-yuan:annotation-origin

Conversation

@ting-yuan

Copy link
Copy Markdown
Contributor

Annotations applied in sources can be attached to synthetic elements. In that case, they should still be considered as source.

Fixes #2425

Annotations applied in sources can be attached to synthetic elements.
In that case, they should still be considered as source.
@ting-yuan ting-yuan requested review from dx404 and jsjeon April 29, 2025 22:15
Comment on lines +143 to +147
val parentOrigin = parent?.origin ?: Origin.SYNTHETIC
when (parentOrigin) {
Origin.SYNTHETIC -> containingFile?.origin ?: Origin.SYNTHETIC
else -> parentOrigin
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to reduce the occurrence of Origin.SYNTHETIC, but was able to do just one removal. 😄

parent?.origin?.takeIf { it != Origin.SYNTHETIC }
  ?.let { return it }
return containingFile?.origin ?: Origin.SYNTHETIC

or...

return when (val parentOrigin = parent?.origin) {
  null,
  Origin.SYNTHETIC -> containingFile?.origin ?: Origin.SYNTHETIC
  else -> parentOrigin
}

@ting-yuan ting-yuan merged commit 8b94047 into google:main Apr 30, 2025
@ting-yuan ting-yuan added this to the 2.0.1 milestone Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[KSP2] Annotation values shouldn't be marked as default (synthetic origin) broken after PR #2424

2 participants