diff options
60 files changed, 263 insertions, 913 deletions
diff --git a/.gitignore b/.gitignore index 84c048a73c..e60505f663 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,43 @@ +# +# Are you tempted to edit this file? +# +# First consider if the changes make sense for all, +# or if they are specific to your workflow/system. +# If it is the latter, you can augment this list with +# entries in .git/info/excludes +# +# see also test/files/.gitignore +# + +*.jar +*~ + +build.properties + +# target directories for ant build /build/ +/dists/ + +# other +/out/ +/bin/ +/sandbox/ + +# eclipse, intellij +/.classpath +/.project +/src/intellij/*.iml +/src/intellij/*.ipr +/src/intellij/*.iws +/.cache +/.idea +/.settings + +# bak files produced by ./cleanup-commit +*.bak + +# Standard symbolic link to build/quick/bin +qbin + +# Mac specific, but that is common enough a dev platform to warrant inclusion. +.DS_Store diff --git a/README.md b/README.md new file mode 100644 index 0000000000..a273cfb544 --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +This is the repository for the [Scala Programming Language](http://www.scala-lang.org). + + - [Report an issue](https://issues.scala-lang.org); + - [Read about the development of the compiler and the standard library](http://docs.scala-lang.org/scala/); + - [Check our Jenkins status](https://scala-webapps.epfl.ch/jenkins/); + - [Download the latest nightly](https://scala-webapps.epfl.ch/jenkins/job/scala-nightly-main-master/ws/dists/latest/*zip*/latest.zip); + - ... and contribute right here! Please, first read our [policy](http://docs.scala-lang.org/scala/pull-request-policy.html), +and [sign the contributor's license agreement](http://typesafe.com/contribute/cla/scala). diff --git a/README.rst b/README.rst deleted file mode 100644 index 004d7b63d0..0000000000 --- a/README.rst +++ /dev/null @@ -1,206 +0,0 @@ -################################################################################ - THE SCALA REPOSITORY -################################################################################ - -This document describes the Scala core (core library and compiler) repository -and how to build it. For information about Scala as a language, you can visit -the web site http://www.scala-lang.org/ - -Part I. The repository layout --------------------------------------------------------------------------------- - -Follows the file layout of the Scala repository. Files marked with a † are not -part of the repository but are either automatically generated by the -build script or user-created if needed. This is not a complete listing. :: - scala/ - +--build/ Build products output directory for ant. - +--build.xml The main Ant build script. - +--dist/ The destination folder for Scala distributions. - +--docs/ Documentation and sample code. - +--lib/ Pre-compiled libraries for the build. - | +--scala-compiler.jar The stable reference ('starr') compiler jar - | +--scala-library.jar The stable reference ('starr') library jar - | +--scala-library-src.jar A snapshot of the source used to build starr. - | ---ant/ Support libraries for ant. - +--pull-binary-libs.sh Pulls binary artifacts from remote repository. - +--push-binary-libs.sh Pushes new binary artifacts and creates sha. - +--README.rst The file you are currently reading. - +--src/ All the source files of Scala. - | +--actors/ The sources of the Actor library. - | +--compiler/ The sources of the Scala compiler. - | +--library/ The sources of the core Scala library. - | ---swing/ The sources of the Swing library. - +--target/ † Build products output directory for sbt. - +--test/ The Scala test suite. - ---tools/ Developer utilities. - - - -Part II. Building Scala with SABBUS --------------------------------------------------------------------------------- - -SABBUS is the name of the Ant build script used to compile Scala. It is mostly -automated and takes care of managing the dependencies. - -^^^^^^^^^^^^^^^^^^^^^^^^ - LAYERS: -^^^^^^^^^^^^^^^^^^^^^^^^ -In order to guarantee the bootstrapping of the Scala compiler, SABBUS builds -Scala in layers. Each layer is a complete compiled Scala compiler and library. -A superior layer is always compiled by the layer just below it. Here is a short -description of the four layers that SABBUS uses, from bottom to top: - -- ``starr``: the stable reference Scala release which is shared by all the - developers. It is found in the repository as 'lib/scala-compiler.jar' and - 'lib/scala-library.jar'. Any committable source code must be compiled directly - by starr to guarantee the bootstrapping of the compiler. - -- ``locker``: the local reference which is compiled by starr and is the work - compiler in a typical development cycle. When it has been built once, it is - “frozen” in this state. Updating it to fit the current source code must be - explicitly requested (see below). - -- ``quick``: the layer which is incrementally built when testing changes in the - compiler or library. This is considered an actual new version when locker is - up-to-date in relation to the source code. - -- ``strap``: a test layer used to check stability of the build. - -^^^^^^^^^^^^^^^^^^^^^^^^ - DEPENDENT CHANGES: -^^^^^^^^^^^^^^^^^^^^^^^^ -SABBUS compiles, for each layer, the Scala library first and the compiler next. -That means that any changes in the library can immediately be used in the -compiler without an intermediate build. On the other hand, if building the -library requires changes in the compiler, a new locker must be built if -bootstrapping is still possible, or a new starr if it is not. - - -^^^^^^^^^^^^^^^^^^^^^^^^ -REQUIREMENTS FOR SABBUS: -^^^^^^^^^^^^^^^^^^^^^^^^ -The Scala build system is based on Apache Ant. Most required pre-compiled -libraries are part of the repository (in 'lib/'). The following however is -assumed to be installed on the build machine: - -- A Java runtime environment (JRE) or SDK 1.6 or above. -- Apache Ant version 1.7.0 or above. -- bash (via cygwin for windows) -- curl - - -Part III. Common use-cases --------------------------------------------------------------------------------- -- ``./pull-binary-libs.sh`` - - Downloads all binary artifacts associated with this commit. This requires - internet access to http://typesafe.artifactoryonline.com/typesafe. - -- ``ant -p`` - - Prints out information about the commonly used ant targets. The interested - developer can find the rest in the XML files. - -- ``ant`` or ``ant build`` - - A quick compilation (to quick) of your changes using the locker compiler. - - - This will rebuild all quick if locker changed. - - This will also rebuild locker if starr changed. - -- ``ln -s build/quick/bin qbin`` (once): -- ``ant && qbin/scalac -d sandbox sandbox/test.scala && qbin/scala -cp sandbox Test`` - - Incrementally builds quick, and then uses it to compile and run the file - ``sandbox/test.scala``. This is a typical debug cycle. - -- ``ant replacelocker`` - - "unfreezes" locker by updating it to match the current source code. - - - This will delete quick so as not to mix classes compiled with different - versions of locker. - -- ``ant test`` - - Tests that your code is working and fit to be committed. - - - Runs the test suite and bootstrapping test on quick. - - You can run the suite only (skipping strap) with 'ant test.suite'. - -- ``ant docs`` - Generates the HTML documentation for the library from the sources using the - scaladoc tool in quick. Note: on most machines this requires more heap than - is allocate by default. You can adjust the parameters with ANT_OPTS. - Example command line:: - ANT_OPTS="-Xms512M -Xmx2048M -Xss1M -XX:MaxPermSize=128M" ant docs - -- ``ant dist`` - - Builds a distribution. - - - Rebuilds locker from scratch (to make sure it bootstraps). - - Builds everything twice more and compares bit-to-bit the two builds (to - make sure it is stable). - - Runs the test suite (and refuses to build a distribution if it fails). - - Creates a local distribution in 'dists/latest'. - -- ``ant clean`` - - Removes all temporary build files (locker is preserved). - -- ``ant locker.clean`` - - Removes all build files. - -- ``ant all.clean`` - - Removes all build files (including locker) and all distributions. - -Many of these targets offer a variant which runs with -optimise enabled. -Optimized targets include build-opt, test-opt, dist-opt, fastdist-opt, -replacestarr-opt, replacelocker-opt, and distpack-opt. - -Part IV. Contributing to Scala --------------------------------------------------------------------------------- - -If you wish to contribute, you can find all of the necessary information on -the official Scala website: www.scala-lang.org. - -Specifically, you can subscribe to the Scala mailing lists, read all of the -available documentation, and browse the live github repository. You can contact -the Scala team by sending us a message on one of the mailing lists, or by using -the available contact form. - -In detail: - -- Scala website (links to everything else): - http://www.scala-lang.org - -- Scala documentation: - http://docs.scala-lang.org - -- Scala mailing lists: - http://www.scala-lang.org/node/199 - -- Scala bug and issue tracker: - https://issues.scala-lang.org - -- Scala live git source tree: - http://github.com/scala/scala - -If you are interested in contributing code, we ask you to sign the -[Scala Contributor License Agreement](http://typesafe.com/contribute/cla/scala), -which allows us to ensure that all code submitted to the project is -unencumbered by copyrights or patents. - -Before submitting a pull-request, please make sure you have followed the guidelines -outlined in our `Pull Request Policy <https://github.com/scala/scala/wiki/Pull-Request-Policy>`_. - ------------------- - - - -Thank you! - -The Scala Team diff --git a/gitignore.SAMPLE b/gitignore.SAMPLE deleted file mode 100644 index 7114225a4a..0000000000 --- a/gitignore.SAMPLE +++ /dev/null @@ -1,28 +0,0 @@ -# see also test/files/.gitignore -/.gitignore -/test/files/.gitignore - -*.jar -*~ - -# target directories for ant build -/build/ -/dists/ - -# other -/out/ -/bin/ -/sandbox/ - -# eclipse, intellij -/.classpath -/.project -/src/intellij/*.iml -/src/intellij/*.ipr -/src/intellij/*.iws -/.cache -/.idea -/.settings - -# bak files produced by ./cleanup-commit -*.bak diff --git a/lib/.gitignore b/lib/.gitignore deleted file mode 100644 index 0c507490be..0000000000 --- a/lib/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -ant-contrib.jar -ant-dotnet-1.0.jar -ant.jar -fjbg.jar -forkjoin.jar -jline.jar -maven-ant-tasks-2.1.1.jar -msil.jar -scala-compiler.jar -scala-compiler-src.jar -scala-library.jar -scala-library-src.jar -scala-reflect.jar -scala-reflect-src.jar -vizant.jar diff --git a/lib/scala-compiler-src.jar.desired.sha1 b/lib/scala-compiler-src.jar.desired.sha1 index debbce2d7e..e3fa18b018 100644 --- a/lib/scala-compiler-src.jar.desired.sha1 +++ b/lib/scala-compiler-src.jar.desired.sha1 @@ -1 +1 @@ -19d04510ac6f25d088da82527d8435b68c00153d ?scala-compiler-src.jar +d62bc132cba37b17c8d5ac65feb20193a3f8cc28 ?scala-compiler-src.jar diff --git a/lib/scala-compiler.jar.desired.sha1 b/lib/scala-compiler.jar.desired.sha1 index 4ec9610bae..68ac8d7e5c 100644 --- a/lib/scala-compiler.jar.desired.sha1 +++ b/lib/scala-compiler.jar.desired.sha1 @@ -1 +1 @@ -3585351c6a62186097be55fff88bee88a985f5c0 ?scala-compiler.jar +d049885894b93e12f034d4d871c38bfc4d026525 ?scala-compiler.jar diff --git a/lib/scala-library-src.jar.desired.sha1 b/lib/scala-library-src.jar.desired.sha1 index 6e97551fc7..5f74d96c66 100644 --- a/lib/scala-library-src.jar.desired.sha1 +++ b/lib/scala-library-src.jar.desired.sha1 @@ -1 +1 @@ -e606934dc00ced6bfac715bbdba427f9c2c18bc7 ?scala-library-src.jar +58db8f554695791217de332aa6500a7aa240e480 ?scala-library-src.jar diff --git a/lib/scala-library.jar.desired.sha1 b/lib/scala-library.jar.desired.sha1 index 36aedb2ad7..b7befab52a 100644 --- a/lib/scala-library.jar.desired.sha1 +++ b/lib/scala-library.jar.desired.sha1 @@ -1 +1 @@ -36456c52b0395fc1e6e367291e45bd503fa019c5 ?scala-library.jar +12007d1b1b913b563093b22e947e6c05fe40f3de ?scala-library.jar diff --git a/lib/scala-reflect-src.jar.desired.sha1 b/lib/scala-reflect-src.jar.desired.sha1 index ebd6dcbf5a..566111fd51 100644 --- a/lib/scala-reflect-src.jar.desired.sha1 +++ b/lib/scala-reflect-src.jar.desired.sha1 @@ -1 +1 @@ -51787a41cae5b0ec6910c5a1a6af392e17550856 ?scala-reflect-src.jar +c842d370d814515f15159cefa4b9c495d99bb1a9 ?scala-reflect-src.jar diff --git a/lib/scala-reflect.jar.desired.sha1 b/lib/scala-reflect.jar.desired.sha1 index 4378fec9d6..a6cdbc18ad 100644 --- a/lib/scala-reflect.jar.desired.sha1 +++ b/lib/scala-reflect.jar.desired.sha1 @@ -1 +1 @@ -d4a4c0aab882412461fbd9d39cf47da5a619855e ?scala-reflect.jar +a6595b3d7589085f683d4ad5a6072a057ab15ef9 ?scala-reflect.jar diff --git a/src/compiler/scala/reflect/macros/compiler/Errors.scala b/src/compiler/scala/reflect/macros/compiler/Errors.scala index a60a2c2306..6ec111cf7c 100644 --- a/src/compiler/scala/reflect/macros/compiler/Errors.scala +++ b/src/compiler/scala/reflect/macros/compiler/Errors.scala @@ -53,7 +53,7 @@ trait Errors extends Traces { // not exactly an error generator, but very related // and I dearly wanted to push it away from Macros.scala private def checkConforms(slot: String, rtpe: Type, atpe: Type) = { - val verbose = macroDebugVerbose || settings.explaintypes.value + val verbose = macroDebugVerbose def check(rtpe: Type, atpe: Type): Boolean = { def success() = { if (verbose) println(rtpe + " <: " + atpe + "?" + EOL + "true"); true } @@ -70,9 +70,12 @@ trait Errors extends Traces { if (verbose) withTypesExplained(check(rtpe, atpe)) else check(rtpe, atpe) if (!ok) { - if (!macroDebugVerbose) - explainTypes(rtpe, atpe) - compatibilityError("type mismatch for %s: %s does not conform to %s".format(slot, abbreviateCoreAliases(rtpe.toString), abbreviateCoreAliases(atpe.toString))) + if (!verbose) explainTypes(rtpe, atpe) + val msg = { + val ss = Seq(rtpe, atpe) map (this abbreviateCoreAliases _.toString) + s"type mismatch for $slot: ${ss(0)} does not conform to ${ss(1)}" + } + compatibilityError(msg) } } @@ -106,8 +109,8 @@ trait Errors extends Traces { def MacroImplTargMismatchError(atargs: List[Type], atparams: List[Symbol]) = compatibilityError(NotWithinBoundsErrorMessage("", atargs, atparams, macroDebugVerbose || settings.explaintypes.value)) - def MacroImplTparamInstantiationError(atparams: List[Symbol], ex: NoInstance) = - compatibilityError( - "type parameters "+(atparams map (_.defString) mkString ", ")+" cannot be instantiated\n"+ - ex.getMessage) -}
\ No newline at end of file + def MacroImplTparamInstantiationError(atparams: List[Symbol], e: NoInstance) = { + val badps = atparams map (_.defString) mkString ", " + compatibilityError(f"type parameters $badps cannot be instantiated%n${e.getMessage}") + } +} diff --git a/src/compiler/scala/reflect/reify/codegen/GenAnnotationInfos.scala b/src/compiler/scala/reflect/reify/codegen/GenAnnotationInfos.scala index 5a454e1e07..bd60faf4cd 100644 --- a/src/compiler/scala/reflect/reify/codegen/GenAnnotationInfos.scala +++ b/src/compiler/scala/reflect/reify/codegen/GenAnnotationInfos.scala @@ -45,6 +45,8 @@ trait GenAnnotationInfos { mirrorFactoryCall(nme.ArrayAnnotArg, scalaFactoryCall(nme.Array, args map reifyClassfileAnnotArg: _*)) case NestedAnnotArg(ann) => mirrorFactoryCall(nme.NestedAnnotArg, reifyAnnotationInfo(ann)) + case _ => + sys.error(s"Don't know what to do with $arg") } // if you reify originals of anns, you get SO when trying to reify AnnotatedTypes, so screw it - after all, it's not that important diff --git a/src/compiler/scala/reflect/reify/phases/Reshape.scala b/src/compiler/scala/reflect/reify/phases/Reshape.scala index 5f53f558b4..ae4a03d232 100644 --- a/src/compiler/scala/reflect/reify/phases/Reshape.scala +++ b/src/compiler/scala/reflect/reify/phases/Reshape.scala @@ -231,13 +231,10 @@ trait Reshape { val args = if (ann.assocs.isEmpty) { ann.args } else { - def toScalaAnnotation(jann: ClassfileAnnotArg): Tree = jann match { - case LiteralAnnotArg(const) => - Literal(const) - case ArrayAnnotArg(arr) => - Apply(Ident(definitions.ArrayModule), arr.toList map toScalaAnnotation) - case NestedAnnotArg(ann) => - toPreTyperAnnotation(ann) + def toScalaAnnotation(jann: ClassfileAnnotArg): Tree = (jann: @unchecked) match { + case LiteralAnnotArg(const) => Literal(const) + case ArrayAnnotArg(arr) => Apply(Ident(definitions.ArrayModule), arr.toList map toScalaAnnotation) + case NestedAnnotArg(ann) => toPreTyperAnnotation(ann) } ann.assocs map { case (nme, arg) => AssignOrNamedArg(Ident(nme), toScalaAnnotation(arg)) } diff --git a/src/compiler/scala/tools/nsc/Phases.scala b/src/compiler/scala/tools/nsc/Phases.scala deleted file mode 100644 index e379afce9b..0000000000 --- a/src/compiler/scala/tools/nsc/Phases.scala +++ /dev/null @@ -1,43 +0,0 @@ -/* NSC -- new Scala compiler - * Copyright 2005-2013 LAMP/EPFL - * @author Martin Odersky - */ - -package scala.tools.nsc - -import scala.reflect.internal.util.TableDef -import scala.language.postfixOps - -@deprecated("Scheduled for removal as being a dead-code in the compiler.", "2.10.1") -object Phases { - val MaxPhases = 64 - - /** A class for tracking something about each phase. - */ - class Model[T] { - case class Cell(ph: Phase, value: T) { - def name = ph.name - def id = ph.id - } - val values = new Array[Cell](MaxPhases + 1) - def results = values filterNot (_ == null) - def update(ph: Phase, value: T): Unit = values(ph.id) = Cell(ph, value) - } - /** A class for recording the elapsed time of each phase in the - * interests of generating a classy and informative table. - */ - class TimingModel extends Model[Long] { - var total: Long = 0 - def table() = { - total = results map (_.value) sum; - new Format.Table(results sortBy (-_.value)) - } - object Format extends TableDef[Cell] { - >> ("phase" -> (_.name)) >+ " " - << ("id" -> (_.id)) >+ " " - >> ("ms" -> (_.value)) >+ " " - << ("share" -> (_.value.toDouble * 100 / total formatted "%.2f")) - } - } -} - diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index 03cdead472..2a8412b105 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -952,9 +952,8 @@ trait Scanners extends ScannersCommon { } if (value > limit) syntaxError("floating point number too large") - if (isDeprecatedForm) { - deprecationWarning("This lexical syntax is deprecated. From scala 2.11, a dot will only be considered part of a number if it is immediately followed by a digit.") - } + if (isDeprecatedForm) + syntaxError("floating point number is missing digit after dot") if (negated) -value else value } catch { @@ -1010,10 +1009,8 @@ trait Scanners extends ScannersCommon { val lookahead = lookaheadReader val c = lookahead.getc() - /* As of scala 2.11, it isn't a number unless c here is a digit, so - * settings.future.value excludes the rest of the logic. - */ - if (settings.future && !isDigit(c)) + /* Prohibit 1. */ + if (!isDigit(c)) return setStrVal() val isDefinitelyNumber = (c: @switch) match { diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala index 62270b7c0a..182209dfe6 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala @@ -654,7 +654,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { def emitArgument(av: asm.AnnotationVisitor, name: String, arg: ClassfileAnnotArg) { - arg match { + (arg: @unchecked) match { case LiteralAnnotArg(const) => if (const.isNonUnitAnyVal) { av.visit(name, const.value) } diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala index ea2cbbe3d3..4cb2f514ec 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala @@ -932,7 +932,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { def emitArgument(av: asm.AnnotationVisitor, name: String, arg: ClassfileAnnotArg) { - arg match { + (arg: @unchecked) match { case LiteralAnnotArg(const) => if(const.isNonUnitAnyVal) { av.visit(name, const.value) } diff --git a/src/compiler/scala/tools/nsc/dependencies/Changes.scala b/src/compiler/scala/tools/nsc/dependencies/Changes.scala deleted file mode 100644 index 81d64421b3..0000000000 --- a/src/compiler/scala/tools/nsc/dependencies/Changes.scala +++ /dev/null @@ -1,221 +0,0 @@ -package scala.tools.nsc -package dependencies - -import symtab.Flags - -import scala.collection._ - -/** A component that describes the possible changes between successive - * compilations of a class. - */ -abstract class Changes { - - /** A compiler instance used to compile files on demand. */ - val compiler: Global - - import compiler._ - import symtab.Flags._ - - sealed abstract class Change - - private lazy val annotationsChecked = - List(definitions.SpecializedClass) // Any others that should be checked? - - private val flagsToCheck = IMPLICIT | FINAL | PRIVATE | PROTECTED | SEALED | - OVERRIDE | CASE | ABSTRACT | DEFERRED | METHOD | - MODULE | INTERFACE | PARAM | BYNAMEPARAM | CONTRAVARIANT | - DEFAULTPARAM | ACCESSOR | LAZY | SPECIALIZED - - /** Are the new modifiers more restrictive than the old ones? */ - private def moreRestrictive(from: Long, to: Long): Boolean = - ((((to & PRIVATE) != 0L) && (from & PRIVATE) == 0L) - || (((to & PROTECTED) != 0L) && (from & PROTECTED) == 0L)) - - /** Check if flags have changed **/ - private def modifiedFlags(from: Long, to: Long): Boolean = - (from & IMPLICIT) != (to & IMPLICIT) - - /** An entity in source code, either a class or a member definition. - * Name is fully-qualified. - */ - sealed abstract class Entity - case class Class(name: String) extends Entity - case class Definition(name: String) extends Entity - - case class Added(e: Entity) extends Change - case class Removed(e: Entity) extends Change - case class Changed(e: Entity)(implicit val reason: String) extends Change { - override def toString = "Changed(" + e + ")[" + reason + "]" - } - case class ParentChanged(e: Entity) extends Change - - private val changedTypeParams = new mutable.HashSet[String] - - private def sameParameterSymbolNames(sym1: Symbol, sym2: Symbol): Boolean = - sameSymbol(sym1, sym2, simple = true) || sym2.encodedName.startsWith(sym1.encodedName + nme.NAME_JOIN_STRING) // see #3140 - private def sameSymbol(sym1: Symbol, sym2: Symbol, simple: Boolean = false): Boolean = - if (simple) sym1.encodedName == sym2.encodedName else sym1.fullName == sym2.fullName - private def sameFlags(sym1: Symbol, sym2: Symbol): Boolean = - (sym1.flags & flagsToCheck) == (sym2.flags & flagsToCheck) - private def sameAnnotations(sym1: Symbol, sym2: Symbol): Boolean = - annotationsChecked.forall(a => - (sym1.hasAnnotation(a) == sym2.hasAnnotation(a))) - - private def sameType(tp1: Type, tp2: Type)(implicit strict: Boolean) = sameType0(tp1, tp2) - - private def sameType0(tp1: Type, tp2: Type)(implicit strict: Boolean): Boolean = ((tp1, tp2) match { - /*case (ErrorType, _) => false - case (WildcardType, _) => false - case (_, ErrorType) => false - case (_, WildcardType) => false - */ - case (NoType, _) => false - case (NoPrefix, NoPrefix) => true - case (_, NoType) => false - case (_, NoPrefix) => false - - case (ThisType(sym1), ThisType(sym2)) - if sameSymbol(sym1, sym2) => true - - case (SingleType(pre1, sym1), SingleType(pre2, sym2)) - if sameType(pre1, pre2) && sameSymbol(sym1, sym2) => true - case (ConstantType(value1), ConstantType(value2)) => - value1 == value2 - case (TypeRef(pre1, sym1, args1), TypeRef(pre2, sym2, args2)) => - val testSymbols = - if (!sameSymbol(sym1, sym2)) { - val v = (!strict && sym1.isType && sym2.isType && sameType(sym1.info, sym2.info)) - if (v) changedTypeParams += sym1.fullName - v - } else - !sym1.isTypeParameter || !changedTypeParams.contains(sym1.fullName) - - // @M! normalize reduces higher-kinded case to PolyType's - testSymbols && sameType(pre1, pre2) && - (sym1.variance == sym2.variance) && - ((tp1.isHigherKinded && tp2.isHigherKinded && tp1.normalize =:= tp2.normalize) || - sameTypes(args1, args2)) - - case (RefinedType(parents1, ref1), RefinedType(parents2, ref2)) => - def isSubScope(s1: Scope, s2: Scope): Boolean = s2.toList.forall { - sym2 => - var e1 = s1.lookupEntry(sym2.name) - (e1 ne null) && { - var isEqual = false - while (!isEqual && (e1 ne null)) { - isEqual = sameType(e1.sym.info, sym2.info) - e1 = s1.lookupNextEntry(e1) - } - isEqual - } - } - sameTypes(parents1, parents2) && isSubScope(ref1, ref2) && isSubScope(ref2, ref1) - case (mt1 @ MethodType(params1, res1), mt2 @ MethodType(params2, res2)) => - // new dependent types: probably fix this, use substSym as done for PolyType - sameTypes(tp1.paramTypes, tp2.paramTypes) && - (tp1.params corresponds tp2.params)((t1, t2) => sameParameterSymbolNames(t1, t2) && sameFlags(t1, t2)) && - sameType(res1, res2) && - mt1.isImplicit == mt2.isImplicit - case (PolyType(tparams1, res1), PolyType(tparams2, res2)) => - sameTypeParams(tparams1, tparams2) && sameType(res1, res2) - case (NullaryMethodType(res1), NullaryMethodType(res2)) => - sameType(res1, res2) - case (ExistentialType(tparams1, res1), ExistentialType(tparams2, res2)) => - sameTypeParams(tparams1, tparams2)(strict = false) && sameType(res1, res2)(strict = false) - case (TypeBounds(lo1, hi1), TypeBounds(lo2, hi2)) => - sameType(lo1, lo2) && sameType(hi1, hi2) - case (BoundedWildcardType(bounds), _) => - bounds containsType tp2 - case (_, BoundedWildcardType(bounds)) => - bounds containsType tp1 - case (AnnotatedType(_,_,_), _) => - annotationsConform(tp1, tp2) && annotationsConform(tp2, tp1) && - sameType(tp1.withoutAnnotations, tp2.withoutAnnotations) - case (_, AnnotatedType(_,_,_)) => - annotationsConform(tp1, tp2) && annotationsConform(tp2, tp1) && - sameType(tp1.withoutAnnotations, tp2.withoutAnnotations) - case (_: SingletonType, _: SingletonType) => - var origin1 = tp1 - while (origin1.underlying.isInstanceOf[SingletonType]) { - assert(origin1 ne origin1.underlying, origin1) - origin1 = origin1.underlying - } - var origin2 = tp2 - while (origin2.underlying.isInstanceOf[SingletonType]) { - assert(origin2 ne origin2.underlying, origin2) - origin2 = origin2.underlying - } - ((origin1 ne tp1) || (origin2 ne tp2)) && sameType(origin1, origin2) - case _ => - false - }) || { - val tp1n = normalizePlus(tp1) - val tp2n = normalizePlus(tp2) - ((tp1n ne tp1) || (tp2n ne tp2)) && sameType(tp1n, tp2n) - } - - private def sameTypeParams(tparams1: List[Symbol], tparams2: List[Symbol])(implicit strict: Boolean) = - sameTypes(tparams1 map (_.info), tparams2 map (_.info)) && - sameTypes(tparams1 map (_.tpe), tparams2 map (_.tpe)) && - (tparams1 corresponds tparams2)((t1, t2) => sameAnnotations(t1, t2)) - - private def sameTypes(tps1: List[Type], tps2: List[Type])(implicit strict: Boolean) = - (tps1 corresponds tps2)(sameType(_, _)) - - /** Return the list of changes between 'from' and 'toSym.info'. - */ - def changeSet(from: Type, toSym: Symbol): List[Change] = { - implicit val defaultStrictTypeRefTest = true - - val to = toSym.info - changedTypeParams.clear() - def omitSymbols(s: Symbol): Boolean = !s.hasFlag(LOCAL | LIFTED | PRIVATE | SYNTHETIC) - val cs = new mutable.ListBuffer[Change] - - if ((from.parents zip to.parents) exists { case (t1, t2) => !sameType(t1, t2) }) - cs += Changed(toEntity(toSym))(from.parents.zip(to.parents).toString) - if (!sameTypeParams(from.typeParams, to.typeParams)(strict = false)) - cs += Changed(toEntity(toSym))(" tparams: " + from.typeParams.zip(to.typeParams)) - - // new members not yet visited - val newMembers = mutable.HashSet[Symbol]() - newMembers ++= to.decls.iterator filter omitSymbols - - for (o <- from.decls.iterator filter omitSymbols) { - val n = to.decl(o.name) - newMembers -= n - - if (o.isClass) - cs ++= changeSet(o.info, n) - else if (n == NoSymbol) - cs += Removed(toEntity(o)) - else { - val newSym = - o match { - case _:TypeSymbol if o.isAliasType => - n.suchThat(ov => sameType(ov.info, o.info)) - case _ => - n.suchThat(ov => sameType(ov.tpe, o.tpe)) - } - if (newSym == NoSymbol || moreRestrictive(o.flags, newSym.flags) || modifiedFlags(o.flags, newSym.flags)) - cs += Changed(toEntity(o))(n + " changed from " + o.tpe + " to " + n.tpe + " flags: " + Flags.flagsToString(o.flags)) - else if (newSym.isGetter && (o.accessed(from).hasFlag(MUTABLE) != newSym.accessed.hasFlag(MUTABLE))) - // o.owner is already updated to newSym.owner - // so o.accessed will return the accessed for the new owner - cs += Changed(toEntity(o))(o.accessed(from) + " changed to " + newSym.accessed) - else - newMembers -= newSym - } - }: Unit // Give the type explicitly until #2281 is fixed - - cs ++= (newMembers map (Added compose toEntity)) - cs.toList - } - def removeChangeSet(sym: Symbol): Change = Removed(toEntity(sym)) - def changeChangeSet(sym: Symbol, msg: String): Change = Changed(toEntity(sym))(msg) - def parentChangeSet(sym: Symbol): Change = ParentChanged(toEntity(sym)) - - private def toEntity(sym: Symbol): Entity = - if (sym.isClass) Class(sym.fullName) - else Definition(sym.fullName) -} diff --git a/src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala index c9718f711a..8b897b83b2 100644 --- a/src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala @@ -33,11 +33,4 @@ trait AbsScalaSettings { def PhasesSetting(name: String, descr: String, default: String): PhasesSetting def StringSetting(name: String, helpArg: String, descr: String, default: String): StringSetting def PrefixSetting(name: String, prefix: String, descr: String): PrefixSetting - - /** **/ - abstract class SettingGroup(val prefix: String) extends AbsSetting { - def name = prefix - def helpDescription: String = sys.error("todo") - def unparse: List[String] = List(name) - } } diff --git a/src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala index d173aaa848..37dfafb01c 100644 --- a/src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala @@ -35,8 +35,6 @@ trait StandardScalaSettings { val feature = BooleanSetting ("-feature", "Emit warning and location for usages of features that should be imported explicitly.") val g = ChoiceSetting ("-g", "level", "Set level of generated debugging info.", List("none", "source", "line", "vars", "notailcalls"), "vars") val help = BooleanSetting ("-help", "Print a synopsis of standard options") - val make = ChoiceSetting ("-make", "policy", "Recompilation detection policy", List("all", "changed", "immediate", "transitive", "transitivenocp"), "all") - . withDeprecationMessage ("this option is unmaintained. Use sbt or an IDE for selective recompilation.") val nowarn = BooleanSetting ("-nowarn", "Generate no warnings.") val optimise: BooleanSetting // depends on post hook which mutates other settings val print = BooleanSetting ("-print", "Print program with Scala-specific features removed.") diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala index 3265af9f5b..9bad29097c 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala @@ -486,14 +486,10 @@ abstract class Pickler extends SubComponent { } } def putClassfileAnnotArg(carg: ClassfileAnnotArg) { - carg match { - case LiteralAnnotArg(const) => - putConstant(const) - case ArrayAnnotArg(args) => - if (putEntry(carg)) - args foreach putClassfileAnnotArg - case NestedAnnotArg(annInfo) => - putAnnotation(annInfo) + (carg: @unchecked) match { + case LiteralAnnotArg(const) => putConstant(const) + case ArrayAnnotArg(args) => if (putEntry(carg)) args foreach putClassfileAnnotArg + case NestedAnnotArg(annInfo) => putAnnotation(annInfo) } } val AnnotationInfo(tpe, args, assocs) = annot @@ -559,13 +555,10 @@ abstract class Pickler extends SubComponent { /** Write a ClassfileAnnotArg (argument to classfile annotation) */ def writeClassfileAnnotArg(carg: ClassfileAnnotArg) { - carg match { - case LiteralAnnotArg(const) => - writeRef(const) - case ArrayAnnotArg(args) => - writeRef(carg) - case NestedAnnotArg(annInfo) => - writeRef(annInfo) + (carg: @unchecked) match { + case LiteralAnnotArg(const) => writeRef(const) + case ArrayAnnotArg(args) => writeRef(carg) + case NestedAnnotArg(annInfo) => writeRef(annInfo) } } diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 1282cfb416..e8a1e8e85a 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -35,7 +35,8 @@ trait Namers extends MethodSynthesis { } def apply(tree: Tree) = { val r = transform(tree) - if (r.exists(_.isEmpty)) TypeTree() + if (r exists { case tt: TypeTree => tt.isEmpty case _ => false }) + TypeTree() else r } } diff --git a/src/compiler/scala/tools/nsc/util/package.scala b/src/compiler/scala/tools/nsc/util/package.scala index 1e43d18900..752aac5c8c 100644 --- a/src/compiler/scala/tools/nsc/util/package.scala +++ b/src/compiler/scala/tools/nsc/util/package.scala @@ -86,12 +86,6 @@ package object util { @deprecated("Moved to scala.reflect.internal.util.StringOps", "2.10.0") type StringOps = scala.reflect.internal.util.StringOps - @deprecated("Moved to scala.reflect.internal.util.TableDef", "2.10.0") - val TableDef = scala.reflect.internal.util.TableDef - - @deprecated("Moved to scala.reflect.internal.util.TableDef", "2.10.0") - type TableDef[T] = scala.reflect.internal.util.TableDef[T] - @deprecated("scala.reflect.internal.util.WeakHashSet", "2.10.0") type WeakHashSet[T <: AnyRef] = scala.reflect.internal.util.WeakHashSet[T] diff --git a/src/library/scala/collection/mutable/DefaultMapModel.scala b/src/library/scala/collection/mutable/DefaultMapModel.scala index 4dfae047c3..0088620540 100644 --- a/src/library/scala/collection/mutable/DefaultMapModel.scala +++ b/src/library/scala/collection/mutable/DefaultMapModel.scala @@ -19,6 +19,7 @@ package mutable * @version 1.0, 08/07/2003 * @since 1 */ +@deprecated("This trait will be removed.", "2.11.0") trait DefaultMapModel[A, B] extends Map[A, B] { type Entry = DefaultEntry[A, B] diff --git a/src/library/scala/concurrent/Promise.scala b/src/library/scala/concurrent/Promise.scala index f950b13b78..cdde019cd0 100644 --- a/src/library/scala/concurrent/Promise.scala +++ b/src/library/scala/concurrent/Promise.scala @@ -82,7 +82,7 @@ trait Promise[T] { /** Completes the promise with a value. * - * @param v The value to complete the promise with. + * @param value The value to complete the promise with. * * $promiseCompletion */ @@ -98,7 +98,7 @@ trait Promise[T] { /** Completes the promise with an exception. * - * @param t The throwable to complete the promise with. + * @param cause The throwable to complete the promise with. * * $allowedThrowables * diff --git a/src/library/scala/sys/process/ProcessBuilder.scala b/src/library/scala/sys/process/ProcessBuilder.scala index c8e548c76b..adf5a4f6b2 100644 --- a/src/library/scala/sys/process/ProcessBuilder.scala +++ b/src/library/scala/sys/process/ProcessBuilder.scala @@ -127,7 +127,7 @@ import ProcessBuilder._ * * Finally, `!` at the end executes the commands, and returns the exit value. * Whatever is printed will be sent to the Scala process standard output. If - * we wanted to caputre it, we could run that with `!!` instead. + * we wanted to capture it, we could run that with `!!` instead. * * Note: though it is not shown above, the equivalent of a shell's `;` would be * `###`. The reason for this name is that `;` is a reserved token in Scala. diff --git a/src/library/scala/text/Document.scala b/src/library/scala/text/Document.scala index 59d5b1bf93..aa55ac4f0f 100644 --- a/src/library/scala/text/Document.scala +++ b/src/library/scala/text/Document.scala @@ -10,11 +10,17 @@ package scala.text import java.io.Writer +@deprecated("This object will be removed.", "2.11.0") case object DocNil extends Document +@deprecated("This object will be removed.", "2.11.0") case object DocBreak extends Document +@deprecated("This class will be removed.", "2.11.0") case class DocText(txt: String) extends Document +@deprecated("This class will be removed.", "2.11.0") case class DocGroup(doc: Document) extends Document +@deprecated("This class will be removed.", "2.11.0") case class DocNest(indent: Int, doc: Document) extends Document +@deprecated("This class will be removed.", "2.11.0") case class DocCons(hd: Document, tl: Document) extends Document /** @@ -24,6 +30,7 @@ case class DocCons(hd: Document, tl: Document) extends Document * @author Michel Schinz * @version 1.0 */ +@deprecated("This class will be removed.", "2.11.0") abstract class Document { def ::(hd: Document): Document = DocCons(hd, this) def ::(hd: String): Document = DocCons(DocText(hd), this) @@ -96,6 +103,7 @@ abstract class Document { } } +@deprecated("This object will be removed.", "2.11.0") object Document { /** The empty document */ def empty = DocNil diff --git a/src/library/scala/util/Either.scala b/src/library/scala/util/Either.scala index 1ed3f4becb..523270b31c 100644 --- a/src/library/scala/util/Either.scala +++ b/src/library/scala/util/Either.scala @@ -216,7 +216,7 @@ object Either { * r.merge: Seq[Int] // Vector(1) * }}} */ - implicit class MergeableEither[A](x: Either[A, A]) { + implicit class MergeableEither[A](val x: Either[A, A]) extends AnyVal { def merge: A = x match { case Left(a) => a case Right(a) => a diff --git a/src/reflect/scala/reflect/api/Importers.scala b/src/reflect/scala/reflect/api/Importers.scala index e6f314b712..4182b7d0ba 100644 --- a/src/reflect/scala/reflect/api/Importers.scala +++ b/src/reflect/scala/reflect/api/Importers.scala @@ -9,7 +9,7 @@ package api * ''Note: this trait should typically be used only rarely.'' * * Reflection artifacts, such as [[scala.reflect.api.Symbols Symbols]] and [[scala.reflect.api.Types Types]], - * are contained in [[scala.reflect.api.Universes Universe]]s. Typically all processing happens + * are contained in [[scala.reflect.api.Universe Universe]]s. Typically all processing happens * within a single `Universe` (e.g. a compile-time macro `Universe` or a runtime reflection `Universe`), but sometimes * there is a need to migrate artifacts from one `Universe` to another. For example, runtime compilation works by * importing runtime reflection trees into a runtime compiler universe, compiling the importees and exporting the @@ -101,4 +101,4 @@ trait Importers { self: Universe => */ def importPosition(pos: from.Position): Position } -}
\ No newline at end of file +} diff --git a/src/reflect/scala/reflect/internal/Importers.scala b/src/reflect/scala/reflect/internal/Importers.scala index f8584ac9b0..b0828e9c54 100644 --- a/src/reflect/scala/reflect/internal/Importers.scala +++ b/src/reflect/scala/reflect/internal/Importers.scala @@ -434,6 +434,8 @@ trait Importers extends api.Importers { to: SymbolTable => ScalaSigBytes(bytes) case from.NestedAnnotArg(annInfo) => NestedAnnotArg(importAnnotationInfo(annInfo)) + case from.UnmappableAnnotArg => + UnmappableAnnotArg } // todo. careful import of positions diff --git a/src/reflect/scala/reflect/internal/util/TableDef.scala b/src/reflect/scala/reflect/internal/util/TableDef.scala index 1626da2c93..e97aa662d8 100644 --- a/src/reflect/scala/reflect/internal/util/TableDef.scala +++ b/src/reflect/scala/reflect/internal/util/TableDef.scala @@ -5,27 +5,24 @@ import TableDef._ import scala.language.postfixOps /** A class for representing tabular data in a way that preserves - * its inner beauty. See Exceptional for an example usage. + * its inner beauty. * One creates an instance of TableDef by defining the columns of * the table, then uses that to create an instance of Table by * passing in a sequence of rows. */ class TableDef[T](_cols: Column[T]*) { - /** These operators are about all there is to it. - * - * ~ appends a column to the table - * >> creates a right-justified column and appends it - * << creates a left-justified column and appends it - * >+ specifies a string to separate the previous column from the next. - * if none is specified, a space is used. - */ + // These operators are about all there is to it. + /** Appends a column to the table. */ def ~(next: Column[T]) = retThis(cols :+= next) + /** Creates a right-justified column and appends it. */ def >>(pair: (String, T => Any)) = this ~ Column(pair._1, pair._2, left = false) + /** Creates a left-justified column and appends it. */ def <<(pair: (String, T => Any)) = this ~ Column(pair._1, pair._2, left = true) + /** Specifies a string to separate the previous column from the next. + * If none is specified, a space is used. */ def >+(sep: String) = retThis(separators += ((cols.size - 1, sep))) - /** Below this point should all be considered private/internal. - */ + // Below this point should all be considered private/internal. private var cols: List[Column[T]] = _cols.toList private var separators: Map[Int, String] = Map() diff --git a/src/repl/scala/tools/nsc/interpreter/JLineReader.scala b/src/repl/scala/tools/nsc/interpreter/JLineReader.scala index d8a876feb2..8b0c6d78fa 100644 --- a/src/repl/scala/tools/nsc/interpreter/JLineReader.scala +++ b/src/repl/scala/tools/nsc/interpreter/JLineReader.scala @@ -34,6 +34,9 @@ class JLineReader(_completion: => Completion) extends InteractiveReader { } class JLineConsoleReader extends ConsoleReader with ConsoleReaderHelper { + // ASAP + this setExpandEvents false + // working around protected/trait/java insufficiencies. def goBack(num: Int): Unit = back(num) if ((history: History) ne NoHistory) diff --git a/src/repl/scala/tools/nsc/interpreter/JavapClass.scala b/src/repl/scala/tools/nsc/interpreter/JavapClass.scala index ef6f4c2920..49bdd69a8b 100644 --- a/src/repl/scala/tools/nsc/interpreter/JavapClass.scala +++ b/src/repl/scala/tools/nsc/interpreter/JavapClass.scala @@ -44,33 +44,78 @@ class JavapClass( val (flags, upgraded) = upgrade(options) import flags.{ app, fun, help, raw } val targets = if (fun && !help) FunFinder(loader, intp).funs(claases) else claases - if (help || claases.isEmpty) List(JpResult(JavapTool.helper(printWriter))) - else if (targets.isEmpty) List(JpResult("No anonfuns found.")) - else tool(raw, upgraded)(targets map (claas => claas -> bytesFor(claas, app))) + if (help || claases.isEmpty) + List(JpResult(JavapTool.helper(printWriter))) + else if (targets.isEmpty) + List(JpResult("No anonfuns found.")) + else + tool(raw, upgraded)(targets map (claas => targeted(claas, app))) } /** Cull our tool options. */ - private def upgrade(options: Seq[String]): (ToolArgs, Seq[String]) = ToolArgs fromArgs options match { - case (t,s) if s.nonEmpty => (t,s) - case (t,s) => (t, JavapTool.DefaultOptions) - } + private def upgrade(options: Seq[String]): (ToolArgs, Seq[String]) = + ToolArgs fromArgs options match { + case (t, s) if s.nonEmpty => (t, s) + case (t, s) => (t, JavapTool.DefaultOptions) + } + + /** Associate the requested path with a possibly failed or empty array of bytes. */ + private def targeted(path: String, app: Boolean): (String, Try[Array[Byte]]) = + bytesFor(path, app) match { + case Success((target, bytes)) => (target, Try(bytes)) + case f: Failure[_] => (path, Failure(f.exception)) + } /** Find bytes. Handle "-", "-app", "Foo#bar" (by ignoring member), "#bar" (by taking "bar"). */ private def bytesFor(path: String, app: Boolean) = Try { def last = intp.get.mostRecentVar // fail if no intp - def req = if (path == "-") last else { - val s = path.splitHashMember - if (s._1.nonEmpty) s._1 - else s._2 getOrElse "#" + def req = path match { + case "-" => last + case HashSplit(prefix, member) => + if (prefix != null) prefix + else if (member != null) member + else "#" + } + val targetedBytes = if (app) findAppBody(req) else (req, findBytes(req)) + if (targetedBytes._2.isEmpty) throw new FileNotFoundException(s"Could not find class bytes for '$path'") + targetedBytes + } + + private def findAppBody(path: String): (String, Array[Byte]) = { + // is this new style delayedEndpoint? then find it. + // the name test is naive. could add $mangled path. + // assumes only the first match is of interest (because only one endpoint is generated). + def findNewStyle(bytes: Array[Byte]) = { + import scala.tools.asm.ClassReader + import scala.tools.asm.tree.ClassNode + import PartialFunction.cond + import JavaConverters._ + val rdr = new ClassReader(bytes) + val nod = new ClassNode + rdr.accept(nod, 0) + //foo/Bar.delayedEndpoint$foo$Bar$1 + val endpoint = "delayedEndpoint".r.unanchored + def isEndPoint(s: String) = (s contains '$') && cond(s) { case endpoint() => true } + nod.methods.asScala collectFirst { case m if isEndPoint(m.name) => m.name } } - def asAppBody(s: String) = { - val (cls, fix) = s.splitSuffix - s"${cls}$$delayedInit$$body${fix}" + // try new style, and add foo#delayedEndpoint$bar$1 to filter on the endpoint + def asNewStyle(bytes: Array[Byte]) = Some(bytes) filter (_.nonEmpty) flatMap { bs => + findNewStyle(bs) map (n => (s"$path#$n", bs)) } - def todo = if (app) asAppBody(req) else req - val bytes = findBytes(todo) - if (bytes.isEmpty) throw new FileNotFoundException(s"Could not find class bytes for '${path}'") - else bytes + // use old style, and add foo# to filter on apply method + def asOldStyle = { + def asAppBody(s: String) = { + val (cls, fix) = s.splitSuffix + s"${cls}$$delayedInit$$body${fix}" + } + val oldStyle = asAppBody(path) + val oldBytes = findBytes(oldStyle) + if (oldBytes.nonEmpty) (s"$oldStyle#", oldBytes) + else (path, oldBytes) + } + + val pathBytes = findBytes(path) + asNewStyle(pathBytes) getOrElse asOldStyle } def findBytes(path: String): Array[Byte] = tryFile(path) getOrElse tryClass(path) @@ -496,6 +541,7 @@ object JavapClass { intp: Option[IMain] = None ) = new JavapClass(loader, printWriter, intp) + val HashSplit = "(.*?)(?:#([^#]*))?".r // We enjoy flexibility in specifying either a fully-qualified class name com.acme.Widget // or a resource path com/acme/Widget.class; but not widget.out implicit class MaybeClassLike(val s: String) extends AnyVal { diff --git a/src/scalap/scala/tools/scalap/scalax/rules/Arrows.scala b/src/scalap/scala/tools/scalap/scalax/rules/Arrows.scala deleted file mode 100644 index f8761ca0ed..0000000000 --- a/src/scalap/scala/tools/scalap/scalax/rules/Arrows.scala +++ /dev/null @@ -1,37 +0,0 @@ -package scala.tools.scalap -package scalax -package rules - -trait Arrows extends UnitFunctors { - type Arr[-A, +B] <: Arrow[A, B] - type M[+B] = Arr[Nothing, B] - - def arrow[A, B](f : A => B) : Arr[A, B] - def diag[A] = arrow[A, (A, A)] { a => (a, a) } - - override def unit[B](b : => B) : M[B] = arrow { any : Any => b } - - trait Arrow[-A, +B] extends Functor[B] { this : Arr[A, B] => - - def map[C](f : B => C) = comp(arrow(f)) - def comp[C](bc : => Arr[B, C]) : Arr[A, C] - def fst[C] : Arr[(A, C), (B, C)] - } -} - -trait ApplicativeArrows extends Arrows { - type Arr[-A, +B] <: ApplicativeArrow[A, B] - - def app[A, B] : Arr[(Arr[A, B], A), B] - - trait ApplicativeArrow[-A, +B] extends Arrow[A, B] { self : Arr[A, B] => - def flatMap[SubA <: A, C](f : B => Arr[SubA, C]) : Arr[SubA, C] = - diag[SubA].comp(map(f).fst[SubA]).comp(app[SubA, C]) - } -} - -trait ArrowMonads extends ApplicativeArrows with Monads { - type Arr[-A, +B] <: ApplicativeArrow[A, B] with Monad[B] - - override def unit[A](a : => A) : M[A] = arrow[Unit, A](Unit => a) -} diff --git a/src/scalap/scala/tools/scalap/scalax/rules/Functors.scala b/src/scalap/scala/tools/scalap/scalax/rules/Functors.scala deleted file mode 100644 index aa852c1e63..0000000000 --- a/src/scalap/scala/tools/scalap/scalax/rules/Functors.scala +++ /dev/null @@ -1,81 +0,0 @@ -// ----------------------------------------------------------------------------- -// -// Scalax - The Scala Community Library -// Copyright (c) 2005-8 The Scalax Project. All rights reserved. -// -// The primary distribution site is http://scalax.scalaforge.org/ -// -// This software is released under the terms of the Revised BSD License. -// There is NO WARRANTY. See the file LICENSE for the full text. -// -// ----------------------------------------------------------------------------- - -package scala.tools.scalap -package scalax -package rules - -trait Functor[+A] { - type M[+A] <: Functor[A] - def map[B](f : A => B) : M[B] -} - -trait Filter[+A] { - type M[+A] <: Filter[A] - def filter(f : A => Boolean) : M[A] -} - -trait Plus[+A] { - type M[+A] <: Plus[A] - def plus[B >: A](other : => M[B]) : M[B] -} - -trait OrElse[+A] { - type M[+A] <: OrElse[A] - def orElse[B >: A](other : => M[B]) : M[B] -} - -trait Units { - type M[+A] - def unit : M[Unit] - def unit[A](a : => A) : M[A] -} - -trait Zero { - type M[+A] - def zero : M[Nothing] -} - -trait Functors { - type M[+A] <: Functor[A] - - trait Functor[+A] extends rules.Functor[A] { this : M[A] => - type M[+A] = Functors.this.M[A] - } - - trait ZeroFunctor extends Functor[Nothing] { this : M[Nothing] => - override def map[B](f : Nothing => B) : M[B] = this - def filter(f : Nothing => Boolean) : M[Nothing] = this - def plus[B](other : => M[B]) : M[B] = other - def orElse[B](other : => M[B]) : M[B] = other - } -} - -/** One of the 'unit' definitions must be overridden in concrete subclasses */ -trait UnitFunctors extends Units with Functors { - def unit : M[Unit] = unit(()) - def unit[A](a : => A) : M[A] = unit map { Unit => a } -} - - -trait Monoidals extends UnitFunctors { - type M[+A] <: Monoidal[A] - - implicit def app[A, B](fab : M[A => B]) = (fa : M[A]) => fa applyTo fab - implicit def appUnit[A, B](a2b : A => B) = app(unit(a2b)) - - /** One of 'and' and 'applyTo' definitions must be overridden in concrete subclasses */ - trait Monoidal[+A] extends Functor[A] { self : M[A] => - def and[B](fb : => M[B]) : M[(A, B)] = ((a : A) => (b : B) => (a, b))(this)(fb) - def applyTo[B](fab : M[A => B]) : M[B] = fab and this map { case (f, a) => f(a) } - } -} diff --git a/src/scalap/scala/tools/scalap/scalax/rules/Input.scala b/src/scalap/scala/tools/scalap/scalax/rules/Input.scala deleted file mode 100644 index 370eb0d054..0000000000 --- a/src/scalap/scala/tools/scalap/scalax/rules/Input.scala +++ /dev/null @@ -1,68 +0,0 @@ -// ----------------------------------------------------------------------------- -// -// Scalax - The Scala Community Library -// Copyright (c) 2005-8 The Scalax Project. All rights reserved. -// -// The primary distribution site is http://scalax.scalaforge.org/ -// -// This software is released under the terms of the Revised BSD License. -// There is NO WARRANTY. See the file LICENSE for the full text. -// -// ----------------------------------------------------------------------------- - -package scala.tools.scalap -package scalax -package rules - -trait Input[+A] extends Iterable[A] { - - def next : Result[Input[A], A, Nothing] - def index : Int - - def iterator = new Iterator[A] { - private var input : Input[A] = Input.this - private var result = input.next - - def hasNext = result != Failure - def next = { - val Success(input, value) = result - this.input = input - this.result = input.next - value - } - } -} - - -class ArrayInput[A](val array : Array[A], val index : Int) extends Input[A] { - def this(array : Array[A]) = this(array, 0) - - lazy val next : Result[ArrayInput[A], A, Nothing] = if (index >= array.length) Failure - else Success(new ArrayInput[A](array, index + 1), array(index)) - - override lazy val toString = this.iterator.mkString("\"", "", "\"") -} - - -class IterableInput[A](iterator : Iterator[A], val index : Int) extends Input[A] { - def this(iterable : Iterable[A]) = this(iterable.iterator, 0) - - lazy val next : Result[IterableInput[A], A, Nothing] = if (!iterator.hasNext) Failure - else Success(new IterableInput(iterator, index + 1), iterator.next) - - override lazy val toString = this.iterator.mkString("\"", "", "\"") -} - - -/** View one type of input as another based on a transformation rule */ -class View[A, B]( - transform : Input[A] => Result[Input[A], B, Nothing], - val input : Input[A], - val index : Int) - extends Input[B] { - - def next : Result[Input[B], B, Nothing] = transform(input) match { - case Success(context, b) => Success(new View(transform, context, index + 1), b) - case _ => Failure - } -} diff --git a/src/scalap/scala/tools/scalap/scalax/rules/Monad.scala b/src/scalap/scala/tools/scalap/scalax/rules/Monad.scala deleted file mode 100644 index 639c414675..0000000000 --- a/src/scalap/scala/tools/scalap/scalax/rules/Monad.scala +++ /dev/null @@ -1,46 +0,0 @@ -// ----------------------------------------------------------------------------- -// -// Scalax - The Scala Community Library -// Copyright (c) 2005-8 The Scalax Project. All rights reserved. -// -// The primary distribution site is http://scalax.scalaforge.org/ -// -// This software is released under the terms of the Revised BSD License. -// There is NO WARRANTY. See the file LICENSE for the full text. -// -// ----------------------------------------------------------------------------- - -package scala.tools.scalap -package scalax -package rules - -trait Monad[+A] extends Functor[A] { - type M[+A] <: Monad[A] - def flatMap[B](f : A => M[B]) : M[B] -} - -trait Monads extends UnitFunctors { - type M[+A] <: Monad[A] - - trait Monad[+A] extends Functor[A] with rules.Monad[A] { this : M[A] => - def map[B](f : A => B) = flatMap { a => unit(f(a)) } - } - - trait ZeroMonad extends Monad[Nothing] with ZeroFunctor { this : M[Nothing] => - def flatMap[B](f : Nothing => M[B]) : M[B] = this - } -} - - -trait StateReader extends Monads { - type S - - def get : M[S] - def read[A](f : S => A) : M[A] - def set(s : => S) : M[S] - def update(f : S => S) : M[S] -} - - - - diff --git a/src/scalap/scala/tools/scalap/scalax/rules/package.scala b/src/scalap/scala/tools/scalap/scalax/rules/package.scala deleted file mode 100644 index b1cc18f90b..0000000000 --- a/src/scalap/scala/tools/scalap/scalax/rules/package.scala +++ /dev/null @@ -1,9 +0,0 @@ -package scala.tools.scalap -package scalax - -package object rules { - implicit lazy val higherKinds = scala.language.higherKinds - implicit lazy val postfixOps = scala.language.postfixOps - implicit lazy val implicitConversions = scala.language.implicitConversions - implicit lazy val reflectiveCalls = scala.language.reflectiveCalls -} diff --git a/starr.number b/starr.number index 89659fcbf3..d55aa7d7fc 100644 --- a/starr.number +++ b/starr.number @@ -1 +1 @@ -starr.version=2.11.0-M2
\ No newline at end of file +starr.version=2.11.0-M4
\ No newline at end of file diff --git a/test/files/gitignore.SAMPLE b/test/files/.gitignore index 161be5b55f..161be5b55f 100644 --- a/test/files/gitignore.SAMPLE +++ b/test/files/.gitignore diff --git a/test/files/codelib/.gitignore b/test/files/codelib/.gitignore deleted file mode 100644 index f77a26afb7..0000000000 --- a/test/files/codelib/.gitignore +++ /dev/null @@ -1 +0,0 @@ -code.jar diff --git a/test/files/lib/.gitignore b/test/files/lib/.gitignore deleted file mode 100644 index b4ac0b8789..0000000000 --- a/test/files/lib/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -annotations.jar -enums.jar -genericNest.jar -javac-artifacts.jar -jsoup-1.3.1.jar -methvsfield.jar -nest.jar -scalacheck.jar diff --git a/test/files/neg/ambiguous-float-dots.check b/test/files/neg/ambiguous-float-dots.check deleted file mode 100644 index cdd2d6fa2a..0000000000 --- a/test/files/neg/ambiguous-float-dots.check +++ /dev/null @@ -1,27 +0,0 @@ -ambiguous-float-dots.scala:2: warning: This lexical syntax is deprecated. From scala 2.11, a dot will only be considered part of a number if it is immediately followed by a digit. - val x0 = 5. - ^ -ambiguous-float-dots.scala:6: warning: This lexical syntax is deprecated. From scala 2.11, a dot will only be considered part of a number if it is immediately followed by a digit. - val x1 = 5.f - ^ -ambiguous-float-dots.scala:7: warning: Treating numbers with a leading zero as octal is deprecated. - val y0 = 055 - ^ -ambiguous-float-dots.scala:11: warning: This lexical syntax is deprecated. From scala 2.11, a dot will only be considered part of a number if it is immediately followed by a digit. - 1.+(2) - ^ -ambiguous-float-dots.scala:12: warning: This lexical syntax is deprecated. From scala 2.11, a dot will only be considered part of a number if it is immediately followed by a digit. - 1. + 2 - ^ -ambiguous-float-dots.scala:11: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses - 1.+(2) - ^ -ambiguous-float-dots.scala:12: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses - 1. + 2 - ^ -ambiguous-float-dots.scala:13: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses - 1 + 2 - ^ -error: No warnings can be incurred under -Xfatal-warnings. -8 warnings found -one error found diff --git a/test/files/neg/ambiguous-float-dots.flags b/test/files/neg/ambiguous-float-dots.flags deleted file mode 100644 index 65faf53579..0000000000 --- a/test/files/neg/ambiguous-float-dots.flags +++ /dev/null @@ -1 +0,0 @@ --Xfatal-warnings -deprecation
\ No newline at end of file diff --git a/test/files/neg/ambiguous-float-dots.scala b/test/files/neg/ambiguous-float-dots.scala deleted file mode 100644 index 87e948db35..0000000000 --- a/test/files/neg/ambiguous-float-dots.scala +++ /dev/null @@ -1,14 +0,0 @@ -class A { - val x0 = 5. -} - -class B { - val x1 = 5.f - val y0 = 055 -} - -class D { - 1.+(2) - 1. + 2 - 1 + 2 -} diff --git a/test/files/neg/ambiguous-float-dots2.check b/test/files/neg/ambiguous-float-dots2.check index 8919d2c6a8..40c9b4186d 100644 --- a/test/files/neg/ambiguous-float-dots2.check +++ b/test/files/neg/ambiguous-float-dots2.check @@ -1,10 +1,7 @@ -ambiguous-float-dots2.scala:7: error: Non-zero numbers may not have a leading zero. - val y0 = 055 - ^ ambiguous-float-dots2.scala:3: error: identifier expected but '}' found. } ^ -ambiguous-float-dots2.scala:12: error: ';' expected but integer literal found. +ambiguous-float-dots2.scala:11: error: ';' expected but integer literal found. 1. + 2 ^ -three errors found +two errors found diff --git a/test/files/neg/ambiguous-float-dots2.flags b/test/files/neg/ambiguous-float-dots2.flags deleted file mode 100644 index 112fc720a0..0000000000 --- a/test/files/neg/ambiguous-float-dots2.flags +++ /dev/null @@ -1 +0,0 @@ --Xfuture
\ No newline at end of file diff --git a/test/files/neg/ambiguous-float-dots2.scala b/test/files/neg/ambiguous-float-dots2.scala index 87e948db35..b1615c9273 100644 --- a/test/files/neg/ambiguous-float-dots2.scala +++ b/test/files/neg/ambiguous-float-dots2.scala @@ -4,7 +4,6 @@ class A { class B { val x1 = 5.f - val y0 = 055 } class D { diff --git a/test/files/neg/t6123-explaintypes-macros.check b/test/files/neg/t6123-explaintypes-macros.check new file mode 100644 index 0000000000..ebcb8069d5 --- /dev/null +++ b/test/files/neg/t6123-explaintypes-macros.check @@ -0,0 +1,9 @@ +c.universe.Expr[Any]* <: c.universe.Expr[String]*? +false +BadMac_2.scala:6: error: macro implementation has wrong shape: + required: (c: scala.reflect.macros.Context)(format: c.Expr[String], params: c.Expr[Any]*): c.Expr[Unit] + found : (c: scala.reflect.macros.Context)(format: c.Expr[String], params: c.Expr[String]*): c.Expr[Unit] +type mismatch for parameter params: c.Expr[Any]* does not conform to c.Expr[String]* + def printf(format: String, params: Any*): Unit = macro printf_impl + ^ +one error found diff --git a/test/files/pos/t6123-explaintypes-macros.flags b/test/files/neg/t6123-explaintypes-macros/BadMac_2.flags index b36707c7cf..b36707c7cf 100644 --- a/test/files/pos/t6123-explaintypes-macros.flags +++ b/test/files/neg/t6123-explaintypes-macros/BadMac_2.flags diff --git a/test/files/neg/t6123-explaintypes-macros/BadMac_2.scala b/test/files/neg/t6123-explaintypes-macros/BadMac_2.scala new file mode 100644 index 0000000000..38b8e24444 --- /dev/null +++ b/test/files/neg/t6123-explaintypes-macros/BadMac_2.scala @@ -0,0 +1,8 @@ +import scala.language.experimental.macros +import scala.reflect.macros.Context + +// explain some macro types to me +object BadMac { + def printf(format: String, params: Any*): Unit = macro printf_impl + def printf_impl(c: Context)(format: c.Expr[String], params: c.Expr[String]*): c.Expr[Unit] = ??? +} diff --git a/test/files/neg/t6123-explaintypes-macros/Macros.flags b/test/files/neg/t6123-explaintypes-macros/Macros.flags new file mode 100644 index 0000000000..b36707c7cf --- /dev/null +++ b/test/files/neg/t6123-explaintypes-macros/Macros.flags @@ -0,0 +1 @@ +-explaintypes diff --git a/test/files/pos/t6123-explaintypes-macros.scala b/test/files/neg/t6123-explaintypes-macros/Macros.scala index e650ad2038..a12c277c86 100644 --- a/test/files/pos/t6123-explaintypes-macros.scala +++ b/test/files/neg/t6123-explaintypes-macros/Macros.scala @@ -5,3 +5,6 @@ object Macros { def printf(format: String, params: Any*): Unit = macro printf_impl def printf_impl(c: Context)(format: c.Expr[String], params: c.Expr[Any]*): c.Expr[Unit] = ??? } + +// something trivial to run +object Test extends App diff --git a/test/files/pos/t2081.scala b/test/files/pos/t2081.scala index d772c02dc2..f4f21600c6 100644 --- a/test/files/pos/t2081.scala +++ b/test/files/pos/t2081.scala @@ -7,5 +7,5 @@ object ScalaForRubyists { val x = 10.days // a couple parser corner cases I wanted not to break - val y = 5.e0 + 5e7 + val y = 5.0e0 + 5e7 } diff --git a/test/files/pos/t7689.scala b/test/files/pos/t7689.scala new file mode 100644 index 0000000000..022e7ab7a0 --- /dev/null +++ b/test/files/pos/t7689.scala @@ -0,0 +1,7 @@ +object A { + // The default getter must have an explicit return type (List[_] => Int) + // This wasn't happening since e28c3edda4. That commit encoded upper/lower + // bounds of Any/Nothing as EmptyTree, which were triggering an .isEmpty + // check in Namers#TypeTreeSubstitutor + def x(f: List[_] => Int = _ => 3) = 9 +} diff --git a/test/files/run/repl-javap-app.check b/test/files/run/repl-javap-app.check new file mode 100644 index 0000000000..db1f09b977 --- /dev/null +++ b/test/files/run/repl-javap-app.check @@ -0,0 +1,39 @@ +#partest java6 +Type in expressions to have them evaluated. +Type :help for more information. + +scala> :javap -app MyApp$ +public final void delayedEndpoint$MyApp$1(); + Code: + Stack=2, Locals=1, Args_size=1 + 0: getstatic #61; //Field scala/Console$.MODULE$:Lscala/Console$; + 3: ldc #63; //String Hello, delayed world. + 5: invokevirtual #67; //Method scala/Console$.println:(Ljava/lang/Object;)V + 8: return + LocalVariableTable: + Start Length Slot Name Signature + 0 9 0 this LMyApp$; +} + +scala> +#partest !java6 +Type in expressions to have them evaluated. +Type :help for more information. + +scala> :javap -app MyApp$ + public final void delayedEndpoint$MyApp$1(); + flags: ACC_PUBLIC, ACC_FINAL + Code: + stack=2, locals=1, args_size=1 + 0: getstatic #61 // Field scala/Console$.MODULE$:Lscala/Console$; + 3: ldc #63 // String Hello, delayed world. + 5: invokevirtual #67 // Method scala/Console$.println:(Ljava/lang/Object;)V + 8: return + LocalVariableTable: + Start Length Slot Name Signature + 0 9 0 this LMyApp$; + LineNumberTable: + line 5: 0 +} + +scala> diff --git a/test/files/run/repl-javap-app.scala b/test/files/run/repl-javap-app.scala new file mode 100644 index 0000000000..be04920be1 --- /dev/null +++ b/test/files/run/repl-javap-app.scala @@ -0,0 +1,10 @@ + +import scala.tools.partest.ReplTest + +object MyApp extends App { + Console println "Hello, delayed world." +} + +object Test extends ReplTest { + def code = ":javap -app MyApp$" +} diff --git a/test/files/speclib/.gitignore b/test/files/speclib/.gitignore deleted file mode 100644 index 2b26f5dfc5..0000000000 --- a/test/files/speclib/.gitignore +++ /dev/null @@ -1 +0,0 @@ -instrumented.jar diff --git a/tools/.gitignore b/tools/.gitignore deleted file mode 100644 index 57701c8353..0000000000 --- a/tools/.gitignore +++ /dev/null @@ -1 +0,0 @@ -push.jar |