Skip to content

Commit 359b80f

Browse files
committed
Make toplevel wrappers unexpressible as normal objects
1 parent 61564ba commit 359b80f

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ object desugar {
10231023
}
10241024

10251025
/** Group all patterm, value and method definitions and all non-class type definitions
1026-
* in an object named `<source>$object` where `<source>` is the name of the source file.
1026+
* in an object named `<source>#object` where `<source>` is the name of the source file.
10271027
*/
10281028
def packageDef(pdef: PackageDef)(implicit ctx: Context): PackageDef = {
10291029
def needsObject(stat: Tree) = stat match {
@@ -1036,8 +1036,7 @@ object desugar {
10361036
else {
10371037
val sourceName = ctx.source.file.name.takeWhile(_ != '.')
10381038
val groupName = (sourceName ++ str.TOPLEVEL_SUFFIX).toTermName
1039-
val templ = Template(emptyConstructor, Nil, Nil, EmptyValDef, nestedStats)
1040-
val grouped = ModuleDef(groupName, templ)
1039+
val grouped = ModuleDef(groupName, Template(emptyConstructor, Nil, Nil, EmptyValDef, nestedStats))
10411040
cpy.PackageDef(pdef)(pdef.pid, grouped :: topStats)
10421041
}
10431042
}

compiler/src/dotty/tools/dotc/core/NameOps.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ object NameOps {
8787
false
8888
}
8989

90+
/** is this the name of an object enclosing packagel-level definitions? */
9091
def isPackageObjectName: Boolean = name match {
9192
case name: TermName => name == nme.PACKAGE || name.endsWith(str.TOPLEVEL_SUFFIX)
9293
case name: TypeName =>

compiler/src/dotty/tools/dotc/core/StdNames.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ object StdNames {
2020
final val INITIALIZER_PREFIX = "initial$"
2121
final val AVOID_CLASH_SUFFIX = "$_avoid_name_clash_$"
2222
final val MODULE_SUFFIX = "$"
23-
final val TOPLEVEL_SUFFIX = "__object"
23+
final val TOPLEVEL_SUFFIX = "#object"
2424
final val NAME_JOIN = "$"
2525
final val DEFAULT_GETTER = "$default$"
2626
final val LOCALDUMMY_PREFIX = "<local " // owner of local blocks

0 commit comments

Comments
 (0)