Skip to content

Commit

Permalink
Don't implement functional interfaces
Browse files Browse the repository at this point in the history
This isn't allowed in JavaScript.
  • Loading branch information
squarejesse committed May 15, 2024
1 parent a6b742f commit 61aa473
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,12 @@ internal fun generateProtocolNode(
}
if (trait.parameterTypes.isEmpty()) {
addStatement(
"%L(json, change.id, eventSink)",
"%L(json, change.id, eventSink)::invoke",
trait.eventHandlerName,
)
} else {
addStatement(
"%L(json, change.id, eventSink, %L)",
"%L(json, change.id, eventSink, %L)::invoke",
trait.eventHandlerName,
arguments.joinToCode(),
)
Expand Down Expand Up @@ -528,11 +528,9 @@ private fun generateEventHandler(
): TypeSpec {
val constructor = FunSpec.constructorBuilder()
val invoke = FunSpec.builder("invoke")
.addModifiers(OVERRIDE)

val classBuilder = TypeSpec.classBuilder(trait.eventHandlerName)
.addModifiers(PRIVATE)
.addSuperinterface(trait.lambdaType.copy(nullable = false))

addConstructorParameterAndProperty(classBuilder, constructor, "json", KotlinxSerialization.Json)
addConstructorParameterAndProperty(classBuilder, constructor, "id", Protocol.Id)
Expand Down

0 comments on commit 61aa473

Please sign in to comment.