File tree Expand file tree Collapse file tree 2 files changed +3
-12
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 2 files changed +3
-12
lines changed Original file line number Diff line number Diff line change @@ -1071,10 +1071,6 @@ object Parsers {
10711071 nme.ERROR
10721072 }
10731073
1074- def checkNotRoot (name : Name ): name.type =
1075- if name == nme.ROOTPKG then syntaxError(em " Illegal use of root package name. " )
1076- name
1077-
10781074 /** Accept identifier and return Ident with its name as a term name. */
10791075 def termIdent (): Ident =
10801076 makeIdent(in.token, in.offset, ident())
@@ -3602,13 +3598,6 @@ object Parsers {
36023598 case _ =>
36033599 first :: Nil
36043600 }
3605-
3606- def checkForRoot (trees : List [Tree ]): Unit = for tree <- trees do tree match
3607- case IdPattern (id, _) => checkNotRoot(id.name)
3608- case Tuple (trees) => checkForRoot(trees)
3609- case _ =>
3610- checkForRoot(lhs)
3611-
36123601 val tpt = typedOpt()
36133602 val rhs =
36143603 if tpt.isEmpty || in.token == EQUALS then
@@ -3689,7 +3678,7 @@ object Parsers {
36893678 else {
36903679 val mods1 = addFlag(mods, Method )
36913680 val ident = termIdent()
3692- var name = checkNotRoot( ident.name) .asTermName
3681+ var name = ident.name.asTermName
36933682 val paramss =
36943683 if in.featureEnabled(Feature .clauseInterleaving) then
36953684 // If you are making interleaving stable manually, please refer to the PR introducing it instead, section "How to make non-experimental"
Original file line number Diff line number Diff line change @@ -2472,6 +2472,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
24722472
24732473 def typedValDef (vdef : untpd.ValDef , sym : Symbol )(using Context ): Tree = {
24742474 val ValDef (name, tpt, _) = vdef
2475+ if name == nme.ROOTPKG then report.error(em " Illegal use of root package name. " , vdef)
24752476 completeAnnotations(vdef, sym)
24762477 if (sym.isOneOf(GivenOrImplicit )) checkImplicitConversionDefOK(sym)
24772478 if sym.is(Module ) then checkNoModuleClash(sym)
@@ -2505,6 +2506,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
25052506 // hence we special case it until `erased` is no longer experimental.
25062507 sym.setFlag(Erased )
25072508 val DefDef (name, paramss, tpt, _) = ddef
2509+ if name == nme.ROOTPKG then report.error(em " Illegal use of root package name. " , ddef)
25082510 completeAnnotations(ddef, sym)
25092511 val paramss1 = paramss.nestedMapConserve(typed(_)).asInstanceOf [List [ParamClause ]]
25102512 for case ValDefs (vparams) <- paramss1 do
You can’t perform that action at this time.
0 commit comments