Skip to content

Commit 2ebfae1

Browse files
committed
Tweak assertion in withMods
Fixes #5037
1 parent 8c404b1 commit 2ebfae1

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,10 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
281281
else {
282282
if (ms.nonEmpty)
283283
for (m <- ms)
284-
assert(flags.isAllOf(m.flags) ||
285-
m.isInstanceOf[Mod.Private] && !privateWithin.isEmpty,
286-
s"unaccounted modifier: $m in $this when adding $ms")
284+
assert(flags.isAllOf(m.flags)
285+
|| m.isInstanceOf[Mod.Private] && !privateWithin.isEmpty
286+
|| m.isInstanceOf[Mod.Abstract] || m.isInstanceOf[Mod.Override] && flags.is(AbsOverride),
287+
s"unaccounted modifier: $m in $this with flags ${flags.flagsString} when adding $ms")
287288
copy(mods = ms)
288289
}
289290

tests/neg/i5037.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Foo {
2+
abstract override var // error
3+
}

0 commit comments

Comments
 (0)