Skip to content

Eq should extend AnyVal until Phantom types (now Erased terms) are ready #2717

@Blaisorblade

Description

@Blaisorblade

That way, at least you can't pass null as an instance. The suggestion is not mine, it comes from https://www.reddit.com/r/programming/comments/6elim6/announcing_dotty_012rc1_a_major_step_towards/dimg0nz/.

import dotty.DottyPredef.{eqAny => _, _}
class Foo
object Main {
  def bar[T](value: T)(implicit teq: Eq[T,T]) = value == value
  def main(args: Array[String]): Unit = bar(new Foo)(null) //<--
}

@nicolasstucki , can Eq be made a phantom type, now or later? I'm asking this at the design level for now.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions