Skip to content

Commit 16852fd

Browse files
committed
Make toplevel wrappers unexpressible as normal objects
1 parent e510418 commit 16852fd

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
@@ -955,7 +955,7 @@ object desugar {
955955
}
956956

957957
/** Group all patterm, value and method definitions and all non-class type definitions
958-
* in an object named `<source>$object` where `<source>` is the name of the source file.
958+
* in an object named `<source>#object` where `<source>` is the name of the source file.
959959
*/
960960
def packageDef(pdef: PackageDef)(implicit ctx: Context): PackageDef = {
961961
def needsObject(stat: Tree) = stat match {
@@ -968,8 +968,7 @@ object desugar {
968968
else {
969969
val sourceName = ctx.source.file.name.takeWhile(_ != '.')
970970
val groupName = (sourceName ++ str.TOPLEVEL_SUFFIX).toTermName
971-
val templ = Template(emptyConstructor, Nil, Nil, EmptyValDef, nestedStats)
972-
val grouped = ModuleDef(groupName, templ)
971+
val grouped = ModuleDef(groupName, Template(emptyConstructor, Nil, Nil, EmptyValDef, nestedStats))
973972
cpy.PackageDef(pdef)(pdef.pid, grouped :: topStats)
974973
}
975974
}

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)