Skip to content

Commit 70ed23d

Browse files
committed
SI-9089 Another REPL/FSC + specialization bug fix
The enclosed test case stopped working in 2.11.5 on the back of scala#4040. The key change was that we ran all post-typer info transformers on each run of the compiler, rather than trying to reuse the results of the previous run. In that patch, I noticed one place [1] in specialization that aggressively entered specialized members into the owning scope, rather than relying on `transformInfo` to place the new members in the scope of the newly created element of the info history. I made that change after noticing that this code could actually mutated scopes of specializaed types at the parser phase, which led to fairly obscure failures. This bug is another one of these obscure failures, and has the same root cause. We effectively "double specialiaze" Function0, which trips an assertion when `method apply$mcI$sp` is found twice in a scope. I have found another spot that was directly manipulating the scope, and removed the offending code. [1] scala#4040 (comment)
1 parent 0561239 commit 70ed23d

File tree

4 files changed

+7
-1
lines changed

4 files changed

+7
-1
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,6 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
894894
}
895895

896896
val specMember = subst(outerEnv)(specializedOverload(owner, sym, spec))
897-
owner.info.decls.enter(specMember)
898897
typeEnv(specMember) = typeEnv(sym) ++ outerEnv ++ spec
899898
wasSpecializedForTypeVars(specMember) ++= spec collect { case (s, tp) if s.tpe == tp => s }
900899

test/files/res/t9089.check

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
nsc>
3+
nsc>
4+
nsc>

test/files/res/t9089.res

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
t9089/A.scala
2+
t9089/A.scala

test/files/res/t9089/A.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
object O { def f(x: => Int): Int = x }

0 commit comments

Comments
 (0)