Skip to content

Scaladoc: Minimize casting between public and compiler API #13371

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
1 of 9 tasks
pikinier20 opened this issue Aug 24, 2021 · 2 comments
Closed
1 of 9 tasks

Scaladoc: Minimize casting between public and compiler API #13371

pikinier20 opened this issue Aug 24, 2021 · 2 comments
Assignees
Labels
area:doctool area:metaprogramming:reflection Issues related to the quotes reflection API discussion
Milestone

Comments

@pikinier20
Copy link
Contributor

pikinier20 commented Aug 24, 2021

In some places of Scaladoc we need to cast members of public API into compiler API to get more information. We can try to expose necessary elements of compiler API in public API to minimize casting.

Things missing in public API:

  • TypeRepr.isTupleType (see Add TypeRepr.isTupleN to reflection API #13384)
  • Position.exists
  • TypeRepr.isCompiletimeAppliedType
  • TypeRepr.memberInfo(sym: Symbol) <- equivalent of Type.memberInfo(sym: Symbol)
  • Method which returns all supertypes of class
  • Method which returns all members of Symbol
  • Method which returns TypeRepr of ClassDef

There are also some fishy pieces of code that should probably be removed:

  • We need to filter out some methods by matching Strings: s.name.contains("$super$") , ".*\\$default\\$\\d+$".r.matches(s.name). There's no flags set to filter these methods, maybe we should add Synthetic flag or expose some API to be able to filter them out.
  • There's currently no way to disambiguate constructor with empty param list and constructor without param list: for DefDef.paramss both return List(List()). Currently we hack this check using positions.

It's probably a good time to do the changes now to add them to 3.1.0.

@smarter
@nicolasstucki
@romanowski

@nicolasstucki
Copy link
Contributor

We do not need to have them all by 3.1.0. Others can be added as experimental in 3.1.x and stabilized in 3.2.0.

@pikinier20
Copy link
Contributor Author

Basically, all methods that used internal API in Scaladoc are removed besides the method that gets all members from ClassDef. The reason of that is that methods from Quotes are calling lookupMember which also returns members from self-type which shouldn't be documented.

Besides that, there are two methods that check if a member is a super accessor or a default parameter forwarder which are implemented a bit hacky, basing on the member name. In the future we might want to replace them with some flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:doctool area:metaprogramming:reflection Issues related to the quotes reflection API discussion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants