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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions compiler/src/dotty/tools/dotc/reporting/messages.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1510,13 +1510,6 @@ import transform.SymUtils._
def explain = ""
}

class TopLevelCantBeImplicit(sym: Symbol)(
implicit ctx: Context)
extends SyntaxMsg(TopLevelCantBeImplicitID) {
def msg = em"""${hl("implicit")} modifier cannot be used for top-level definitions"""
def explain = ""
}

class TypesAndTraitsCantBeImplicit()(using Context)
extends SyntaxMsg(TypesAndTraitsCantBeImplicitID) {
def msg = em"""${hl("implicit")} modifier cannot be used for types or traits"""
Expand Down
3 changes: 1 addition & 2 deletions compiler/src/dotty/tools/dotc/typer/Checking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,7 @@ object Checking {
if sym.isInlineMethod && !sym.is(Deferred) && sym.allOverriddenSymbols.nonEmpty then
checkInlineOverrideParameters(sym)
if (sym.is(Implicit)) {
if (sym.owner.is(Package))
fail(TopLevelCantBeImplicit(sym))
assert(!sym.owner.is(Package), s"top-level implicit $sym should be wrapped by a package after typer")
if sym.isType && (!sym.isClass || sym.is(Trait)) then
fail(TypesAndTraitsCantBeImplicit())
}
Expand Down