scala.tools.nsc.transform.ExtensionMethods
We will need to clone the info of the original method (which obtains clones of the method type parameters), clone the type parameters of the value class, and create a new polymethod with the union of all those type parameters, with their infos adjusted to be consistent with their new home.
We will need to clone the info of the original method (which obtains clones of the method type parameters), clone the type parameters of the value class, and create a new polymethod with the union of all those type parameters, with their infos adjusted to be consistent with their new home. Example:
class Foo[+A <: AnyRef](val xs: List[A]) extends AnyVal { def baz[B >: A](x: B): List[B] = x :: xs // baz has to be transformed into this extension method, where // A is cloned from class Foo and B is cloned from method baz: // def extension$baz[B >: A <: Any, A >: Nothing <: AnyRef]($this: Foo[A])(x: B): List[B] }
TODO: factor out the logic for consolidating type parameters from a class and a method for re-use elsewhere, because nobody will get this right without some higher level facilities.
(extender: StringAdd).self
(extender: StringFormat).self
(extender: ArrowAssoc[Extender]).x
(Since version 2.10.0) Use leftOfArrow
instead
(extender: Ensuring[Extender]).x
(Since version 2.10.0) Use resultOfEnsuring
instead