scala3 icon indicating copy to clipboard operation
scala3 copied to clipboard

GADT contraint not considered for given/extension in implicit scope

Open eejbyfeldt opened this issue 1 week ago • 3 comments

Compiler version

3.7.4, 3.8.1-RC1-bin-20251203-b2850be-NIGHTL

Minimized code

$ cat gadt_contraint_implicit.scala
trait Expr[T]
object Expr {
  extension (lhs: Expr[Boolean])
    infix def ||(rhs: Expr[Boolean]): Expr[Boolean] = ???
}

object test {
  sealed trait A[T]
  object Or extends A[Boolean]

  def g[T](a: A[T], lhs: Expr[T]): Expr[T] = 
    a match {
    case Or => lhs || lhs
  }
}

Output

[error] ./gadt_contraint_implicit.scala:13:16
[error] value || is not a member of Expr[T]
[error] 
[error] where:    T is a type in method g which is an alias of Boolean
[error]     case Or => lhs || lhs
[error]   

Expectation

The code some compile.

eejbyfeldt avatar Dec 03 '25 08:12 eejbyfeldt