Skip to content

Commit 72cd50c

Browse files
committed
SI-7406 crasher with specialized lazy val
This reverts a tiny bit of f7d5f45 where the crasher was introduced. The enclosed test case compiles and runs under 2.9, but prints the wrong answer. It crashes in 2.10 and until this patch. Now it compiles and prints the right answer.
1 parent 9f0594c commit 72cd50c

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
923923

924924
/** Return the specialized overload of `m`, in the given environment. */
925925
private def specializedOverload(owner: Symbol, sym: Symbol, env: TypeEnv, nameSymbol: Symbol = NoSymbol): Symbol = {
926-
val newFlags = (sym.flags | SPECIALIZED) & ~(DEFERRED | CASEACCESSOR)
926+
val newFlags = (sym.flags | SPECIALIZED) & ~(DEFERRED | CASEACCESSOR | LAZY)
927927
// this method properly duplicates the symbol's info
928928
val specname = specializedName(nameSymbol orElse sym, env)
929929
( sym.cloneSymbol(owner, newFlags, newName = specname)

test/files/run/t7406.check

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

test/files/run/t7406.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Arne[@specialized(Long) T](x: T) {
2+
val regularVal = x
3+
lazy val lazyVal = x
4+
5+
def apply(f: (T, T) => T): T = f(regularVal, lazyVal)
6+
}
7+
8+
object Test {
9+
val arne = new Arne(5L)
10+
def f = arne(_ + _)
11+
def main(args: Array[String]): Unit = {
12+
println(f)
13+
}
14+
}

0 commit comments

Comments
 (0)