Skip to content

Bridge method clash with value class #8001

Closed
@travisbrown

Description

@travisbrown

minimized code

trait TC[A] {
  def apply(a: A): Unit
}

class Foo[A](val value: A) extends AnyVal
object Foo {
  val tc = new TC[Foo[String]] {
    def apply(a: Foo[String]): Unit = ()
  }
}
Compilation output
-- Error: TC.scala:8:8 ---------------------------------------------------------
8 |    def apply(a: Foo[String]): Unit = ()
  |        ^
  |bridge generated for member method apply(a: Foo[String]): Unit in anonymous class Object with TC {...}
  |which overrides method apply(a: A): Unit in trait TC
  |clashes with definition of the member itself; both have erased type (a: Object): Unit."
1 error found

expectation

Another minimization from the Cats tests. Scala 2 is fine with this.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions