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
> Task :compileJsBenchmarkKotlinJs FAILED
e: file:///home/jb/IdeaProjects/benchmark-Instant-parse/build/benchmarks/js/sources/kotlinx/benchmark/generated/org/example/ExampleBenchmark_Descriptor.kt:30:52 This declaration needs opt-in. Its usage must be marked with '@kotlin.time.ExperimentalTime' or '@OptIn(kotlin.time.ExperimentalTime::class)'
e: file:///home/jb/IdeaProjects/benchmark-Instant-parse/build/benchmarks/js/sources/kotlinx/benchmark/generated/org/example/ExampleBenchmark_Descriptor.kt:32:52 This declaration needs opt-in. Its usage must be marked with '@kotlin.time.ExperimentalTime' or '@OptIn(kotlin.time.ExperimentalTime::class)'
Moving OptIn somewhere outside also causes the compilation failure. The one way I've found to write this benchmark is to use block bodies for these functions:
The issue is not specific to K/JS and I was able to reproduce it with other targets as well.
The compilation fails because ExampleBenchmark::parse and ::parseNoFrac had an experimental return type (kotlin.time.Instant).
As a workaround that won't affect benchmark's semantics, the experimental annotation could be opted-in using a compiler flag (-opt-in=kotlin.time.ExperimentalTime).
It would be nice to add all necessary plugins to a generated plugin automatically, however, supporting it might be tricky:
for klib-based targets (well, all non-JVM targets), we have to load all transitive dependencies in order to track down all experimental annotations; I'm not sure if it is worth support right now.
for JVM target, we need to intercept JMH's code generator to emit all required opt-ins (further investigation is required here).
fzhinkin
changed the title
Opt-ins don't propagate to JS and Wasm/JS benchmarks, causing a compilation failure
Automatically opt-in all experimental annotations for types publicly exposed by a benchmark class
Apr 21, 2025
I've used https://github.com/fzhinkin/benchmarks-template.
then fails to compile with
Moving
OptIn
somewhere outside also causes the compilation failure. The one way I've found to write this benchmark is to use block bodies for these functions:The text was updated successfully, but these errors were encountered: