Closed
Description
Compiler version
3.2.0
Minimized code
I'm not sure if this is a bug, a feature, or something else but it is impossible to export methods from a generic type. The important of this kind of feature is that if it existed, it would be (probably) be possible to replace Quill's implicit conversion Quoted[T] => T
with implicit exports (so long as the exported method themselves are inline).
class Wrapped[T](t: T) {
def unwrap:T = ???
}
extension [T](t: Wrapped[T])
def unwrapped: T = t.unwrap
export unwrapped.*
Wrapped("blah").toUpperCase()
Output
[error] 27 | PrintMac(Wrapped("blah").toUpperCase())
[error] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error] |value toUpperCase is not a member of org.deusaquilus.ImplicitConf.Wrapped[String], but could be made available as an extension method.
Expectation
It should recognize that .toUpperCase()
exists on Wrapped[String]
because it exists on String
.
The functionality should be equivalent to this (which works):
extension (t: Wrapped[String])
def unwrapped: String = t.unwrap
export unwrapped.*
Wrapped("blah").toUpperCase()
Of if inline
is used,
extension (inline t: Wrapped[String])
inline def unwrapped: String = t.unwrap
export unwrapped.*
Wrapped("blah").toUpperCase()
// Which in the AST should be encoded as:
Wrapped("blah").unwrap.toUpperCase()
it should be equivalent to this:
extension (inline t: Wrapped[String])
inline def unwrapped: String = t.unwrap
inline def toUpperCase(): String = unwrapped.toUpperCase()
Wrapped("blah").toUpperCase()
Quill's unquotation Quoted[T] => T
function specifically relies on this kind of pattern (i.e. the input t
has to be directly spliced).