Permalink
Browse files

Switch from Scala 2.10.0 to 2.10.1 and workaround Scalac regression

"Fix" compilation with Scalac 2.10.1. Look at the comment in the diff for
details on the bug.

Among other advantages, updating Scala version might help some new crazy code
(which I have tested with 2.10.2, so I don't know if it works with 2.10.0),
which might be useful for RBI-like things.
  • Loading branch information...
1 parent 794fd91 commit c429f15f90bcef6ae38fdc320f45ba70ad00605b @Blaisorblade Blaisorblade committed Aug 21, 2013
Showing with 28 additions and 2 deletions.
  1. +1 −1 build.sbt
  2. +27 −1 src/main/scala/ivm/expressiontree/Exp.scala
View
@@ -10,7 +10,7 @@ version := "0.3-SNAPSHOT"
//scalaVersion in ThisBuild := "2.9.2"
-scalaVersion in ThisBuild := "2.10.0"
+scalaVersion in ThisBuild := "2.10.1"
//resolvers in ThisBuild += Resolver.sonatypeRepo("snapshots")
@@ -56,7 +56,33 @@ sealed trait Exp[+T] extends TreeNode[T, Exp[_]] /*with MsgSeqPublisher[T, Exp[T
//This could use as interface some Foldable-like stuff (or Haskell's Traversable, IIRC).
//Write it as a fold on the tree!!!
def treeMap[S](mapper: (Exp[_], Seq[S]) => S): S = {
- val mappedChilds = for (c <- children) yield c.treeMap(mapper)
+ //Worked in 2.10.0, not in 2.10.1 or 2.10.2 - now it does again!
+ //val mappedChilds = for (c <- children) yield c.treeMap(mapper)
+ // Help a bit type inference:
+ //val mappedChilds = for (c <- children) yield c.treeMap[S](mapper)
+ // Doesn't give additional help.
+ //val mappedChilds: List[S] = for (c <- children) yield c.treeMap[S](mapper)
+ // This tells that no implicit is found:
+ //val mappedChilds: List[S] = children.map[S, List[S]](c => c.treeMap[S](mapper))
+ //Also doesn't work:
+ //val mappedChilds = for (c <- children) yield (c: Exp[_]).asInstanceOf[Exp[Any]].treeMap[S](mapper)
+
+ //Doesn't work.
+ //val mappedChilds: List[S] = children.asInstanceOf[List[Exp[Any]]].map[S, List[S]](c => c.asInstanceOf[Exp[Any]].treeMap[S](mapper))(List.canBuildFrom)
+ //Works in 2.10.1! (Maybe in 2.10.2).
+ val mappedChilds: List[S] = children.asInstanceOf[List[Exp[Any]]].map[S, List[S]](c => c.asInstanceOf[Exp[Any]].treeMap[S](mapper))(List.canBuildFrom[S])
+
+ //After compiling with that line, we can use pretty much any definition and
+ //it will work. That is, we can comment out the working definition, comment
+ //back in the one which worked in 2.10.0 (or many other ones, but I didn't
+ //test each of them), and that one will compile. At least in 2.10.1.
+ //
+ //Yeah, that's crazy, yet reproducible on this computer. And compiling a
+ //file separate from its codebase is known to work differently. Usually not
+ //up to this point though.
+
+ // This is another of the many examples of code which works after the first compilation.
+ //val mappedChilds = children.asInstanceOf[List[Exp[Any]]].map(c => c.treeMap(mapper))
mapper(this, mappedChilds)
}

0 comments on commit c429f15

Please sign in to comment.