Skip to content
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

refactor: TopLevel implicit is now allowed, remove unnecessary checking for toplevel implicits #14935

Merged
merged 1 commit into from
Apr 22, 2022

Conversation

tanishiking
Copy link
Member

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 ErrorMessage definition for TopLevelCantBeImplicit.

Or should we leave the check just in case the compiler got a bug for some reason and we encounter the case?

@bishabosha
Copy link
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.

@tanishiking
Copy link
Member Author

Thank you for the input! Yeah, I think that's why there shouldn't be a case where reach the path.

I think this is useful as a regression test still.

For regression test purpose, can we make it assertion instead of emitting compile error?

@bishabosha
Copy link
Member

For regression test purpose, can we make it assertion instead of emitting compile error?

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.
@tanishiking
Copy link
Member Author

rebased and replace it with assert :)

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.

2 participants