Skip to content

Scala docs on extension methods #9339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nicolasstucki opened this issue Jul 10, 2020 · 2 comments · Fixed by #9375
Closed

Scala docs on extension methods #9339

nicolasstucki opened this issue Jul 10, 2020 · 2 comments · Fixed by #9375

Comments

@nicolasstucki
Copy link
Contributor

Where can we add the documentation of an extension method?

// This should work
/** Doc of `foo` */
extension (x: T) def foo(): U = ...

// Should this work? Should it warn?
/** Doc of `foo` */
extension (x: T) 
  def foo(): U = ...

extension (x: T) 
  // This should work
  /** Doc of `foo` */
  def foo(): U = ...

// Should this work? It is fragile if another method is added. Should it warn?
/** Doc of `foo` */
extension (x: T):
  def foo(): U = ...

extension (x: T):
  //  This should work
  /** Doc of `foo` */
  def foo(): U = ...
@nicolasstucki
Copy link
Contributor Author

nicolasstucki commented Jul 10, 2020

Currently the following does not get any documentation generated

    /** Members of Tree */
    extension (tree: Tree):
      /** Position in the source code */
      def pos(using ctx: Context): Position = internal.Tree_pos(tree)
      ...

https://github.com/lampepfl/dotty/blob/master/library/src/scala/tasty/Reflection.scala#L475
http://dotty.epfl.ch/api/scala/tasty/Reflection/Tree$.html

@nicolasstucki
Copy link
Contributor Author

The documentation for extensions is not in the TASTy file

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 16, 2020
@nicolasstucki nicolasstucki linked a pull request Jul 16, 2020 that will close this issue
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 16, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 16, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 17, 2020
nicolasstucki added a commit that referenced this issue Jul 18, 2020
Fix #9339: Register doc of extension methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
@nicolasstucki and others