Open
Description
Compiler version
3.3.4, 3.7.0-RC1-bin-20250116-0f9e502-NIGHTLY
Minimized code
class Foo():
def x1: Int = 123
object Foo:
extension (foo: Foo)
def x2: Int = 123
implicit class FooOps(foo: Foo):
def x3: Int = 123
class Bar():
val foo = Foo()
export foo.x1
export foo.x2
object Bar:
extension (bar: Bar)
private def fooOps = Foo.FooOps(Foo())
export fooOps.x3
val xs = Seq(
Foo().x1,
Foo().x2,
Foo().x3,
Bar().x1,
Bar().x2,
Bar().x3
)
Output
[error] /tmp/ExportExtension.scala:14:14
[error] no eligible member x2 at this.foo
[error] export foo.x2
[error] ^^
[error] /tmp/ExportExtension.scala:27:3
[error] value x2 is not a member of Bar - did you mean Bar.x1?
[error] Bar().x2,
[error] ^^^^^^^^
Expectation
It should be possible to export an extension method applied on a specific receiver.
Though technically this might be considered a lack of a feature rather than a bug, this is a point were extension methods are less useful than implicit classes.
Considerations
Could this work with export foo.*
or would extension exports be restricted to explicitly named methods?