Skip to content

extending java.lang.Enum should be desugared before TASTy #7478

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 Oct 31, 2019 · 6 comments
Open

extending java.lang.Enum should be desugared before TASTy #7478

bishabosha opened this issue Oct 31, 2019 · 6 comments
Labels
area:enums area:tasty-format issues relating to TASTy as a portable standard backlog No work planned on this by the core team for the time being. itype:bug

Comments

@bishabosha
Copy link
Member

bishabosha commented Oct 31, 2019

minimized code

Compile with 0.27.0-RC1

enum A extends java.lang.Enum[A]
  case A1

In TASTy, the first parent of A is

TypeApply(Select(New(java.lang.Enum[A]),<init>[Signed (1)java.lang.Enum]), List(A))

with no value arguments passed.

expectation

The parent in TASTy should be

Apply(TypeApply(Select(New(java.lang.Enum[A]),<init>[Signed (1,java.lang.String,scala.Int)java.lang.Enum]), List(A)), List($name, _$ordinal))

with any other relevant desugarings applied, such as adding $name and _$ordinal to the constructor of A

Alternative

special-casing the synthetic no-arg java.lang.Enum constructor becomes part of the specification for TASTy

@bishabosha
Copy link
Member Author

bishabosha commented Sep 23, 2020

This one seems more tricky, if we move the phase CompleteJavaEnums before pickling, then the check fails for the @static annotated forwarders to enum values after moving them to the enum class, we can either keep the forwarder moving in a later phase, or special case the error for @static, or special case pickling for this signature, or do nothing.

@smarter @sjrd

@smarter
Copy link
Member

smarter commented Sep 23, 2020

if we move the phase CompleteJavaEnums before pickling

We can't have a phase that changes signature before pickling anyway: 1818b99

@bishabosha
Copy link
Member Author

bishabosha commented Sep 23, 2020

we could chalk it up to another special case primitive of scala implementations? ala Nothing, &, |, AnyKind etc,

@bishabosha
Copy link
Member Author

bishabosha commented Sep 23, 2020

I imagine this leaks into tasty reflect also so that could be a lot of special casing
Edit: seems reflection doesn't reify apply nodes for parents

@bishabosha
Copy link
Member Author

I am going to special case signatures in pickling and then benchmark it

@bishabosha
Copy link
Member Author

bishabosha commented Sep 23, 2020

On second thought, it just makes no sense to patch extends java.lang.Enum[MyEnum] with the correct signature without also expanding the tree to extends java.lang.Enum[MyEnum]($name, $ordinal), where $name and $ordinal do not exist yet. So again making this change seems pretty dubious without the complete desugaring of constructors appearing before tasty, which is more tricky because there is no precedent for patching a specific parent in desugaring

@bishabosha bishabosha changed the title TASTy should pickle parent java.lang.Enum.<init>(String,Int) extending java.lang.Enum should be desugared before TASTy Oct 16, 2020
@odersky odersky added the backlog No work planned on this by the core team for the time being. label Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:enums area:tasty-format issues relating to TASTy as a portable standard backlog No work planned on this by the core team for the time being. itype:bug
Projects
None yet
Development

No branches or pull requests

3 participants