File tree 2 files changed +19
-5
lines changed
compiler/src/dotty/tools/dotc/parsing 2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -1071,12 +1071,18 @@ object Parsers {
1071
1071
nme.ERROR
1072
1072
}
1073
1073
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
+
1074
1083
/** Accept identifier and return Ident with its name as a term name. */
1075
1084
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())
1080
1086
1081
1087
/** Accept identifier and return Ident with its name as a type name. */
1082
1088
def typeIdent (): Ident =
@@ -4091,7 +4097,7 @@ object Parsers {
4091
4097
val derived =
4092
4098
if (isIdent(nme.derives )) {
4093
4099
in.nextToken()
4094
- commaSeparated(() => convertToTypeId(qualId( )))
4100
+ commaSeparated(() => convertToTypeId(dotSelectors(rootOrTermIdent() )))
4095
4101
}
4096
4102
else Nil
4097
4103
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