Skip to content

Commit 2e35c09

Browse files
committed
repro for finding nested class error
1 parent 765e308 commit 2e35c09

File tree

1 file changed

+39
-0
lines changed
  • ksp/src/test/kotlin/com/tschuchort/compiletesting

1 file changed

+39
-0
lines changed

ksp/src/test/kotlin/com/tschuchort/compiletesting/KspTest.kt

+39
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.tschuchort.compiletesting
22

3+
import com.google.devtools.ksp.getClassDeclarationByName
4+
import com.google.devtools.ksp.getDeclaredProperties
35
import com.google.devtools.ksp.processing.Dependencies
46
import com.google.devtools.ksp.processing.Resolver
57
import com.google.devtools.ksp.processing.SymbolProcessor
@@ -196,6 +198,43 @@ class KspTest {
196198
)
197199
}
198200

201+
@Test
202+
fun resolveNestedClass() {
203+
val javaSource = SourceFile.java(
204+
"JavaSubject.java",
205+
"""
206+
import java.util.List;
207+
class JavaSubject {
208+
int intField;
209+
List<Integer> listOfInts;
210+
List incompleteGeneric;
211+
Nested nested;
212+
static class Nested {
213+
}
214+
}
215+
""".trimIndent()
216+
)
217+
val kotlinSource = SourceFile.kotlin(
218+
"placeholder.kt",
219+
""
220+
)
221+
var nestedClassIsError: Boolean = true
222+
val processor = object : AbstractTestSymbolProcessor() {
223+
override fun process(resolver: Resolver) {
224+
val decl = resolver.getClassDeclarationByName("JavaSubject")!!
225+
nestedClassIsError = decl.getDeclaredProperties().single {
226+
it.simpleName.asString() == "nested"
227+
}.type.resolve().isError
228+
}
229+
}
230+
val compilation = KotlinCompilation().apply {
231+
sources = listOf(javaSource, kotlinSource)
232+
symbolProcessors += processor
233+
}
234+
compilation.compile()
235+
assertThat(nestedClassIsError).isFalse()
236+
}
237+
199238
internal open class ClassGeneratingProcessor(
200239
private val packageName: String,
201240
private val className: String

0 commit comments

Comments
 (0)