Skip to content

Commit ff92610

Browse files
committed
SI-6595, lost modifiers in early defs.
[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.
1 parent 98534b2 commit ff92610

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

src/compiler/scala/tools/nsc/ast/Trees.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ trait Trees extends scala.reflect.internal.Trees { self: Global =>
111111
rhs = EmptyTree
112112
)
113113
}
114-
val lvdefs = evdefs collect { case vdef: ValDef => copyValDef(vdef)(mods = Modifiers(PRESUPER)) }
114+
val lvdefs = evdefs collect { case vdef: ValDef => copyValDef(vdef)(mods = vdef.mods | PRESUPER) }
115115

116116
val constrs = {
117117
if (constrMods hasFlag TRAIT) {

test/files/pos/t6595.flags

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Xfatal-warnings

test/files/pos/t6595.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import scala.annotation.switch
2+
3+
class Foo extends {
4+
final val b0 = 5
5+
} with AnyRef {
6+
final val b1 = 10
7+
8+
// Using the @switch annotation as a means of testing that the
9+
// type inferred for b0 is Int(5) and not Int. Only in the former
10+
// case can a switch be generated.
11+
def f(p: Int) = (p: @switch) match {
12+
case `b0` => 1
13+
case `b1` => 2
14+
case 15 => 3
15+
case 20 => 4
16+
case _ => 5
17+
}
18+
}

0 commit comments

Comments
 (0)