Skip to content

fix #9324: forbid no-arg java.lang.Enum ctor #10027

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

Merged
merged 2 commits into from
Oct 19, 2020

Conversation

bishabosha
Copy link
Member

@bishabosha bishabosha commented Oct 16, 2020

pretend the no-arg constructor does not exist unless called from an enum parent

@smarter
Copy link
Member

smarter commented Oct 16, 2020

Why is this not forbidden by default?

@bishabosha bishabosha force-pushed the fix-9324 branch 2 times, most recently from 44d022c to 04da9e2 Compare October 16, 2020 16:35
@bishabosha
Copy link
Member Author

Why is this not forbidden by default?

good point- will adjust

@bishabosha
Copy link
Member Author

so now there is just an extra error in the case where it was possible to call the no arg ctor, which basically only ever could happen in migration mode

@bishabosha
Copy link
Member Author

bishabosha commented Oct 16, 2020

this still doesn't deal with this:

// running repl with -source:3.0-migration
scala> final class C extends jl.Enum[C]("N")                                                                         
1 |final class C extends jl.Enum[C]("N")
  |                      ^^^^^^^^^^
  |None of the overloaded alternatives of constructor Enum in class Enum with types
  | [E <: Enum[LazyRef(E)]](x$0: String, x$1: Int): Enum[E]
  | [E <: Enum[LazyRef(E)]](): Enum[E]
  |match arguments (("N" : String))

do we want the other thing to never exist in overload errors?, and files can locally import a language mode for source so we can't patch it in Definitions

@smarter
Copy link
Member

smarter commented Oct 16, 2020

If it's only temporary for migration the overload error message is fine

@smarter smarter assigned bishabosha and unassigned smarter Oct 16, 2020
@bishabosha bishabosha changed the title fix #9324: forbid no-arg java.lang.Enum ctor for migration mode fix #9324: forbid no-arg java.lang.Enum ctor Oct 17, 2020
@bishabosha bishabosha assigned smarter and unassigned bishabosha Oct 19, 2020
@bishabosha bishabosha requested a review from smarter October 19, 2020 10:32
@bishabosha bishabosha merged commit bd64de7 into scala:master Oct 19, 2020
@bishabosha bishabosha deleted the fix-9324 branch October 19, 2020 13:15
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants