Skip to content

@main methods can't be experimental #13848

Closed
@prolativ

Description

@prolativ

Compiler version

3.1.1-RC1

Minimized code

import annotation.experimental

@main
@experimental
def run(): Unit = {}

Output

[error] method run is marked @experimental and therefore may only be used in an experimental scope.
[error] @main
[error] ^

Expectation

As the code below compiles successfully

import annotation.experimental

object Main:
  @experimental
  def main(args: Array[String]): Unit = {}

I would expect the variant with @main @experimental to work as well unless for some reason we decide it would be better not to have experimental main methods at all, in which case we should disallow marking main methods in objects as @experimental.

@odersky @smarter what do you think?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions