summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2010-09-16 14:16:07 +0000
committerIulian Dragos <jaguarul@gmail.com>2010-09-16 14:16:07 +0000
commitd505a106f8e77cc54903ac6216a64b2a19db551b (patch)
tree794cbdc935e50886dd3937b6fbfb03994a68df7a /src/compiler
parente998a5e747941cb42939d45232fa87e8a3688727 (diff)
downloadscala-d505a106f8e77cc54903ac6216a64b2a19db551b.tar.gz
scala-d505a106f8e77cc54903ac6216a64b2a19db551b.tar.bz2
scala-d505a106f8e77cc54903ac6216a64b2a19db551b.zip
Closes #3779.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/transform/Constructors.scala22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Constructors.scala b/src/compiler/scala/tools/nsc/transform/Constructors.scala
index 21db224eef..34b7b7f95b 100644
--- a/src/compiler/scala/tools/nsc/transform/Constructors.scala
+++ b/src/compiler/scala/tools/nsc/transform/Constructors.scala
@@ -305,6 +305,23 @@ abstract class Constructors extends Transform with ast.TreeDSL {
case _ => false
}
+ /** Rewrite calls to ScalaRunTime.array_update to the proper apply method in scala.Array.
+ * Erasure transforms Array.update to ScalaRunTime.update when the element type is a type
+ * variable, but after specialization this is a concrete primitive type, so it would
+ * be an error to pass it to array_update(.., .., Object).
+ */
+ def rewriteArrayUpdate(tree: Tree): Tree = {
+ val array_update = definitions.ScalaRunTimeModule.info.member("array_update")
+ val adapter = new Transformer {
+ override def transform(t: Tree): Tree = t match {
+ case Apply(fun @ Select(receiver, method), List(xs, idx, v)) if fun.symbol == array_update =>
+ localTyper.typed(Apply(gen.mkAttributedSelect(xs, definitions.Array_update), List(idx, v)))
+ case _ => super.transform(t)
+ }
+ }
+ adapter.transform(tree)
+ }
+
log("merging: " + originalStats.mkString("\n") + "\nwith\n" + specializedStats.mkString("\n"))
val res = for (s <- originalStats; val stat = s.duplicate) yield {
log("merge: looking at " + stat)
@@ -323,12 +340,13 @@ abstract class Constructors extends Transform with ast.TreeDSL {
// this is just to make private fields public
(new specializeTypes.ImplementationAdapter(ctorParams(genericClazz), constrParams, null, true))(stat1)
+ val stat2 = rewriteArrayUpdate(stat1)
// statements coming from the original class need retyping in the current context
- if (settings.debug.value) log("retyping " + stat1)
+ if (settings.debug.value) log("retyping " + stat2)
val d = new specializeTypes.Duplicator
d.retyped(localTyper.context1.asInstanceOf[d.Context],
- stat1,
+ stat2,
genericClazz,
clazz,
Map.empty)