Skip to content

Commit b2bf66a

Browse files
committed
Merge pull request scala#3297 from paulp/pr/7406
crasher with specialized lazy val
2 parents fbbe7cc + 72cd50c commit b2bf66a

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)