You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Using KotlinPoet 1.18.1 I get the exception: java.lang.IllegalStateException: Functional interfaces must have exactly one abstract function. Contained 0: []
when try to generate valid kotlin code. I'm trying to generate functional interface which doesn't contains new methods and inherits another functional interface with method declaration.
To Reproduce
val bClassName =ClassName("","B")
val aClassName =ClassName("","A")
val fileSpec =FileSpec.builder("", "Example")
.addType(
TypeSpec.funInterfaceBuilder(bClassName)
.addFunction(
FunSpec.builder("foo")
.addModifiers(KModifier.ABSTRACT)
.build(),
)
.build()
)
.addType(
TypeSpec.funInterfaceBuilder(aClassName)
.addSuperinterface(bClassName)
.build()
)
.build()
fileSpec.writeTo(System.out)
Expected behavior
I expect to get generated code instead of exception.
Additional context
This is a correct kotlin code and it can be compiled.
fun interface A: B
fun interface B {
fun foo()
}
The text was updated successfully, but these errors were encountered:
Does the compiler check that B is a functional interface, or an interface that has exactly one method?
But given that KotlinPoet's correctness checks don't have to be as exhaustive as the real compiler's, I think we can allow zero methods in a functional interface if it has a superinterface. Would that make sense?
Describe the bug
Using KotlinPoet 1.18.1 I get the exception:
java.lang.IllegalStateException: Functional interfaces must have exactly one abstract function. Contained 0: []
when try to generate valid kotlin code. I'm trying to generate functional interface which doesn't contains new methods and inherits another functional interface with method declaration.
To Reproduce
Expected behavior
I expect to get generated code instead of exception.
Additional context
This is a correct kotlin code and it can be compiled.
The text was updated successfully, but these errors were encountered: