File tree 2 files changed +3
-12
lines changed
compiler/src/dotty/tools/dotc
2 files changed +3
-12
lines changed Original file line number Diff line number Diff line change @@ -1071,10 +1071,6 @@ object Parsers {
1071
1071
nme.ERROR
1072
1072
}
1073
1073
1074
- def checkNotRoot (name : Name ): name.type =
1075
- if name == nme.ROOTPKG then syntaxError(em " Illegal use of root package name. " )
1076
- name
1077
-
1078
1074
/** Accept identifier and return Ident with its name as a term name. */
1079
1075
def termIdent (): Ident =
1080
1076
makeIdent(in.token, in.offset, ident())
@@ -3602,13 +3598,6 @@ object Parsers {
3602
3598
case _ =>
3603
3599
first :: Nil
3604
3600
}
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
-
3612
3601
val tpt = typedOpt()
3613
3602
val rhs =
3614
3603
if tpt.isEmpty || in.token == EQUALS then
@@ -3689,7 +3678,7 @@ object Parsers {
3689
3678
else {
3690
3679
val mods1 = addFlag(mods, Method )
3691
3680
val ident = termIdent()
3692
- var name = checkNotRoot( ident.name) .asTermName
3681
+ var name = ident.name.asTermName
3693
3682
val paramss =
3694
3683
if in.featureEnabled(Feature .clauseInterleaving) then
3695
3684
// 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
2472
2472
2473
2473
def typedValDef (vdef : untpd.ValDef , sym : Symbol )(using Context ): Tree = {
2474
2474
val ValDef (name, tpt, _) = vdef
2475
+ if name == nme.ROOTPKG then report.error(em " Illegal use of root package name. " , vdef)
2475
2476
completeAnnotations(vdef, sym)
2476
2477
if (sym.isOneOf(GivenOrImplicit )) checkImplicitConversionDefOK(sym)
2477
2478
if sym.is(Module ) then checkNoModuleClash(sym)
@@ -2505,6 +2506,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
2505
2506
// hence we special case it until `erased` is no longer experimental.
2506
2507
sym.setFlag(Erased )
2507
2508
val DefDef (name, paramss, tpt, _) = ddef
2509
+ if name == nme.ROOTPKG then report.error(em " Illegal use of root package name. " , ddef)
2508
2510
completeAnnotations(ddef, sym)
2509
2511
val paramss1 = paramss.nestedMapConserve(typed(_)).asInstanceOf [List [ParamClause ]]
2510
2512
for case ValDefs (vparams) <- paramss1 do
You can’t perform that action at this time.
0 commit comments