Skip to content

TASTy should list the types of template parents #8028

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

Open
bishabosha opened this issue Jan 17, 2020 · 4 comments
Open

TASTy should list the types of template parents #8028

bishabosha opened this issue Jan 17, 2020 · 4 comments
Labels
area:pickling area:tasty-format issues relating to TASTy as a portable standard

Comments

@bishabosha
Copy link
Member

Currently in order to unpickle the parents of a template in TASTy, you must parse many arbitrary trees including selecting the correct overloaded constructor, and performing unification of type variables on the return type of that constructor.

In Scala 2 all that is required is the types of the parents; it is inefficient to traverse expressions to calculate and propagate a type.

there should be a simple list of types enumerating the parents, that can be referenced to from the actual trees that make up the extends clauses.

@bishabosha bishabosha added area:tasty-format issues relating to TASTy as a portable standard area:pickling labels Jan 17, 2020
@LPTK
Copy link
Contributor

LPTK commented Jan 21, 2020

As far as I know, one way of doing it in Scala 2 is through symbols. One can call baseClasses on the child ClassSymbol, and then call child.selfType.baseType(theParentSymbol) to get the type of the parent from the POV of the child.

This does not seem possible with the current API, but it would be very useful.

Also, is there a reason why we cannot list the members of a Type anymore?

@bishabosha
Copy link
Member Author

I has been possible to optimise reading the parents by shortcutting traversals to only go as far as identifying the prefix of a parent constructor. Which may be cached in a simple tree if seen before within the same tasty file

@sjrd
Copy link
Member

sjrd commented Apr 6, 2020

Even if you found a more efficient workaround, I still believe that this information not being available at our fingers is an issue, that needs fixing.

I'll reopen so that this doesn't get lost.

@sjrd sjrd reopened this Apr 6, 2020
@bishabosha
Copy link
Member Author

bishabosha commented Apr 6, 2020

for the definition

class Lexeme private (private val str: String) extends AnyVal with Ordered[Lexeme] {
  def compare(that: Lexeme) = str.compareTo(that.str)
}

the tasty we care about looks like

     5:   TYPEDEF(183) 2 [Lexeme]
     9:     TEMPLATE(162)
...
    22:       APPLY(9)
    24:         SELECT 13 [<init>[Signed Signature(List(),java.lang.Object)]]
    26:           NEW
    27:             IDENTtpt 14 [AnyVal]
    29:               TYPEREF 14 [AnyVal]
    31:                 TERMREFpkg 6 [scala]
    33:       APPLIEDtpt(14)
    35:         IDENTtpt 15 [Ordered]
    37:           TYPEREF 15 [Ordered]
    39:             TERMREF 16 [package]
    41:               SHAREDtype 19
    43:         IDENTtpt 2 [Lexeme]
    45:           TYPEREFsymbol 5
    47:             TERMREFpkg 1 [tastytest]

and we can basically skip Address 22 as there is no need to resolve the constructor and complex trees can be avoided for IDENTtpt and APPLIEDtpt, just use the simple TypeTree wrapper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:pickling area:tasty-format issues relating to TASTy as a portable standard
Projects
None yet
Development

No branches or pull requests

3 participants