Skip to content

Commit 3c43627

Browse files
committed
Repro for missing constructor in compiled java classes
1 parent 1189677 commit 3c43627

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

compiler-plugin/src/main/kotlin/com/google/devtools/ksp/processor/AllFunctionsProcessor.kt

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
package com.google.devtools.ksp.processor
2020

21+
import com.google.devtools.ksp.getClassDeclarationByName
2122
import com.google.devtools.ksp.processing.Resolver
2223
import com.google.devtools.ksp.symbol.*
2324

@@ -33,6 +34,7 @@ class AllFunctionsProcessor : AbstractTestProcessor() {
3334

3435
override fun process(resolver: Resolver) {
3536
resolver.getAllFiles().map { it.accept(visitor, Unit) }
37+
resolver.getClassDeclarationByName("JavaWithConstructorInLib")!!.accept(visitor, Unit)
3638
}
3739

3840
inner class AllFunctionsVisitor : KSVisitorVoid() {

compiler-plugin/testData/api/allFunctions.kt

+30
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
// class: KotlinInterfaceWithProperty
2222
// <init>(): C
2323
// <init>(): JavaImplOfKotlinInterface
24+
// <init>(kotlin.Int): JavaWithConstructor
25+
// <init>(kotlin.Int): JavaWithConstructorInLib
2426
// a
2527
// aFromC
2628
// aFromC
@@ -33,6 +35,8 @@
3335
// class: Data
3436
// class: Foo
3537
// class: JavaImplOfKotlinInterface
38+
// class: JavaWithConstructor
39+
// class: JavaWithConstructorInLib
3640
// component1(): kotlin.String
3741
// contains(kotlin.Number): kotlin.Boolean
3842
// containsAll(kotlin.collections.Collection): kotlin.Boolean
@@ -42,13 +46,17 @@
4246
// equals(kotlin.Any): kotlin.Boolean
4347
// equals(kotlin.Any): kotlin.Boolean
4448
// equals(kotlin.Any): kotlin.Boolean
49+
// equals(kotlin.Any): kotlin.Boolean
50+
// equals(kotlin.Any): kotlin.Boolean
4551
// forEach(java.util.function.Consumer): kotlin.Unit
4652
// get(kotlin.Int): kotlin.Number
4753
// hashCode(): kotlin.Int
4854
// hashCode(): kotlin.Int
4955
// hashCode(): kotlin.Int
5056
// hashCode(): kotlin.Int
5157
// hashCode(): kotlin.Int
58+
// hashCode(): kotlin.Int
59+
// hashCode(): kotlin.Int
5260
// indexOf(kotlin.Number): kotlin.Int
5361
// isEmpty(): kotlin.Boolean
5462
// iterator(): kotlin.collections.Iterator
@@ -60,6 +68,8 @@
6068
// lastIndexOf(kotlin.Number): kotlin.Int
6169
// listIterator(): kotlin.collections.ListIterator
6270
// listIterator(kotlin.Int): kotlin.collections.ListIterator
71+
// method1(kotlin.Int): kotlin.Unit
72+
// method1(kotlin.Int): kotlin.Unit
6373
// parallelStream(): java.util.stream.Stream
6474
// size
6575
// spliterator(): java.util.Spliterator
@@ -70,9 +80,23 @@
7080
// toString(): kotlin.String
7181
// toString(): kotlin.String
7282
// toString(): kotlin.String
83+
// toString(): kotlin.String
84+
// toString(): kotlin.String
7385
// x
7486
// x
7587
// END
88+
// MODULE: lib
89+
// FILE: JavaWithConstructorInLib.java
90+
class JavaWithConstructorInLib {
91+
JavaWithConstructorInLib(int constructorArg1) {
92+
}
93+
void method1(int arg1) {}
94+
}
95+
// FILE: KotlinInLib.kt
96+
class KotlinClassInLib(constructorArg1:Int) {
97+
fun method1(arg1: Int) {}
98+
}
99+
// MODULE: mainModule(lib)
76100
// FILE: a.kt
77101
abstract class Foo : C(), List<out Number> {
78102
override fun javaListFun(): List<Int> {
@@ -126,4 +150,10 @@ class JavaImplOfKotlinInterface implements KotlinInterfaceWithProperty {
126150
}
127151
public void setX(int value) {
128152
}
153+
}
154+
// FILE: JavaWithConstructor.java
155+
class JavaWithConstructor {
156+
JavaWithConstructor(int constructorArg1) {
157+
}
158+
void method1(int arg1) {}
129159
}

0 commit comments

Comments
 (0)