-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Scaladoc: new heuristic for extension method parameter extraction #14810
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
Scaladoc: new heuristic for extension method parameter extraction #14810
Conversation
val method = sym.tree.asInstanceOf[DefDef] | ||
(for { | ||
defPosition <- method.symbol.pos | ||
defStart <- scala.util.Try(defPosition.start).toOption |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does start
here throw exceptions?
If so, I'm not sure if it's not a bug
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it does. It fails assertions for some methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nicolasstucki is this intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the exception?
Does the position exist? If not, calling start should fail an assertion. It would be unexpected for the position to not
exist and I would say that is a bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the assertion failure just as you said.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assertion fails for methods, which have position of type NoSourcePosition
. These are mostly methods from inheritance such as productElementNames from Product
trait. Is this a bug, as symbol.pos
returns Option
and logically it should return None
for NoSourcePosition
?
val method = sym.tree.asInstanceOf[DefDef] | ||
(for { | ||
defPosition <- method.symbol.pos | ||
defStart <- scala.util.Try(defPosition.start).toOption |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the exception?
Does the position exist? If not, calling start should fail an assertion. It would be unexpected for the position to not
exist and I would say that is a bug.
5d5f5d4
to
dbf84f5
Compare
@nicolasstucki Could you take a look at the last commit? |
Now that we know that that Scala 2 symbol did not have a position we should check why that was the case. Maybe there is a bug somewhere else and this is only hiding it. |
Co-authored-by: Nicolas Stucki <[email protected]>
87eea93
to
6cdc381
Compare
def ffffff[B](b: B): (A, B) = ??? | ||
extension (using String)(using Unit)(a: Animal)(using Int)(using Number) | ||
def f11(b: Any)(c: Any): Any | ||
= ??? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do these tests work? I see test “fixtures” but no test specification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had answered in person, but I'll put it here for posterity:
This works by comparing the text of the file with the output of scala-meta, similarly to what is done in the compiler with the tests/pos
, tests/neg
folders.
This is therefore both the declaration and the specification for the tests !
@pikinier20, I’ve re-requested a review from you because the content of the PR changed since your previous review. |
Duplicate of scala#14810, once merged, frop this
Hello, |
Duplicate of scala#14810, once merged, frop this
Hello, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me, but @Florian3k has the most expertise there right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. (But please note that I'm in no way expert on this part of codebase)
P.S. Sorry for the delay, something was wrong with my github notifications. Should be working fine now.
Before this changes, it wouldn't generate due to incorrect extension parameters extractor functions.
It also implements new heuristic to distinct extensions and method parameters based on definition position.
Also fixed type parameter coloring by adding new css rule, to match doc style.
Based on #14321 , it should be closed after this PR is merged.
Documentation for test

tests.extensionParams