Skip to content

Cannot use experimental language features in @experimental code #13392

Closed
@odersky

Description

@odersky

Compiler version

3.1.0

Minimized example

import language.experimental.erasedDefinitions
import annotation.experimental

@experimental
erased class CanThrow[-E <: Exception]

Output

Error:  2 |import language.experimental.erasedDefinitions
Error:    |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error:    |Experimental features may only be used with a nightly or snapshot version of the compiler

Expectation

Should compile.

Otherwise, we cannot use experimental language features in @experimental code.

I think what happens is that we check the compiler version when we analyze the import statement. We should wait with it until we need to check whether the language import is enabled. If all these tests are from experimental scopes, this should be permitted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions