workflow-kotlin: Kotlin IntelliJ plugin crashes on StatefulWorkflow and action builder

There is a bug in the plugin that crashes the parser when it encounters action. @kirillzh filed JetBrains an issue about it.

I’ve created a minimal Android Studio project that demonstrates this bug: https://github.com/zach-klippenstein/repro-KT-34524

Open the project in Android Studio and open the file app/src/main/java/com/example/kt_34524repro/SampleWorkflow.kt to see the bug in action.

There are a few other issues that look to be related or duplicates:

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 5
  • Comments: 19 (9 by maintainers)

Most upvoted comments

Good news, upgrading Android Studio to Kotlin plugin 1.4-M1 seems to fix the issue in our repro project (https://github.com/zach-klippenstein/repro-KT-34524). The kotlin file is parsed, the action {} builder is highlighted as missing and offered to be imported, and the uncommented prose is highlighted as invalid syntax. Haven’t tested with our big internal codebase yet, but this is a good step in the right direction!

We just heard from a contact at JetBrains that they’re aware of this issue and considering how to prioritize it. There’s maybe even a small chance it could be fixed in 1.3.70, but no guarantees.

But we’ll wind up needing two implementations of RenderTester. Yuck.

Maybe there’s a base context type they can share, and then the inner classes are little facades with the two workflow base classes.

abstract class AbstractRenderContext<P, S, O> { ... }

abstract class StatefulWorkflow<P, S, O, R>() : Workflow<P, O , R> {
  inner class RenderContext : AbstractRenderContext<P, S, O> { ... }
}

class StatefulRenderTester <P, S, O, R>: AbstractRenderContext<P, S, O> { }

abstract class StatelessWorkflow<P, O, R>() : Workflow<P, Unit, O , R> {
  inner class RenderContext : AbstractRenderContext<P, Unit, Nothing> { ... }
}

class StatelessRenderTester <P, O, R>: AbstractRenderContext<P, Unit, O> { }