Closed
Description
Compiler version
3.3.1-RC1-bin-20230313-f28d708-NIGHTLY and before
Minimized code
trait Sel extends Selectable
extension (s: Sel)
def selectDynamic(name: String) = ???
val sel = (new Sel {}).asInstanceOf[Sel{ def foo: String }]
val foo = sel.foo
Output
[error] ./Selectable.scala:7:11
[error] value selectDynamic is not a member of Sel{def foo: String}, but could be made available as an extension method.
[error]
[error] The following import might fix the problem:
[error]
[error] import reflect.Selectable.reflectiveSelectable
[error]
[error] val foo = sel.foo
[error] ^^^
Expectation
According to our reference documentation:
Implementations of Selectable have to make available one or both of the methods selectDynamic and applyDynamic. The methods could be members of the Selectable implementation or they could be extension methods.
To my understanding this means that the code snippet should compile successfully, by applying the syntax desugarings:
sel.foo
sel.selectDynamic("foo").asInstanceOf[String]
selectDynamic(sel)("foo").asInstanceOf[String]
Similarly it should be possible to provide the implementation of applyDynamic
as an extension method.