Skip to content

Commit

Permalink
Merge pull request #14935 from tanishiking/toplevel-can-be-implicit
Browse files Browse the repository at this point in the history
refactor: TopLevel implicit is now allowed, remove unnecessary checking for toplevel implicits
  • Loading branch information
bishabosha authored Apr 22, 2022
2 parents b636633 + 6442498 commit 7ee8986
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
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

0 comments on commit 7ee8986

Please sign in to comment.