Skip to content

Commit 6e1704c

Browse files
committed
Fix #3471: Avoid wrong flag kind when desugaring module definitions
1 parent 745fae6 commit 6e1704c

File tree

5 files changed

+5
-4
lines changed

5 files changed

+5
-4
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: 1 addition & 1 deletion
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

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

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 // error

0 commit comments

Comments
 (0)