Skip to content

Commit

Permalink
clear all flags when resetting a symbol
Browse files Browse the repository at this point in the history
this change is a bit scary because it changes code that's not been
changed in 11 years
scala@7fa7c93#diff-d5789e5ae5061197d782d08324b260dbL214
  • Loading branch information
lrytz authored and retronym committed May 31, 2016
1 parent 6c779c6 commit 926e772
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/reflect/scala/reflect/internal/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>

def setFlag(mask: Long): this.type = { _rawflags |= mask ; this }
def resetFlag(mask: Long): this.type = { _rawflags &= ~mask ; this }
def resetFlags() { rawflags &= TopLevelCreationFlags }
def resetFlags() { rawflags = 0 }

/** Default implementation calls the generic string function, which
* will print overloaded flags as <flag1/flag2/flag3>. Subclasses
Expand Down
11 changes: 11 additions & 0 deletions test/junit/scala/tools/nsc/backend/jvm/DirectCompileTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,15 @@ class DirectCompileTest extends BytecodeTesting {
def compileErroneous(): Unit = {
compileToBytes("class C { def f: String = 1 }", allowMessage = _.msg contains "type mismatch")
}

@Test
def residentRedefineFinalFlag(): Unit = {
val compiler = newCompiler()
val a = "final class C { def c1 = 0 }"
// for re-defined class symbols (C), the compiler did not clear the `final` flag.
// so compiling `D` would give an error `illegal inheritance from final class C`.
val b = "class C; class D extends C"
compiler.compileToBytes(a)
compiler.compileToBytes(b)
}
}

0 comments on commit 926e772

Please sign in to comment.