Skip to content

Commit 7ee8986

Browse files
authored
Merge pull request #14935 from tanishiking/toplevel-can-be-implicit
refactor: TopLevel implicit is now allowed, remove unnecessary checking for toplevel implicits
2 parents b636633 + 6442498 commit 7ee8986

File tree

2 files changed

+1
-9
lines changed

2 files changed

+1
-9
lines changed

compiler/src/dotty/tools/dotc/reporting/messages.scala

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,13 +1510,6 @@ import transform.SymUtils._
15101510
def explain = ""
15111511
}
15121512

1513-
class TopLevelCantBeImplicit(sym: Symbol)(
1514-
implicit ctx: Context)
1515-
extends SyntaxMsg(TopLevelCantBeImplicitID) {
1516-
def msg = em"""${hl("implicit")} modifier cannot be used for top-level definitions"""
1517-
def explain = ""
1518-
}
1519-
15201513
class TypesAndTraitsCantBeImplicit()(using Context)
15211514
extends SyntaxMsg(TypesAndTraitsCantBeImplicitID) {
15221515
def msg = em"""${hl("implicit")} modifier cannot be used for types or traits"""

compiler/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,7 @@ object Checking {
473473
if sym.isInlineMethod && !sym.is(Deferred) && sym.allOverriddenSymbols.nonEmpty then
474474
checkInlineOverrideParameters(sym)
475475
if (sym.is(Implicit)) {
476-
if (sym.owner.is(Package))
477-
fail(TopLevelCantBeImplicit(sym))
476+
assert(!sym.owner.is(Package), s"top-level implicit $sym should be wrapped by a package after typer")
478477
if sym.isType && (!sym.isClass || sym.is(Trait)) then
479478
fail(TypesAndTraitsCantBeImplicit())
480479
}

0 commit comments

Comments
 (0)