Skip to content

Commit 96d8661

Browse files
Merge pull request #3486 from dotty-staging/fix-#3471
Fix #3471: Avoid wrong flag kind when desugaring module definitions
2 parents f16f71a + 439b65c commit 96d8661

File tree

6 files changed

+7
-6
lines changed

6 files changed

+7
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ object desugar {
578578
val clsName = moduleName.moduleClassName
579579
val clsRef = Ident(clsName)
580580
val modul = ValDef(moduleName, clsRef, New(clsRef, Nil))
581-
.withMods(mods | ModuleCreationFlags | mods.flags & AccessFlags)
581+
.withMods(mods.toTermFlags & RetainedModuleValFlags | ModuleValCreationFlags)
582582
.withPos(mdef.pos.startPos)
583583
val ValDef(selfName, selfTpt, _) = impl.self
584584
val selfMods = impl.self.mods

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ object Flags {
472472
final val RetainedTypeArgFlags = VarianceFlags | Protected | Local
473473

474474
/** Modules always have these flags set */
475-
final val ModuleCreationFlags = ModuleVal | Lazy | Final | Stable
475+
final val ModuleValCreationFlags = ModuleVal | Lazy | Final | Stable
476476

477477
/** Module classes always have these flags set */
478478
final val ModuleClassCreationFlags = ModuleClass | Final
@@ -503,7 +503,7 @@ object Flags {
503503
/** Flags that can apply to a module val */
504504
final val RetainedModuleValFlags: FlagSet = RetainedModuleValAndClassFlags |
505505
Override | Final | Method | Implicit | Lazy |
506-
Accessor | AbsOverride | Stable | Captured | Synchronized
506+
Accessor | AbsOverride | Stable | Captured | Synchronized | Inline
507507

508508
/** Flags that can apply to a module class */
509509
final val RetainedModuleClassFlags: FlagSet = RetainedModuleValAndClassFlags | ImplClass | Enum

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ trait Symbols { this: Context =>
153153
modcls, owner, modclsName, modclsFlags,
154154
infoFn(module, modcls), privateWithin)
155155
val mdenot = SymDenotation(
156-
module, owner, name, modFlags | ModuleCreationFlags,
156+
module, owner, name, modFlags | ModuleValCreationFlags,
157157
if (cdenot.isCompleted) TypeRef.withSym(owner.thisType, modcls, modclsName)
158158
else new ModuleCompleter(modcls))
159159
module.denot = mdenot

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ class TreeUnpickler(reader: TastyReader, nameAtRef: NameRef => TermName, posUnpi
382382
if (lacksDefinition && tag != PARAM) flags |= Deferred
383383
if (tag == DEFDEF) flags |= Method
384384
if (givenFlags is Module)
385-
flags = flags | (if (tag == VALDEF) ModuleCreationFlags else ModuleClassCreationFlags)
385+
flags = flags | (if (tag == VALDEF) ModuleValCreationFlags else ModuleClassCreationFlags)
386386
if (ctx.owner.isClass) {
387387
if (tag == TYPEPARAM) flags |= Param
388388
else if (tag == PARAM) flags |= ParamAccessor

compiler/src/dotty/tools/dotc/typer/Namer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ class Namer { typer: Typer =>
274274
def preExisting = ctx.effectiveScope.lookup(name)
275275
if (ctx.owner is PackageClass)
276276
if (preExisting.isDefinedInCurrentRun)
277-
errorName(s"${preExisting.showLocated} has already been compiled\nonce during this run")
277+
errorName(s"${preExisting.showLocated} has already been compiled once during this run")
278278
else name
279279
else
280280
if ((!ctx.owner.isClass || name.isTypeName) && preExisting.exists)

tests/pos/i3471.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sealed object Fun

0 commit comments

Comments
 (0)