Skip to content

Documentation help needed: given [T]: CanEqual[T, T] resolves CanEquals of different types #18631

Open
@joan38

Description

@joan38

Compiler version: 3.3.1
Compiler option: -language:strictEquality

The following code compiles fine. But why? Where does it finds CanEqual[Test, Test2] of different types?

case class Test(i: Int)
case class Test2(i: Int)

object Eq:
  given [T]: CanEqual[T, T] = CanEqual.derived

  @main def run(): Unit =
    Test(1) == Test2(2)
    ()

https://scastie.scala-lang.org/X6boEpObQXee5uhESbviuQ

Thanks

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