Skip to content

compileTimeOnly results in error message for overridden method with abstract return type #20446

Open
@pweisenburger

Description

@pweisenburger

Compiler version

3.3.3, 3.4.1

Minimized code

import scala.annotation.compileTimeOnly

trait A[T]:
  @compileTimeOnly("error") def x: T

object B extends A[Int]:
  @compileTimeOnly("error") def x = 1

or similar:

import scala.annotation.compileTimeOnly

trait A:
  type T
  @compileTimeOnly("error") def x: T

object B extends A:
  type T = Int
  @compileTimeOnly("error") def x = 1

Output

Prints the specified compile-time error message error.

Expectation

Should compile without errors as x is never used.
Also compiles in Scala 2.
The issue could have something to do with forwarders/bridges generated for the abstract type T of A.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions