Skip to content

strictEquality doesn't work with GADTs #24836

@japgolly

Description

@japgolly

Minimized code

//> using scala 3.7.4
//> using option -language:strictEquality

sealed trait Op derives CanEqual
case object OpA extends Op

object Test1:
  val op: Op => Int =
    case OpA => 42

sealed trait OpX[X] derives CanEqual
case object OpXA extends OpX[Int]

object Test2:
  def op[A]: OpX[A] => Int =
    case OpXA => 42 //

Output

[error] ./what.scala:16:10
[error] Values of types object OpXA and OpX[A] cannot be compared with == or !=.
[error] I found:
[error] 
[error]     OpX.derived$CanEqual[Int, A](/* missing */summon[CanEqual[Int, A]])
[error] 
[error] But no implicit values were found that match type CanEqual[Int, A]
[error] 
[error] where:    A is a type in method op which is an alias of Int
[error] .
[error]     case OpXA => 42 // ❌
[error]          ^^^^

Expectation

Successful compilation.

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