From 8fba722d616618962455d5fe5167e0f6e34817c7 Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Fri, 19 Jun 2015 18:04:02 +0200 Subject: [PATCH] Arrays.newRefArray has multiple symbols that coexist during bootstrap. More magic is needed, as enumerating array symbols does not work in backend. --- project/Build.scala | 2 +- src/dotty/runtime/Arrays.scala | 2 ++ .../tools/backend/jvm/DottyBackendInterface.scala | 11 +++++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/project/Build.scala b/project/Build.scala index 79cb7d9b717e..473ef2443f06 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -42,7 +42,7 @@ object DottyBuild extends Build { resolvers += Resolver.sonatypeRepo("releases"), // get libraries onboard - partestDeps := Seq("me.d-d" % "scala-compiler" % "2.11.5-20150506-175515-8fc7635b56", + partestDeps := Seq("me.d-d" % "scala-compiler" % "2.11.5-20150619-173733-3bcd390afa", "org.scala-lang" % "scala-reflect" % scalaVersion.value, "org.scala-lang" % "scala-library" % scalaVersion.value % "test"), libraryDependencies ++= partestDeps.value, diff --git a/src/dotty/runtime/Arrays.scala b/src/dotty/runtime/Arrays.scala index 1fb4fe5ebc69..4469dced7ff1 100644 --- a/src/dotty/runtime/Arrays.scala +++ b/src/dotty/runtime/Arrays.scala @@ -7,6 +7,8 @@ import scala.reflect.ClassTag */ object Arrays { + // note: this class is magical. Do not touch it unless you know what you are doing.` + /** Creates an array of some element type determined by the given `ClassTag` * argument. The erased type of applications of this method is `Object`. */ diff --git a/src/dotty/tools/backend/jvm/DottyBackendInterface.scala b/src/dotty/tools/backend/jvm/DottyBackendInterface.scala index 855147ac44ff..2ee4197147ea 100644 --- a/src/dotty/tools/backend/jvm/DottyBackendInterface.scala +++ b/src/dotty/tools/backend/jvm/DottyBackendInterface.scala @@ -157,9 +157,16 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{ }.toMap def unboxMethods: Map[Symbol, Symbol] = defn.ScalaValueClasses.map(x => (x, Erasure.Boxing.unboxMethod(x.asClass))).toMap - private val mkArrayNames: Set[String] = Set("Byte", "Float", "Char", "Double", "Boolean", "Unit", "Long", "Int", "Short", "Ref") + private val mkArrayNames: Set[Name] = Set("Byte", "Float", "Char", "Double", "Boolean", "Unit", "Long", "Int", "Short", "Ref").map{ x=> + ("new" + x + "Array").toTermName + } + + val dottyArraysModuleClass = toDenot(defn.DottyArraysModule).moduleClass.asClass - override lazy val syntheticArrayConstructors: Set[Symbol] = mkArrayNames.map(nm => ctx.requiredMethod(toDenot(defn.DottyArraysModule).moduleClass.asClass, s"new${nm}Array")) + + override def isSyntheticArrayConstructor(s: Symbol) = { + (toDenot(s).maybeOwner eq dottyArraysModuleClass) && mkArrayNames.contains(s.name) + } def isBox(sym: Symbol): Boolean = Erasure.Boxing.isBox(sym) def isUnbox(sym: Symbol): Boolean = Erasure.Boxing.isUnbox(sym)