File tree Expand file tree Collapse file tree 2 files changed +19
-5
lines changed
compiler/src/dotty/tools/dotc/parsing Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -1071,12 +1071,18 @@ object Parsers {
10711071 nme.ERROR
10721072 }
10731073
1074+ def checkNotRoot (tree : Tree ): tree.type =
1075+ tree match
1076+ case Ident (nme.ROOTPKG ) => syntaxError(em " Illegal use of root package name. " )
1077+ case _ =>
1078+ tree
1079+
1080+ def rootOrTermIdent (): Ident =
1081+ makeIdent(in.token, in.offset, ident())
1082+
10741083 /** Accept identifier and return Ident with its name as a term name. */
10751084 def termIdent (): Ident =
1076- val t = makeIdent(in.token, in.offset, ident())
1077- if t.name == nme.ROOTPKG then
1078- syntaxError(em " Illegal use of root package name. " )
1079- t
1085+ checkNotRoot(rootOrTermIdent())
10801086
10811087 /** Accept identifier and return Ident with its name as a type name. */
10821088 def typeIdent (): Ident =
@@ -4091,7 +4097,7 @@ object Parsers {
40914097 val derived =
40924098 if (isIdent(nme.derives )) {
40934099 in.nextToken()
4094- commaSeparated(() => convertToTypeId(qualId( )))
4100+ commaSeparated(() => convertToTypeId(dotSelectors(rootOrTermIdent() )))
40954101 }
40964102 else Nil
40974103 possibleTemplateStart()
Original file line number Diff line number Diff line change 1+ package foo
2+
3+ enum MyEnum derives _root_.foo.Eq :
4+ case One
5+
6+ trait Eq [T ]
7+ object Eq :
8+ inline def derived [T ](using m : scala.deriving.Mirror .Of [T ]): Eq [T ] = ???
You can’t perform that action at this time.
0 commit comments