Skip to content

Commit 79fa035

Browse files
lrytzretronym
authored andcommitted
clear all flags when resetting a symbol
this change is a bit scary because it changes code that's not been changed in 11 years scala@7fa7c93#diff-d5789e5ae5061197d782d08324b260dbL214
1 parent 14cea39 commit 79fa035

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/reflect/scala/reflect/internal/Symbols.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
725725

726726
def setFlag(mask: Long): this.type = { _rawflags |= mask ; this }
727727
def resetFlag(mask: Long): this.type = { _rawflags &= ~mask ; this }
728-
def resetFlags() { rawflags &= TopLevelCreationFlags }
728+
def resetFlags() { rawflags = 0 }
729729

730730
/** Default implementation calls the generic string function, which
731731
* will print overloaded flags as <flag1/flag2/flag3>. Subclasses

test/junit/scala/tools/nsc/backend/jvm/DirectCompileTest.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,15 @@ class DirectCompileTest extends BytecodeTesting {
8888
def compileErroneous(): Unit = {
8989
compileToBytes("class C { def f: String = 1 }", allowMessage = _.msg contains "type mismatch")
9090
}
91+
92+
@Test
93+
def residentRedefineFinalFlag(): Unit = {
94+
val compiler = newCompiler()
95+
val a = "final class C { def c1 = 0 }"
96+
// for re-defined class symbols (C), the compiler did not clear the `final` flag.
97+
// so compiling `D` would give an error `illegal inheritance from final class C`.
98+
val b = "class C; class D extends C"
99+
compiler.compileToBytes(a)
100+
compiler.compileToBytes(b)
101+
}
91102
}

0 commit comments

Comments
 (0)