Skip to content

Return static function kind if modifier has static modifier#2411

Merged
ting-yuan merged 2 commits into
google:mainfrom
bacecek:users/bacecek/2410
Apr 14, 2025
Merged

Return static function kind if modifier has static modifier#2411
ting-yuan merged 2 commits into
google:mainfrom
bacecek:users/bacecek/2410

Conversation

@bacecek

@bacecek bacecek commented Apr 11, 2025

Copy link
Copy Markdown
Contributor

Fixes #2410

override val functionKind: FunctionKind by lazy {
if (modifiers.contains(Modifier.JAVA_STATIC)) {
FunctionKind.STATIC
}

@ting-yuan ting-yuan Apr 11, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the fix! Unfortunately getting modifiers can be slow in some cases. Can we patch the when case KaSymbolLocation.CLASS below, and make it consider ktFunctionSymbol.isStatic when it is a KaNamedFunctionSymbol? I.e., something like

            KaSymbolLocation.CLASS -> {
                if (ktFunctionSymbol is KaNamedFunctionSymbol && ktFunctionSymbol.isStatic)
                    FunctionKind.STATIC
                else
                    FunctionKind.MEMBER
            }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, looks way better, thank you!

@bacecek bacecek force-pushed the users/bacecek/2410 branch from b8679cc to f391f3b Compare April 12, 2025 11:23
@ting-yuan ting-yuan merged commit 3b05662 into google:main Apr 14, 2025
@ting-yuan

Copy link
Copy Markdown
Contributor

Thank you so much for the fix!

@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] functionKind is MEMBER for static method in interface in Java

2 participants