Skip to content
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

Semi-Fix scaladoc of extensions methods #14321

Closed
wants to merge 8 commits into from

Conversation

Sporarum
Copy link
Contributor

@Sporarum Sporarum commented Jan 21, 2022

This changes the heuristic used by scaladoc to one I was not able to fault (smarter people might)
(à propos, the main idea behind the heuristic was @smarter's)

Note that it is not enough for tests to pass, as unwrapMemberInfo is also incorrect, but I do not have the time to fix it

The commits are neatly split and annotated, so it should be relatively easy to understand what I did

I left some commented printlns, they highlight that the new heuristic works correctly, and how unwrapMemberInfo is incorrect, for example with f1 from the rehabilitated test extensionParams:
file:

extension [A](a: A)(using Int)
  def f1[B](b: B): (A, B) 

cleaned up output:

f1
ExtensionPart:
List(type A)
List(val a: A)
List(val x$2: scala.Int)
NonExtensionPart:
List(type B)
List(val b: B)

f1
MemberInfo:
List(Map(b -> TypeParamRef(B)))
extended...:
List(List(ValDef(a,Ident(A),EmptyTree)), List(ValDef(x$2,Ident(Int),EmptyTree)))

Uses the assumption that there is the
following "pos hierachy":
extension paramss < DefDef < extMethod paramss
def nonUsingClauses(clauses: List[reflect.ParamClause]) = clauses.zipWithIndex.collect{case (terms: reflect.TermParamClause, i) if !terms.isGiven => (terms, i)}
val extNonUsingClause = nonUsingClauses(extPart)
val defNonUsingClauses = nonUsingClauses(defPart)
assert(extNonUsingClause.size == 1)
Copy link
Contributor Author

@Sporarum Sporarum Jan 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assert seems to be causing some of the tests to fail, but I don't understand why

@@ -152,52 +160,68 @@ object SymOps:
else termParamss(1).params(0)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extendedSymbol should probably also be updated, as it implicitly uses the old heuristic

@Sporarum
Copy link
Contributor Author

Sporarum commented Apr 7, 2022

(actually no, it doesn't ...)
I noticed @rochala's work only after sadly, I'll leave those commits here for now, as those changes might still be useful to scaladoc methods with multiple type param clauses (see: #14019)

@Sporarum Sporarum closed this Aug 24, 2022
@Sporarum Sporarum deleted the fix-scaladoc-extensions branch August 24, 2022 07:29
Sporarum pushed a commit that referenced this pull request Jan 5, 2023
…4810)

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`

![image](https://user-images.githubusercontent.com/48657087/160649612-ac5b1883-0e28-4acb-9886-c9108b376665.png)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants