Repository navigation
Fix parent of Java method overriding Kotlin property - #3289
Open
KlyneChrysler wants to merge 2 commits into
Open
KlyneChrysler wants to merge 2 commits into
KlyneChrysler wants to merge 2 commits into
Conversation
A Java method overriding a Kotlin property is modeled by the Analysis API as a synthetic property accessor whose containing symbol is the property. Return the declaring class as its parent while keeping the declaration synthetic, and resolve the overridden property through the containing symbol so override checks keep working. Fixes google#2498
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal
Fixes #2498.
parent/parentDeclarationof a Java method that overrides a Kotlin property returned the Kotlin property instead of the Java class declaring the method.Summary
parentfor Analysis API synthetic Java property accessors so it returns the declaring class.originasSYNTHETICfor those accessors.overrides()checks through the containing property symbol.Design decisions
KaFirSyntheticPropertyGetterSymbolwithKaSymbolOrigin.JAVA_SYNTHETIC_PROPERTY; theircontainingSymbolis the synthetic property. That relationship is kept for override resolution, butparentnow exposes the class because the declaration is a Java method.ResolverAAImpl.overridespreviously castparenttoKSPropertyDeclarationImpl, which would throw after the parent fix. It now usescontainingSymbolinstead.Test plan
./gradlew :kotlin-analysis-api:test(AA/PSI and new-features suites, 620 tests)