Skip to content

Commit

Permalink
get delegation working again but dangerously
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewparmet committed Jun 9, 2024
1 parent 159dc33 commit d4b445f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package protokt.v1.codegen.generate

import com.squareup.kotlinpoet.ClassName
import com.squareup.kotlinpoet.CodeBlock
import com.squareup.kotlinpoet.TypeSpec
import protokt.v1.codegen.generate.CodeGenerator.Context
import protokt.v1.codegen.util.Message
Expand Down Expand Up @@ -47,7 +48,7 @@ internal object Implements {
if (msg.options.protokt.implements.delegates()) {
addSuperinterface(
ClassName.bestGuess(msg.options.protokt.implements.substringBefore(" by ")),
msg.options.protokt.implements.substringAfter(" by ")
CodeBlock.of(msg.options.protokt.implements.substringAfter(" by ") + "!!")
)
} else {
addSuperinterface(msg.superInterface(ctx)!!)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ message ImplementsModel2 {
}

message ImplementsWithDelegate {
// option (.protokt.v1.class).implements = "IModel2 by modelTwo!!";
option (.protokt.v1.class).implements = "IModel2 by modelTwo";

ImplementsModel2 model_two = 1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class MessageImplementsTest {

@Test
fun `message implementing by a delegate can be assigned to its interface`() {
// val byDelegate: IModel2 = ImplementsWithDelegate { modelTwo = model2 }
val byDelegate: IModel2 = ImplementsWithDelegate { modelTwo = model2 }

// assertThat(byDelegate.id).isEqualTo(model2.id)
assertThat(byDelegate.id).isEqualTo(model2.id)
}
}

0 comments on commit d4b445f

Please sign in to comment.