From b7f92ae07fe618d342dc5c8e99dff3f77dde1885 Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Fri, 4 Mar 2011 05:25:40 -0500 Subject: [PATCH] 2.9 compatibility fixes --- compile/Eval.scala | 3 +- compile/persist/SourceFormat.scala | 109 ----------------------------- ivy/IvyActions.scala | 2 +- main/Structure.scala | 2 +- 4 files changed, 4 insertions(+), 112 deletions(-) diff --git a/compile/Eval.scala b/compile/Eval.scala index 86884e402..02a96a957 100644 --- a/compile/Eval.scala +++ b/compile/Eval.scala @@ -106,6 +106,7 @@ final class Eval(optionsNoncp: Seq[String], classpath: Seq[File], mkReporter: Se //wrap tree in object objectName { def WrapValName = } def augment(parser: global.syntaxAnalyzer.UnitParser, imports: Seq[Tree], tree: Tree, tpt: Tree, objectName: String): Tree = { + val emptyTypeName = nme.EMPTY.toTypeName def emptyPkg = parser.atPos(0, 0, 0) { Ident(nme.EMPTY_PACKAGE_NAME) } def emptyInit = DefDef( NoMods, @@ -113,7 +114,7 @@ final class Eval(optionsNoncp: Seq[String], classpath: Seq[File], mkReporter: Se Nil, List(Nil), TypeTree(), - Block(List(Apply(Select(Super("", ""), nme.CONSTRUCTOR), Nil)), Literal(Constant(()))) + Block(List(Apply(Select(Super(emptyTypeName, emptyTypeName), nme.CONSTRUCTOR), Nil)), Literal(Constant(()))) ) def method = DefDef(NoMods, WrapValName, Nil, Nil, tpt, tree) diff --git a/compile/persist/SourceFormat.scala b/compile/persist/SourceFormat.scala index c8772088b..446c345fa 100644 --- a/compile/persist/SourceFormat.scala +++ b/compile/persist/SourceFormat.scala @@ -39,115 +39,6 @@ final class OutputWrapperStream(out: Output) extends java.io.OutputStream def write(b: Int) = out.writeByte(b.toByte) } -object SourceFormat2 extends Format[Source] -{ - private[this] final val StructureFields = 3 - private[this] final val ClassFields = 2 - - private[this]def toMap[T](a: Seq[T]): Map[T, Int] = a.zipWithIndex.toMap - - def reads(in: Input): Source = - { - var pending: List[Lazy[_]] = Nil - def forcePending() = pending foreach { _.get } - - def lzyC[T <: AnyRef](i: Int, off: Int): Lazy[T] = lzy { getData[T](i, off, classData, ClassFields) } - def lzyS[T <: AnyRef](i: Int, off: Int): Lazy[T] = lzy { getData[T](i, off, structureData, StructureFields) } - def getData[T <: AnyRef](i: Int, off: Int, backing: Array[AnyRef], fields: Int): T = backing(i*fields+off).asInstanceOf[T] - def lzy[T <: AnyRef](t: => T): Lazy[T] = - { - val z = SafeLazy(t) - pending ::= z - z - } - - val structureCount = read[Int](in) - - lazy val refs: References = new References { - def structure(id: Int) = structures(id) - def classLike(id: Int) = classes(id) - def id(s: Structure) = noID() - def id(s: ClassLike) = noID() - def noID() = error("References only for reading") - } - lazy val formats = new DefaultAPIFormats()(refs) - import formats._ - - lazy val classesStrict = read[Array[(DefinitionType, Array[TypeParameter], String, Access, Modifiers, Array[Annotation])]](in) - - // shells for types that can be cyclic. The actual contents are filled in after the shells are constructed so that - // the contents can have cyclic references - lazy val structures = Array.tabulate(structureCount)(i => new xsbti.api.Structure( lzyS(i,0), lzyS(i,1), lzyS(i,2) ) ) - lazy val classes = Array.tabulate(classesStrict.size) { i => - val c = classesStrict(i) - new xsbti.api.ClassLike( c._1, lzyC(i,0), lzyC(i,1), c._2, c._3, c._4, c._5, c._6 ) - } - - def readFlat[T <: Product](implicit r: Reads[Array[T]]): Array[AnyRef] = - read[Array[T]](in)(r).flatMap(_.productIterator.asInstanceOf[Iterator[AnyRef]].toTraversable) - - lazy val structureData = readFlat[(Array[Type], Array[Definition], Array[Definition])] - lazy val classData = readFlat[(Type, Structure)] - - // order is important here, we are forcing in the correct order - classesStrict; // read the strict contents of ClassLikes - structures; // force the Structure shells to be constructed - classes; // force the ClassLike shells to be constructed, filling in the strict parts now and deferring the lazy parts - structureData; // force loading the lazy contents of Structures - classData; // force loading the lazy contents of ClassLikes - - forcePending() // force the shells to be filled in - read[Source](in) - } - - def writes(out: Output, s: Source) - { - val (structures, classes) = getStructures(s) - val structuresMap = toMap(structures) - val classesMap = toMap(classes) - implicit val references = new References { - def id(s: Structure) = structuresMap(s) - def id(s: ClassLike) = classesMap(s) - def noID() = error("References only for writing") - def structure(id: Int) = noID() - def classLike(id: Int) = noID() - } - val formats = new DefaultAPIFormats - import formats._ - - val expandedStructures = structures map { s => (s.parents, s.declared, s.inherited)} - // TODO: type parameters and annotations might need to be lazy as well - val expandedClassesStrict = classes map { c => (c.definitionType, c.typeParameters, c.name, c.access, c.modifiers, c.annotations) } - val expandedClassesLazy = classes map { c => (c.selfType, c.structure) } - - write(out, structures.size ) - write(out, expandedClassesStrict) - write(out, expandedStructures) - write(out, expandedClassesLazy) - write(out, s) - } - - def getStructures(s: Source): (Array[Structure], Array[ClassLike]) = - { - val structures = new mutable.HashSet[Structure] - val classes = new mutable.HashSet[ClassLike] - val search = new Visit { - override def visitStructure0(s: Structure) - { - structures += s - super.visitStructure0(s) - } - override def visitClass0(c: ClassLike) - { - classes += c - super.visitClass0(c: ClassLike) - } - } - search.visit(s) - (structures.toArray, classes.toArray) - } -} - trait References { def id(s: Structure): Int def id(s: ClassLike): Int diff --git a/ivy/IvyActions.scala b/ivy/IvyActions.scala index 966d68753..a685ed2e7 100644 --- a/ivy/IvyActions.scala +++ b/ivy/IvyActions.scala @@ -138,7 +138,7 @@ object IvyActions val map = rawMap.asInstanceOf[java.util.Map[ArtifactDownloadReport,java.util.Set[String]]] val confMap = new collection.mutable.HashMap[String, Seq[File]] - import collection.JavaConversions.{asScalaMap,asScalaSet} + import collection.JavaConversions._ for( (report, all) <- map; retrieved <- all; val file = new File(retrieved); conf <- report.getArtifact.getConfigurations) confMap.put(conf, file +: confMap.getOrElse(conf, Nil)) confMap.toMap diff --git a/main/Structure.scala b/main/Structure.scala index e7b1f1d93..dfa6c7785 100644 --- a/main/Structure.scala +++ b/main/Structure.scala @@ -380,7 +380,7 @@ object Scoped } private val ssToSK = new (ScopedSetting ~> ScopedKey) { def apply[T](sk: ScopedSetting[T]) = new ScopedKey(sk.scope, sk.key) } private val stToSK = new (ScopedTask ~> ScopedTaskKey) { def apply[T](st: ScopedTask[T]) = new ScopedKey(st.scope, st.key) } - private type ScopedTaskKey[T] = ScopedKey[Task[T]] + type ScopedTaskKey[T] = ScopedKey[Task[T]] } final class Apply2[A,B](t2: (ScopedSetting[A], ScopedSetting[B])) {