Skip to content

Commit 88b78d4

Browse files
neetopiating-yuan
authored andcommitted
use proper scope for getting declared static memberscope
1 parent d87c083 commit 88b78d4

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

kotlin-analysis-api/src/main/kotlin/com/google/devtools/ksp/impl/symbol/kotlin/util.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ internal inline fun <R> analyze(crossinline action: KtAnalysisSession.() -> R):
231231
internal fun KtSymbolWithMembers.declarations(): Sequence<KSDeclaration> {
232232
return analyze {
233233
this@declarations.let {
234-
it.getDeclaredMemberScope().getAllSymbols() + it.getStaticMemberScope().getAllSymbols()
234+
it.getDeclaredMemberScope().getAllSymbols() + it.getStaticDeclaredMemberScope().getAllSymbols()
235235
}.distinct().map { symbol ->
236236
when (symbol) {
237237
is KtNamedClassOrObjectSymbol -> KSClassDeclarationImpl.getCached(symbol)

test-utils/src/main/kotlin/com/google/devtools/ksp/processor/DefaultFunctionProcessor.kt

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package com.google.devtools.ksp.processor
1919

2020
import com.google.devtools.ksp.getClassDeclarationByName
2121
import com.google.devtools.ksp.getDeclaredFunctions
22+
import com.google.devtools.ksp.getDeclaredProperties
2223
import com.google.devtools.ksp.isAbstract
2324
import com.google.devtools.ksp.processing.Resolver
2425
import com.google.devtools.ksp.symbol.KSAnnotated
@@ -100,6 +101,9 @@ class DefaultFunctionProcessor : AbstractTestProcessor() {
100101
result.add("${aProperty.simpleName.asString()}: ${aProperty.isAbstract()}")
101102
val D = resolver.getClassDeclarationByName("D")!!
102103
D.getAllProperties().forEach { result.add("${it.simpleName.asString()}: isMutable: ${it.isMutable}") }
104+
resolver.getClassDeclarationByName("JavaDerived")!!.getDeclaredProperties().forEach {
105+
result.add(it.toString())
106+
}
103107
return emptyList()
104108
}
105109

test-utils/testData/api/interfaceWithDefault.kt

+10
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,13 @@ class D {
7676

7777
final int finalField;
7878
}
79+
80+
// FILE: JavaBase.java
81+
82+
class JavaBase {
83+
static String staticField;
84+
}
85+
86+
// FILE: JavaDerived.java
87+
class JavaDerived extends JavaBase {
88+
}

0 commit comments

Comments
 (0)