scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.87k stars 1.06k forks source link

Export foo.given ignores implicit members #18605

Open bishabosha opened 1 year ago

bishabosha commented 1 year ago

Compiler version

3.3.0

Minimized code

//> using option -Xprint:typer

import java.time.LocalDate
import mymath.given

object mymath:
  export math.Ordered.given

def before(d1: LocalDate, d2: LocalDate): Boolean = d1 < d2 // error

Output

-- [E008] Not Found Error: -----------------------------------------------------
6 |def before(d1: LocalDate, d2: LocalDate): Boolean = d1 < d2 // error
  |                                                    ^^^^
  |value < is not a member of java.time.LocalDate, but could be made available as an extension method.
  |
  |One of the following imports might fix the problem:
  |
  |  import math.Ordered.orderingToOrdered
  |  import math.Ordering.Implicits.infixOrderingOps
  |
1 error found

Expectation

I would expect that at least orderingToOrdered would be exported, e.g.

final lazy module val mymath: mymath = new mymath()
final module class mymath() extends Object() { this: mymath.type =>
  export math.Ordered.given
  ...
  final implicit def orderingToOrdered[T](x: T)(implicit ord: Ordering[T]):
    Ordered[T] = math.Ordered.orderingToOrdered[T](x)(ord)
}
bishabosha commented 1 year ago

@odersky given that import foo.given also imports implicit members it seems strange that export only sees given