refactor: TopLevel implicit is now allowed, remove unnecessary checking for toplevel implicits#14935
Merged
Merged
Conversation
Member
|
I believe that this check runs after desugaring + typing, by which point the "top-level" implicit definition is wrapped in an object, so then its owner would be the wrapper object, not a package. I think this is useful as a regression test still. |
Member
Author
|
Thank you for the input! Yeah, I think that's why there shouldn't be a case where reach the path.
For regression test purpose, can we make it assertion instead of emitting compile error? |
Member
I think that would be a good option, this PR needs rebasing anyway to try and fix the CI |
It seems like TopLevelCantBeImplicit is no longer the case as of scala#5754 And it is actually confirmed in https://github.com/lampepfl/dotty/blob/93fc41fcb624df73cc12d52b79d518a30a778a7c/tests/run/toplevel-implicits/a.b.scala#L19-L21 This commit replace the unnecessary check in from Checking.scala to assertion and deleted the `ErrorMessage` definition for `TopLevelCantBeImplicit`. I'm leaving the `TopLevelCantBeImplicitID` in `ErrorMessageID.scala` so we don't screw up the error number.
2042a08 to
6442498
Compare
Member
Author
|
rebased and replace it with |
bishabosha
approved these changes
Apr 22, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It seems like TopLevelCantBeImplicit is no longer the case as of #5754
And it is actually confirmed in https://github.com/lampepfl/dotty/blob/93fc41fcb624df73cc12d52b79d518a30a778a7c/tests/run/toplevel-implicits/a.b.scala#L19-L21
This commit removes the unnecessary check in from Checking.scala
and deleted the
ErrorMessagedefinition forTopLevelCantBeImplicit.Or should we leave the check just in case the compiler got a bug for some reason and we encounter the case?