Skip to content

Strangely omitted compileTimeOnly message for Unit companion #17515

@som-snytt

Description

@som-snytt

Compiler version

3.2.2

Minimized code

scala> class C { @annotation.compileTimeOnly("non-clonal") override def clone() = null } // defined class C scala> C().clone() -- Error: -------------------------------------------------------------------------------------------------------------- 1 |C().clone() |^^^^^^^^^ |non-clonal 1 error found scala> val u = Unit -- Error: -------------------------------------------------------------------------------------------------------------- 1 |val u = Unit | ^^^^ | Reference to object Unit in package scala should not have survived, | it should have been processed and eliminated during expansion of an enclosing macro or term erasure. 1 error found scala>  ~ scala Welcome to Scala 2.13.10 (OpenJDK 64-Bit Server VM, Java 20.0.1). Type in expressions for evaluation. Or try :help. scala> val u = Unit ^ error: `Unit` companion object is not allowed in source; instead, use `()` for the unit value scala>

Expectation

Lowered.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions