Skip to content

Commit

Permalink
SI-6595, lost modifiers in early defs.
Browse files Browse the repository at this point in the history
[backport]
Saw this by accident; the trees created for early defs would
wholesale replace the modifiers with PRESUPER rather than
combining them. FINAL was lost that way, as would be any other
modifiers which might be valid there.
  • Loading branch information
paulp committed Jan 30, 2013
1 parent 98534b2 commit ff92610
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/ast/Trees.scala
Expand Up @@ -111,7 +111,7 @@ trait Trees extends scala.reflect.internal.Trees { self: Global =>
rhs = EmptyTree rhs = EmptyTree
) )
} }
val lvdefs = evdefs collect { case vdef: ValDef => copyValDef(vdef)(mods = Modifiers(PRESUPER)) } val lvdefs = evdefs collect { case vdef: ValDef => copyValDef(vdef)(mods = vdef.mods | PRESUPER) }


val constrs = { val constrs = {
if (constrMods hasFlag TRAIT) { if (constrMods hasFlag TRAIT) {
Expand Down
1 change: 1 addition & 0 deletions test/files/pos/t6595.flags
@@ -0,0 +1 @@
-Xfatal-warnings
18 changes: 18 additions & 0 deletions test/files/pos/t6595.scala
@@ -0,0 +1,18 @@
import scala.annotation.switch

class Foo extends {
final val b0 = 5
} with AnyRef {
final val b1 = 10

// Using the @switch annotation as a means of testing that the
// type inferred for b0 is Int(5) and not Int. Only in the former
// case can a switch be generated.
def f(p: Int) = (p: @switch) match {
case `b0` => 1
case `b1` => 2
case 15 => 3
case 20 => 4
case _ => 5
}
}

0 comments on commit ff92610

Please sign in to comment.