diff options
149 files changed, 1901 insertions, 2825 deletions
@@ -128,6 +128,7 @@ TODO: <!-- Sets location of build folders --> <property name="build.dir" value="${basedir}/build"/> + <property name="build-deps.dir" value="${build.dir}/deps"/> <property name="build-libs.dir" value="${build.dir}/libs"/> <property name="build-asm.dir" value="${build.dir}/asm"/> <property name="build-forkjoin.dir" value="${build-libs.dir}"/> @@ -192,6 +193,18 @@ TODO: </touch> </target> + <macrodef name="copy-deps" description="Copy a file set based on maven dependency resolution to a directory. Currently used by the IntelliJ config files."> + <attribute name="fileset.prefix"></attribute> + <attribute name="out"></attribute> + <sequential> + <delete dir="${build-deps.dir}/@{out}" includes="*.jar"/> + <copy todir="${build-deps.dir}/@{out}"> + <fileset refid="@{fileset.prefix}.fileset" /> + <mapper type="flatten" /> + </copy> + </sequential> + </macrodef> + <target name="init" depends="boot"> <!-- Set up Ant contrib tasks so we can use <if><then><else> instead of the clunky `unless` attribute --> <taskdef resource="net/sf/antcontrib/antlib.xml" classpath="${lib-ant.dir}/ant-contrib.jar"/> @@ -218,6 +231,7 @@ TODO: <artifact:dependencies pathId="junit.classpath" filesetId="junit.fileset"> <dependency groupId="junit" artifactId="junit" version="${junit.version}"/> </artifact:dependencies> + <copy-deps fileset.prefix="junit" out="junit"/> <!-- Pax runner --> <property name="pax.exam.version" value="2.5.0"/> @@ -238,10 +252,12 @@ TODO: <dependency groupId="com.googlecode.java-diff-utils" artifactId="diffutils" version="1.3.0"/> <dependency groupId="org.scala-tools.testing" artifactId="test-interface" version="0.5" /> </artifact:dependencies> + <copy-deps fileset.prefix="partest.extras" out="partest"/> <artifact:dependencies pathId="repl.deps.classpath" filesetId="repl.deps.fileset" versionsId="repl.deps.versions"> <dependency groupId="jline" artifactId="jline" version="${jline.version}"/> </artifact:dependencies> + <copy-deps fileset.prefix="repl.deps" out="repl"/> <!-- BND support --> <typedef resource="aQute/bnd/ant/taskdef.properties" classpathref="extra.tasks.classpath" /> @@ -379,7 +395,7 @@ TODO: <property name="scalac.args" value=""/> <property name="javac.args" value=""/> - <property name="scalac.args.always" value="" /> + <property name="scalac.args.always" value="-feature" /> <property name="scalac.args.optimise" value=""/> <!-- scalac.args.optimise is selectively overridden in certain antcall tasks. --> <property name="scalac.args.all" value="${scalac.args.always} ${scalac.args} ${scalac.args.optimise}"/> <property name="scalac.args.locker" value="${scalac.args.all}"/> diff --git a/src/actors/scala/actors/Scheduler.scala b/src/actors/scala/actors/Scheduler.scala index 5b5b4a946d..67c8e5cd10 100644 --- a/src/actors/scala/actors/Scheduler.scala +++ b/src/actors/scala/actors/Scheduler.scala @@ -9,7 +9,6 @@ package scala.actors -import java.util.concurrent._ import scheduler.{DelegatingScheduler, ForkJoinScheduler, ResizableThreadPoolScheduler, ThreadPoolConfig} /** diff --git a/src/actors/scala/actors/remote/TcpService.scala b/src/actors/scala/actors/remote/TcpService.scala index ad78ff784c..75e36b2738 100644 --- a/src/actors/scala/actors/remote/TcpService.scala +++ b/src/actors/scala/actors/remote/TcpService.scala @@ -67,7 +67,7 @@ object TcpService { timeout => try { val to = timeout.toInt - Debug.info("Using socket timeout $to") + Debug.info(s"Using socket timeout $to") Some(to) } catch { case e: NumberFormatException => diff --git a/src/compiler/scala/reflect/macros/compiler/DefaultMacroCompiler.scala b/src/compiler/scala/reflect/macros/compiler/DefaultMacroCompiler.scala index 32c6da8007..2e82e34bd9 100644 --- a/src/compiler/scala/reflect/macros/compiler/DefaultMacroCompiler.scala +++ b/src/compiler/scala/reflect/macros/compiler/DefaultMacroCompiler.scala @@ -2,7 +2,6 @@ package scala.reflect.macros package compiler import scala.tools.nsc.Global -import scala.reflect.macros.contexts.Context abstract class DefaultMacroCompiler extends Resolvers with Validators @@ -11,7 +10,6 @@ abstract class DefaultMacroCompiler extends Resolvers import global._ val typer: global.analyzer.Typer - private implicit val context0 = typer.context val context = typer.context val macroDdef: DefDef diff --git a/src/compiler/scala/reflect/macros/compiler/Validators.scala b/src/compiler/scala/reflect/macros/compiler/Validators.scala index 60cfc94a23..fafd79d1d7 100644 --- a/src/compiler/scala/reflect/macros/compiler/Validators.scala +++ b/src/compiler/scala/reflect/macros/compiler/Validators.scala @@ -11,8 +11,6 @@ trait Validators { import global._ import analyzer._ import definitions._ - import treeInfo._ - import typer.infer._ def validateMacroImplRef() = { sanityCheck() diff --git a/src/compiler/scala/reflect/macros/runtime/JavaReflectionRuntimes.scala b/src/compiler/scala/reflect/macros/runtime/JavaReflectionRuntimes.scala index 3ef11fad9d..450cb4d9ea 100644 --- a/src/compiler/scala/reflect/macros/runtime/JavaReflectionRuntimes.scala +++ b/src/compiler/scala/reflect/macros/runtime/JavaReflectionRuntimes.scala @@ -10,8 +10,6 @@ trait JavaReflectionRuntimes { trait JavaReflectionResolvers { self: MacroRuntimeResolver => - import global._ - def resolveJavaReflectionRuntime(classLoader: ClassLoader): MacroRuntime = { val implClass = Class.forName(className, true, classLoader) val implMeths = implClass.getDeclaredMethods.find(_.getName == methName) diff --git a/src/compiler/scala/reflect/macros/runtime/MacroRuntimes.scala b/src/compiler/scala/reflect/macros/runtime/MacroRuntimes.scala index 0f89163803..ffdbe11151 100644 --- a/src/compiler/scala/reflect/macros/runtime/MacroRuntimes.scala +++ b/src/compiler/scala/reflect/macros/runtime/MacroRuntimes.scala @@ -1,11 +1,8 @@ package scala.reflect.macros package runtime -import scala.collection.mutable.{Map => MutableMap} import scala.reflect.internal.Flags._ import scala.reflect.runtime.ReflectionUtils -import scala.tools.nsc.util.ScalaClassLoader -import scala.tools.nsc.util.AbstractFileClassLoader trait MacroRuntimes extends JavaReflectionRuntimes with ScalaReflectionRuntimes { self: scala.tools.nsc.typechecker.Analyzer => diff --git a/src/compiler/scala/reflect/macros/runtime/ScalaReflectionRuntimes.scala b/src/compiler/scala/reflect/macros/runtime/ScalaReflectionRuntimes.scala index 1999e525ff..50f64310f8 100644 --- a/src/compiler/scala/reflect/macros/runtime/ScalaReflectionRuntimes.scala +++ b/src/compiler/scala/reflect/macros/runtime/ScalaReflectionRuntimes.scala @@ -9,8 +9,6 @@ trait ScalaReflectionRuntimes { trait ScalaReflectionResolvers { self: MacroRuntimeResolver => - import global._ - def resolveScalaReflectionRuntime(classLoader: ClassLoader): MacroRuntime = { val macroMirror: ru.JavaMirror = ru.runtimeMirror(classLoader) val implContainerSym = macroMirror.classSymbol(Class.forName(className, true, classLoader)) diff --git a/src/compiler/scala/reflect/macros/util/Helpers.scala b/src/compiler/scala/reflect/macros/util/Helpers.scala index 9b7680717e..f12582a3a1 100644 --- a/src/compiler/scala/reflect/macros/util/Helpers.scala +++ b/src/compiler/scala/reflect/macros/util/Helpers.scala @@ -23,7 +23,7 @@ trait Helpers { * or to streamline creation of the list of macro arguments. */ def transformTypeTagEvidenceParams(macroImplRef: Tree, transform: (Symbol, Symbol) => Symbol): List[List[Symbol]] = { - val treeInfo.MacroImplReference(isBundle, owner, macroImpl, _) = macroImplRef + val treeInfo.MacroImplReference(isBundle, _, macroImpl, _) = macroImplRef val paramss = macroImpl.paramss if (paramss.isEmpty || paramss.last.isEmpty) return paramss // no implicit parameters in the signature => nothing to do val rc = @@ -44,11 +44,6 @@ trait Helpers { if (transformed.isEmpty) paramss.init else paramss.init :+ transformed } - private def dealiasAndRewrap(tp: Type)(fn: Type => Type): Type = { - if (isRepeatedParamType(tp)) scalaRepeatedType(fn(tp.typeArgs.head.dealias)) - else fn(tp.dealias) - } - /** Increases metalevel of the type, i.e. transforms: * * T to c.Expr[T] * diff --git a/src/compiler/scala/reflect/reify/phases/Reshape.scala b/src/compiler/scala/reflect/reify/phases/Reshape.scala index 7578def687..b6f27f71ce 100644 --- a/src/compiler/scala/reflect/reify/phases/Reshape.scala +++ b/src/compiler/scala/reflect/reify/phases/Reshape.scala @@ -256,7 +256,7 @@ trait Reshape { val flags1 = (flags0 & GetterFlags) & ~(STABLE | ACCESSOR | METHOD) val mods1 = Modifiers(flags1, privateWithin0, annotations0) setPositions mods0.positions val mods2 = toPreTyperModifiers(mods1, ddef.symbol) - ValDef(mods2, name1.toTermName, tpt0, extractRhs(rhs0)) + ValDef(mods2, name1, tpt0, extractRhs(rhs0)) } private def trimAccessors(deff: Tree, stats: List[Tree]): List[Tree] = { diff --git a/src/compiler/scala/tools/ant/sabbus/Settings.scala b/src/compiler/scala/tools/ant/sabbus/Settings.scala index 4cbc03d8d4..a86af73fe3 100644 --- a/src/compiler/scala/tools/ant/sabbus/Settings.scala +++ b/src/compiler/scala/tools/ant/sabbus/Settings.scala @@ -93,7 +93,7 @@ class Settings { case _ => false } - override lazy val hashCode: Int = Seq( + override lazy val hashCode: Int = Seq[Any]( gBf, uncheckedBf, classpathBf, diff --git a/src/compiler/scala/tools/cmd/CommandLine.scala b/src/compiler/scala/tools/cmd/CommandLine.scala index e44752eb6e..781cc564cb 100644 --- a/src/compiler/scala/tools/cmd/CommandLine.scala +++ b/src/compiler/scala/tools/cmd/CommandLine.scala @@ -24,13 +24,13 @@ class CommandLine(val spec: Reference, val originalArgs: List[String]) extends C val Terminator = "--" val ValueForUnaryOption = "true" // so if --opt is given, x(--opt) = true - def mapForUnary(opt: String) = Map(opt -> ValueForUnaryOption) + def mapForUnary(opt: String) = Map(fromOpt(opt) -> ValueForUnaryOption) def errorFn(msg: String) = println(msg) /** argMap is option -> argument (or "" if it is a unary argument) * residualArgs are what is left after removing the options and their args. */ - lazy val (argMap, residualArgs) = { + lazy val (argMap, residualArgs): (Map[String, String], List[String]) = { val residualBuffer = new ListBuffer[String] def loop(args: List[String]): Map[String, String] = { @@ -72,7 +72,7 @@ class CommandLine(val spec: Reference, val originalArgs: List[String]) extends C if (x2 == Terminator) mapForUnary(x1) ++ residual(xs) else if (isUnaryOption(x1)) mapForUnary(x1) ++ loop(args.tail) - else if (isBinaryOption(x1)) Map(x1 -> x2) ++ loop(xs) + else if (isBinaryOption(x1)) Map(fromOpt(x1) -> x2) ++ loop(xs) else if (isUnknown(x1)) loop(args.tail) else residual(List(x1)) ++ loop(args.tail) } diff --git a/src/compiler/scala/tools/cmd/CommandLineParser.scala b/src/compiler/scala/tools/cmd/CommandLineParser.scala index ef55178594..6132eff557 100644 --- a/src/compiler/scala/tools/cmd/CommandLineParser.scala +++ b/src/compiler/scala/tools/cmd/CommandLineParser.scala @@ -40,16 +40,16 @@ object CommandLineParser { // parse `in` for an argument, return it and the remainder of the input (or an error message) // (argument may be in single/double quotes, taking escaping into account, quotes are stripped) private def argument(in: String): Either[String, (String, String)] = in match { - case DoubleQuoted(arg, rest) => Right(arg, rest) - case SingleQuoted(arg, rest) => Right(arg, rest) - case Word(arg, rest) => Right(arg, rest) - case _ => Left("Illegal argument: "+ in) + case DoubleQuoted(arg, rest) => Right((arg, rest)) + case SingleQuoted(arg, rest) => Right((arg, rest)) + case Word(arg, rest) => Right((arg, rest)) + case _ => Left(s"Illegal argument: $in") } // parse a list of whitespace-separated arguments (ignoring whitespace in quoted arguments) @tailrec private def commandLine(in: String, accum: List[String] = Nil): Either[String, (List[String], String)] = { val trimmed = in.trim - if (trimmed.isEmpty) Right(accum.reverse, "") + if (trimmed.isEmpty) Right((accum.reverse, "")) else argument(trimmed) match { case Right((arg, next)) => (next span Character.isWhitespace) match { diff --git a/src/compiler/scala/tools/cmd/Opt.scala b/src/compiler/scala/tools/cmd/Opt.scala index 2c193128f1..df3d0c4462 100644 --- a/src/compiler/scala/tools/cmd/Opt.scala +++ b/src/compiler/scala/tools/cmd/Opt.scala @@ -26,10 +26,10 @@ object Opt { trait Implicit { def name: String def programInfo: Info - protected def opt = toOpt(name) + protected def opt = fromOpt(name) def --? : Boolean // --opt is set - def --> (body: => Unit): Unit // if --opt is set, execute body + def --> (body: => Unit): Boolean // if --opt is set, execute body def --| : Option[String] // --opt <arg: String> is optional, result is Option[String] def --^[T: FromString] : Option[T] // --opt <arg: T> is optional, result is Option[T] @@ -51,7 +51,7 @@ object Opt { import options._ def --? = { addUnary(opt) ; false } - def --> (body: => Unit) = { addUnary(opt) } + def --> (body: => Unit) = { addUnary(opt) ; false } def --| = { addBinary(opt) ; None } def --^[T: FromString] = { addBinary(opt) ; None } @@ -65,7 +65,7 @@ object Opt { class Instance(val programInfo: Info, val parsed: CommandLine, val name: String) extends Implicit with Error { def --? = parsed isSet opt - def --> (body: => Unit) = if (parsed isSet opt) body + def --> (body: => Unit) = { val isSet = parsed isSet opt ; if (isSet) body ; isSet } def --| = parsed get opt def --^[T: FromString] = { val fs = implicitly[FromString[T]] diff --git a/src/compiler/scala/tools/cmd/Reference.scala b/src/compiler/scala/tools/cmd/Reference.scala index ec2a414065..62b6c893cf 100644 --- a/src/compiler/scala/tools/cmd/Reference.scala +++ b/src/compiler/scala/tools/cmd/Reference.scala @@ -23,13 +23,13 @@ trait Reference extends Spec { def helpMsg = options.helpMsg def propertyArgs: List[String] = Nil - def isUnaryOption(s: String) = unary contains toOpt(s) - def isBinaryOption(s: String) = binary contains toOpt(s) - def isExpandOption(s: String) = expansionMap contains toOpt(s) + def isUnaryOption(s: String) = unary contains fromOpt(s) + def isBinaryOption(s: String) = binary contains fromOpt(s) + def isExpandOption(s: String) = expansionMap contains fromOpt(s) - def expandArg(arg: String) = expansionMap.getOrElse(fromOpt(arg), List(arg)) + def expandArg(arg: String): List[String] = expansionMap.getOrElse(fromOpt(arg), List(arg)) - protected def help(str: => String) = addHelp(() => str) + protected def help(str: => String): Unit = addHelp(() => str) type ThisCommandLine <: CommandLine @@ -53,20 +53,20 @@ object Reference { def helpFormatStr = " %-" + longestArg + "s %s" def defaultFormatStr = (" " * (longestArg + 7)) + "%s" - def addUnary(s: String) = _unary +:= s - def addBinary(s: String) = _binary +:= s + def addUnary(s: String): Unit = _unary +:= s + def addBinary(s: String): Unit = _binary +:= s def addExpand(opt: String, expanded: List[String]) = _expand += (opt -> expanded) - def mapHelp(g: String => String) = { + def mapHelp(g: String => String): Unit = { val idx = _help.length - 1 val f = _help(idx) _help(idx) = () => g(f()) } - def addHelp(f: () => String) = _help += f + def addHelp(f: () => String): Unit = _help += f def addHelpAlias(f: () => String) = mapHelp { s => val str = "alias for '%s'" format f() def noHelp = (helpFormatStr.format("", "")).length == s.length @@ -74,13 +74,13 @@ object Reference { s + str2 } - def addHelpDefault(f: () => String) = mapHelp { s => + def addHelpDefault(f: () => String): Unit = mapHelp { s => val str = "(default: %s)" format f() if (s.length + str.length < MaxLine) s + " " + str else defaultFormatStr.format(s, str) } - def addHelpEnvDefault(name: String) = mapHelp { s => + def addHelpEnvDefault(name: String): Unit = mapHelp { s => val line1 = "%s (default: %s)".format(s, name) val envNow = envOrNone(name) map ("'" + _ + "'") getOrElse "unset" val line2 = defaultFormatStr.format("Currently " + envNow) diff --git a/src/compiler/scala/tools/cmd/gen/AnyVals.scala b/src/compiler/scala/tools/cmd/gen/AnyVals.scala index 7e01afac2b..842851b4f6 100644 --- a/src/compiler/scala/tools/cmd/gen/AnyVals.scala +++ b/src/compiler/scala/tools/cmd/gen/AnyVals.scala @@ -6,24 +6,23 @@ package scala.tools.cmd package gen -/** Code generation of the AnyVal types and their companions. - */ +/** Code generation of the AnyVal types and their companions. */ trait AnyValReps { self: AnyVals => - sealed abstract class AnyValNum(name: String, repr: Option[String], javaEquiv: String) extends AnyValRep(name,repr,javaEquiv) { + sealed abstract class AnyValNum(name: String, repr: Option[String], javaEquiv: String) + extends AnyValRep(name,repr,javaEquiv) { case class Op(op : String, doc : String) private def companionCoercions(tos: AnyValRep*) = { tos.toList map (to => - """implicit def @javaequiv@2%s(x: @name@): %s = x.to%s""".format(to.javaEquiv, to.name, to.name) + s"implicit def @javaequiv@2${to.javaEquiv}(x: @name@): ${to.name} = x.to${to.name}" ) } - def coercionCommentExtra = "" - def coercionComment = """ -/** Language mandated coercions from @name@ to "wider" types.%s - */""".format(coercionCommentExtra) + def coercionComment = +"""/** Language mandated coercions from @name@ to "wider" types. */ +import scala.language.implicitConversions""" def implicitCoercions: List[String] = { val coercions = this match { @@ -41,12 +40,8 @@ trait AnyValReps { def isCardinal: Boolean = isIntegerType(this) def unaryOps = { val ops = List( - Op("+", "/**\n" + - " * Returns this value, unmodified.\n" + - " */"), - Op("-", "/**\n" + - " * Returns the negation of this value.\n" + - " */")) + Op("+", "/** Returns this value, unmodified. */"), + Op("-", "/** Returns the negation of this value. */")) if(isCardinal) Op("~", "/**\n" + @@ -95,7 +90,7 @@ trait AnyValReps { " */")) else Nil - def shiftOps = + def shiftOps = if (isCardinal) List( Op("<<", "/**\n" + @@ -127,20 +122,20 @@ trait AnyValReps { " */")) else Nil - def comparisonOps = List( - Op("==", "/**\n * Returns `true` if this value is equal to x, `false` otherwise.\n */"), - Op("!=", "/**\n * Returns `true` if this value is not equal to x, `false` otherwise.\n */"), - Op("<", "/**\n * Returns `true` if this value is less than x, `false` otherwise.\n */"), - Op("<=", "/**\n * Returns `true` if this value is less than or equal to x, `false` otherwise.\n */"), - Op(">", "/**\n * Returns `true` if this value is greater than x, `false` otherwise.\n */"), - Op(">=", "/**\n * Returns `true` if this value is greater than or equal to x, `false` otherwise.\n */")) + def comparisonOps = List( + Op("==", "/** Returns `true` if this value is equal to x, `false` otherwise. */"), + Op("!=", "/** Returns `true` if this value is not equal to x, `false` otherwise. */"), + Op("<", "/** Returns `true` if this value is less than x, `false` otherwise. */"), + Op("<=", "/** Returns `true` if this value is less than or equal to x, `false` otherwise. */"), + Op(">", "/** Returns `true` if this value is greater than x, `false` otherwise. */"), + Op(">=", "/** Returns `true` if this value is greater than or equal to x, `false` otherwise. */")) def otherOps = List( - Op("+", "/**\n * Returns the sum of this value and `x`.\n */"), - Op("-", "/**\n * Returns the difference of this value and `x`.\n */"), - Op("*", "/**\n * Returns the product of this value and `x`.\n */"), - Op("/", "/**\n * Returns the quotient of this value and `x`.\n */"), - Op("%", "/**\n * Returns the remainder of the division of this value by `x`.\n */")) + Op("+", "/** Returns the sum of this value and `x`. */"), + Op("-", "/** Returns the difference of this value and `x`. */"), + Op("*", "/** Returns the product of this value and `x`. */"), + Op("/", "/** Returns the quotient of this value and `x`. */"), + Op("%", "/** Returns the remainder of the division of this value by `x`. */")) // Given two numeric value types S and T , the operation type of S and T is defined as follows: // If both S and T are subrange types then the operation type of S and T is Int. @@ -278,8 +273,7 @@ trait AnyValReps { } trait AnyValTemplates { - def headerTemplate = (""" -/* __ *\ + def headerTemplate = """/* __ *\ ** ________ ___ / / ___ Scala API ** ** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** @@ -287,12 +281,13 @@ trait AnyValTemplates { ** |/ ** \* */ -%s -package scala +// DO NOT EDIT, CHANGES WILL BE LOST +// This auto-generated code can be modified in scala.tools.cmd.gen. +// Afterwards, running tools/codegen-anyvals regenerates this source file. -import scala.language.implicitConversions +package scala -""".trim.format(timestampString) + "\n\n") +""" def classDocTemplate = (""" /** `@name@`@representation@ (equivalent to Java's `@javaequiv@` primitive type) is a @@ -304,8 +299,6 @@ import scala.language.implicitConversions */ """.trim + "\n") - def timestampString = "// DO NOT EDIT, CHANGES WILL BE LOST.\n" - def allCompanions = """ /** Transform a value type into a boxed reference type. *@boxRunTimeDoc@ @@ -324,20 +317,17 @@ def box(x: @name@): @boxed@ = @boxImpl@ */ def unbox(x: java.lang.Object): @name@ = @unboxImpl@ -/** The String representation of the scala.@name@ companion object. - */ +/** The String representation of the scala.@name@ companion object. */ override def toString = "object scala.@name@" """ def nonUnitCompanions = "" // todo def cardinalCompanion = """ -/** The smallest value representable as a @name@. - */ +/** The smallest value representable as a @name@. */ final val MinValue = @boxed@.MIN_VALUE -/** The largest value representable as a @name@. - */ +/** The largest value representable as a @name@. */ final val MaxValue = @boxed@.MAX_VALUE """ @@ -372,18 +362,16 @@ class AnyVals extends AnyValReps with AnyValTemplates { object D extends AnyValNum("Double", Some("64-bit IEEE-754 floating point number"), "double") object Z extends AnyValRep("Boolean", None, "boolean") { def classLines = """ -/** - * Negates a Boolean expression. - * - * - `!a` results in `false` if and only if `a` evaluates to `true` and - * - `!a` results in `true` if and only if `a` evaluates to `false`. - * - * @return the negated expression - */ +/** Negates a Boolean expression. + * + * - `!a` results in `false` if and only if `a` evaluates to `true` and + * - `!a` results in `true` if and only if `a` evaluates to `false`. + * + * @return the negated expression + */ def unary_! : Boolean -/** - * Compares two Boolean expressions and returns `true` if they evaluate to the same value. +/** Compares two Boolean expressions and returns `true` if they evaluate to the same value. * * `a == b` returns `true` if and only if * - `a` and `b` are `true` or @@ -400,8 +388,7 @@ def ==(x: Boolean): Boolean */ def !=(x: Boolean): Boolean -/** - * Compares two Boolean expressions and returns `true` if one or both of them evaluate to true. +/** Compares two Boolean expressions and returns `true` if one or both of them evaluate to true. * * `a || b` returns `true` if and only if * - `a` is `true` or @@ -414,8 +401,7 @@ def !=(x: Boolean): Boolean */ def ||(x: Boolean): Boolean -/** - * Compares two Boolean expressions and returns `true` if both of them evaluate to true. +/** Compares two Boolean expressions and returns `true` if both of them evaluate to true. * * `a && b` returns `true` if and only if * - `a` and `b` are `true`. @@ -430,8 +416,7 @@ def &&(x: Boolean): Boolean // def ||(x: => Boolean): Boolean // def &&(x: => Boolean): Boolean -/** - * Compares two Boolean expressions and returns `true` if one or both of them evaluate to true. +/** Compares two Boolean expressions and returns `true` if one or both of them evaluate to true. * * `a | b` returns `true` if and only if * - `a` is `true` or @@ -442,8 +427,7 @@ def &&(x: Boolean): Boolean */ def |(x: Boolean): Boolean -/** - * Compares two Boolean expressions and returns `true` if both of them evaluate to true. +/** Compares two Boolean expressions and returns `true` if both of them evaluate to true. * * `a & b` returns `true` if and only if * - `a` and `b` are `true`. @@ -452,8 +436,7 @@ def |(x: Boolean): Boolean */ def &(x: Boolean): Boolean -/** - * Compares two Boolean expressions and returns `true` if they evaluate to a different value. +/** Compares two Boolean expressions and returns `true` if they evaluate to a different value. * * `a ^ b` returns `true` if and only if * - `a` is `true` and `b` is `false` or @@ -499,5 +482,3 @@ override def getClass(): Class[Boolean] = null def make() = values map (x => (x.name, x.make())) } - -object AnyVals extends AnyVals { } diff --git a/src/compiler/scala/tools/cmd/gen/Codegen.scala b/src/compiler/scala/tools/cmd/gen/Codegen.scala index b49322ab4a..c3aa527ef2 100644 --- a/src/compiler/scala/tools/cmd/gen/Codegen.scala +++ b/src/compiler/scala/tools/cmd/gen/Codegen.scala @@ -6,11 +6,9 @@ package scala.tools.cmd package gen -import scala.language.postfixOps - class Codegen(args: List[String]) extends { val parsed = CodegenSpec(args: _*) -} with CodegenSpec with Instance { } +} with CodegenSpec with Instance object Codegen { def echo(msg: String) = Console println msg @@ -31,7 +29,7 @@ object Codegen { val av = new AnyVals { } av.make() foreach { case (name, code ) => - val file = out / (name + ".scala") toFile; + val file = (out / (name + ".scala")).toFile echo("Writing: " + file) file writeAll code } diff --git a/src/compiler/scala/tools/cmd/package.scala b/src/compiler/scala/tools/cmd/package.scala index 7d67fa738b..9754becf10 100644 --- a/src/compiler/scala/tools/cmd/package.scala +++ b/src/compiler/scala/tools/cmd/package.scala @@ -13,19 +13,19 @@ package object cmd { implicit def implicitConversions = scala.language.implicitConversions implicit def postfixOps = scala.language.postfixOps - private[cmd] def debug(msg: String) = println(msg) + private[cmd] def debug(msg: String): Unit = println(msg) def runAndExit(body: => Unit): Nothing = { body sys.exit(0) } - def toOpt(s: String) = if (s startsWith "--") s else "--" + s - def fromOpt(s: String) = s stripPrefix "--" - def toArgs(line: String) = CommandLineParser tokenize line - def fromArgs(args: List[String]) = args mkString " " + def toOpt(s: String): String = if (s startsWith "--") s else "--" + s + def fromOpt(s: String): String = s stripPrefix "--" + def toArgs(line: String): List[String] = CommandLineParser tokenize line + def fromArgs(args: List[String]): String = args mkString " " - def stripQuotes(s: String) = { + def stripQuotes(s: String): String = { def isQuotedBy(c: Char) = s.length > 0 && s.head == c && s.last == c if (List('"', '\'') exists isQuotedBy) s.tail.init else s } diff --git a/src/compiler/scala/tools/nsc/ast/TreeDSL.scala b/src/compiler/scala/tools/nsc/ast/TreeDSL.scala index b17de9b9d5..66ed0c8fae 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeDSL.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeDSL.scala @@ -187,7 +187,7 @@ trait TreeDSL { def vparamss: List[List[ValDef]] type ResultTreeType = DefDef - def mkTree(rhs: Tree): DefDef = DefDef(mods, name, tparams, vparamss, tpt, rhs) + def mkTree(rhs: Tree): DefDef = DefDef(mods, name.toTermName, tparams, vparamss, tpt, rhs) } class DefSymStart(val sym: Symbol) extends SymVODDStart with DefCreator { diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index eb924a811b..d0b0c09d59 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -2542,7 +2542,7 @@ self => } expr() } - DefDef(newmods, name, tparams, vparamss, restype, rhs) + DefDef(newmods, name.toTermName, tparams, vparamss, restype, rhs) } signalParseProgress(result.pos) result diff --git a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala index 2a799acbc7..239ecb4f8a 100644 --- a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala +++ b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala @@ -510,7 +510,7 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners { if (inInterface) mods1 |= Flags.DEFERRED List { atPos(pos) { - DefDef(mods1, name, tparams, List(vparams), rtpt, body) + DefDef(mods1, name.toTermName, tparams, List(vparams), rtpt, body) } } } else { diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index c6ea6b23e5..454c9db73c 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -74,7 +74,6 @@ abstract class ClassfileParser { def srcfile = srcfile0 private def optimized = settings.optimise.value - private def currentIsTopLevel = !(currentClass.decodedName containsChar '$') // u1, u2, and u4 are what these data types are called in the JVM spec. // They are an unsigned byte, unsigned char, and unsigned int respectively. @@ -349,7 +348,7 @@ abstract class ClassfileParser { /** Throws an exception signaling a bad tag at given address. */ protected def errorBadTag(start: Int) = - abort("bad constant pool tag ${in.buf(start)} at byte $start") + abort(s"bad constant pool tag ${in.buf(start)} at byte $start") } private def loadClassSymbol(name: Name): Symbol = { diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 0f65b11e9b..ee687e56b0 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -706,7 +706,8 @@ abstract class Erasure extends AddInterfaces // } typed(untyped) } - } else tree + } else qual1 + case Apply(TypeApply(sel @ Select(qual, name), List(targ)), List()) if tree.symbol == Any_isInstanceOf => targ.tpe match { diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index 60641d6752..f3a22a2cee 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -1194,7 +1194,7 @@ trait Contexts { self: Analyzer => override final def imports = impInfo :: super.imports override final def firstImport = Some(impInfo) override final def isRootImport = !tree.pos.isDefined - override final def toString = s"ImportContext { $impInfo; outer.owner = ${outer.owner} }" + override final def toString = super.toString + " with " + s"ImportContext { $impInfo; outer.owner = ${outer.owner} }" } /** A buffer for warnings and errors that are accumulated during speculative type checking. */ @@ -1340,6 +1340,7 @@ trait Contexts { self: Analyzer => } object ContextMode { + import scala.language.implicitConversions private implicit def liftIntBitsToContextState(bits: Int): ContextMode = apply(bits) def apply(bits: Int): ContextMode = new ContextMode(bits) final val NOmode: ContextMode = 0 diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 100112fec1..4265efc839 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -60,6 +60,8 @@ trait Implicits { * @return A search result */ def inferImplicit(tree: Tree, pt: Type, reportAmbiguous: Boolean, isView: Boolean, context: Context, saveAmbiguousDivergent: Boolean, pos: Position): SearchResult = { + // Note that the isInvalidConversionTarget seems to make a lot more sense right here, before all the + // work is performed, than at the point where it presently exists. val shouldPrint = printTypings && !context.undetparams.isEmpty val rawTypeStart = if (Statistics.canEnable) Statistics.startCounter(rawTypeImpl) else null val findMemberStart = if (Statistics.canEnable) Statistics.startCounter(findMemberImpl) else null @@ -813,7 +815,7 @@ trait Implicits { if (search.isDivergent && countdown > 0) { countdown -= 1 implicitSym = i.sym - log("discarding divergent implicit ${implicitSym} during implicit search") + log(s"discarding divergent implicit $implicitSym during implicit search") SearchFailure } else search } @@ -1335,12 +1337,18 @@ trait Implicits { } } if (result.isSuccess && isView) { + def maybeInvalidConversionError(msg: String) { + // We have to check context.ambiguousErrors even though we are calling "issueAmbiguousError" + // which ostensibly does exactly that before issuing the error. Why? I have no idea. Test is pos/t7690. + if (context.ambiguousErrors) + context.issueAmbiguousError(AmbiguousImplicitTypeError(tree, msg)) + } if (isInvalidConversionTarget(pt)) { - context.issueAmbiguousError(AmbiguousImplicitTypeError(tree, "the result type of an implicit conversion must be more specific than AnyRef")) + maybeInvalidConversionError("the result type of an implicit conversion must be more specific than AnyRef") result = SearchFailure } else if (isInvalidConversionSource(pt)) { - context.issueAmbiguousError(AmbiguousImplicitTypeError(tree, "an expression of type Null is ineligible for implicit conversion")) + maybeInvalidConversionError("an expression of type Null is ineligible for implicit conversion") result = SearchFailure } } diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index 06892053fa..8ca0d82e93 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -700,7 +700,7 @@ trait Infer extends Checkable { tp nonPrivateMember nme.apply match { case NoSymbol => tp case sym if !sym.isOverloaded && sym.isPublic => OverloadedType(tp, sym.alternatives) - case sym => OverloadedType(tp, sym filter (_.isPublic) alternatives) + case sym => OverloadedType(tp, sym.filter(_.isPublic).alternatives) } } diff --git a/src/compiler/scala/tools/reflect/MacroImplementations.scala b/src/compiler/scala/tools/reflect/MacroImplementations.scala index 8e1bcb5f87..4e3761454d 100644 --- a/src/compiler/scala/tools/reflect/MacroImplementations.scala +++ b/src/compiler/scala/tools/reflect/MacroImplementations.scala @@ -94,7 +94,8 @@ abstract class MacroImplementations { def errorAtIndex(idx: Int, msg: String) = c.error(new OffsetPosition(strTree.pos.source, strTree.pos.point + idx), msg) def wrongConversionString(idx: Int) = errorAtIndex(idx, "wrong conversion string") def illegalConversionCharacter(idx: Int) = errorAtIndex(idx, "illegal conversion character") - def nonEscapedPercent(idx: Int) = errorAtIndex(idx, "percent signs not directly following splicees must be escaped") + def nonEscapedPercent(idx: Int) = errorAtIndex(idx, + "conversions must follow a splice; use %% for literal %, %n for newline") // STEP 1: handle argument conversion // 1) "...${smth}" => okay, equivalent to "...${smth}%s" diff --git a/src/compiler/scala/tools/util/PathResolver.scala b/src/compiler/scala/tools/util/PathResolver.scala index bdd6a02043..82f2c5dc74 100644 --- a/src/compiler/scala/tools/util/PathResolver.scala +++ b/src/compiler/scala/tools/util/PathResolver.scala @@ -8,8 +8,8 @@ package tools package util import scala.tools.reflect.WrappedProperties.AccessControl -import scala.tools.nsc.{ Settings, GenericRunnerSettings } -import scala.tools.nsc.util.{ ClassPath, JavaClassPath, ScalaClassLoader } +import scala.tools.nsc.{ Settings } +import scala.tools.nsc.util.{ ClassPath, JavaClassPath } import scala.reflect.io.{ File, Directory, Path, AbstractFile } import ClassPath.{ JavaContext, DefaultJavaContext, join, split } import PartialFunction.condOpt diff --git a/src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala b/src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala index f260ee4093..3963447de3 100644 --- a/src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala +++ b/src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala @@ -396,7 +396,6 @@ abstract class CPSAnnotationChecker extends CPSUtils { * for a tree. All this should do is add annotations. */ override def pluginsTyped(tpe: Type, typer: Typer, tree: Tree, mode: Mode, pt: Type): Type = { - import scala.util.control._ if (!cpsEnabled) { val report = try hasCpsParamTypes(tpe) catch { case _: MissingRequirementError => false } if (report) diff --git a/src/intellij/README b/src/intellij/README index 9ef612bd0a..ade87749cd 100644 --- a/src/intellij/README +++ b/src/intellij/README @@ -1,13 +1,8 @@ Use the latest IntelliJ IDEA release and install the Scala plugin from within the IDE. The following steps are required to use IntelliJ IDEA on Scala trunk - - compile "locker" using "ant locker.done" - - Copy the *.iml.SAMPLE / *.ipr.SAMPLE files to *.iml / *.ipr - - In IDEA, create a global library named "ant" which contains "ant.jar" - - Also create an SDK entry named "1.6" containing the java 1.6 SDK - - In the Scala Facet of the "library" and "reflect" modules, update the path in the - command-line argument for "-sourcepath" - - In the Project Settings, update the "Version Control" to match your checkout - -Known problems - - Due to SI-4365, the "library" module has to be built using "-Yno-generic-signatures" + - compile "locker" using "ant locker.done". This will also download some JARs from + Maven to ./build/deps, which are included in IntelliJ's classpath. + - Run src/intellij/setup.sh + - Open ./src/intellij/scala-lang.ipr in IntelliJ + - File, Project Settings, Project, SDK. Create an SDK entry named "1.6" containing the java 1.6 SDK diff --git a/src/intellij/compiler.iml.SAMPLE b/src/intellij/compiler.iml.SAMPLE index f8b1f31327..9fb9cd55eb 100644 --- a/src/intellij/compiler.iml.SAMPLE +++ b/src/intellij/compiler.iml.SAMPLE @@ -19,9 +19,8 @@ <orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="module" module-name="library" /> <orderEntry type="module" module-name="reflect" /> - <orderEntry type="module" module-name="asm" /> - <orderEntry type="library" name="ant" level="application" /> - <orderEntry type="library" name="jline" level="project" /> + <orderEntry type="module" module-name="asm" exported="" /> + <orderEntry type="library" exported="" name="ant" level="project" /> </component> </module> diff --git a/src/intellij/diff.sh b/src/intellij/diff.sh new file mode 100755 index 0000000000..54f9248608 --- /dev/null +++ b/src/intellij/diff.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +# +# Diffs the SAMPLE files against the working project config. +# +export SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )" +for f in "$SCRIPT_DIR"/*.{iml,ipr}; do + echo $f; diff -u $f.SAMPLE $f; +done diff --git a/src/intellij/library.iml.SAMPLE b/src/intellij/library.iml.SAMPLE index 9c1b7ec185..cac53dff15 100644 --- a/src/intellij/library.iml.SAMPLE +++ b/src/intellij/library.iml.SAMPLE @@ -5,7 +5,7 @@ <configuration> <option name="compilerLibraryLevel" value="Project" /> <option name="compilerLibraryName" value="compiler-locker" /> - <option name="compilerOptions" value="-sourcepath /Users/luc/scala/scala/src/library -Yno-generic-signatures" /> + <option name="compilerOptions" value="-sourcepath $BASE_DIR$/src/library" /> <option name="maximumHeapSize" value="1536" /> <option name="vmOptions" value="-Xms1536m -Xss1m -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=256m -XX:+CMSClassUnloadingEnabled -XX:+UseCompressedOops -XX:+UseParallelGC" /> </configuration> diff --git a/src/intellij/manual.iml.SAMPLE b/src/intellij/manual.iml.SAMPLE index 62810e0cba..3295a4a877 100644 --- a/src/intellij/manual.iml.SAMPLE +++ b/src/intellij/manual.iml.SAMPLE @@ -18,7 +18,8 @@ <orderEntry type="inheritedJdk" /> <orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="module" module-name="library" /> - <orderEntry type="library" name="ant" level="application" /> + <orderEntry type="module" module-name="xml" /> + <orderEntry type="library" name="ant" level="project" /> </component> </module> diff --git a/src/intellij/parser-combinators.iml.SAMPLE b/src/intellij/parser-combinators.iml.SAMPLE new file mode 100644 index 0000000000..1ef913dbe4 --- /dev/null +++ b/src/intellij/parser-combinators.iml.SAMPLE @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="JAVA_MODULE" version="4"> + <component name="FacetManager"> + <facet type="scala" name="Scala"> + <configuration> + <option name="compilerLibraryLevel" value="Project" /> + <option name="compilerLibraryName" value="compiler-locker" /> + <option name="maximumHeapSize" value="1536" /> + <option name="vmOptions" value="-Xms1536m -Xss1m -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=256m -XX:+CMSClassUnloadingEnabled -XX:+UseCompressedOops -XX:+UseParallelGC" /> + </configuration> + </facet> + </component> + <component name="NewModuleRootManager" inherit-compiler-output="true"> + <exclude-output /> + <content url="file://$MODULE_DIR$/../parser-combinators"> + <sourceFolder url="file://$MODULE_DIR$/../parser-combinators" isTestSource="false" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="module" module-name="library" /> + </component> +</module> diff --git a/src/intellij/partest.iml.SAMPLE b/src/intellij/partest.iml.SAMPLE index ab4a32a9b3..5b8cfa3f38 100644 --- a/src/intellij/partest.iml.SAMPLE +++ b/src/intellij/partest.iml.SAMPLE @@ -18,11 +18,13 @@ <orderEntry type="inheritedJdk" /> <orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="module" module-name="library" /> + <orderEntry type="module" module-name="xml" /> <orderEntry type="module" module-name="reflect" /> <orderEntry type="module" module-name="actors" /> <orderEntry type="module" module-name="scalap" /> <orderEntry type="module" module-name="compiler" /> - <orderEntry type="library" name="ant" level="application" /> + <orderEntry type="library" name="partest-deps" level="project" /> + <orderEntry type="module" module-name="repl" /> </component> </module> diff --git a/src/intellij/reflect.iml.SAMPLE b/src/intellij/reflect.iml.SAMPLE index 10973c503f..7d10522826 100644 --- a/src/intellij/reflect.iml.SAMPLE +++ b/src/intellij/reflect.iml.SAMPLE @@ -5,7 +5,7 @@ <configuration> <option name="compilerLibraryLevel" value="Project" /> <option name="compilerLibraryName" value="compiler-locker" /> - <option name="compilerOptions" value="-sourcepath /Users/luc/scala/scala/src/reflect" /> + <option name="compilerOptions" value="-sourcepath $BASE_DIR$/src/reflect" /> <option name="maximumHeapSize" value="1536" /> <option name="vmOptions" value="-Xms1536m -Xss1m -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=256m -XX:+CMSClassUnloadingEnabled -XX:+UseCompressedOops -XX:+UseParallelGC" /> </configuration> diff --git a/src/intellij/repl.iml.SAMPLE b/src/intellij/repl.iml.SAMPLE index 5e11ff1cf6..fc78ffe8c2 100644 --- a/src/intellij/repl.iml.SAMPLE +++ b/src/intellij/repl.iml.SAMPLE @@ -20,6 +20,6 @@ <orderEntry type="module" module-name="library" /> <orderEntry type="module" module-name="reflect" /> <orderEntry type="module" module-name="compiler" /> + <orderEntry type="library" name="repl-deps" level="project" /> </component> </module> - diff --git a/src/intellij/scala-lang.ipr.SAMPLE b/src/intellij/scala-lang.ipr.SAMPLE index 61c813df01..f91a346b75 100644 --- a/src/intellij/scala-lang.ipr.SAMPLE +++ b/src/intellij/scala-lang.ipr.SAMPLE @@ -33,6 +33,9 @@ <component name="EntryPointsManager"> <entry_points version="2.0" /> </component> + <component name="HighlightingAdvisor"> + <option name="SUGGEST_TYPE_AWARE_HIGHLIGHTING" value="false" /> + </component> <component name="InspectionProjectProfileManager"> <profiles> <profile version="1.0" is_locked="false"> @@ -204,6 +207,7 @@ <module fileurl="file://$PROJECT_DIR$/interactive.iml" filepath="$PROJECT_DIR$/interactive.iml" /> <module fileurl="file://$PROJECT_DIR$/library.iml" filepath="$PROJECT_DIR$/library.iml" /> <module fileurl="file://$PROJECT_DIR$/manual.iml" filepath="$PROJECT_DIR$/manual.iml" /> + <module fileurl="file://$PROJECT_DIR$/parser-combinators.iml" filepath="$PROJECT_DIR$/parser-combinators.iml" /> <module fileurl="file://$PROJECT_DIR$/partest.iml" filepath="$PROJECT_DIR$/partest.iml" /> <module fileurl="file://$PROJECT_DIR$/reflect.iml" filepath="$PROJECT_DIR$/reflect.iml" /> <module fileurl="file://$PROJECT_DIR$/repl.iml" filepath="$PROJECT_DIR$/repl.iml" /> @@ -212,6 +216,7 @@ <module fileurl="file://$PROJECT_DIR$/scalap.iml" filepath="$PROJECT_DIR$/scalap.iml" /> <module fileurl="file://$PROJECT_DIR$/swing.iml" filepath="$PROJECT_DIR$/swing.iml" /> <module fileurl="file://$PROJECT_DIR$/test.iml" filepath="$PROJECT_DIR$/test.iml" /> + <module fileurl="file://$PROJECT_DIR$/xml.iml" filepath="$PROJECT_DIR$/xml.iml" /> </modules> </component> <component name="ProjectResources"> @@ -228,6 +233,13 @@ <mapping directory="$PROJECT_DIR$/../.." vcs="Git" /> </component> <component name="libraryTable"> + <library name="ant"> + <CLASSES> + <root url="jar://$PROJECT_DIR$/../../lib/ant/ant.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> <library name="compiler-locker"> <CLASSES> <root url="file://$PROJECT_DIR$/../../build/locker/classes/library" /> @@ -238,13 +250,35 @@ <JAVADOC /> <SOURCES /> </library> - <library name="jline"> + <library name="junit"> <CLASSES> - <root url="jar://$PROJECT_DIR$/../../lib/jline.jar!/" /> + <root url="file://$PROJECT_DIR$/../../build/deps/junit" /> </CLASSES> <JAVADOC /> - <SOURCES /> + <SOURCES> + <root url="file://$PROJECT_DIR$/../../build/deps/junit" /> + </SOURCES> + <jarDirectory url="file://$PROJECT_DIR$/../../build/deps/junit" recursive="false" /> + <jarDirectory url="file://$PROJECT_DIR$/../../build/deps/junit" recursive="false" type="SOURCES" /> + </library> + <library name="partest-deps"> + <CLASSES> + <root url="file://$PROJECT_DIR$/../../build/deps/partest" /> + </CLASSES> + <JAVADOC /> + <SOURCES> + <root url="file://$PROJECT_DIR$/../../build/deps/junit" /> + </SOURCES> + <jarDirectory url="file://$PROJECT_DIR$/../../build/deps/partest" recursive="false" /> + <jarDirectory url="file://$PROJECT_DIR$/../../build/deps/junit" recursive="false" type="SOURCES" /> </library> + <library name="repl-deps"> + <CLASSES> + <root url="file://$PROJECT_DIR$/../../build/deps/repl" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + <jarDirectory url="file://$PROJECT_DIR$/../../build/deps/repl" recursive="false" /> + </library> </component> </project> - diff --git a/src/intellij/scala.iml.SAMPLE b/src/intellij/scala.iml.SAMPLE index 8ea9d0dd71..a4d863800b 100644 --- a/src/intellij/scala.iml.SAMPLE +++ b/src/intellij/scala.iml.SAMPLE @@ -2,7 +2,9 @@ <module type="JAVA_MODULE" version="4"> <component name="NewModuleRootManager" inherit-compiler-output="true"> <exclude-output /> - <content url="file://$MODULE_DIR$/../.." /> + <content url="file://$MODULE_DIR$/../.."> + <excludeFolder url="file://$MODULE_DIR$/../../build" /> + </content> <orderEntry type="inheritedJdk" /> <orderEntry type="sourceFolder" forTests="false" /> </component> diff --git a/src/intellij/scaladoc.iml.SAMPLE b/src/intellij/scaladoc.iml.SAMPLE index 6cc609919c..07bea5bf5d 100644 --- a/src/intellij/scaladoc.iml.SAMPLE +++ b/src/intellij/scaladoc.iml.SAMPLE @@ -20,5 +20,8 @@ <orderEntry type="module" module-name="library" /> <orderEntry type="module" module-name="reflect" /> <orderEntry type="module" module-name="compiler" /> + <orderEntry type="module" module-name="xml" /> + <orderEntry type="module" module-name="parser-combinators" /> + <orderEntry type="module" module-name="partest" /> </component> </module> diff --git a/src/intellij/setup.sh b/src/intellij/setup.sh new file mode 100755 index 0000000000..d0e1abeb96 --- /dev/null +++ b/src/intellij/setup.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# +# Generates IntelliJ IDEA project files based on the checked-in samples. +# + +set -e +export SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )" +export BASE="$( cd "$( dirname "$0" )"/../.. && pwd )" +echo "About to delete .ipr and .iml files and replace with the .SAMPLE files. Press enter to continue or CTRL-C to cancel." +read + +(rm *.ipr *.iml 2>/dev/null) +for f in $(ls "$SCRIPT_DIR"/*.SAMPLE); do + NEW_FILE=`echo $f | perl -pe 's/.SAMPLE//'`; + + cp $f $NEW_FILE + + # IntelliJ doesn't process the "compilerOptions" setting for variable + # replacement. If it did, we would just use "$PROJECT_DIR$". Instead, + # we do this replacement ourselves. + perl -pi -e 's/\$BASE_DIR\$/$ENV{"BASE"}/g' $NEW_FILE + echo "Created $NEW_FILE" +done diff --git a/src/intellij/test.iml.SAMPLE b/src/intellij/test.iml.SAMPLE index 3ce369be05..423be2062c 100644 --- a/src/intellij/test.iml.SAMPLE +++ b/src/intellij/test.iml.SAMPLE @@ -6,6 +6,8 @@ <orderEntry type="inheritedJdk" /> <orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="module" module-name="library" /> + <orderEntry type="module" module-name="xml" /> + <orderEntry type="module" module-name="parser-combinators" /> <orderEntry type="module" module-name="reflect" /> <orderEntry type="module" module-name="compiler" /> <orderEntry type="module" module-name="actors" /> @@ -13,6 +15,7 @@ <orderEntry type="module" module-name="partest" /> <orderEntry type="module" module-name="asm" /> <orderEntry type="module" module-name="forkjoin" /> + <orderEntry type="library" name="junit" level="project" /> </component> </module> diff --git a/src/intellij/xml.iml.SAMPLE b/src/intellij/xml.iml.SAMPLE new file mode 100644 index 0000000000..b721f4e7f2 --- /dev/null +++ b/src/intellij/xml.iml.SAMPLE @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="JAVA_MODULE" version="4"> + <component name="FacetManager"> + <facet type="scala" name="Scala"> + <configuration> + <option name="compilerLibraryLevel" value="Project" /> + <option name="compilerLibraryName" value="compiler-locker" /> + <option name="maximumHeapSize" value="1536" /> + <option name="vmOptions" value="-Xms1536m -Xss1m -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=256m -XX:+CMSClassUnloadingEnabled -XX:+UseCompressedOops -XX:+UseParallelGC" /> + </configuration> + </facet> + </component> + <component name="NewModuleRootManager" inherit-compiler-output="true"> + <exclude-output /> + <content url="file://$MODULE_DIR$/../xml"> + <sourceFolder url="file://$MODULE_DIR$/../xml" isTestSource="false" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="module" module-name="library" /> + </component> +</module> diff --git a/src/library/scala/Boolean.scala b/src/library/scala/Boolean.scala index ddd11257c6..53b4fb2af2 100644 --- a/src/library/scala/Boolean.scala +++ b/src/library/scala/Boolean.scala @@ -6,12 +6,12 @@ ** |/ ** \* */ -// DO NOT EDIT, CHANGES WILL BE LOST. +// DO NOT EDIT, CHANGES WILL BE LOST +// This auto-generated code can be modified in scala.tools.cmd.gen. +// Afterwards, running tools/codegen-anyvals regenerates this source file. package scala -import scala.language.implicitConversions - /** `Boolean` (equivalent to Java's `boolean` primitive type) is a * subtype of [[scala.AnyVal]]. Instances of `Boolean` are not * represented by an object in the underlying runtime system. @@ -20,18 +20,16 @@ import scala.language.implicitConversions * which provides useful non-primitive operations. */ final abstract class Boolean private extends AnyVal { - /** - * Negates a Boolean expression. - * - * - `!a` results in `false` if and only if `a` evaluates to `true` and - * - `!a` results in `true` if and only if `a` evaluates to `false`. - * - * @return the negated expression - */ + /** Negates a Boolean expression. + * + * - `!a` results in `false` if and only if `a` evaluates to `true` and + * - `!a` results in `true` if and only if `a` evaluates to `false`. + * + * @return the negated expression + */ def unary_! : Boolean - /** - * Compares two Boolean expressions and returns `true` if they evaluate to the same value. + /** Compares two Boolean expressions and returns `true` if they evaluate to the same value. * * `a == b` returns `true` if and only if * - `a` and `b` are `true` or @@ -48,8 +46,7 @@ final abstract class Boolean private extends AnyVal { */ def !=(x: Boolean): Boolean - /** - * Compares two Boolean expressions and returns `true` if one or both of them evaluate to true. + /** Compares two Boolean expressions and returns `true` if one or both of them evaluate to true. * * `a || b` returns `true` if and only if * - `a` is `true` or @@ -62,8 +59,7 @@ final abstract class Boolean private extends AnyVal { */ def ||(x: Boolean): Boolean - /** - * Compares two Boolean expressions and returns `true` if both of them evaluate to true. + /** Compares two Boolean expressions and returns `true` if both of them evaluate to true. * * `a && b` returns `true` if and only if * - `a` and `b` are `true`. @@ -78,8 +74,7 @@ final abstract class Boolean private extends AnyVal { // def ||(x: => Boolean): Boolean // def &&(x: => Boolean): Boolean - /** - * Compares two Boolean expressions and returns `true` if one or both of them evaluate to true. + /** Compares two Boolean expressions and returns `true` if one or both of them evaluate to true. * * `a | b` returns `true` if and only if * - `a` is `true` or @@ -90,8 +85,7 @@ final abstract class Boolean private extends AnyVal { */ def |(x: Boolean): Boolean - /** - * Compares two Boolean expressions and returns `true` if both of them evaluate to true. + /** Compares two Boolean expressions and returns `true` if both of them evaluate to true. * * `a & b` returns `true` if and only if * - `a` and `b` are `true`. @@ -100,8 +94,7 @@ final abstract class Boolean private extends AnyVal { */ def &(x: Boolean): Boolean - /** - * Compares two Boolean expressions and returns `true` if they evaluate to a different value. + /** Compares two Boolean expressions and returns `true` if they evaluate to a different value. * * `a ^ b` returns `true` if and only if * - `a` is `true` and `b` is `false` or @@ -135,8 +128,7 @@ object Boolean extends AnyValCompanion { */ def unbox(x: java.lang.Object): Boolean = x.asInstanceOf[java.lang.Boolean].booleanValue() - /** The String representation of the scala.Boolean companion object. - */ + /** The String representation of the scala.Boolean companion object. */ override def toString = "object scala.Boolean" } diff --git a/src/library/scala/Byte.scala b/src/library/scala/Byte.scala index 2510e859c0..413231c0d1 100644 --- a/src/library/scala/Byte.scala +++ b/src/library/scala/Byte.scala @@ -6,12 +6,12 @@ ** |/ ** \* */ -// DO NOT EDIT, CHANGES WILL BE LOST. +// DO NOT EDIT, CHANGES WILL BE LOST +// This auto-generated code can be modified in scala.tools.cmd.gen. +// Afterwards, running tools/codegen-anyvals regenerates this source file. package scala -import scala.language.implicitConversions - /** `Byte`, a 8-bit signed integer (equivalent to Java's `byte` primitive type) is a * subtype of [[scala.AnyVal]]. Instances of `Byte` are not * represented by an object in the underlying runtime system. @@ -37,13 +37,9 @@ final abstract class Byte private extends AnyVal { * }}} */ def unary_~ : Int - /** - * Returns this value, unmodified. - */ + /** Returns this value, unmodified. */ def unary_+ : Int - /** - * Returns the negation of this value. - */ + /** Returns the negation of this value. */ def unary_- : Int def +(x: String): String @@ -105,178 +101,94 @@ final abstract class Byte private extends AnyVal { */ def >>(x: Long): Int - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Byte): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Short): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Char): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Int): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Long): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Float): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Double): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Byte): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Short): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Char): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Int): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Long): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Float): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Double): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Byte): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Short): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Char): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Int): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Long): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Float): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Double): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Byte): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Short): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Char): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Int): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Long): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Float): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Double): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Byte): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Short): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Char): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Int): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Long): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Float): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Double): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Byte): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Short): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Char): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Int): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Long): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Float): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Double): Boolean /** @@ -447,161 +359,89 @@ final abstract class Byte private extends AnyVal { */ def ^(x: Long): Long - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Byte): Int - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Short): Int - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Char): Int - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Int): Int - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Long): Long - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Float): Float - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Double): Double - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Byte): Int - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Short): Int - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Char): Int - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Int): Int - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Long): Long - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Float): Float - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Double): Double - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Byte): Int - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Short): Int - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Char): Int - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Int): Int - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Long): Long - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Float): Float - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Double): Double - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Byte): Int - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Short): Int - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Char): Int - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Int): Int - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Long): Long - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Float): Float - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Double): Double - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Byte): Int - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Short): Int - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Char): Int - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Int): Int - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Long): Long - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Float): Float - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Double): Double override def getClass(): Class[Byte] = null } object Byte extends AnyValCompanion { - /** The smallest value representable as a Byte. - */ + /** The smallest value representable as a Byte. */ final val MinValue = java.lang.Byte.MIN_VALUE - /** The largest value representable as a Byte. - */ + /** The largest value representable as a Byte. */ final val MaxValue = java.lang.Byte.MAX_VALUE /** Transform a value type into a boxed reference type. @@ -625,12 +465,10 @@ object Byte extends AnyValCompanion { */ def unbox(x: java.lang.Object): Byte = x.asInstanceOf[java.lang.Byte].byteValue() - /** The String representation of the scala.Byte companion object. - */ + /** The String representation of the scala.Byte companion object. */ override def toString = "object scala.Byte" - - /** Language mandated coercions from Byte to "wider" types. - */ + /** Language mandated coercions from Byte to "wider" types. */ + import scala.language.implicitConversions implicit def byte2short(x: Byte): Short = x.toShort implicit def byte2int(x: Byte): Int = x.toInt implicit def byte2long(x: Byte): Long = x.toLong diff --git a/src/library/scala/Char.scala b/src/library/scala/Char.scala index 1c9a2ba44f..ec2d48c181 100644 --- a/src/library/scala/Char.scala +++ b/src/library/scala/Char.scala @@ -6,12 +6,12 @@ ** |/ ** \* */ -// DO NOT EDIT, CHANGES WILL BE LOST. +// DO NOT EDIT, CHANGES WILL BE LOST +// This auto-generated code can be modified in scala.tools.cmd.gen. +// Afterwards, running tools/codegen-anyvals regenerates this source file. package scala -import scala.language.implicitConversions - /** `Char`, a 16-bit unsigned integer (equivalent to Java's `char` primitive type) is a * subtype of [[scala.AnyVal]]. Instances of `Char` are not * represented by an object in the underlying runtime system. @@ -37,13 +37,9 @@ final abstract class Char private extends AnyVal { * }}} */ def unary_~ : Int - /** - * Returns this value, unmodified. - */ + /** Returns this value, unmodified. */ def unary_+ : Int - /** - * Returns the negation of this value. - */ + /** Returns the negation of this value. */ def unary_- : Int def +(x: String): String @@ -105,178 +101,94 @@ final abstract class Char private extends AnyVal { */ def >>(x: Long): Int - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Byte): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Short): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Char): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Int): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Long): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Float): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Double): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Byte): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Short): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Char): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Int): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Long): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Float): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Double): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Byte): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Short): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Char): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Int): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Long): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Float): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Double): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Byte): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Short): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Char): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Int): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Long): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Float): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Double): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Byte): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Short): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Char): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Int): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Long): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Float): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Double): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Byte): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Short): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Char): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Int): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Long): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Float): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Double): Boolean /** @@ -447,161 +359,89 @@ final abstract class Char private extends AnyVal { */ def ^(x: Long): Long - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Byte): Int - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Short): Int - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Char): Int - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Int): Int - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Long): Long - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Float): Float - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Double): Double - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Byte): Int - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Short): Int - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Char): Int - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Int): Int - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Long): Long - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Float): Float - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Double): Double - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Byte): Int - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Short): Int - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Char): Int - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Int): Int - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Long): Long - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Float): Float - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Double): Double - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Byte): Int - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Short): Int - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Char): Int - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Int): Int - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Long): Long - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Float): Float - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Double): Double - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Byte): Int - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Short): Int - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Char): Int - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Int): Int - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Long): Long - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Float): Float - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Double): Double override def getClass(): Class[Char] = null } object Char extends AnyValCompanion { - /** The smallest value representable as a Char. - */ + /** The smallest value representable as a Char. */ final val MinValue = java.lang.Character.MIN_VALUE - /** The largest value representable as a Char. - */ + /** The largest value representable as a Char. */ final val MaxValue = java.lang.Character.MAX_VALUE /** Transform a value type into a boxed reference type. @@ -625,12 +465,10 @@ object Char extends AnyValCompanion { */ def unbox(x: java.lang.Object): Char = x.asInstanceOf[java.lang.Character].charValue() - /** The String representation of the scala.Char companion object. - */ + /** The String representation of the scala.Char companion object. */ override def toString = "object scala.Char" - - /** Language mandated coercions from Char to "wider" types. - */ + /** Language mandated coercions from Char to "wider" types. */ + import scala.language.implicitConversions implicit def char2int(x: Char): Int = x.toInt implicit def char2long(x: Char): Long = x.toLong implicit def char2float(x: Char): Float = x.toFloat diff --git a/src/library/scala/Double.scala b/src/library/scala/Double.scala index ce081bbec1..a58fa3ed25 100644 --- a/src/library/scala/Double.scala +++ b/src/library/scala/Double.scala @@ -6,12 +6,12 @@ ** |/ ** \* */ -// DO NOT EDIT, CHANGES WILL BE LOST. +// DO NOT EDIT, CHANGES WILL BE LOST +// This auto-generated code can be modified in scala.tools.cmd.gen. +// Afterwards, running tools/codegen-anyvals regenerates this source file. package scala -import scala.language.implicitConversions - /** `Double`, a 64-bit IEEE-754 floating point number (equivalent to Java's `double` primitive type) is a * subtype of [[scala.AnyVal]]. Instances of `Double` are not * represented by an object in the underlying runtime system. @@ -28,334 +28,176 @@ final abstract class Double private extends AnyVal { def toFloat: Float def toDouble: Double - /** - * Returns this value, unmodified. - */ + /** Returns this value, unmodified. */ def unary_+ : Double - /** - * Returns the negation of this value. - */ + /** Returns the negation of this value. */ def unary_- : Double def +(x: String): String - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Byte): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Short): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Char): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Int): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Long): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Float): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Double): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Byte): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Short): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Char): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Int): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Long): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Float): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Double): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Byte): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Short): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Char): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Int): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Long): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Float): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Double): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Byte): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Short): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Char): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Int): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Long): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Float): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Double): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Byte): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Short): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Char): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Int): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Long): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Float): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Double): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Byte): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Short): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Char): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Int): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Long): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Float): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Double): Boolean - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Byte): Double - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Short): Double - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Char): Double - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Int): Double - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Long): Double - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Float): Double - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Double): Double - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Byte): Double - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Short): Double - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Char): Double - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Int): Double - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Long): Double - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Float): Double - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Double): Double - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Byte): Double - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Short): Double - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Char): Double - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Int): Double - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Long): Double - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Float): Double - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Double): Double - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Byte): Double - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Short): Double - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Char): Double - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Int): Double - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Long): Double - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Float): Double - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Double): Double - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Byte): Double - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Short): Double - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Char): Double - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Int): Double - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Long): Double - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Float): Double - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Double): Double override def getClass(): Class[Double] = null @@ -401,8 +243,7 @@ object Double extends AnyValCompanion { */ def unbox(x: java.lang.Object): Double = x.asInstanceOf[java.lang.Double].doubleValue() - /** The String representation of the scala.Double companion object. - */ + /** The String representation of the scala.Double companion object. */ override def toString = "object scala.Double" } diff --git a/src/library/scala/Float.scala b/src/library/scala/Float.scala index 4ff2d509b8..3c59057a8d 100644 --- a/src/library/scala/Float.scala +++ b/src/library/scala/Float.scala @@ -6,12 +6,12 @@ ** |/ ** \* */ -// DO NOT EDIT, CHANGES WILL BE LOST. +// DO NOT EDIT, CHANGES WILL BE LOST +// This auto-generated code can be modified in scala.tools.cmd.gen. +// Afterwards, running tools/codegen-anyvals regenerates this source file. package scala -import scala.language.implicitConversions - /** `Float`, a 32-bit IEEE-754 floating point number (equivalent to Java's `float` primitive type) is a * subtype of [[scala.AnyVal]]. Instances of `Float` are not * represented by an object in the underlying runtime system. @@ -28,334 +28,176 @@ final abstract class Float private extends AnyVal { def toFloat: Float def toDouble: Double - /** - * Returns this value, unmodified. - */ + /** Returns this value, unmodified. */ def unary_+ : Float - /** - * Returns the negation of this value. - */ + /** Returns the negation of this value. */ def unary_- : Float def +(x: String): String - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Byte): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Short): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Char): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Int): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Long): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Float): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Double): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Byte): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Short): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Char): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Int): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Long): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Float): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Double): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Byte): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Short): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Char): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Int): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Long): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Float): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Double): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Byte): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Short): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Char): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Int): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Long): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Float): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Double): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Byte): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Short): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Char): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Int): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Long): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Float): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Double): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Byte): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Short): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Char): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Int): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Long): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Float): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Double): Boolean - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Byte): Float - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Short): Float - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Char): Float - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Int): Float - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Long): Float - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Float): Float - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Double): Double - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Byte): Float - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Short): Float - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Char): Float - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Int): Float - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Long): Float - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Float): Float - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Double): Double - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Byte): Float - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Short): Float - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Char): Float - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Int): Float - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Long): Float - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Float): Float - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Double): Double - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Byte): Float - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Short): Float - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Char): Float - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Int): Float - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Long): Float - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Float): Float - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Double): Double - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Byte): Float - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Short): Float - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Char): Float - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Int): Float - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Long): Float - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Float): Float - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Double): Double override def getClass(): Class[Float] = null @@ -401,12 +243,10 @@ object Float extends AnyValCompanion { */ def unbox(x: java.lang.Object): Float = x.asInstanceOf[java.lang.Float].floatValue() - /** The String representation of the scala.Float companion object. - */ + /** The String representation of the scala.Float companion object. */ override def toString = "object scala.Float" - - /** Language mandated coercions from Float to "wider" types. - */ + /** Language mandated coercions from Float to "wider" types. */ + import scala.language.implicitConversions implicit def float2double(x: Float): Double = x.toDouble } diff --git a/src/library/scala/Int.scala b/src/library/scala/Int.scala index 6a27195b10..72e5ebf81b 100644 --- a/src/library/scala/Int.scala +++ b/src/library/scala/Int.scala @@ -6,12 +6,12 @@ ** |/ ** \* */ -// DO NOT EDIT, CHANGES WILL BE LOST. +// DO NOT EDIT, CHANGES WILL BE LOST +// This auto-generated code can be modified in scala.tools.cmd.gen. +// Afterwards, running tools/codegen-anyvals regenerates this source file. package scala -import scala.language.implicitConversions - /** `Int`, a 32-bit signed integer (equivalent to Java's `int` primitive type) is a * subtype of [[scala.AnyVal]]. Instances of `Int` are not * represented by an object in the underlying runtime system. @@ -37,13 +37,9 @@ final abstract class Int private extends AnyVal { * }}} */ def unary_~ : Int - /** - * Returns this value, unmodified. - */ + /** Returns this value, unmodified. */ def unary_+ : Int - /** - * Returns the negation of this value. - */ + /** Returns the negation of this value. */ def unary_- : Int def +(x: String): String @@ -105,178 +101,94 @@ final abstract class Int private extends AnyVal { */ def >>(x: Long): Int - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Byte): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Short): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Char): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Int): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Long): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Float): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Double): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Byte): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Short): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Char): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Int): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Long): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Float): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Double): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Byte): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Short): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Char): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Int): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Long): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Float): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Double): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Byte): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Short): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Char): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Int): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Long): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Float): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Double): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Byte): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Short): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Char): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Int): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Long): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Float): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Double): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Byte): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Short): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Char): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Int): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Long): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Float): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Double): Boolean /** @@ -447,161 +359,89 @@ final abstract class Int private extends AnyVal { */ def ^(x: Long): Long - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Byte): Int - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Short): Int - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Char): Int - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Int): Int - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Long): Long - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Float): Float - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Double): Double - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Byte): Int - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Short): Int - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Char): Int - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Int): Int - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Long): Long - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Float): Float - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Double): Double - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Byte): Int - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Short): Int - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Char): Int - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Int): Int - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Long): Long - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Float): Float - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Double): Double - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Byte): Int - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Short): Int - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Char): Int - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Int): Int - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Long): Long - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Float): Float - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Double): Double - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Byte): Int - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Short): Int - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Char): Int - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Int): Int - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Long): Long - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Float): Float - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Double): Double override def getClass(): Class[Int] = null } object Int extends AnyValCompanion { - /** The smallest value representable as a Int. - */ + /** The smallest value representable as a Int. */ final val MinValue = java.lang.Integer.MIN_VALUE - /** The largest value representable as a Int. - */ + /** The largest value representable as a Int. */ final val MaxValue = java.lang.Integer.MAX_VALUE /** Transform a value type into a boxed reference type. @@ -625,12 +465,10 @@ object Int extends AnyValCompanion { */ def unbox(x: java.lang.Object): Int = x.asInstanceOf[java.lang.Integer].intValue() - /** The String representation of the scala.Int companion object. - */ + /** The String representation of the scala.Int companion object. */ override def toString = "object scala.Int" - - /** Language mandated coercions from Int to "wider" types. - */ + /** Language mandated coercions from Int to "wider" types. */ + import scala.language.implicitConversions implicit def int2long(x: Int): Long = x.toLong implicit def int2float(x: Int): Float = x.toFloat implicit def int2double(x: Int): Double = x.toDouble diff --git a/src/library/scala/Long.scala b/src/library/scala/Long.scala index 4d369ae010..1bd0fe88b1 100644 --- a/src/library/scala/Long.scala +++ b/src/library/scala/Long.scala @@ -6,12 +6,12 @@ ** |/ ** \* */ -// DO NOT EDIT, CHANGES WILL BE LOST. +// DO NOT EDIT, CHANGES WILL BE LOST +// This auto-generated code can be modified in scala.tools.cmd.gen. +// Afterwards, running tools/codegen-anyvals regenerates this source file. package scala -import scala.language.implicitConversions - /** `Long`, a 64-bit signed integer (equivalent to Java's `long` primitive type) is a * subtype of [[scala.AnyVal]]. Instances of `Long` are not * represented by an object in the underlying runtime system. @@ -37,13 +37,9 @@ final abstract class Long private extends AnyVal { * }}} */ def unary_~ : Long - /** - * Returns this value, unmodified. - */ + /** Returns this value, unmodified. */ def unary_+ : Long - /** - * Returns the negation of this value. - */ + /** Returns the negation of this value. */ def unary_- : Long def +(x: String): String @@ -105,178 +101,94 @@ final abstract class Long private extends AnyVal { */ def >>(x: Long): Long - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Byte): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Short): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Char): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Int): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Long): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Float): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Double): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Byte): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Short): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Char): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Int): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Long): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Float): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Double): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Byte): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Short): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Char): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Int): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Long): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Float): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Double): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Byte): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Short): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Char): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Int): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Long): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Float): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Double): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Byte): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Short): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Char): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Int): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Long): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Float): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Double): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Byte): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Short): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Char): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Int): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Long): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Float): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Double): Boolean /** @@ -447,161 +359,89 @@ final abstract class Long private extends AnyVal { */ def ^(x: Long): Long - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Byte): Long - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Short): Long - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Char): Long - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Int): Long - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Long): Long - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Float): Float - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Double): Double - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Byte): Long - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Short): Long - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Char): Long - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Int): Long - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Long): Long - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Float): Float - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Double): Double - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Byte): Long - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Short): Long - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Char): Long - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Int): Long - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Long): Long - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Float): Float - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Double): Double - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Byte): Long - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Short): Long - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Char): Long - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Int): Long - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Long): Long - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Float): Float - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Double): Double - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Byte): Long - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Short): Long - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Char): Long - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Int): Long - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Long): Long - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Float): Float - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Double): Double override def getClass(): Class[Long] = null } object Long extends AnyValCompanion { - /** The smallest value representable as a Long. - */ + /** The smallest value representable as a Long. */ final val MinValue = java.lang.Long.MIN_VALUE - /** The largest value representable as a Long. - */ + /** The largest value representable as a Long. */ final val MaxValue = java.lang.Long.MAX_VALUE /** Transform a value type into a boxed reference type. @@ -625,12 +465,10 @@ object Long extends AnyValCompanion { */ def unbox(x: java.lang.Object): Long = x.asInstanceOf[java.lang.Long].longValue() - /** The String representation of the scala.Long companion object. - */ + /** The String representation of the scala.Long companion object. */ override def toString = "object scala.Long" - - /** Language mandated coercions from Long to "wider" types. - */ + /** Language mandated coercions from Long to "wider" types. */ + import scala.language.implicitConversions implicit def long2float(x: Long): Float = x.toFloat implicit def long2double(x: Long): Double = x.toDouble } diff --git a/src/library/scala/Short.scala b/src/library/scala/Short.scala index 4f91c51550..36b9ec4df9 100644 --- a/src/library/scala/Short.scala +++ b/src/library/scala/Short.scala @@ -6,12 +6,12 @@ ** |/ ** \* */ -// DO NOT EDIT, CHANGES WILL BE LOST. +// DO NOT EDIT, CHANGES WILL BE LOST +// This auto-generated code can be modified in scala.tools.cmd.gen. +// Afterwards, running tools/codegen-anyvals regenerates this source file. package scala -import scala.language.implicitConversions - /** `Short`, a 16-bit signed integer (equivalent to Java's `short` primitive type) is a * subtype of [[scala.AnyVal]]. Instances of `Short` are not * represented by an object in the underlying runtime system. @@ -37,13 +37,9 @@ final abstract class Short private extends AnyVal { * }}} */ def unary_~ : Int - /** - * Returns this value, unmodified. - */ + /** Returns this value, unmodified. */ def unary_+ : Int - /** - * Returns the negation of this value. - */ + /** Returns the negation of this value. */ def unary_- : Int def +(x: String): String @@ -105,178 +101,94 @@ final abstract class Short private extends AnyVal { */ def >>(x: Long): Int - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Byte): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Short): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Char): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Int): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Long): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Float): Boolean - /** - * Returns `true` if this value is equal to x, `false` otherwise. - */ + /** Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Double): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Byte): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Short): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Char): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Int): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Long): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Float): Boolean - /** - * Returns `true` if this value is not equal to x, `false` otherwise. - */ + /** Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Double): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Byte): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Short): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Char): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Int): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Long): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Float): Boolean - /** - * Returns `true` if this value is less than x, `false` otherwise. - */ + /** Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Double): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Byte): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Short): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Char): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Int): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Long): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Float): Boolean - /** - * Returns `true` if this value is less than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Double): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Byte): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Short): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Char): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Int): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Long): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Float): Boolean - /** - * Returns `true` if this value is greater than x, `false` otherwise. - */ + /** Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Double): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Byte): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Short): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Char): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Int): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Long): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Float): Boolean - /** - * Returns `true` if this value is greater than or equal to x, `false` otherwise. - */ + /** Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Double): Boolean /** @@ -447,161 +359,89 @@ final abstract class Short private extends AnyVal { */ def ^(x: Long): Long - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Byte): Int - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Short): Int - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Char): Int - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Int): Int - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Long): Long - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Float): Float - /** - * Returns the sum of this value and `x`. - */ + /** Returns the sum of this value and `x`. */ def +(x: Double): Double - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Byte): Int - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Short): Int - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Char): Int - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Int): Int - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Long): Long - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Float): Float - /** - * Returns the difference of this value and `x`. - */ + /** Returns the difference of this value and `x`. */ def -(x: Double): Double - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Byte): Int - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Short): Int - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Char): Int - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Int): Int - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Long): Long - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Float): Float - /** - * Returns the product of this value and `x`. - */ + /** Returns the product of this value and `x`. */ def *(x: Double): Double - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Byte): Int - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Short): Int - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Char): Int - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Int): Int - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Long): Long - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Float): Float - /** - * Returns the quotient of this value and `x`. - */ + /** Returns the quotient of this value and `x`. */ def /(x: Double): Double - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Byte): Int - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Short): Int - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Char): Int - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Int): Int - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Long): Long - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Float): Float - /** - * Returns the remainder of the division of this value by `x`. - */ + /** Returns the remainder of the division of this value by `x`. */ def %(x: Double): Double override def getClass(): Class[Short] = null } object Short extends AnyValCompanion { - /** The smallest value representable as a Short. - */ + /** The smallest value representable as a Short. */ final val MinValue = java.lang.Short.MIN_VALUE - /** The largest value representable as a Short. - */ + /** The largest value representable as a Short. */ final val MaxValue = java.lang.Short.MAX_VALUE /** Transform a value type into a boxed reference type. @@ -625,12 +465,10 @@ object Short extends AnyValCompanion { */ def unbox(x: java.lang.Object): Short = x.asInstanceOf[java.lang.Short].shortValue() - /** The String representation of the scala.Short companion object. - */ + /** The String representation of the scala.Short companion object. */ override def toString = "object scala.Short" - - /** Language mandated coercions from Short to "wider" types. - */ + /** Language mandated coercions from Short to "wider" types. */ + import scala.language.implicitConversions implicit def short2int(x: Short): Int = x.toInt implicit def short2long(x: Short): Long = x.toLong implicit def short2float(x: Short): Float = x.toFloat diff --git a/src/library/scala/StringContext.scala b/src/library/scala/StringContext.scala index 42fb2f36e8..70f95750da 100644 --- a/src/library/scala/StringContext.scala +++ b/src/library/scala/StringContext.scala @@ -59,7 +59,8 @@ case class StringContext(parts: String*) { */ def checkLengths(args: Seq[Any]): Unit = if (parts.length != args.length + 1) - throw new IllegalArgumentException("wrong number of arguments for interpolated string") + throw new IllegalArgumentException("wrong number of arguments ("+ args.length + +") for interpolated string with "+ parts.length +" parts") /** The simple string interpolator. diff --git a/src/library/scala/Unit.scala b/src/library/scala/Unit.scala index 0e59a184d1..018ad24a99 100644 --- a/src/library/scala/Unit.scala +++ b/src/library/scala/Unit.scala @@ -6,12 +6,12 @@ ** |/ ** \* */ -// DO NOT EDIT, CHANGES WILL BE LOST. +// DO NOT EDIT, CHANGES WILL BE LOST +// This auto-generated code can be modified in scala.tools.cmd.gen. +// Afterwards, running tools/codegen-anyvals regenerates this source file. package scala -import scala.language.implicitConversions - /** `Unit` is a subtype of [[scala.AnyVal]]. There is only one value of type * `Unit`, `()`, and it is not represented by any object in the underlying @@ -41,8 +41,7 @@ object Unit extends AnyValCompanion { */ def unbox(x: java.lang.Object): Unit = () - /** The String representation of the scala.Unit companion object. - */ + /** The String representation of the scala.Unit companion object. */ override def toString = "object scala.Unit" } diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala index c01694960c..b11368acdf 100644 --- a/src/library/scala/collection/immutable/List.scala +++ b/src/library/scala/collection/immutable/List.scala @@ -161,6 +161,8 @@ sealed abstract class List[+A] extends AbstractSeq[A] * @inheritdoc */ @inline final def mapConserve[B >: A <: AnyRef](f: A => B): List[B] = { + // Note to developers: there exists a duplication between this function and `reflect.internal.util.Collections#map2Conserve`. + // If any successful optimization attempts or other changes are made, please rehash them there too. @tailrec def loop(mapped: ListBuffer[B], unchanged: List[A], pending: List[A]): List[B] = if (pending.isEmpty) { diff --git a/src/library/scala/collection/parallel/mutable/LazyCombiner.scala b/src/library/scala/collection/parallel/mutable/LazyCombiner.scala index cc25b5b4b2..5ab2bb81c6 100644 --- a/src/library/scala/collection/parallel/mutable/LazyCombiner.scala +++ b/src/library/scala/collection/parallel/mutable/LazyCombiner.scala @@ -30,6 +30,7 @@ trait LazyCombiner[Elem, +To, Buff <: Growable[Elem] with Sizing] extends Combin def result: To = allocateAndCopy def clear() = { chain.clear() } def combine[N <: Elem, NewTo >: To](other: Combiner[N, NewTo]): Combiner[N, NewTo] = if (this ne other) { + import language.existentials // FIXME: See SI-7750 if (other.isInstanceOf[LazyCombiner[_, _, _]]) { val that = other.asInstanceOf[LazyCombiner[Elem, To, Buff]] newLazyCombiner(chain ++= that.chain) diff --git a/src/library/scala/concurrent/Lock.scala b/src/library/scala/concurrent/Lock.scala index 4b8139702f..1c00c0e91f 100644 --- a/src/library/scala/concurrent/Lock.scala +++ b/src/library/scala/concurrent/Lock.scala @@ -14,6 +14,7 @@ package scala.concurrent * * @author Martin Odersky * @version 1.0, 10/03/2003 + * @deprecated("Use java.util.concurrent.locks.Lock", "2.11.0") */ class Lock { var available = true diff --git a/src/library/scala/runtime/ScalaRunTime.scala b/src/library/scala/runtime/ScalaRunTime.scala index c049de3a28..77fe2eb1e1 100644 --- a/src/library/scala/runtime/ScalaRunTime.scala +++ b/src/library/scala/runtime/ScalaRunTime.scala @@ -267,7 +267,18 @@ object ScalaRunTime { } def isScalaClass(x: AnyRef) = packageOf(x) startsWith "scala." def isScalaCompilerClass(x: AnyRef) = packageOf(x) startsWith "scala.tools.nsc." - def isXmlClass(x: AnyRef) = packageOf(x) startsWith "scala.xml." + + // We use reflection because the scala.xml package might not be available + def isSubClassOf(potentialSubClass: Class[_], ofClass: String) = + try { + val classLoader = potentialSubClass.getClassLoader + val clazz = Class.forName(ofClass, /*initialize =*/ false, classLoader) + clazz.isAssignableFrom(potentialSubClass) + } catch { + case cnfe: ClassNotFoundException => false + } + def isXmlNode(potentialSubClass: Class[_]) = isSubClassOf(potentialSubClass, "scala.xml.Node") + def isXmlMetaData(potentialSubClass: Class[_]) = isSubClassOf(potentialSubClass, "scala.xml.MetaData") // When doing our own iteration is dangerous def useOwnToString(x: Any) = x match { @@ -279,11 +290,12 @@ object ScalaRunTime { case _: StringLike[_] => true // Don't want to evaluate any elements in a view case _: TraversableView[_, _] => true - // Node extends NodeSeq extends Seq[Node] and MetaData extends Iterable[MetaData] -> catch those and more by isXmlClass(x) + // Node extends NodeSeq extends Seq[Node] and MetaData extends Iterable[MetaData] + // -> catch those by isXmlNode and isXmlMetaData. // Don't want to a) traverse infinity or b) be overly helpful with peoples' custom // collections which may have useful toString methods - ticket #3710 // or c) print AbstractFiles which are somehow also Iterable[AbstractFile]s. - case x: Traversable[_] => !x.hasDefiniteSize || !isScalaClass(x) || isScalaCompilerClass(x) || isXmlClass(x) + case x: Traversable[_] => !x.hasDefiniteSize || !isScalaClass(x) || isScalaCompilerClass(x) || isXmlNode(x.getClass) || isXmlMetaData(x.getClass) // Otherwise, nothing could possibly go wrong case _ => false } @@ -324,7 +336,7 @@ object ScalaRunTime { // to be iterated, such as some scala.tools.nsc.io.AbstractFile derived classes. try inner(arg) catch { - case _: StackOverflowError | _: UnsupportedOperationException | _: AssertionError => "" + arg + case _: UnsupportedOperationException | _: AssertionError => "" + arg } } @@ -335,20 +347,6 @@ object ScalaRunTime { nl + s + "\n" } - private[scala] def checkZip(what: String, coll1: TraversableOnce[_], coll2: TraversableOnce[_]) { - if (sys.props contains "scala.debug.zip") { - val xs = coll1.toIndexedSeq - val ys = coll2.toIndexedSeq - if (xs.length != ys.length) { - Console.err.println( - "Mismatched zip in " + what + ":\n" + - " this: " + xs.mkString(", ") + "\n" + - " that: " + ys.mkString(", ") - ) - (new Exception).getStackTrace.drop(2).take(10).foreach(println) - } - } - } def box[T](clazz: jClass[T]): jClass[_] = clazz match { case java.lang.Byte.TYPE => classOf[java.lang.Byte] diff --git a/src/library/scala/util/Properties.scala b/src/library/scala/util/Properties.scala index 02c461f3c6..8b63a73638 100644 --- a/src/library/scala/util/Properties.scala +++ b/src/library/scala/util/Properties.scala @@ -131,10 +131,9 @@ private[scala] trait PropertiesTrait { def javaVmName = propOrEmpty("java.vm.name") def javaVmVendor = propOrEmpty("java.vm.vendor") def javaVmVersion = propOrEmpty("java.vm.version") - // this property must remain less-well-known until 2.11 - private def javaSpecVersion = propOrEmpty("java.specification.version") - //private def javaSpecVendor = propOrEmpty("java.specification.vendor") - //private def javaSpecName = propOrEmpty("java.specification.name") + def javaSpecVersion = propOrEmpty("java.specification.version") + def javaSpecVendor = propOrEmpty("java.specification.vendor") + def javaSpecName = propOrEmpty("java.specification.name") def osName = propOrEmpty("os.name") def scalaHome = propOrEmpty("scala.home") def tmpDir = propOrEmpty("java.io.tmpdir") diff --git a/src/library/scala/util/matching/Regex.scala b/src/library/scala/util/matching/Regex.scala index 8eac0a2520..439b30e714 100644 --- a/src/library/scala/util/matching/Regex.scala +++ b/src/library/scala/util/matching/Regex.scala @@ -194,6 +194,44 @@ class Regex private[matching](val pattern: Pattern, groupNames: String*) extends else None } + /** Tries to match the String representation of a [[scala.Char]]. + * If the match succeeds, the result is the first matching + * group if any groups are defined, or an empty Sequence otherwise. + * + * For example: + * + * {{{ + * val cat = "cat" + * // the case must consume the group to match + * val r = """(\p{Lower})""".r + * cat(0) match { case r(x) => true } + * cat(0) match { case r(_) => true } + * cat(0) match { case r(_*) => true } + * cat(0) match { case r() => true } // no match + * + * // there is no group to extract + * val r = """\p{Lower}""".r + * cat(0) match { case r(x) => true } // no match + * cat(0) match { case r(_) => true } // no match + * cat(0) match { case r(_*) => true } // matches + * cat(0) match { case r() => true } // matches + * + * // even if there are multiple groups, only one is returned + * val r = """((.))""".r + * cat(0) match { case r(_) => true } // matches + * cat(0) match { case r(_,_) => true } // no match + * }}} + * + * @param c The Char to match + * @return The match + */ + def unapplySeq(c: Char): Option[Seq[Char]] = { + val m = pattern matcher c.toString + if (runMatcher(m)) { + if (m.groupCount > 0) Some(m group 1) else Some(Nil) + } else None + } + /** Tries to match on a [[scala.util.matching.Regex.Match]]. * A previously failed match results in None. * If a successful match was made against the current pattern, then that result is used. diff --git a/src/partest/scala/tools/partest/BytecodeTest.scala b/src/partest/scala/tools/partest/BytecodeTest.scala index 172fa29189..2690b784d1 100644 --- a/src/partest/scala/tools/partest/BytecodeTest.scala +++ b/src/partest/scala/tools/partest/BytecodeTest.scala @@ -55,7 +55,7 @@ abstract class BytecodeTest extends ASMConverters { val name2 = clazzB.name if (ms1.length != ms2.length) { - println("Different member counts in $name1 and $name2") + println(s"Different member counts in $name1 and $name2") false } else (ms1, ms2).zipped forall { (m1, m2) => diff --git a/src/partest/scala/tools/partest/TestState.scala b/src/partest/scala/tools/partest/TestState.scala index dbe8a222a5..e58b479e54 100644 --- a/src/partest/scala/tools/partest/TestState.scala +++ b/src/partest/scala/tools/partest/TestState.scala @@ -59,7 +59,6 @@ object TestState { def reason = s"caught $caught_s - ${caught.getMessage}" private def caught_s = (caught.getClass.getName split '.').last - private def stack_s = stackTraceString(caught) override def transcriptString = nljoin(super.transcriptString, caught_s) } } diff --git a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala index 332131ca3a..17c0b74cb7 100644 --- a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala +++ b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala @@ -89,11 +89,6 @@ class ConsoleRunner(argstr: String) extends { } def run(): Unit = { - if (optDebug) NestUI.setDebug() - if (optVerbose) NestUI.setVerbose() - if (optTerse) NestUI.setTerse() - if (optShowDiff) NestUI.setDiffOnFail() - // Early return on no args, version, or invalid args if (optVersion) return echo(versionMsg) if ((argstr == "") || optHelp) return NestUI.usage() @@ -138,7 +133,7 @@ class ConsoleRunner(argstr: String) extends { val rerunTests = if (isRerun) TestKinds.failedTests else Nil def miscTests = partestTests ++ individualTests ++ greppedTests ++ rerunTests - val givenKinds = standardKinds filter parsed.isSet + val givenKinds = standardKinds filter (parsed isSet "--" + _) val kinds = ( if (optAll) standardKinds else if (givenKinds.nonEmpty) givenKinds @@ -197,7 +192,7 @@ class ConsoleRunner(argstr: String) extends { val num = paths.size val ss = if (num == 1) "" else "s" comment(s"starting $num test$ss in $kind") - val results = runTestsForFiles(paths map (_.jfile), kind) + val results = runTestsForFiles(paths map (_.jfile.getAbsoluteFile), kind) val (passed, failed) = results partition (_.isOk) passedTests ++= passed @@ -212,7 +207,7 @@ class ConsoleRunner(argstr: String) extends { issueSummaryReport() System exit ( if (isSuccess) 0 else 1 ) } - + run() } diff --git a/src/partest/scala/tools/partest/nest/ConsoleRunnerSpec.scala b/src/partest/scala/tools/partest/nest/ConsoleRunnerSpec.scala index f9143013e9..bb831a4964 100644 --- a/src/partest/scala/tools/partest/nest/ConsoleRunnerSpec.scala +++ b/src/partest/scala/tools/partest/nest/ConsoleRunnerSpec.scala @@ -36,11 +36,11 @@ trait ConsoleRunnerSpec extends Spec with Meta.StdOpts with Interpolation { val optSourcePath = "srcpath" / "set (relative) path to test source files (ex.: --srcpath pending)" --| heading("Test output options:") - val optShowDiff = "show-diff" / "show diffs for failed tests" --? - val optVerbose = "verbose" / "show verbose progress information" --? - val optTerse = "terse" / "show terse progress information" --? - val optDebug = "debug" / "enable debugging output" --? - + val optShowDiff = "show-diff" / "show diffs for failed tests" --> NestUI.setDiffOnFail() + val optVerbose = "verbose" / "show verbose progress information" --> NestUI.setVerbose() + val optTerse = "terse" / "show terse progress information" --> NestUI.setTerse() + val optDebug = "debug" / "enable debugging output" --> NestUI.setDebug() + heading("Other options:") val optVersion = "version" / "show Scala version and exit" --? val optSelfTest = "self-test" / "run tests for partest itself" --? diff --git a/src/partest/scala/tools/partest/nest/FileManager.scala b/src/partest/scala/tools/partest/nest/FileManager.scala index 7bfa8c6e77..208418047c 100644 --- a/src/partest/scala/tools/partest/nest/FileManager.scala +++ b/src/partest/scala/tools/partest/nest/FileManager.scala @@ -148,7 +148,7 @@ trait FileManager extends FileUtil { val srcpath = Path(srcdir.path) val pd = (srcpath / plugxml).toFile if (pd.exists) pd copyTo (pout / plugxml) - pout + pout.toAbsolute } else Path(p) def absolutize(path: String) = pathOrCwd(path) match { case x if x.isAbsolute => x.path diff --git a/src/partest/scala/tools/partest/nest/NestUI.scala b/src/partest/scala/tools/partest/nest/NestUI.scala index 5148115905..d063c17ac0 100644 --- a/src/partest/scala/tools/partest/nest/NestUI.scala +++ b/src/partest/scala/tools/partest/nest/NestUI.scala @@ -28,7 +28,6 @@ class Colors(enabled: => Boolean) { object NestUI { private val testNum = new java.util.concurrent.atomic.AtomicInteger(1) @volatile private var testNumberFmt = "%3d" - // @volatile private var testNumber = 1 private def testNumber = testNumberFmt format testNum.getAndIncrement() def resetTestNumber(max: Int = -1) { testNum set 1 diff --git a/src/partest/scala/tools/partest/nest/Runner.scala b/src/partest/scala/tools/partest/nest/Runner.scala index d7d87bdcf5..fa2fb99f2f 100644 --- a/src/partest/scala/tools/partest/nest/Runner.scala +++ b/src/partest/scala/tools/partest/nest/Runner.scala @@ -17,11 +17,10 @@ import scala.reflect.internal.FatalError import scala.sys.process.{ Process, ProcessLogger } import scala.tools.nsc.Properties.{ envOrElse, isWin, jdkHome, javaHome, propOrElse, propOrEmpty, setProp } import scala.tools.nsc.{ Settings, CompilerCommand, Global } -import scala.tools.nsc.io.{ AbstractFile, PlainFile } import scala.tools.nsc.reporters.ConsoleReporter import scala.tools.nsc.util.{ Exceptional, ScalaClassLoader, stackTraceString } import scala.tools.scalap.Main.decompileScala -import scala.tools.scalap.scalax.rules.scalasig.ByteCode +import scala.tools.scalap.scalasig.ByteCode import scala.util.{ Try, Success, Failure } import ClassPath.{ join, split } import PartestDefaults.{ javaCmd, javacCmd } @@ -86,7 +85,7 @@ class Runner(val testFile: File, fileManager: FileManager, val testRunParams: Te type RanOneTest = (Boolean, LogContext) def showCrashInfo(t: Throwable) { - System.err.println("Crashed running test $testIdent: " + t) + System.err.println(s"Crashed running test $testIdent: $t") if (!isPartestTerse) System.err.println(stackTraceString(t)) } @@ -270,60 +269,54 @@ class Runner(val testFile: File, fileManager: FileManager, val testRunParams: Te false } - /** Filter the diff for conditional blocks. + /** Filter the check file for conditional blocks. * The check file can contain lines of the form: * `#partest java7` * where the line contains a conventional flag name. - * In the diff output, these lines have the form: - * `> #partest java7` - * Blocks which don't apply are filtered out, - * and what remains is the desired diff. - * Line edit commands such as `0a1,6` don't count - * as diff, so return a nonempty diff only if - * material diff output was seen. - * Filtering the diff output (instead of every check - * file) means that we only post-process a test that - * might be failing, in the normal case. + * If the flag tests true, succeeding lines are retained + * (removed on false) until the next #partest flag. + * A missing flag evaluates the same as true. */ - def diffilter(d: String) = { + def filteredCheck: Seq[String] = { import scala.util.Properties.{javaVersion, isAvian} - val prefix = "#partest" - val margin = "> " - val leader = margin + prefix // use lines in block so labeled? Default to sorry, Charlie. - def retainOn(f: String) = { + def retainOn(expr: String) = { + val f = expr.trim + def flagWasSet(f: String) = fileManager.SCALAC_OPTS contains f val (invert, token) = if (f startsWith "!") (true, f drop 1) else (false, f) - val cond = token match { + val cond = token.trim match { case "java7" => javaVersion startsWith "1.7" case "java6" => javaVersion startsWith "1.6" case "avian" => isAvian case "true" => true - case _ => false + case "-optimise" | "-optimize" + => flagWasSet("-optimise") || flagWasSet("-optimize") + case flag if flag startsWith "-" + => flagWasSet(flag) + case rest => rest.isEmpty } if (invert) !cond else cond } - if (d contains prefix) { - val sb = new StringBuilder - var retain = true // use the current line - var material = false // saw a line of diff - for (line <- d.lines) - if (line startsWith leader) { - val rest = (line stripPrefix leader).trim - retain = retainOn(rest) - } else if (retain) { - if (line startsWith margin) material = true - sb ++= line - sb ++= EOL - } - if (material) sb.toString else "" - } else d + val prefix = "#partest" + val b = new ListBuffer[String]() + var on = true + for (line <- file2String(checkFile).lines) { + if (line startsWith prefix) { + on = retainOn(line stripPrefix prefix) + } else if (on) { + b += line + } + } + b.toList } - def currentDiff = ( - if (checkFile.canRead) diffilter(compareFiles(logFile, checkFile)) - else compareContents(augmentString(file2String(logFile)).lines.toList, Nil) - ) + def currentDiff = { + val logged = augmentString(file2String(logFile)).lines.toList + val (other, othername) = + if (checkFile.canRead) (filteredCheck, checkFile.getName) else (Nil, "empty") + compareContents(logged, other, logFile.getName, othername) + } val gitRunner = List("/usr/local/bin/git", "/usr/bin/git") map (f => new java.io.File(f)) find (_.canRead) val gitDiffOptions = "--ignore-space-at-eol --no-index " + propOrEmpty("partest.git_diff_options") @@ -496,13 +489,7 @@ class Runner(val testFile: File, fileManager: FileManager, val testRunParams: Te def fsString = fs map (_.toString stripPrefix parentFile.toString + "/") mkString " " def isOk = result.isOk - def mkScalacString(): String = { - val flags = file2String(flagsFile) match { - case "" => "" - case s => " " + s - } - s"""scalac $fsString""" - } + def mkScalacString(): String = s"""scalac $fsString""" override def toString = description + ( if (result.isOk) "" else "\n" + result.status ) } case class OnlyJava(fs: List[File]) extends CompileRound { @@ -721,6 +708,9 @@ class Runner(val testFile: File, fileManager: FileManager, val testRunParams: Te } def run(): TestState = { + // javac runner, for one, would merely append to an existing log file, so just delete it before we start + logFile.delete() + if (kind == "neg" || (kind endsWith "-neg")) runNegTest() else kind match { case "pos" => runTestCommon(true) @@ -773,7 +763,7 @@ trait DirectRunner { import PartestDefaults.{ numThreads, waitTime } setUncaughtHandler - + def runTestsForFiles(kindFiles: List[File], kind: String): List[TestState] = { NestUI.resetTestNumber(kindFiles.size) @@ -786,7 +776,7 @@ trait DirectRunner { //val parentClassLoader = ScalaClassLoader fromURLs (List(scalaCheck.toURL), getClass().getClassLoader) val pool = Executors newFixedThreadPool numThreads val manager = new RunnerManager(kind, fileManager, TestRunParams(parentClassLoader)) - val futures = kindFiles map (f => pool submit callable(manager runTest f)) + val futures = kindFiles map (f => pool submit callable(manager runTest f.getAbsoluteFile)) pool.shutdown() Try (pool.awaitTermination(waitTime) { @@ -869,7 +859,6 @@ object Output { /** Use a Runner to run a test. */ class RunnerManager(kind: String, fileManager: FileManager, params: TestRunParams) { - import fileManager._ fileManager.CLASSPATH += File.pathSeparator + PathSettings.scalaCheck fileManager.CLASSPATH += File.pathSeparator + PathSettings.diffUtils // needed to put diffutils on test/partest's classpath @@ -881,7 +870,7 @@ class RunnerManager(kind: String, fileManager: FileManager, params: TestRunParam if (fileManager.failed && !runner.logFile.canRead) runner.genPass() else { - val (state, elapsed) = + val (state, _) = try timed(runner.run()) catch { case t: Throwable => throw new RuntimeException(s"Error running $testFile", t) diff --git a/src/partest/scala/tools/partest/package.scala b/src/partest/scala/tools/partest/package.scala index 5a1afeb77f..77400b1b9c 100644 --- a/src/partest/scala/tools/partest/package.scala +++ b/src/partest/scala/tools/partest/package.scala @@ -216,16 +216,16 @@ package object partest { c.Expr(Block( List(Apply( - Select(Ident(PredefModule), newTermName("println")), + Select(Ident(PredefModule), TermName("println")), List(Apply( Select(Apply( - Select(Ident(ScalaPackage), newTermName("StringContext")), + Select(Ident(ScalaPackage), TermName("StringContext")), List( Literal(Constant("trace> ")), Literal(Constant("\\nres: ")), Literal(Constant(" = ")), Literal(Constant("\\n")))), - newTermName("s")), + TermName("s")), List( Literal(Constant(show(a.tree))), Literal(Constant(show(a.actualType))), diff --git a/src/reflect/scala/reflect/api/Mirrors.scala b/src/reflect/scala/reflect/api/Mirrors.scala index d702555ba6..ec128e31a3 100644 --- a/src/reflect/scala/reflect/api/Mirrors.scala +++ b/src/reflect/scala/reflect/api/Mirrors.scala @@ -101,7 +101,7 @@ package api * via `ModuleMirror.instance`). Entry point: `val mm = im.reflectMethod(<method symbol>)`. * Example: * {{{ - * scala> val methodX = typeOf[C].declaration(newTermName("x")).asMethod + * scala> val methodX = typeOf[C].declaration(TermName("x")).asMethod * methodX: reflect.runtime.universe.MethodSymbol = method x * * scala> val mm = im.reflectMethod(methodX) @@ -126,7 +126,7 @@ package api * scala> val im = m.reflect(new C) * im: reflect.runtime.universe.InstanceMirror = instance mirror for C@5f0c8ac1 * - * scala> val fieldX = typeOf[C].declaration(newTermName("x")).asTerm.accessed.asTerm + * scala> val fieldX = typeOf[C].declaration(TermName("x")).asTerm.accessed.asTerm * fieldX: reflect.runtime.universe.TermSymbol = value x * scala> val fmX = im.reflectField(fieldX) * fmX: reflect.runtime.universe.FieldMirror = field mirror for C.x (bound to C@5f0c8ac1) @@ -136,7 +136,7 @@ package api * * scala> fmX.set(3) // NOTE: can set an underlying value of an immutable field! * - * scala> val fieldY = typeOf[C].declaration(newTermName("y")).asTerm.accessed.asTerm + * scala> val fieldY = typeOf[C].declaration(TermName("y")).asTerm.accessed.asTerm * fieldY: reflect.runtime.universe.TermSymbol = variable y * * scala> val fmY = im.reflectField(fieldY) @@ -255,7 +255,7 @@ trait Mirrors { self: Universe => * Note also that only accessor MethodMirrors, but not FieldMirrors will accurately reflect overriding behavior. * * To get a field symbol by the name of the field you would like to reflect, - * use `<this mirror>.symbol.typeSignature.member(newTermName(<name of the field>)).asTerm.accessed`. + * use `<this mirror>.symbol.typeSignature.member(TermName(<name of the field>)).asTerm.accessed`. * For further information about member lookup refer to `Symbol.typeSignature`. * * The input symbol can be either private or non-private (Scala reflection transparently deals with visibility). @@ -275,7 +275,7 @@ trait Mirrors { self: Universe => * that can be used to invoke the method provided. * * To get a method symbol by the name of the method you would like to reflect, - * use `<this mirror>.symbol.typeSignature.member(newTermName(<name of the method>)).asMethod`. + * use `<this mirror>.symbol.typeSignature.member(TermName(<name of the method>)).asMethod`. * For further information about member lookup refer to `Symbol.typeSignature`. * * The input symbol can be either private or non-private (Scala reflection transparently deals with visibility). @@ -299,7 +299,7 @@ trait Mirrors { self: Universe => * that can be used to get the instance of the object or inspect its companion class. * * To get a module symbol by the name of the object you would like to reflect, - * use `<this mirror>.symbol.typeSignature.member(newTermName(<name of the object>)).asModule`. + * use `<this mirror>.symbol.typeSignature.member(TermName(<name of the object>)).asModule`. * For further information about member lookup refer to `Symbol.typeSignature`. * * The input symbol can be either private or non-private (Scala reflection transparently deals with visibility). diff --git a/src/reflect/scala/reflect/api/Names.scala b/src/reflect/scala/reflect/api/Names.scala index f74e0ce014..87d7f9fd8e 100644 --- a/src/reflect/scala/reflect/api/Names.scala +++ b/src/reflect/scala/reflect/api/Names.scala @@ -33,13 +33,13 @@ trait Names { * Enables an alternative notation `"map": TermName` as opposed to `newTermName("map")`. * @group Names */ - implicit def stringToTermName(s: String): TermName = newTermName(s) + implicit def stringToTermName(s: String): TermName = TermName(s) /** An implicit conversion from String to TypeName. * Enables an alternative notation `"List": TypeName` as opposed to `newTypeName("List")`. * @group Names */ - implicit def stringToTypeName(s: String): TypeName = newTypeName(s) + implicit def stringToTypeName(s: String): TypeName = TypeName(s) /** The abstract type of names. * @group Names diff --git a/src/reflect/scala/reflect/api/Trees.scala b/src/reflect/scala/reflect/api/Trees.scala index f7a6a68946..443f34ccae 100644 --- a/src/reflect/scala/reflect/api/Trees.scala +++ b/src/reflect/scala/reflect/api/Trees.scala @@ -572,8 +572,8 @@ trait Trees { self: Universe => * @group Extractors */ abstract class DefDefExtractor { - def apply(mods: Modifiers, name: Name, tparams: List[TypeDef], vparamss: List[List[ValDef]], tpt: Tree, rhs: Tree): DefDef - def unapply(defDef: DefDef): Option[(Modifiers, Name, List[TypeDef], List[List[ValDef]], Tree, Tree)] + def apply(mods: Modifiers, name: TermName, tparams: List[TypeDef], vparamss: List[List[ValDef]], tpt: Tree, rhs: Tree): DefDef + def unapply(defDef: DefDef): Option[(Modifiers, TermName, List[TypeDef], List[List[ValDef]], Tree, Tree)] } /** The API that all def defs support @@ -584,7 +584,7 @@ trait Trees { self: Universe => def mods: Modifiers /** @inheritdoc */ - def name: Name + def name: TermName /** The type parameters of the method. */ def tparams: List[TypeDef] diff --git a/src/reflect/scala/reflect/internal/Kinds.scala b/src/reflect/scala/reflect/internal/Kinds.scala index 46a95c7d26..d1c215713e 100644 --- a/src/reflect/scala/reflect/internal/Kinds.scala +++ b/src/reflect/scala/reflect/internal/Kinds.scala @@ -233,7 +233,7 @@ trait Kinds { /** * The data structure describing the kind of a given type. - * + * * Proper types are represented using ProperTypeKind. * * Type constructors are reprented using TypeConKind. @@ -251,7 +251,7 @@ trait Kinds { * it uses prescribed letters for each level: A, F, X, Y, Z. */ def scalaNotation: String - + /** Kind notation used in http://adriaanm.github.com/files/higher.pdf. * Proper types are expressed as *. * Type constructors are expressed * -> *(lo, hi) -(+)-> *. @@ -261,13 +261,13 @@ trait Kinds { /** Contains bounds either as part of itself or its arguments. */ def hasBounds: Boolean = !bounds.isEmptyBounds - + private[internal] def buildState(sym: Symbol, v: Variance)(s: StringState): StringState } object Kind { private[internal] sealed trait ScalaNotation private[internal] sealed case class Head(order: Int, n: Option[Int], alias: Option[String]) extends ScalaNotation { - override def toString: String = { + override def toString: String = { alias getOrElse { typeAlias(order) + n.map(_.toString).getOrElse("") } @@ -285,7 +285,7 @@ trait Kinds { } private[internal] sealed case class Text(value: String) extends ScalaNotation { override def toString: String = value - } + } private[internal] case class StringState(tokens: Seq[ScalaNotation]) { override def toString: String = tokens.mkString def append(value: String): StringState = StringState(tokens :+ Text(value)) @@ -310,7 +310,7 @@ trait Kinds { ts map { case Head(`o`, _, a) => Head(o, None, a) case t => t - } + } else ts }) } @@ -332,7 +332,7 @@ trait Kinds { val order = 0 private[internal] def buildState(sym: Symbol, v: Variance)(s: StringState): StringState = { s.append(v.symbolicString).appendHead(order, sym).append(bounds.scalaNotation(_.toString)) - } + } def scalaNotation: String = Kind.Head(order, None, None) + bounds.scalaNotation(_.toString) def starNotation: String = "*" + bounds.starNotation(_.toString) } @@ -344,7 +344,7 @@ trait Kinds { class TypeConKind(val bounds: TypeBounds, val args: Seq[TypeConKind.Argument]) extends Kind { import Kind.StringState - val order = (args map {_.kind.order} max) + 1 + val order = (args map (_.kind.order)).max + 1 def description: String = if (order == 1) "This is a type constructor: a 1st-order-kinded type." else "This is a type constructor that takes type constructor(s): a higher-kinded type." @@ -380,7 +380,7 @@ trait Kinds { object TypeConKind { def apply(args: Seq[TypeConKind.Argument]): TypeConKind = this(TypeBounds.empty, args) def apply(bounds: TypeBounds, args: Seq[TypeConKind.Argument]): TypeConKind = new TypeConKind(bounds, args) - def unapply(tck: TypeConKind): Some[(TypeBounds, Seq[TypeConKind.Argument])] = Some(tck.bounds, tck.args) + def unapply(tck: TypeConKind): Some[(TypeBounds, Seq[TypeConKind.Argument])] = Some((tck.bounds, tck.args)) case class Argument(variance: Variance, kind: Kind)(val sym: Symbol) {} } @@ -389,7 +389,7 @@ trait Kinds { */ object inferKind { import TypeConKind.Argument - + abstract class InferKind { protected def infer(tpe: Type, owner: Symbol, topLevel: Boolean): Kind protected def infer(sym: Symbol, topLevel: Boolean): Kind = infer(sym.tpeHK, sym.owner, topLevel) @@ -398,7 +398,7 @@ trait Kinds { } def apply(pre: Type): InferKind = new InferKind { - protected def infer(tpe: Type, owner: Symbol, topLevel: Boolean): Kind = { + protected def infer(tpe: Type, owner: Symbol, topLevel: Boolean): Kind = { val bounds = if (topLevel) TypeBounds.empty else tpe.asSeenFrom(pre, owner).bounds if(!tpe.isHigherKinded) ProperTypeKind(bounds) diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala index ceb3b383d7..df1ba1e2ea 100644 --- a/src/reflect/scala/reflect/internal/Trees.scala +++ b/src/reflect/scala/reflect/internal/Trees.scala @@ -312,7 +312,7 @@ trait Trees extends api.Trees { self: SymbolTable => case class ValDef(mods: Modifiers, name: TermName, tpt: Tree, rhs: Tree) extends ValOrDefDef with ValDefApi object ValDef extends ValDefExtractor - case class DefDef(mods: Modifiers, name: Name, tparams: List[TypeDef], + case class DefDef(mods: Modifiers, name: TermName, tparams: List[TypeDef], vparamss: List[List[ValDef]], tpt: Tree, rhs: Tree) extends ValOrDefDef with DefDefApi object DefDef extends DefDefExtractor diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index 11527d88ca..71f46fedb7 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -80,7 +80,8 @@ trait Types with tpe.CommonOwners with tpe.GlbLubs with tpe.TypeMaps - with tpe.TypeConstraints { self: SymbolTable => + with tpe.TypeConstraints + with util.Collections { self: SymbolTable => import definitions._ import TypesStats._ @@ -4317,18 +4318,6 @@ trait Types } } - /** like map2, but returns list `xs` itself - instead of a copy - if function - * `f` maps all elements to themselves. - */ - def map2Conserve[A <: AnyRef, B](xs: List[A], ys: List[B])(f: (A, B) => A): List[A] = - if (xs.isEmpty || ys.isEmpty) xs - else { - val x1 = f(xs.head, ys.head) - val xs1 = map2Conserve(xs.tail, ys.tail)(f) - if ((x1 eq xs.head) && (xs1 eq xs.tail)) xs - else x1 :: xs1 - } - /** Do type arguments `targs` conform to formal parameters `tparams`? */ def isWithinBounds(pre: Type, owner: Symbol, tparams: List[Symbol], targs: List[Type]): Boolean = { diff --git a/src/reflect/scala/reflect/internal/transform/Erasure.scala b/src/reflect/scala/reflect/internal/transform/Erasure.scala index 580ada8254..90ffe9d9e7 100644 --- a/src/reflect/scala/reflect/internal/transform/Erasure.scala +++ b/src/reflect/scala/reflect/internal/transform/Erasure.scala @@ -60,7 +60,7 @@ trait Erasure { */ protected def unboundedGenericArrayLevel(tp: Type): Int = tp match { case GenericArray(level, core) if !(core <:< AnyRefTpe) => level - case RefinedType(ps, _) if ps.nonEmpty => logResult(s"Unbounded generic level for $tp is")(ps map unboundedGenericArrayLevel max) + case RefinedType(ps, _) if ps.nonEmpty => logResult(s"Unbounded generic level for $tp is")((ps map unboundedGenericArrayLevel).max) case _ => 0 } diff --git a/src/reflect/scala/reflect/internal/util/Collections.scala b/src/reflect/scala/reflect/internal/util/Collections.scala index e127d577e1..59af819dad 100644 --- a/src/reflect/scala/reflect/internal/util/Collections.scala +++ b/src/reflect/scala/reflect/internal/util/Collections.scala @@ -53,6 +53,42 @@ trait Collections { } lb.toList } + + /** like map2, but returns list `xs` itself - instead of a copy - if function + * `f` maps all elements to themselves. + */ + final def map2Conserve[A <: AnyRef, B](xs: List[A], ys: List[B])(f: (A, B) => A): List[A] = { + // Note to developers: there exists a duplication between this function and `List#mapConserve`. + // If any successful optimization attempts or other changes are made, please rehash them there too. + @tailrec + def loop(mapped: ListBuffer[A], unchanged: List[A], pending0: List[A], pending1: List[B]): List[A] = { + if (pending0.isEmpty || pending1.isEmpty) { + if (mapped eq null) unchanged + else mapped.prependToList(unchanged) + } else { + val head00 = pending0.head + val head01 = pending1.head + val head1 = f(head00, head01) + + if ((head1 eq head00.asInstanceOf[AnyRef])) { + loop(mapped, unchanged, pending0.tail, pending1.tail) + } else { + val b = if (mapped eq null) new ListBuffer[A] else mapped + var xc = unchanged + while ((xc ne pending0) && (xc ne pending1)) { + b += xc.head + xc = xc.tail + } + b += head1 + val tail0 = pending0.tail + val tail1 = pending1.tail + loop(b, tail0, tail0, tail1) + } + } + } + loop(null, xs, xs, ys) + } + final def map3[A, B, C, D](xs1: List[A], xs2: List[B], xs3: List[C])(f: (A, B, C) => D): List[D] = { if (xs1.isEmpty || xs2.isEmpty || xs3.isEmpty) Nil else f(xs1.head, xs2.head, xs3.head) :: map3(xs1.tail, xs2.tail, xs3.tail)(f) diff --git a/src/reflect/scala/reflect/internal/util/ScalaClassLoader.scala b/src/reflect/scala/reflect/internal/util/ScalaClassLoader.scala index a7fd787dfc..63ea6e2c49 100644 --- a/src/reflect/scala/reflect/internal/util/ScalaClassLoader.scala +++ b/src/reflect/scala/reflect/internal/util/ScalaClassLoader.scala @@ -44,7 +44,7 @@ trait ScalaClassLoader extends JClassLoader { /** Create an instance of a class with this classloader */ def create(path: String): AnyRef = - tryToInitializeClass[AnyRef](path) map (_.newInstance()) orNull + tryToInitializeClass[AnyRef](path).map(_.newInstance()).orNull /** The actual bytes for a class file, or an empty array if it can't be found. */ def classBytes(className: String): Array[Byte] = classAsStream(className) match { @@ -116,7 +116,7 @@ object ScalaClassLoader { /** True if supplied class exists in supplied path */ def classExists(urls: Seq[URL], name: String): Boolean = - fromURLs(urls) tryToLoadClass name isDefined + (fromURLs(urls) tryToLoadClass name).isDefined /** Finding what jar a clazz or instance came from */ def originOfClass(x: Class[_]): Option[URL] = diff --git a/src/reflect/scala/reflect/internal/util/TriState.scala b/src/reflect/scala/reflect/internal/util/TriState.scala index c7a35d4637..4074d974d2 100644 --- a/src/reflect/scala/reflect/internal/util/TriState.scala +++ b/src/reflect/scala/reflect/internal/util/TriState.scala @@ -3,6 +3,8 @@ package reflect package internal package util +import scala.language.implicitConversions + import TriState._ /** A simple true/false/unknown value, for those days when diff --git a/src/reflect/scala/reflect/internal/util/WeakHashSet.scala b/src/reflect/scala/reflect/internal/util/WeakHashSet.scala index 9b792a3f43..a8bc79d832 100644 --- a/src/reflect/scala/reflect/internal/util/WeakHashSet.scala +++ b/src/reflect/scala/reflect/internal/util/WeakHashSet.scala @@ -4,7 +4,7 @@ package reflect.internal.util import java.lang.ref.{WeakReference, ReferenceQueue} import scala.annotation.tailrec import scala.collection.generic.Clearable -import scala.collection.mutable.{Set => mSet} +import scala.collection.mutable.{Set => MSet} /** * A HashSet where the elements are stored weakly. Elements in this set are elligible for GC if no other @@ -16,8 +16,8 @@ import scala.collection.mutable.{Set => mSet} * This set implmeentation is not in general thread safe without external concurrency control. However it behaves * properly when GC concurrently collects elements in this set. */ -final class WeakHashSet[A <: AnyRef](val initialCapacity: Int, val loadFactor: Double) extends Set[A] with Function1[A, Boolean] with mSet[A] { - +final class WeakHashSet[A <: AnyRef](val initialCapacity: Int, val loadFactor: Double) extends Set[A] with Function1[A, Boolean] with MSet[A] { + import WeakHashSet._ def this() = this(initialCapacity = WeakHashSet.defaultInitialCapacity, loadFactor = WeakHashSet.defaultLoadFactor) @@ -47,7 +47,7 @@ final class WeakHashSet[A <: AnyRef](val initialCapacity: Int, val loadFactor: D candidate *= 2 } candidate - } + } /** * the underlying table of entries which is an array of Entry linked lists @@ -65,7 +65,7 @@ final class WeakHashSet[A <: AnyRef](val initialCapacity: Int, val loadFactor: D * find the bucket associated with an elements's hash code */ private[this] def bucketFor(hash: Int): Int = { - // spread the bits around to try to avoid accidental collisions using the + // spread the bits around to try to avoid accidental collisions using the // same algorithm as java.util.HashMap var h = hash h ^= h >>> 20 ^ h >>> 12 @@ -98,7 +98,7 @@ final class WeakHashSet[A <: AnyRef](val initialCapacity: Int, val loadFactor: D def poll(): Entry[A] = queue.poll().asInstanceOf[Entry[A]] @tailrec - def queueLoop { + def queueLoop(): Unit = { val stale = poll() if (stale != null) { val bucket = bucketFor(stale.hash) @@ -109,11 +109,11 @@ final class WeakHashSet[A <: AnyRef](val initialCapacity: Int, val loadFactor: D linkedListLoop(null, table(bucket)) - queueLoop + queueLoop() } } - - queueLoop + + queueLoop() } /** @@ -123,7 +123,7 @@ final class WeakHashSet[A <: AnyRef](val initialCapacity: Int, val loadFactor: D val oldTable = table table = new Array[Entry[A]](oldTable.size * 2) threshhold = computeThreshHold - + @tailrec def tableLoop(oldBucket: Int): Unit = if (oldBucket < oldTable.size) { @tailrec @@ -225,7 +225,7 @@ final class WeakHashSet[A <: AnyRef](val initialCapacity: Int, val loadFactor: D def +=(elem: A) = this + elem // from scala.reflect.interanl.Set - override def addEntry(x: A) { this += x } + override def addEntry(x: A) { this += x } // remove an element from this set and return this set override def -(elem: A): this.type = elem match { @@ -274,6 +274,7 @@ final class WeakHashSet[A <: AnyRef](val initialCapacity: Int, val loadFactor: D override def foreach[U](f: A => U): Unit = iterator foreach f + // It has the `()` because iterator runs `removeStaleEntries()` override def toList(): List[A] = iterator.toList // Iterator over all the elements in this set in no particular order @@ -292,7 +293,7 @@ final class WeakHashSet[A <: AnyRef](val initialCapacity: Int, val loadFactor: D */ private[this] var entry: Entry[A] = null - /** + /** * the element that will be the result of the next call to next() */ private[this] var lookaheadelement: A = null.asInstanceOf[A] @@ -339,7 +340,7 @@ final class WeakHashSet[A <: AnyRef](val initialCapacity: Int, val loadFactor: D * the entries must be stable. If any are garbage collected during validation * then an assertion may inappropriately fire. */ - def fullyValidate { + def fullyValidate: Unit = { var computedCount = 0 var bucket = 0 while (bucket < table.size) { @@ -407,10 +408,10 @@ final class WeakHashSet[A <: AnyRef](val initialCapacity: Int, val loadFactor: D e = e.tail } count - } + } } - private[util] def diagnostics = new Diagnostics + private[util] def diagnostics = new Diagnostics } /** diff --git a/src/reflect/scala/reflect/runtime/ReflectSetup.scala b/src/reflect/scala/reflect/runtime/ReflectSetup.scala index 84f159be00..6a364ff0be 100644 --- a/src/reflect/scala/reflect/runtime/ReflectSetup.scala +++ b/src/reflect/scala/reflect/runtime/ReflectSetup.scala @@ -2,7 +2,7 @@ package scala package reflect package runtime -import internal.{SomePhase, NoPhase, Phase, TreeGen} +import internal.{SomePhase, NoPhase, Phase} /** A helper trait to initialize things that need to be set before JavaMirrors and other * reflect specific traits are initialized */ diff --git a/src/scaladoc/scala/tools/nsc/doc/ScaladocAnalyzer.scala b/src/scaladoc/scala/tools/nsc/doc/ScaladocAnalyzer.scala index d407b93a4b..fe5ed47d43 100644 --- a/src/scaladoc/scala/tools/nsc/doc/ScaladocAnalyzer.scala +++ b/src/scaladoc/scala/tools/nsc/doc/ScaladocAnalyzer.scala @@ -7,12 +7,10 @@ package scala.tools.nsc package doc import scala.tools.nsc.ast.parser.{ SyntaxAnalyzer, BracePatch } -import scala.reflect.internal.Chars._ -import symtab._ import typechecker.Analyzer +import scala.reflect.internal.Chars._ import scala.reflect.internal.util.{ BatchSourceFile, RangePosition } import scala.tools.nsc.doc.base.{ CommentFactoryBase, MemberLookupBase, LinkTo, LinkToExternal } -import scala.language.postfixOps trait ScaladocAnalyzer extends Analyzer { val global : Global // generally, a ScaladocGlobal @@ -168,7 +166,7 @@ abstract class ScaladocSyntaxAnalyzer[G <: Global](val global: G) extends Syntax } override def internalLink(sym: Symbol, site: Symbol): Option[LinkTo] = None - override def chooseLink(links: List[LinkTo]): LinkTo = links.headOption orNull + override def chooseLink(links: List[LinkTo]): LinkTo = links.headOption.orNull override def toString(link: LinkTo): String = "No link" override def findExternalLink(sym: Symbol, name: String): Option[LinkToExternal] = None override def warnNoLink: Boolean = false diff --git a/src/scaladoc/scala/tools/nsc/doc/ScaladocGlobal.scala b/src/scaladoc/scala/tools/nsc/doc/ScaladocGlobal.scala index 723f8b1dc8..e654678c6d 100644 --- a/src/scaladoc/scala/tools/nsc/doc/ScaladocGlobal.scala +++ b/src/scaladoc/scala/tools/nsc/doc/ScaladocGlobal.scala @@ -7,7 +7,6 @@ package scala.tools.nsc package doc import scala.tools.nsc.ast.parser.{ SyntaxAnalyzer, BracePatch } -import scala.reflect.internal.Chars._ import symtab._ import reporters.Reporter import typechecker.Analyzer diff --git a/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala b/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala index c4e3c115be..8f217e087c 100644 --- a/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala +++ b/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala @@ -305,10 +305,9 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { else None } + private def templateAndType(ancestor: Symbol): (TemplateImpl, TypeEntity) = (makeTemplate(ancestor), makeType(reprSymbol.info.baseType(ancestor), this)) lazy val (linearizationTemplates, linearizationTypes) = - reprSymbol.ancestors map { ancestor => - (makeTemplate(ancestor), makeType(reprSymbol.info.baseType(ancestor), this)) - } unzip + (reprSymbol.ancestors map templateAndType).unzip /* Subclass cache */ private lazy val subClassesCache = ( @@ -321,7 +320,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { } def directSubClasses = if (subClassesCache == null) Nil else subClassesCache.toList - /* Implcitly convertible class cache */ + /* Implicitly convertible class cache */ private var implicitlyConvertibleClassesCache: mutable.ListBuffer[(DocTemplateImpl, ImplicitConversionImpl)] = null def registerImplicitlyConvertibleClass(dtpl: DocTemplateImpl, conv: ImplicitConversionImpl): Unit = { if (implicitlyConvertibleClassesCache == null) @@ -841,7 +840,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { def value = tree } } - case None => + case None => argTrees map { tree => new ValueArgument { def parameter = None diff --git a/src/scalap/scala/tools/scalap/Arguments.scala b/src/scalap/scala/tools/scalap/Arguments.scala index 9f139cb5ea..123516bb2d 100644 --- a/src/scalap/scala/tools/scalap/Arguments.scala +++ b/src/scalap/scala/tools/scalap/Arguments.scala @@ -5,7 +5,6 @@ ** */ - package scala.tools.scalap import scala.collection.mutable diff --git a/src/scalap/scala/tools/scalap/ByteArrayReader.scala b/src/scalap/scala/tools/scalap/ByteArrayReader.scala index 9c72bdbf1e..59f083ee76 100644 --- a/src/scalap/scala/tools/scalap/ByteArrayReader.scala +++ b/src/scalap/scala/tools/scalap/ByteArrayReader.scala @@ -5,13 +5,9 @@ ** */ - -package scala -package tools.scalap - +package scala.tools.scalap class ByteArrayReader(content: Array[Byte]) { - import java.io._ /** the buffer containing the file */ @@ -105,9 +101,6 @@ class ByteArrayReader(content: Array[Byte]) { def getDouble(bp: Int): Double = java.lang.Double.longBitsToDouble(getLong(bp)) /** skip next 'n' bytes - */ - def skip(n: Int) { - bp += n - } - + */ + def skip(n: Int): Unit = bp += n } diff --git a/src/scalap/scala/tools/scalap/Classfile.scala b/src/scalap/scala/tools/scalap/Classfile.scala index f62df285f9..d9d264bbbf 100644 --- a/src/scalap/scala/tools/scalap/Classfile.scala +++ b/src/scalap/scala/tools/scalap/Classfile.scala @@ -5,10 +5,8 @@ ** */ - package scala.tools.scalap - class Classfile(in: ByteArrayReader) { import Classfiles._ diff --git a/src/scalap/scala/tools/scalap/Classfiles.scala b/src/scalap/scala/tools/scalap/Classfiles.scala index 9295dd7aff..982a83cfa0 100644 --- a/src/scalap/scala/tools/scalap/Classfiles.scala +++ b/src/scalap/scala/tools/scalap/Classfiles.scala @@ -5,10 +5,8 @@ ** */ - package scala.tools.scalap - object Classfiles { final val JAVA_MAGIC = 0xCAFEBABE final val JAVA_MAJOR_VERSION = 45 diff --git a/src/scalap/scala/tools/scalap/CodeWriter.scala b/src/scalap/scala/tools/scalap/CodeWriter.scala index 168050096d..21c4399d5c 100644 --- a/src/scalap/scala/tools/scalap/CodeWriter.scala +++ b/src/scalap/scala/tools/scalap/CodeWriter.scala @@ -6,13 +6,9 @@ */ -package scala -package tools.scalap +package scala.tools.scalap -import java.io._ - - -class CodeWriter(writer: Writer) { +class CodeWriter(writer: java.io.Writer) { private val nl = scala.compat.Platform.EOL private var step = " " diff --git a/src/scalap/scala/tools/scalap/Decode.scala b/src/scalap/scala/tools/scalap/Decode.scala index 76ce3f4173..69325c1ec8 100644 --- a/src/scalap/scala/tools/scalap/Decode.scala +++ b/src/scalap/scala/tools/scalap/Decode.scala @@ -5,17 +5,14 @@ ** */ -// $Id$ - package scala.tools.scalap -import scala.tools.scalap.scalax.rules.scalasig._ -import scala.tools.nsc.util.ScalaClassLoader -import scala.tools.nsc.util.ScalaClassLoader.appLoader +import scala.tools.scalap.scalasig._ + +import scala.reflect.internal.util.ScalaClassLoader import scala.reflect.internal.pickling.ByteCodecs import ClassFileParser.{ ConstValueIndex, Annotation } -import Main.{ SCALA_SIG, SCALA_SIG_ANNOTATION, BYTES_VALUE } /** Temporary decoder. This would be better off in the scala.tools.nsc * but right now the compiler won't acknowledge scala.tools.scalap @@ -31,7 +28,7 @@ object Decode { /** Return the classfile bytes representing the scala sig classfile attribute. * This has been obsoleted by the switch to annotations. */ - def scalaSigBytes(name: String): Option[Array[Byte]] = scalaSigBytes(name, appLoader) + def scalaSigBytes(name: String): Option[Array[Byte]] = scalaSigBytes(name, ScalaClassLoader.appLoader) def scalaSigBytes(name: String, classLoader: ScalaClassLoader): Option[Array[Byte]] = { val bytes = classLoader.classBytes(name) val reader = new ByteArrayReader(bytes) @@ -39,17 +36,16 @@ object Decode { cf.scalaSigAttribute map (_.data) } - /** Return the bytes representing the annotation - */ - def scalaSigAnnotationBytes(name: String): Option[Array[Byte]] = scalaSigAnnotationBytes(name, appLoader) + /** Return the bytes representing the annotation. */ + def scalaSigAnnotationBytes(name: String): Option[Array[Byte]] = scalaSigAnnotationBytes(name, ScalaClassLoader.appLoader) def scalaSigAnnotationBytes(name: String, classLoader: ScalaClassLoader): Option[Array[Byte]] = { val bytes = classLoader.classBytes(name) val byteCode = ByteCode(bytes) val classFile = ClassFileParser.parse(byteCode) import classFile._ - classFile annotation SCALA_SIG_ANNOTATION map { case Annotation(_, els) => - val bytesElem = els find (x => constant(x.elementNameIndex) == BYTES_VALUE) getOrElse null + classFile annotation Main.SCALA_SIG_ANNOTATION map { case Annotation(_, els) => + val bytesElem = els find (x => constant(x.elementNameIndex) == Main.BYTES_VALUE) getOrElse null val _bytes = bytesElem.elementValue match { case ConstValueIndex(x) => constantWrapped(x) } val bytes = _bytes.asInstanceOf[StringBytesPair].bytes val length = ByteCodecs.decode(bytes) @@ -58,8 +54,7 @@ object Decode { } } - /** private[scala] so nobody gets the idea this is a supported interface. - */ + /** private[scala] so nobody gets the idea this is a supported interface. */ private[scala] def caseParamNames(path: String): Option[List[String]] = { val (outer, inner) = (path indexOf '$') match { case -1 => (path, "") @@ -67,7 +62,7 @@ object Decode { } for { - clazz <- appLoader.tryToLoadClass[AnyRef](outer) + clazz <- ScalaClassLoader.appLoader.tryToLoadClass[AnyRef](outer) ssig <- ScalaSigParser.parse(clazz) } yield { @@ -85,11 +80,10 @@ object Decode { } } - /** Returns a map of Alias -> Type for the given package. - */ + /** Returns a map of Alias -> Type for the given package. */ private[scala] def typeAliases(pkg: String) = { for { - clazz <- appLoader.tryToLoadClass[AnyRef](pkg + ".package") + clazz <- ScalaClassLoader.appLoader.tryToLoadClass[AnyRef](pkg + ".package") ssig <- ScalaSigParser.parse(clazz) } yield { diff --git a/src/scalap/scala/tools/scalap/JavaWriter.scala b/src/scalap/scala/tools/scalap/JavaWriter.scala index 772cf6eacd..1ba89e4702 100644 --- a/src/scalap/scala/tools/scalap/JavaWriter.scala +++ b/src/scalap/scala/tools/scalap/JavaWriter.scala @@ -5,13 +5,11 @@ ** */ - package scala.tools.scalap -import java.io._ import scala.reflect.NameTransformer -class JavaWriter(classfile: Classfile, writer: Writer) extends CodeWriter(writer) { +class JavaWriter(classfile: Classfile, writer: java.io.Writer) extends CodeWriter(writer) { val cf = classfile diff --git a/src/scalap/scala/tools/scalap/Main.scala b/src/scalap/scala/tools/scalap/Main.scala index 5da4227e53..44d7ef6a41 100644 --- a/src/scalap/scala/tools/scalap/Main.scala +++ b/src/scalap/scala/tools/scalap/Main.scala @@ -5,16 +5,16 @@ ** */ -package scala -package tools.scalap +package scala.tools.scalap import java.io.{ PrintStream, OutputStreamWriter, ByteArrayOutputStream } -import scala.reflect.NameTransformer -import scalax.rules.scalasig._ + import scala.tools.nsc.util.{ ClassPath, JavaClassPath } -import scala.tools.util.PathResolver -import ClassPath.DefaultJavaContext -import scala.tools.nsc.io.{ PlainFile, AbstractFile } +import scala.tools.nsc.util.ClassPath.DefaultJavaContext +import scala.tools.nsc.io.AbstractFile + +import scala.tools.scalap.scalasig._ + /**The main object used to execute scalap on the command-line. * @@ -104,7 +104,7 @@ class Main { // we have to encode every fragment of a name separately, otherwise the NameTransformer // will encode using unicode escaping dot separators as well // we can afford allocations because this is not a performance critical code - classname.split('.').map(NameTransformer.encode).mkString(".") + classname.split('.').map(scala.reflect.NameTransformer.encode).mkString(".") } val cls = path.findClass(encName) if (cls.isDefined && cls.get.binary.isDefined) { @@ -185,7 +185,7 @@ object Main extends Main { val cparg = List("-classpath", "-cp") map (arguments getArgument _) reduceLeft (_ orElse _) val path = cparg match { case Some(cp) => new JavaClassPath(DefaultJavaContext.classesInExpandedPath(cp), DefaultJavaContext) - case _ => PathResolver.fromPathString(".") // include '.' in the default classpath SI-6669 + case _ => scala.tools.util.PathResolver.fromPathString(".") // include '.' in the default classpath SI-6669 } // print the classpath if output is verbose if (verbose) diff --git a/src/scalap/scala/tools/scalap/MetaParser.scala b/src/scalap/scala/tools/scalap/MetaParser.scala index 8b4ffb3efd..324330466f 100644 --- a/src/scalap/scala/tools/scalap/MetaParser.scala +++ b/src/scalap/scala/tools/scalap/MetaParser.scala @@ -6,18 +6,15 @@ */ -package scala -package tools.scalap +package scala.tools.scalap -import java.io._ -import java.util._ /** a parser class for parsing meta type information in classfiles * generated by pico. */ class MetaParser(meta: String) { - val scanner = new StringTokenizer(meta, "()[], \t<;", true) + val scanner = new java.util.StringTokenizer(meta, "()[], \t<;", true) var token: String = _ val res = new StringBuffer diff --git a/src/scalap/scala/tools/scalap/Properties.scala b/src/scalap/scala/tools/scalap/Properties.scala index 8f9a9d8606..432dd495e9 100644 --- a/src/scalap/scala/tools/scalap/Properties.scala +++ b/src/scalap/scala/tools/scalap/Properties.scala @@ -9,8 +9,7 @@ package scala.tools.scalap /** Loads decoder.properties from the jar. */ -object Properties extends scala.util.PropertiesTrait -{ +object Properties extends scala.util.PropertiesTrait { protected def propCategory = "decoder" protected def pickJarBasedOn = classOf[Classfile] } diff --git a/src/scalap/scala/tools/scalap/scalax/rules/Memoisable.scala b/src/scalap/scala/tools/scalap/rules/Memoisable.scala index b4ce8cab23..418141bee7 100644 --- a/src/scalap/scala/tools/scalap/scalax/rules/Memoisable.scala +++ b/src/scalap/scala/tools/scalap/rules/Memoisable.scala @@ -10,26 +10,24 @@ // // ----------------------------------------------------------------------------- -package scala.tools.scalap -package scalax -package rules +package scala.tools.scalap.rules import scala.collection.mutable trait MemoisableRules extends Rules { - def memo[In <: Memoisable, Out, A, X](key : AnyRef)(toRule : => In => Result[Out, A, X]) = { + def memo[In <: Memoisable, Out, A, X](key: AnyRef)(toRule: => In => Result[Out, A, X]) = { lazy val rule = toRule from[In] { in => in.memo(key, rule(in)) } } - override def ruleWithName[In, Out, A, X](name : String, f : In => rules.Result[Out, A, X]) = super.ruleWithName(name, (in : In) => in match { - case s : Memoisable => s.memo(name, f(in)) + override def ruleWithName[In, Out, A, X](name: String, f: In => Result[Out, A, X]) = super.ruleWithName(name, (in: In) => in match { + case s: Memoisable => s.memo(name, f(in)) case _ => f(in) }) } trait Memoisable { - def memo[A](key : AnyRef, a : => A) : A + def memo[A](key: AnyRef, a: => A): A } @@ -40,22 +38,19 @@ object DefaultMemoisable { trait DefaultMemoisable extends Memoisable { protected val map = new mutable.HashMap[AnyRef, Any] - def memo[A](key : AnyRef, a : => A) = { + def memo[A](key: AnyRef, a: => A) = { map.getOrElseUpdate(key, compute(key, a)).asInstanceOf[A] } - protected def compute[A](key : AnyRef, a : => A): Any = a match { - case success : Success[_, _] => onSuccess(key, success); success + protected def compute[A](key: AnyRef, a: => A): Any = a match { + case success: Success[_, _] => onSuccess(key, success); success case other => if(DefaultMemoisable.debug) println(key + " -> " + other) other } - protected def onSuccess[S, T](key : AnyRef, result : Success[S, T]) { + protected def onSuccess[S, T](key: AnyRef, result: Success[S, T]) { val Success(out, t) = result if(DefaultMemoisable.debug) println(key + " -> " + t + " (" + out + ")") } } - - - diff --git a/src/scalap/scala/tools/scalap/rules/Result.scala b/src/scalap/scala/tools/scalap/rules/Result.scala new file mode 100644 index 0000000000..ae05416d7a --- /dev/null +++ b/src/scalap/scala/tools/scalap/rules/Result.scala @@ -0,0 +1,69 @@ +// ----------------------------------------------------------------------------- +// +// 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.rules; + +/** Represents the combined value of two rules applied in sequence. + * + * @see the Scala parser combinator + */ +case class ~[+A, +B](_1: A, _2: B) { + override def toString = "(" + _1 + " ~ " + _2 + ")" +} + + +sealed abstract class Result[+Out, +A, +X] { + def out: Out + def value: A + def error: X + + implicit def toOption: Option[A] + + def map[B](f: A => B): Result[Out, B, X] + def mapOut[Out2](f: Out => Out2): Result[Out2, A, X] + def map[Out2, B](f: (Out, A) => (Out2, B)): Result[Out2, B, X] + def flatMap[Out2, B](f: (Out, A) => Result[Out2, B, Nothing]): Result[Out2, B, X] + def orElse[Out2 >: Out, B >: A](other: => Result[Out2, B, Nothing]): Result[Out2, B, X] +} + +case class Success[+Out, +A](out: Out, value: A) extends Result[Out, A, Nothing] { + def error = throw new ScalaSigParserError("No error") + + def toOption = Some(value) + + def map[B](f: A => B): Result[Out, B, Nothing] = Success(out, f(value)) + def mapOut[Out2](f: Out => Out2): Result[Out2, A, Nothing] = Success(f(out), value) + def map[Out2, B](f: (Out, A) => (Out2, B)): Success[Out2, B] = f(out, value) match { case (out2, b) => Success(out2, b) } + def flatMap[Out2, B](f: (Out, A) => Result[Out2, B, Nothing]): Result[Out2, B, Nothing]= f(out, value) + def orElse[Out2 >: Out, B >: A](other: => Result[Out2, B, Nothing]): Result[Out2, B, Nothing] = this +} + +sealed abstract class NoSuccess[+X] extends Result[Nothing, Nothing, X] { + def out = throw new ScalaSigParserError("No output") + def value = throw new ScalaSigParserError("No value") + + def toOption = None + + def map[B](f: Nothing => B) = this + def mapOut[Out2](f: Nothing => Out2) = this + def map[Out2, B](f: (Nothing, Nothing) => (Out2, B)) = this + def flatMap[Out2, B](f: (Nothing, Nothing) => Result[Out2, B, Nothing]) = this + def orElse[Out2, B](other: => Result[Out2, B, Nothing]) = other +} + +case object Failure extends NoSuccess[Nothing] { + def error = throw new ScalaSigParserError("No error") +} + +case class ScalaSigParserError(msg: String) extends RuntimeException(msg) + +case class Error[+X](error: X) extends NoSuccess[X] diff --git a/src/scalap/scala/tools/scalap/rules/Rule.scala b/src/scalap/scala/tools/scalap/rules/Rule.scala new file mode 100644 index 0000000000..0a00111f7a --- /dev/null +++ b/src/scalap/scala/tools/scalap/rules/Rule.scala @@ -0,0 +1,172 @@ +// ----------------------------------------------------------------------------- +// +// 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.rules + +/** A Rule is a function from some input to a Result. The result may be: + * <ul> + * <li>Success, with a value of some type and an output that may serve as the input to subsequent rules.</li> + * <li>Failure. A failure may result in some alternative rule being applied.</li> + * <li>Error. No further rules should be attempted.</li> + * </ul> + * + * @author Andrew Foggin + * + * Inspired by the Scala parser combinator. + */ +trait Rule[-In, +Out, +A, +X] extends (In => Result[Out, A, X]) { + val factory: Rules + import factory._ + + def as(name: String) = ruleWithName(name, this) + + def flatMap[Out2, B, X2 >: X](fa2ruleb: A => Out => Result[Out2, B, X2]) = mapResult { + case Success(out, a) => fa2ruleb(a)(out) + case Failure => Failure + case err @ Error(_) => err + } + + def map[B](fa2b: A => B) = flatMap { a => out => Success(out, fa2b(a)) } + + def filter(f: A => Boolean) = flatMap { a => out => if(f(a)) Success(out, a) else Failure } + + def mapResult[Out2, B, Y](f: Result[Out, A, X] => Result[Out2, B, Y]) = rule { + in: In => f(apply(in)) + } + + def orElse[In2 <: In, Out2 >: Out, A2 >: A, X2 >: X](other: => Rule[In2, Out2, A2, X2]): Rule[In2, Out2, A2, X2] = new Choice[In2, Out2, A2, X2] { + val factory = Rule.this.factory + lazy val choices = Rule.this :: other :: Nil + } + + def orError[In2 <: In] = this orElse error[Any] + + def |[In2 <: In, Out2 >: Out, A2 >: A, X2 >: X](other: => Rule[In2, Out2, A2, X2]) = orElse(other) + + def ^^[B](fa2b: A => B) = map(fa2b) + + def ^^?[B](pf: PartialFunction[A, B]) = filter (pf.isDefinedAt(_)) ^^ pf + + def ??(pf: PartialFunction[A, Any]) = filter (pf.isDefinedAt(_)) + + def -^[B](b: B) = map { any => b } + + /** Maps an Error */ + def !^[Y](fx2y: X => Y) = mapResult { + case s @ Success(_, _) => s + case Failure => Failure + case Error(x) => Error(fx2y(x)) + } + + def >>[Out2, B, X2 >: X](fa2ruleb: A => Out => Result[Out2, B, X2]) = flatMap(fa2ruleb) + + def >->[Out2, B, X2 >: X](fa2resultb: A => Result[Out2, B, X2]) = flatMap { a => any => fa2resultb(a) } + + def >>?[Out2, B, X2 >: X](pf: PartialFunction[A, Rule[Out, Out2, B, X2]]) = filter(pf isDefinedAt _) flatMap pf + + def >>&[B, X2 >: X](fa2ruleb: A => Out => Result[Any, B, X2]) = flatMap { a => out => fa2ruleb(a)(out) mapOut { any => out } } + + def ~[Out2, B, X2 >: X](next: => Rule[Out, Out2, B, X2]) = for (a <- this; b <- next) yield new ~(a, b) + + def ~-[Out2, B, X2 >: X](next: => Rule[Out, Out2, B, X2]) = for (a <- this; b <- next) yield a + + def -~[Out2, B, X2 >: X](next: => Rule[Out, Out2, B, X2]) = for (a <- this; b <- next) yield b + + def ~++[Out2, B >: A, X2 >: X](next: => Rule[Out, Out2, Seq[B], X2]) = for (a <- this; b <- next) yield a :: b.toList + + /** Apply the result of this rule to the function returned by the next rule */ + def ~>[Out2, B, X2 >: X](next: => Rule[Out, Out2, A => B, X2]) = for (a <- this; fa2b <- next) yield fa2b(a) + + /** Apply the result of this rule to the function returned by the previous rule */ + def <~:[InPrev, B, X2 >: X](prev: => Rule[InPrev, In, A => B, X2]) = for (fa2b <- prev; a <- this) yield fa2b(a) + + def ~![Out2, B, X2 >: X](next: => Rule[Out, Out2, B, X2]) = for (a <- this; b <- next.orError) yield new ~(a, b) + + def ~-![Out2, B, X2 >: X](next: => Rule[Out, Out2, B, X2]) = for (a <- this; b <- next.orError) yield a + + def -~![Out2, B, X2 >: X](next: => Rule[Out, Out2, B, X2]) = for (a <- this; b <- next.orError) yield b + + def -[In2 <: In](exclude: => Rule[In2, Any, Any, Any]) = !exclude -~ this + + /** ^~^(f) is equivalent to ^^ { case b1 ~ b2 => f(b1, b2) } + */ + def ^~^[B1, B2, B >: A <% B1 ~ B2, C](f: (B1, B2) => C) = map { a => + (a: B1 ~ B2) match { case b1 ~ b2 => f(b1, b2) } + } + + /** ^~~^(f) is equivalent to ^^ { case b1 ~ b2 ~ b3 => f(b1, b2, b3) } + */ + def ^~~^[B1, B2, B3, B >: A <% B1 ~ B2 ~ B3, C](f: (B1, B2, B3) => C) = map { a => + (a: B1 ~ B2 ~ B3) match { case b1 ~ b2 ~ b3 => f(b1, b2, b3) } + } + + /** ^~~~^(f) is equivalent to ^^ { case b1 ~ b2 ~ b3 ~ b4 => f(b1, b2, b3, b4) } + */ + def ^~~~^[B1, B2, B3, B4, B >: A <% B1 ~ B2 ~ B3 ~ B4, C](f: (B1, B2, B3, B4) => C) = map { a => + (a: B1 ~ B2 ~ B3 ~ B4) match { case b1 ~ b2 ~ b3 ~ b4 => f(b1, b2, b3, b4) } + } + + /** ^~~~~^(f) is equivalent to ^^ { case b1 ~ b2 ~ b3 ~ b4 ~ b5 => f(b1, b2, b3, b4, b5) } + */ + def ^~~~~^[B1, B2, B3, B4, B5, B >: A <% B1 ~ B2 ~ B3 ~ B4 ~ B5, C](f: (B1, B2, B3, B4, B5) => C) = map { a => + (a: B1 ~ B2 ~ B3 ~ B4 ~ B5) match { case b1 ~ b2 ~ b3 ~ b4 ~ b5 => f(b1, b2, b3, b4, b5) } + } + + /** ^~~~~~^(f) is equivalent to ^^ { case b1 ~ b2 ~ b3 ~ b4 ~ b5 ~ b6 => f(b1, b2, b3, b4, b5, b6) } + */ + def ^~~~~~^[B1, B2, B3, B4, B5, B6, B >: A <% B1 ~ B2 ~ B3 ~ B4 ~ B5 ~ B6, C](f: (B1, B2, B3, B4, B5, B6) => C) = map { a => + (a: B1 ~ B2 ~ B3 ~ B4 ~ B5 ~ B6) match { case b1 ~ b2 ~ b3 ~ b4 ~ b5 ~ b6 => f(b1, b2, b3, b4, b5, b6) } + } + + /** ^~~~~~~^(f) is equivalent to ^^ { case b1 ~ b2 ~ b3 ~ b4 ~ b5 ~ b6 => f(b1, b2, b3, b4, b5, b6) } + */ + def ^~~~~~~^[B1, B2, B3, B4, B5, B6, B7, B >: A <% B1 ~ B2 ~ B3 ~ B4 ~ B5 ~ B6 ~ B7, C](f: (B1, B2, B3, B4, B5, B6, B7) => C) = map { a => + (a: B1 ~ B2 ~ B3 ~ B4 ~ B5 ~ B6 ~ B7) match { case b1 ~ b2 ~ b3 ~ b4 ~ b5 ~ b6 ~b7 => f(b1, b2, b3, b4, b5, b6, b7) } + } + + /** >~>(f) is equivalent to >> { case b1 ~ b2 => f(b1, b2) } + */ + def >~>[Out2, B1, B2, B >: A <% B1 ~ B2, C, X2 >: X](f: (B1, B2) => Out => Result[Out2, C, X2]) = flatMap { a => + (a: B1 ~ B2) match { case b1 ~ b2 => f(b1, b2) } + } + + /** ^-^(f) is equivalent to ^^ { b2 => b1 => f(b1, b2) } + */ + def ^-^ [B1, B2 >: A, C](f: (B1, B2) => C) = map { b2: B2 => b1: B1 => f(b1, b2) } + + /** ^~>~^(f) is equivalent to ^^ { case b2 ~ b3 => b1 => f(b1, b2, b3) } + */ + def ^~>~^ [B1, B2, B3, B >: A <% B2 ~ B3, C](f: (B1, B2, B3) => C) = map { a => + (a: B2 ~ B3) match { case b2 ~ b3 => b1: B1 => f(b1, b2, b3) } + } +} + + +trait Choice[-In, +Out, +A, +X] extends Rule[In, Out, A, X] { + def choices: List[Rule[In, Out, A, X]] + + def apply(in: In) = { + def oneOf(list: List[Rule[In, Out, A, X]]): Result[Out, A, X] = list match { + case Nil => Failure + case first :: rest => first(in) match { + case Failure => oneOf(rest) + case result => result + } + } + oneOf(choices) + } + + override def orElse[In2 <: In, Out2 >: Out, A2 >: A, X2 >: X](other: => Rule[In2, Out2, A2, X2]): Rule[In2, Out2, A2, X2] = new Choice[In2, Out2, A2, X2] { + val factory = Choice.this.factory + lazy val choices = Choice.this.choices ::: other :: Nil + } +} diff --git a/src/scalap/scala/tools/scalap/scalax/rules/Rules.scala b/src/scalap/scala/tools/scalap/rules/Rules.scala index 70926208b3..bdcc81c22d 100644 --- a/src/scalap/scala/tools/scalap/scalax/rules/Rules.scala +++ b/src/scalap/scala/tools/scalap/rules/Rules.scala @@ -11,11 +11,10 @@ // ----------------------------------------------------------------------------- package scala.tools.scalap -package scalax package rules trait Name { - def name : String + def name: String override def toString = name } @@ -26,13 +25,18 @@ trait Name { * Inspired by the Scala parser combinator. */ trait Rules { - implicit def rule[In, Out, A, X](f : In => Result[Out, A, X]) : Rule[In, Out, A, X] = new DefaultRule(f) - implicit def inRule[In, Out, A, X](rule : Rule[In, Out, A, X]) : InRule[In, Out, A, X] = new InRule(rule) - implicit def seqRule[In, A, X](rule : Rule[In, In, A, X]) : SeqRule[In, A, X] = new SeqRule(rule) + import scala.language.implicitConversions + implicit def rule[In, Out, A, X](f: In => Result[Out, A, X]): Rule[In, Out, A, X] = new DefaultRule(f) + implicit def inRule[In, Out, A, X](rule: Rule[In, Out, A, X]): InRule[In, Out, A, X] = new InRule(rule) + implicit def seqRule[In, A, X](rule: Rule[In, In, A, X]): SeqRule[In, A, X] = new SeqRule(rule) - def from[In] = new { - def apply[Out, A, X](f : In => Result[Out, A, X]) = rule(f) + trait FromRule[In] { + def apply[Out, A, X](f: In => Result[Out, A, X]): Rule[In, Out, A, X] + } + + def from[In] = new FromRule[In] { + def apply[Out, A, X](f: In => Result[Out, A, X]) = rule(f) } def state[s] = new StateRules { @@ -40,30 +44,30 @@ trait Rules { val factory = Rules.this } - def success[Out, A](out : Out, a : A) = rule { in : Any => Success(out, a) } + def success[Out, A](out: Out, a: A) = rule { in: Any => Success(out, a) } - def failure = rule { in : Any => Failure } + def failure = rule { in: Any => Failure } - def error[In] = rule { in : In => Error(in) } - def error[X](err : X) = rule { in : Any => Error(err) } + def error[In] = rule { in: In => Error(in) } + def error[X](err: X) = rule { in: Any => Error(err) } - def oneOf[In, Out, A, X](rules : Rule[In, Out, A, X] *) : Rule[In, Out, A, X] = new Choice[In, Out, A, X] { + def oneOf[In, Out, A, X](rules: Rule[In, Out, A, X] *): Rule[In, Out, A, X] = new Choice[In, Out, A, X] { val factory = Rules.this val choices = rules.toList } - def ruleWithName[In, Out, A, X](_name : String, f : In => Result[Out, A, X]) : Rule[In, Out, A, X] with Name = + def ruleWithName[In, Out, A, X](_name: String, f: In => Result[Out, A, X]): Rule[In, Out, A, X] with Name = new DefaultRule(f) with Name { val name = _name } - class DefaultRule[In, Out, A, X](f : In => Result[Out, A, X]) extends Rule[In, Out, A, X] { + class DefaultRule[In, Out, A, X](f: In => Result[Out, A, X]) extends Rule[In, Out, A, X] { val factory = Rules.this - def apply(in : In) = f(in) + def apply(in: In) = f(in) } /** Converts a rule into a function that throws an Exception on failure. */ - def expect[In, Out, A, Any](rule : Rule[In, Out, A, Any]) : In => A = (in) => rule(in) match { + def expect[In, Out, A, Any](rule: Rule[In, Out, A, Any]): In => A = (in) => rule(in) match { case Success(_, a) => a case Failure => throw new ScalaSigParserError("Unexpected failure") case Error(x) => throw new ScalaSigParserError("Unexpected error: " + x) @@ -82,30 +86,30 @@ trait StateRules { type S type Rule[+A, +X] = rules.Rule[S, S, A, X] - val factory : Rules + val factory: Rules import factory._ - def apply[A, X](f : S => Result[S, A, X]) = rule(f) + def apply[A, X](f: S => Result[S, A, X]) = rule(f) - def unit[A](a : => A) = apply { s => Success(s, a) } - def read[A](f : S => A) = apply { s => Success(s, f(s)) } + def unit[A](a: => A) = apply { s => Success(s, a) } + def read[A](f: S => A) = apply { s => Success(s, f(s)) } def get = apply { s => Success(s, s) } - def set(s : => S) = apply { oldS => Success(s, oldS) } + def set(s: => S) = apply { oldS => Success(s, oldS) } - def update(f : S => S) = apply { s => Success(s, f(s)) } + def update(f: S => S) = apply { s => Success(s, f(s)) } def nil = unit(Nil) def none = unit(None) /** Create a rule that identities if f(in) is true. */ - def cond(f : S => Boolean) = get filter f + def cond(f: S => Boolean) = get filter f /** Create a rule that succeeds if all of the given rules succeed. @param rules the rules to apply in sequence. */ - def allOf[A, X](rules : Seq[Rule[A, X]]) = { - def rep(in : S, rules : List[Rule[A, X]], results : List[A]) : Result[S, List[A], X] = { + def allOf[A, X](rules: Seq[Rule[A, X]]) = { + def rep(in: S, rules: List[Rule[A, X]], results: List[A]): Result[S, List[A], X] = { rules match { case Nil => Success(in, results.reverse) case rule::tl => rule(in) match { @@ -115,19 +119,19 @@ trait StateRules { } } } - in : S => rep(in, rules.toList, Nil) + in: S => rep(in, rules.toList, Nil) } /** Create a rule that succeeds with a list of all the provided rules that succeed. @param rules the rules to apply in sequence. */ - def anyOf[A, X](rules : Seq[Rule[A, X]]) = allOf(rules.map(_ ?)) ^^ { opts => opts.flatMap(x => x) } + def anyOf[A, X](rules: Seq[Rule[A, X]]) = allOf(rules.map(_ ?)) ^^ { opts => opts.flatMap(x => x) } /** Repeatedly apply a rule from initial value until finished condition is met. */ - def repeatUntil[T, X](rule : Rule[T => T, X])(finished : T => Boolean)(initial : T) = apply { + def repeatUntil[T, X](rule: Rule[T => T, X])(finished: T => Boolean)(initial: T) = apply { // more compact using HoF but written this way so it's tail-recursive - def rep(in : S, t : T) : Result[S, T, X] = { + def rep(in: S, t: T): Result[S, T, X] = { if (finished(t)) Success(in, t) else rule(in) match { case Success(out, f) => rep(out, f(t)) // SI-5189 f.asInstanceOf[T => T] diff --git a/src/scalap/scala/tools/scalap/scalax/rules/SeqRule.scala b/src/scalap/scala/tools/scalap/rules/SeqRule.scala index 51a789e041..e96a38b6be 100644 --- a/src/scalap/scala/tools/scalap/scalax/rules/SeqRule.scala +++ b/src/scalap/scala/tools/scalap/rules/SeqRule.scala @@ -10,81 +10,79 @@ // // ----------------------------------------------------------------------------- -package scala.tools.scalap -package scalax -package rules +package scala.tools.scalap.rules /** * A workaround for the difficulties of dealing with * a contravariant 'In' parameter type... */ -class InRule[In, +Out, +A, +X](rule : Rule[In, Out, A, X]) { +class InRule[In, +Out, +A, +X](rule: Rule[In, Out, A, X]) { - def mapRule[Out2, B, Y](f : Result[Out, A, X] => In => Result[Out2, B, Y]) : Rule[In, Out2, B, Y] = rule.factory.rule { - in : In => f(rule(in))(in) + def mapRule[Out2, B, Y](f: Result[Out, A, X] => In => Result[Out2, B, Y]): Rule[In, Out2, B, Y] = rule.factory.rule { + in: In => f(rule(in))(in) } /** Creates a rule that succeeds only if the original rule would fail on the given context. */ def unary_! : Rule[In, In, Unit, Nothing] = mapRule { - case Success(_, _) => in : In => Failure - case _ => in : In => Success(in, ()) + case Success(_, _) => in: In => Failure + case _ => in: In => Success(in, ()) } /** Creates a rule that succeeds if the original rule succeeds, but returns the original input. */ def & : Rule[In, In, A, X] = mapRule { - case Success(_, a) => in : In => Success(in, a) - case Failure => in : In => Failure - case Error(x) => in : In => Error(x) + case Success(_, a) => in: In => Success(in, a) + case Failure => in: In => Failure + case Error(x) => in: In => Error(x) } } -class SeqRule[S, +A, +X](rule : Rule[S, S, A, X]) { +class SeqRule[S, +A, +X](rule: Rule[S, S, A, X]) { import rule.factory._ def ? = rule mapRule { - case Success(out, a) => in : S => Success(out, Some(a)) - case Failure => in : S => Success(in, None) - case Error(x) => in : S => Error(x) + case Success(out, a) => in: S => Success(out, Some(a)) + case Failure => in: S => Success(in, None) + case Error(x) => in: S => Error(x) } /** Creates a rule that always succeeds with a Boolean value. * Value is 'true' if this rule succeeds, 'false' otherwise */ - def -? = ? map { _ isDefined } + def -? = ? map { _.isDefined } def * = from[S] { // tail-recursive function with reverse list accumulator - def rep(in : S, acc : List[A]) : Result[S, List[A], X] = rule(in) match { + def rep(in: S, acc: List[A]): Result[S, List[A], X] = rule(in) match { case Success(out, a) => rep(out, a :: acc) case Failure => Success(in, acc.reverse) - case err : Error[_] => err + case err: Error[_] => err } in => rep(in, Nil) } def + = rule ~++ * - def ~>?[B >: A, X2 >: X](f : => Rule[S, S, B => B, X2]) = for (a <- rule; fs <- f?) yield fs.foldLeft[B](a) { (b, f) => f(b) } + def ~>?[B >: A, X2 >: X](f: => Rule[S, S, B => B, X2]) = for (a <- rule; fs <- f?) yield fs.foldLeft[B](a) { (b, f) => f(b) } - def ~>*[B >: A, X2 >: X](f : => Rule[S, S, B => B, X2]) = for (a <- rule; fs <- f*) yield fs.foldLeft[B](a) { (b, f) => f(b) } + def ~>*[B >: A, X2 >: X](f: => Rule[S, S, B => B, X2]) = for (a <- rule; fs <- f*) yield fs.foldLeft[B](a) { (b, f) => f(b) } - def ~*~[B >: A, X2 >: X](join : => Rule[S, S, (B, B) => B, X2]) = { - this ~>* (for (f <- join; a <- rule) yield f(_ : B, a)) + def ~*~[B >: A, X2 >: X](join: => Rule[S, S, (B, B) => B, X2]) = { + this ~>* (for (f <- join; a <- rule) yield f(_: B, a)) } /** Repeats this rule one or more times with a separator (which is discarded) */ - def +/[X2 >: X](sep : => Rule[S, S, Any, X2]) = rule ~++ (sep -~ rule *) + def +/[X2 >: X](sep: => Rule[S, S, Any, X2]) = rule ~++ (sep -~ rule *) /** Repeats this rule zero or more times with a separator (which is discarded) */ - def */[X2 >: X](sep : => Rule[S, S, Any, X2]) = +/(sep) | state[S].nil + def */[X2 >: X](sep: => Rule[S, S, Any, X2]) = +/(sep) | state[S].nil - def *~-[Out, X2 >: X](end : => Rule[S, Out, Any, X2]) = (rule - end *) ~- end - def +~-[Out, X2 >: X](end : => Rule[S, Out, Any, X2]) = (rule - end +) ~- end + def *~-[Out, X2 >: X](end: => Rule[S, Out, Any, X2]) = (rule - end *) ~- end + def +~-[Out, X2 >: X](end: => Rule[S, Out, Any, X2]) = (rule - end +) ~- end /** Repeats this rule num times */ - def times(num : Int) : Rule[S, S, Seq[A], X] = from[S] { + def times(num: Int): Rule[S, S, Seq[A], X] = from[S] { val result = new scala.collection.mutable.ArraySeq[A](num) // more compact using HoF but written this way so it's tail-recursive - def rep(i : Int, in : S) : Result[S, Seq[A], X] = { + def rep(i: Int, in: S): Result[S, Seq[A], X] = { if (i == num) Success(in, result) else rule(in) match { case Success(out, a) => { @@ -92,10 +90,9 @@ class SeqRule[S, +A, +X](rule : Rule[S, S, A, X]) { rep(i + 1, out) } case Failure => Failure - case err : Error[_] => err + case err: Error[_] => err } } in => rep(0, in) } } - diff --git a/src/scalap/scala/tools/scalap/rules/package.scala b/src/scalap/scala/tools/scalap/rules/package.scala new file mode 100644 index 0000000000..dcd5f7ac00 --- /dev/null +++ b/src/scalap/scala/tools/scalap/rules/package.scala @@ -0,0 +1,6 @@ +package scala.tools.scalap + +package object rules { + // make some language features in this package compile without warning + implicit def postfixOps = scala.language.postfixOps +} diff --git a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ClassFileParser.scala b/src/scalap/scala/tools/scalap/scalasig/ClassFileParser.scala index 1a4b3456b8..9bd8402ccc 100644 --- a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ClassFileParser.scala +++ b/src/scalap/scala/tools/scalap/scalasig/ClassFileParser.scala @@ -1,18 +1,11 @@ -package scala.tools.scalap -package scalax -package rules -package scalasig +package scala.tools.scalap.scalasig - -import java.io.IOException - -import scala._ -import scala.Predef._ +import scala.tools.scalap.rules.{ Success, Failure, ~, RulesWithState } object ByteCode { - def apply(bytes : Array[Byte]) = new ByteCode(bytes, 0, bytes.length) + def apply(bytes: Array[Byte]) = new ByteCode(bytes, 0, bytes.length) - def forClass(clazz : Class[_]) = { + def forClass(clazz: Class[_]) = { val name = clazz.getName val subPath = name.substring(name.lastIndexOf('.') + 1) + ".class" val in = clazz.getResourceAsStream(subPath) @@ -22,7 +15,7 @@ object ByteCode { val bytes = new Array[Byte](rest) while (rest > 0) { val res = in.read(bytes, bytes.length - rest, rest) - if (res == -1) throw new IOException("read error") + if (res == -1) throw new java.io.IOException("read error") rest -= res } ByteCode(bytes) @@ -33,19 +26,18 @@ object ByteCode { } } -/** Represents a chunk of raw bytecode. Used as input for the parsers - */ -class ByteCode(val bytes : Array[Byte], val pos : Int, val length : Int) { +/** Represents a chunk of raw bytecode. Used as input for the parsers. */ +class ByteCode(val bytes: Array[Byte], val pos: Int, val length: Int) { assert(pos >= 0 && length >= 0 && pos + length <= bytes.length) def nextByte = if (length == 0) Failure else Success(drop(1), bytes(pos)) - def next(n : Int) = if (length >= n) Success(drop(n), take(n)) else Failure + def next(n: Int) = if (length >= n) Success(drop(n), take(n)) else Failure - def take(n : Int) = new ByteCode(bytes, pos, n) - def drop(n : Int) = new ByteCode(bytes, pos + n, length - n) + def take(n: Int) = new ByteCode(bytes, pos, n) + def drop(n: Int) = new ByteCode(bytes, pos + n, length - n) - def fold[X](x : X)(f : (X, Byte) => X) : X = { + def fold[X](x: X)(f: (X, Byte) => X): X = { var result = x var i = pos while (i < pos + length) { @@ -72,7 +64,7 @@ class ByteCode(val bytes : Array[Byte], val pos : Int, val length : Int) { StringBytesPair(str, chunk) } - def byte(i : Int) = bytes(pos) & 0xFF + def byte(i: Int) = bytes(pos) & 0xFF } /** @@ -86,22 +78,22 @@ trait ByteCodeReader extends RulesWithState { type S = ByteCode type Parser[A] = Rule[A, String] - val byte = apply(_ nextByte) + val byte = apply(_.nextByte) val u1 = byte ^^ (_ & 0xFF) - val u2 = bytes(2) ^^ (_ toInt) - val u4 = bytes(4) ^^ (_ toInt) // should map to Long?? + val u2 = bytes(2) ^^ (_.toInt) + val u4 = bytes(4) ^^ (_.toInt) // should map to Long?? - def bytes(n : Int) = apply(_ next n) + def bytes(n: Int) = apply(_ next n) } object ClassFileParser extends ByteCodeReader { - def parse(byteCode : ByteCode) = expect(classFile)(byteCode) + def parse(byteCode: ByteCode) = expect(classFile)(byteCode) def parseAnnotations(byteCode: ByteCode) = expect(annotations)(byteCode) val magicNumber = (u4 filter (_ == 0xCAFEBABE)) | error("Not a valid class file") val version = u2 ~ u2 ^^ { case minor ~ major => (major, minor) } - val constantPool = (u2 ^^ ConstantPool) >> repeatUntil(constantPoolEntry)(_ isFull) + val constantPool = (u2 ^^ ConstantPool) >> repeatUntil(constantPoolEntry)(_.isFull) // NOTE currently most constants just evaluate to a string description // TODO evaluate to useful values @@ -169,19 +161,19 @@ object ClassFileParser extends ByteCodeReader { val classFile = header ~ fields ~ methods ~ attributes ~- !u1 ^~~~^ ClassFile // TODO create a useful object, not just a string - def memberRef(description : String) = u2 ~ u2 ^^ add1 { + def memberRef(description: String) = u2 ~ u2 ^^ add1 { case classRef ~ nameAndTypeRef => pool => description + ": " + pool(classRef) + ", " + pool(nameAndTypeRef) } - def add1[T](f : T => ConstantPool => Any)(raw : T)(pool : ConstantPool) = pool add f(raw) - def add2[T](f : T => ConstantPool => Any)(raw : T)(pool : ConstantPool) = pool add f(raw) add { pool => "<empty>" } + def add1[T](f: T => ConstantPool => Any)(raw: T)(pool: ConstantPool) = pool add f(raw) + def add2[T](f: T => ConstantPool => Any)(raw: T)(pool: ConstantPool) = pool add f(raw) add { pool => "<empty>" } } case class ClassFile( - header : ClassFileHeader, - fields : Seq[Field], - methods : Seq[Method], - attributes : Seq[Attribute]) { + header: ClassFileHeader, + fields: Seq[Field], + methods: Seq[Method], + attributes: Seq[Attribute]) { def majorVersion = header.major def minorVersion = header.minor @@ -190,14 +182,14 @@ case class ClassFile( def superClass = constant(header.superClassIndex) def interfaces = header.interfaces.map(constant) - def constant(index : Int) = header.constants(index) match { + def constant(index: Int) = header.constants(index) match { case StringBytesPair(str, _) => str case z => z } def constantWrapped(index: Int) = header.constants(index) - def attribute(name : String) = attributes.find {attrib => constant(attrib.nameIndex) == name } + def attribute(name: String) = attributes.find {attrib => constant(attrib.nameIndex) == name } val RUNTIME_VISIBLE_ANNOTATIONS = "RuntimeVisibleAnnotations" def annotations = (attributes.find(attr => constant(attr.nameIndex) == RUNTIME_VISIBLE_ANNOTATIONS) @@ -206,23 +198,23 @@ case class ClassFile( def annotation(name: String) = annotations.flatMap(seq => seq.find(annot => constant(annot.typeIndex) == name)) } -case class Attribute(nameIndex : Int, byteCode : ByteCode) -case class Field(flags : Int, nameIndex : Int, descriptorIndex : Int, attributes : Seq[Attribute]) -case class Method(flags : Int, nameIndex : Int, descriptorIndex : Int, attributes : Seq[Attribute]) +case class Attribute(nameIndex: Int, byteCode: ByteCode) +case class Field(flags: Int, nameIndex: Int, descriptorIndex: Int, attributes: Seq[Attribute]) +case class Method(flags: Int, nameIndex: Int, descriptorIndex: Int, attributes: Seq[Attribute]) case class ClassFileHeader( - minor : Int, - major : Int, - constants : ConstantPool, - flags : Int, - classIndex : Int, - superClassIndex : Int, - interfaces : Seq[Int]) { - - def constant(index : Int) = constants(index) + minor: Int, + major: Int, + constants: ConstantPool, + flags: Int, + classIndex: Int, + superClassIndex: Int, + interfaces: Seq[Int]) { + + def constant(index: Int) = constants(index) } -case class ConstantPool(len : Int) { +case class ConstantPool(len: Int) { val size = len - 1 private val buffer = new scala.collection.mutable.ArrayBuffer[ConstantPool => Any] @@ -230,7 +222,7 @@ case class ConstantPool(len : Int) { def isFull = buffer.length >= size - def apply(index : Int) = { + def apply(index: Int) = { // Note constant pool indices are 1-based val i = index - 1 values(i) getOrElse { @@ -241,9 +233,8 @@ case class ConstantPool(len : Int) { } } - def add(f : ConstantPool => Any) = { + def add(f: ConstantPool => Any) = { buffer += f this } } - diff --git a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/Flags.scala b/src/scalap/scala/tools/scalap/scalasig/Flags.scala index 218639e4a2..b9925150d2 100644 --- a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/Flags.scala +++ b/src/scalap/scala/tools/scalap/scalasig/Flags.scala @@ -1,10 +1,7 @@ -package scala.tools.scalap -package scalax -package rules -package scalasig +package scala.tools.scalap.scalasig trait Flags { - def hasFlag(flag : Long) : Boolean + def hasFlag(flag: Long): Boolean def isImplicit = hasFlag(0x00000001) def isFinal = hasFlag(0x00000002) diff --git a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSig.scala b/src/scalap/scala/tools/scalap/scalasig/ScalaSig.scala index fd70e0de35..311e4acd6f 100644 --- a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSig.scala +++ b/src/scalap/scala/tools/scalap/scalasig/ScalaSig.scala @@ -5,24 +5,25 @@ ** */ +package scala.tools.scalap.scalasig -package scala.tools.scalap -package scalax -package rules -package scalasig +import scala.language.implicitConversions -import ClassFileParser.{ ConstValueIndex, Annotation } import scala.reflect.internal.pickling.ByteCodecs +import scala.tools.scalap.Main +import scala.tools.scalap.rules._ + +import ClassFileParser.{ ConstValueIndex, Annotation } + object ScalaSigParser { - import Main.{ SCALA_SIG, SCALA_SIG_ANNOTATION, BYTES_VALUE } def scalaSigFromAnnotation(classFile: ClassFile): Option[ScalaSig] = { import classFile._ - classFile.annotation(SCALA_SIG_ANNOTATION) map { + classFile.annotation(Main.SCALA_SIG_ANNOTATION) map { case Annotation(_, elements) => - val bytesElem = elements.find(elem => constant(elem.elementNameIndex) == BYTES_VALUE).get + val bytesElem = elements.find(elem => constant(elem.elementNameIndex) == Main.BYTES_VALUE).get val bytes = ((bytesElem.elementValue match {case ConstValueIndex(index) => constantWrapped(index)}) .asInstanceOf[StringBytesPair].bytes) val length = ByteCodecs.decode(bytes) @@ -31,8 +32,8 @@ object ScalaSigParser { } } - def scalaSigFromAttribute(classFile: ClassFile) : Option[ScalaSig] = - classFile.attribute(SCALA_SIG).map(_.byteCode).map(ScalaSigAttributeParsers.parse) + def scalaSigFromAttribute(classFile: ClassFile): Option[ScalaSig] = + classFile.attribute(Main.SCALA_SIG).map(_.byteCode).map(ScalaSigAttributeParsers.parse) def parse(classFile: ClassFile): Option[ScalaSig] = { val scalaSig = scalaSigFromAttribute(classFile) @@ -45,7 +46,7 @@ object ScalaSigParser { } } - def parse(clazz : Class[_]): Option[ScalaSig] = { + def parse(clazz: Class[_]): Option[ScalaSig] = { val byteCode = ByteCode.forClass(clazz) val classFile = ClassFileParser.parse(byteCode) @@ -54,10 +55,10 @@ object ScalaSigParser { } object ScalaSigAttributeParsers extends ByteCodeReader { - def parse(byteCode : ByteCode) = expect(scalaSig)(byteCode) + def parse(byteCode: ByteCode) = expect(scalaSig)(byteCode) val nat = apply { - def natN(in : ByteCode, x : Int) : Result[ByteCode, Int, Nothing] = in.nextByte match { + def natN(in: ByteCode, x: Int): Result[ByteCode, Int, Nothing] = in.nextByte match { case Success(out, b) => { val y = (x << 7) + (b & 0x7f) if ((b & 0x80) == 0) Success(out, y) else natN(out, y) @@ -76,33 +77,33 @@ object ScalaSigAttributeParsers extends ByteCodeReader { val longValue = read(_ toLong) } -case class ScalaSig(majorVersion : Int, minorVersion : Int, table : Seq[Int ~ ByteCode]) extends DefaultMemoisable { +case class ScalaSig(majorVersion: Int, minorVersion: Int, table: Seq[Int ~ ByteCode]) extends DefaultMemoisable { - case class Entry(index : Int, entryType : Int, byteCode : ByteCode) extends DefaultMemoisable { + case class Entry(index: Int, entryType: Int, byteCode: ByteCode) extends DefaultMemoisable { def scalaSig = ScalaSig.this - def setByteCode(byteCode : ByteCode) = Entry(index, entryType, byteCode) + def setByteCode(byteCode: ByteCode) = Entry(index, entryType, byteCode) } - def hasEntry(index : Int) = table isDefinedAt index + def hasEntry(index: Int) = table isDefinedAt index - def getEntry(index : Int) = { + def getEntry(index: Int) = { val entryType ~ byteCode = table(index) Entry(index, entryType, byteCode) } - def parseEntry(index : Int) = applyRule(ScalaSigParsers.parseEntry(ScalaSigEntryParsers.entry)(index)) + def parseEntry(index: Int) = applyRule(ScalaSigParsers.parseEntry(ScalaSigEntryParsers.entry)(index)) - implicit def applyRule[A](parser : ScalaSigParsers.Parser[A]) = ScalaSigParsers.expect(parser)(this) + implicit def applyRule[A](parser: ScalaSigParsers.Parser[A]) = ScalaSigParsers.expect(parser)(this) override def toString = "ScalaSig version " + majorVersion + "." + minorVersion + { for (i <- 0 until table.size) yield i + ":\t" + parseEntry(i) // + "\n\t" + getEntry(i) }.mkString("\n", "\n", "") - lazy val symbols : Seq[Symbol] = ScalaSigParsers.symbols + lazy val symbols: Seq[Symbol] = ScalaSigParsers.symbols - lazy val topLevelClasses : List[ClassSymbol] = ScalaSigParsers.topLevelClasses - lazy val topLevelObjects : List[ObjectSymbol] = ScalaSigParsers.topLevelObjects + lazy val topLevelClasses: List[ClassSymbol] = ScalaSigParsers.topLevelClasses + lazy val topLevelObjects: List[ObjectSymbol] = ScalaSigParsers.topLevelObjects } object ScalaSigParsers extends RulesWithState with MemoisableRules { @@ -112,14 +113,14 @@ object ScalaSigParsers extends RulesWithState with MemoisableRules { val symTab = read(_.table) val size = symTab ^^ (_.size) - def entry(index : Int) = memo(("entry", index)) { + def entry(index: Int) = memo(("entry", index)) { cond(_ hasEntry index) -~ read(_ getEntry index) >-> { entry => Success(entry, entry.entryType) } } - def parseEntry[A](parser : ScalaSigEntryParsers.EntryParser[A])(index : Int) : Parser[A] = + def parseEntry[A](parser: ScalaSigEntryParsers.EntryParser[A])(index: Int): Parser[A] = entry(index) -~ parser >> { a => entry => Success(entry.scalaSig, a) } - def allEntries[A](f : ScalaSigEntryParsers.EntryParser[A]) = size >> { n => anyOf((0 until n) map parseEntry(f)) } + def allEntries[A](f: ScalaSigEntryParsers.EntryParser[A]) = size >> { n => anyOf((0 until n) map parseEntry(f)) } lazy val entries = allEntries(ScalaSigEntryParsers.entry) as "entries" lazy val symbols = allEntries(ScalaSigEntryParsers.symbol) as "symbols" @@ -136,20 +137,20 @@ object ScalaSigEntryParsers extends RulesWithState with MemoisableRules { type S = ScalaSig#Entry type EntryParser[A] = Rule[A, String] - implicit def byteCodeEntryParser[A](rule : ScalaSigAttributeParsers.Parser[A]) : EntryParser[A] = apply { entry => + implicit def byteCodeEntryParser[A](rule: ScalaSigAttributeParsers.Parser[A]): EntryParser[A] = apply { entry => rule(entry.byteCode) mapOut (entry setByteCode _) } - def toEntry[A](index : Int) = apply { sigEntry => ScalaSigParsers.entry(index)(sigEntry.scalaSig) } + def toEntry[A](index: Int) = apply { sigEntry => ScalaSigParsers.entry(index)(sigEntry.scalaSig) } - def parseEntry[A](parser : EntryParser[A])(index : Int) = (toEntry(index) -~ parser) + def parseEntry[A](parser: EntryParser[A])(index: Int) = (toEntry(index) -~ parser) - implicit def entryType(code : Int) = key filter (_ == code) + implicit def entryType(code: Int) = key filter (_ == code) val index = read(_.index) val key = read(_.entryType) - lazy val entry : EntryParser[Any] = symbol | typeEntry | literal | name | attributeInfo | annotInfo | children | get + lazy val entry: EntryParser[Any] = symbol | typeEntry | literal | name | attributeInfo | annotInfo | children | get val ref = byteCodeEntryParser(nat) @@ -158,7 +159,7 @@ object ScalaSigEntryParsers extends RulesWithState with MemoisableRules { val name = termName | typeName as "name" - def refTo[A](rule : EntryParser[A]) : EntryParser[A] = ref >>& parseEntry(rule) + def refTo[A](rule: EntryParser[A]): EntryParser[A] = ref >>& parseEntry(rule) lazy val nameRef = refTo(name) lazy val symbolRef = refTo(symbol) @@ -169,7 +170,7 @@ object ScalaSigEntryParsers extends RulesWithState with MemoisableRules { def symHeader(key: Int): EntryParser[Any] = (key -~ none | (key + 64) -~ nat) - def symbolEntry(key : Int) = symHeader(key) -~ symbolInfo + def symbolEntry(key: Int) = symHeader(key) -~ symbolInfo val noSymbol = 3 -^ NoSymbol val typeSymbol = symbolEntry(4) ^^ TypeSymbol as "typeSymbol" @@ -180,7 +181,7 @@ object ScalaSigEntryParsers extends RulesWithState with MemoisableRules { val extRef = 9 -~ nameRef ~ (symbolRef?) ~ get ^~~^ ExternalSymbol as "extRef" val extModClassRef = 10 -~ nameRef ~ (symbolRef?) ~ get ^~~^ ExternalSymbol as "extModClassRef" - lazy val symbol : EntryParser[Symbol] = oneOf( + lazy val symbol: EntryParser[Symbol] = oneOf( noSymbol, typeSymbol, aliasSymbol, @@ -195,7 +196,7 @@ object ScalaSigEntryParsers extends RulesWithState with MemoisableRules { val typeLevel = nat val typeIndex = nat - lazy val typeEntry : EntryParser[Type] = oneOf( + lazy val typeEntry: EntryParser[Type] = oneOf( 11 -^ NoType, 12 -^ NoPrefixType, 13 -~ symbolRef ^^ ThisType, @@ -236,17 +237,17 @@ object ScalaSigEntryParsers extends RulesWithState with MemoisableRules { lazy val topLevelClass = classSymbol filter isTopLevelClass lazy val topLevelObject = objectSymbol filter isTopLevel - def isTopLevel(symbol : Symbol) = symbol.parent match { - case Some(ext : ExternalSymbol) => true + def isTopLevel(symbol: Symbol) = symbol.parent match { + case Some(ext: ExternalSymbol) => true case _ => false } - def isTopLevelClass (symbol : Symbol) = !symbol.isModule && isTopLevel(symbol) + def isTopLevelClass (symbol: Symbol) = !symbol.isModule && isTopLevel(symbol) } - case class AttributeInfo(symbol : Symbol, typeRef : Type, value : Option[Any], values : Seq[String ~ Any]) // sym_Ref info_Ref {constant_Ref} {nameRef constantRef} - case class Children(symbolRefs : Seq[Int]) //sym_Ref {sym_Ref} +case class AttributeInfo(symbol: Symbol, typeRef: Type, value: Option[Any], values: Seq[String ~ Any]) // sym_Ref info_Ref {constant_Ref} {nameRef constantRef} +case class Children(symbolRefs: Seq[Int]) //sym_Ref {sym_Ref} - case class AnnotInfo(refs : Seq[Int]) // attarg_Ref {constant_Ref attarg_Ref} +case class AnnotInfo(refs: Seq[Int]) // attarg_Ref {constant_Ref attarg_Ref} /*************************************************** * | 49 TREE len_Nat 1 EMPTYtree diff --git a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala b/src/scalap/scala/tools/scalap/scalasig/ScalaSigPrinter.scala index e5a4ff649e..5929e0f59f 100644 --- a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala +++ b/src/scalap/scala/tools/scalap/scalasig/ScalaSigPrinter.scala @@ -5,17 +5,14 @@ ** */ +package scala.tools.scalap.scalasig -package scala.tools.scalap -package scalax -package rules -package scalasig +import scala.language.implicitConversions import java.io.{PrintStream, ByteArrayOutputStream} import java.util.regex.Pattern -import scala.tools.scalap.scalax.util.StringUtil -import scala.reflect.NameTransformer -import java.lang.String + +import scala.tools.scalap.rules.~ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) { import stream._ @@ -136,7 +133,7 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) { print(" {") //Print class selftype c.selfType match { - case Some(t: Type) => print("\n"); print(" this : " + toString(t) + " =>") + case Some(t: Type) => print("\n"); print(" this: " + toString(t) + " =>") case None => } print("\n") @@ -186,22 +183,12 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) { printWithIndent(level, "}\n") } - def genParamNames(t: {def paramTypes: Seq[Type]}): List[String] = t.paramTypes.toList.map(x => { - var str = toString(x) - val j = str.indexOf("[") - if (j > 0) str = str.substring(0, j) - str = StringUtil.trimStart(str, "=> ") - val i = str.lastIndexOf(".") - val res = if (i > 0) str.substring(i + 1) else str - if (res.length > 1) StringUtil.decapitalize(res.substring(0, 1)) else res.toLowerCase - }) - def printMethodType(t: Type, printResult: Boolean)(cont: => Unit): Unit = { - def _pmt(mt: Type {def resultType: Type; def paramSymbols: Seq[Symbol]}) = { + def _pmt(mt: MethodType) = { val paramEntries = mt.paramSymbols.map({ - case ms: MethodSymbol => ms.name + " : " + toString(ms.infoType)(TypeFlags(true)) + case ms: MethodSymbol => ms.name + ": " + toString(ms.infoType)(TypeFlags(true)) case _ => "^___^" }) val implicitWord = mt.paramSymbols.headOption match { @@ -216,21 +203,21 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) { mt.resultType match { case mt: MethodType => printMethodType(mt, printResult)({}) case x => if (printResult) { - print(" : "); + print(": "); printType(x) } } } t match { - case NullaryMethodType(resType) => if (printResult) { print(" : "); printType(resType) } + case NullaryMethodType(resType) => if (printResult) { print(": "); printType(resType) } case mt@MethodType(resType, paramSymbols) => _pmt(mt) case pt@PolyType(mt, typeParams) => { print(typeParamString(typeParams)) printMethodType(mt, printResult)({}) } //todo consider another method types - case x => print(" : "); printType(x) + case x => print(": "); printType(x) } // Print rest of the symbol output @@ -356,8 +343,8 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) { } case "scala.<byname>" => "=> " + toString(typeArgs.head) case _ => { - val path = StringUtil.cutSubstring(symbol.path)(".package") //remove package object reference - StringUtil.trimStart(processName(path) + typeArgString(typeArgs), "<empty>.") + val path = cutSubstring(symbol.path)(".package") //remove package object reference + trimStart(processName(path) + typeArgString(typeArgs), "<empty>.") } }) case TypeBoundsType(lower, upper) => { @@ -402,7 +389,7 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) { def typeArgString(typeArgs: Seq[Type]): String = if (typeArgs.isEmpty) "" - else typeArgs.map(toString).map(StringUtil.trimStart(_, "=> ")).mkString("[", ", ", "]") + else typeArgs.map(toString).map(trimStart(_, "=> ")).mkString("[", ", ", "]") def typeParamString(params: Seq[Symbol]): String = if (params.isEmpty) "" @@ -423,7 +410,7 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) { if (i > 0) name.substring(i + 2) else name } - def processName(name: String) = { + private def processName(name: String) = { val stripped = stripPrivatePrefix(name) val m = pattern.matcher(stripped) var temp = stripped @@ -433,7 +420,15 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) { temp = temp.replaceAll(re, _syms(re)) } val result = temp.replaceAll(placeholderPattern, "_") - NameTransformer.decode(result) + scala.reflect.NameTransformer.decode(result) } + private def trimStart(s: String, prefix: String) = + if (s != null && s.startsWith(prefix)) s.substring(prefix.length) else s + + private def decapitalize(s: String) = + java.beans.Introspector.decapitalize(s) + + private def cutSubstring(dom: String)(s: String) = + if (dom != null && s != null) dom.replace(s, "") else dom } diff --git a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/SourceFileAttributeParser.scala b/src/scalap/scala/tools/scalap/scalasig/SourceFileAttributeParser.scala index fc5a75c046..88d3d3b8b0 100644 --- a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/SourceFileAttributeParser.scala +++ b/src/scalap/scala/tools/scalap/scalasig/SourceFileAttributeParser.scala @@ -1,7 +1,4 @@ -package scala.tools.scalap -package scalax -package rules -package scalasig +package scala.tools.scalap.scalasig /** * @author ilyas @@ -16,13 +13,12 @@ object SourceFileAttributeParser extends ByteCodeReader { /** * * SourceFile_attribute { - u2 attribute_name_index; - u4 attribute_length; - u2 sourcefile_index; + u2 attribute_name_index; + u4 attribute_length; + u2 sourcefile_index; } * * Contains only file index in ConstantPool, first two fields are already treated * by {@link scalax.rules.scalasig.ClassFile.attribute#attribute} */ case class SourceFileInfo(sourceFileIndex: Int) - diff --git a/src/scalap/scala/tools/scalap/scalasig/Symbol.scala b/src/scalap/scala/tools/scalap/scalasig/Symbol.scala new file mode 100644 index 0000000000..0656938150 --- /dev/null +++ b/src/scalap/scala/tools/scalap/scalasig/Symbol.scala @@ -0,0 +1,70 @@ +package scala.tools.scalap.scalasig + +import ScalaSigEntryParsers._ + +trait Symbol extends Flags { + def name: String + def parent: Option[Symbol] + def children: Seq[Symbol] + + def path: String = parent.map(_.path + ".").getOrElse("") + name +} + +case object NoSymbol extends Symbol { + def name = "<no symbol>" + def parent = None + def hasFlag(flag: Long) = false + def children = Nil +} + +abstract class ScalaSigSymbol extends Symbol { + def applyRule[A](rule: EntryParser[A]): A = expect(rule)(entry) + def applyScalaSigRule[A](rule: ScalaSigParsers.Parser[A]) = ScalaSigParsers.expect(rule)(entry.scalaSig) + + def entry: ScalaSig#Entry + def index = entry.index + + lazy val children: Seq[Symbol] = applyScalaSigRule(ScalaSigParsers.symbols) filter (_.parent == Some(this)) + lazy val attributes: Seq[AttributeInfo] = applyScalaSigRule(ScalaSigParsers.attributes) filter (_.symbol == this) +} + +case class ExternalSymbol(name: String, parent: Option[Symbol], entry: ScalaSig#Entry) extends ScalaSigSymbol { + override def toString = path + def hasFlag(flag: Long) = false +} + +case class SymbolInfo(name: String, owner: Symbol, flags: Int, privateWithin: Option[AnyRef], info: Int, entry: ScalaSig#Entry) { + def symbolString(any: AnyRef) = any match { + case sym: SymbolInfoSymbol => sym.index.toString + case other => other.toString + } + + override def toString = name + ", owner=" + symbolString(owner) + ", flags=" + flags.toHexString + ", info=" + info + (privateWithin match { + case Some(any) => ", privateWithin=" + symbolString(any) + case None => " " + }) +} + +abstract class SymbolInfoSymbol extends ScalaSigSymbol { + def symbolInfo: SymbolInfo + + def entry = symbolInfo.entry + def name = symbolInfo.name + def parent = Some(symbolInfo.owner) + def hasFlag(flag: Long) = (symbolInfo.flags & flag) != 0L + + lazy val infoType = applyRule(parseEntry(typeEntry)(symbolInfo.info)) +} + +case class TypeSymbol(symbolInfo: SymbolInfo) extends SymbolInfoSymbol{ + override def path = name +} + +case class AliasSymbol(symbolInfo: SymbolInfo) extends SymbolInfoSymbol{ + override def path = name +} +case class ClassSymbol(symbolInfo: SymbolInfo, thisTypeRef: Option[Int]) extends SymbolInfoSymbol { + lazy val selfType = thisTypeRef.map{(x: Int) => applyRule(parseEntry(typeEntry)(x))} +} +case class ObjectSymbol(symbolInfo: SymbolInfo) extends SymbolInfoSymbol +case class MethodSymbol(symbolInfo: SymbolInfo, aliasRef: Option[Int]) extends SymbolInfoSymbol diff --git a/src/scalap/scala/tools/scalap/scalasig/Type.scala b/src/scalap/scala/tools/scalap/scalasig/Type.scala new file mode 100644 index 0000000000..97dc28d223 --- /dev/null +++ b/src/scalap/scala/tools/scalap/scalasig/Type.scala @@ -0,0 +1,22 @@ +package scala.tools.scalap.scalasig + +abstract class Type + +case object NoType extends Type +case object NoPrefixType extends Type + +case class ThisType(symbol: Symbol) extends Type +case class SingleType(typeRef: Type, symbol: Symbol) extends Type +case class ConstantType(constant: Any) extends Type +case class TypeRefType(prefix: Type, symbol: Symbol, typeArgs: Seq[Type]) extends Type +case class TypeBoundsType(lower: Type, upper: Type) extends Type +case class RefinedType(classSym: Symbol, typeRefs: List[Type]) extends Type +case class ClassInfoType(symbol: Symbol, typeRefs: Seq[Type]) extends Type +case class ClassInfoTypeWithCons(symbol: Symbol, typeRefs: Seq[Type], cons: String) extends Type +case class MethodType(resultType: Type, paramSymbols: Seq[Symbol]) extends Type +case class NullaryMethodType(resultType: Type) extends Type +case class PolyType(typeRef: Type, symbols: Seq[TypeSymbol]) extends Type +case class PolyTypeWithCons(typeRef: Type, symbols: Seq[TypeSymbol], cons: String) extends Type +case class AnnotatedType(typeRef: Type, attribTreeRefs: List[Int]) extends Type +case class AnnotatedWithSelfType(typeRef: Type, symbol: Symbol, attribTreeRefs: List[Int]) extends Type +case class ExistentialType(typeRef: Type, symbols: Seq[Symbol]) extends Type diff --git a/src/scalap/scala/tools/scalap/scalax/rules/Result.scala b/src/scalap/scala/tools/scalap/scalax/rules/Result.scala deleted file mode 100644 index 17ad4bd053..0000000000 --- a/src/scalap/scala/tools/scalap/scalax/rules/Result.scala +++ /dev/null @@ -1,72 +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; - -/** Represents the combined value of two rules applied in sequence. - * - * @see the Scala parser combinator - */ -case class ~[+A, +B](_1 : A, _2 : B) { - override def toString = "(" + _1 + " ~ " + _2 + ")" -} - - -sealed abstract class Result[+Out, +A, +X] { - def out : Out - def value : A - def error : X - - implicit def toOption : Option[A] - - def map[B](f : A => B) : Result[Out, B, X] - def mapOut[Out2](f : Out => Out2) : Result[Out2, A, X] - def map[Out2, B](f : (Out, A) => (Out2, B)) : Result[Out2, B, X] - def flatMap[Out2, B](f : (Out, A) => Result[Out2, B, Nothing]) : Result[Out2, B, X] - def orElse[Out2 >: Out, B >: A](other : => Result[Out2, B, Nothing]) : Result[Out2, B, X] -} - -case class Success[+Out, +A](out : Out, value : A) extends Result[Out, A, Nothing] { - def error = throw new ScalaSigParserError("No error") - - def toOption = Some(value) - - def map[B](f : A => B) : Result[Out, B, Nothing] = Success(out, f(value)) - def mapOut[Out2](f : Out => Out2) : Result[Out2, A, Nothing] = Success(f(out), value) - def map[Out2, B](f : (Out, A) => (Out2, B)) : Success[Out2, B] = f(out, value) match { case (out2, b) => Success(out2, b) } - def flatMap[Out2, B](f : (Out, A) => Result[Out2, B, Nothing]) : Result[Out2, B, Nothing]= f(out, value) - def orElse[Out2 >: Out, B >: A](other : => Result[Out2, B, Nothing]) : Result[Out2, B, Nothing] = this -} - -sealed abstract class NoSuccess[+X] extends Result[Nothing, Nothing, X] { - def out = throw new ScalaSigParserError("No output") - def value = throw new ScalaSigParserError("No value") - - def toOption = None - - def map[B](f : Nothing => B) = this - def mapOut[Out2](f : Nothing => Out2) = this - def map[Out2, B](f : (Nothing, Nothing) => (Out2, B)) = this - def flatMap[Out2, B](f : (Nothing, Nothing) => Result[Out2, B, Nothing]) = this - def orElse[Out2, B](other : => Result[Out2, B, Nothing]) = other -} - -case object Failure extends NoSuccess[Nothing] { - def error = throw new ScalaSigParserError("No error") -} - -case class ScalaSigParserError(msg: String) extends RuntimeException(msg) - -case class Error[+X](error : X) extends NoSuccess[X] { -} diff --git a/src/scalap/scala/tools/scalap/scalax/rules/Rule.scala b/src/scalap/scala/tools/scalap/scalax/rules/Rule.scala deleted file mode 100644 index 489a05ecd0..0000000000 --- a/src/scalap/scala/tools/scalap/scalax/rules/Rule.scala +++ /dev/null @@ -1,177 +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 - -/** A Rule is a function from some input to a Result. The result may be: - * <ul> - * <li>Success, with a value of some type and an output that may serve as the input to subsequent rules.</li> - * <li>Failure. A failure may result in some alternative rule being applied.</li> - * <li>Error. No further rules should be attempted.</li> - * </ul> - * - * @author Andrew Foggin - * - * Inspired by the Scala parser combinator. - */ -trait Rule[-In, +Out, +A, +X] extends (In => Result[Out, A, X]) { - val factory : Rules - import factory._ - - def as(name : String) = ruleWithName(name, this) - - def flatMap[Out2, B, X2 >: X](fa2ruleb : A => Out => Result[Out2, B, X2]) = mapResult { - case Success(out, a) => fa2ruleb(a)(out) - case Failure => Failure - case err @ Error(_) => err - } - - def map[B](fa2b : A => B) = flatMap { a => out => Success(out, fa2b(a)) } - - def filter(f : A => Boolean) = flatMap { a => out => if(f(a)) Success(out, a) else Failure } - - def mapResult[Out2, B, Y](f : Result[Out, A, X] => Result[Out2, B, Y]) = rule { - in : In => f(apply(in)) - } - - def orElse[In2 <: In, Out2 >: Out, A2 >: A, X2 >: X](other : => Rule[In2, Out2, A2, X2]) : Rule[In2, Out2, A2, X2] = new Choice[In2, Out2, A2, X2] { - val factory = Rule.this.factory - lazy val choices = Rule.this :: other :: Nil - } - - def orError[In2 <: In] = this orElse error[Any] - - def |[In2 <: In, Out2 >: Out, A2 >: A, X2 >: X](other : => Rule[In2, Out2, A2, X2]) = orElse(other) - - def ^^[B](fa2b : A => B) = map(fa2b) - - def ^^?[B](pf : PartialFunction[A, B]) = filter (pf.isDefinedAt(_)) ^^ pf - - def ??(pf : PartialFunction[A, Any]) = filter (pf.isDefinedAt(_)) - - def -^[B](b : B) = map { any => b } - - /** Maps an Error */ - def !^[Y](fx2y : X => Y) = mapResult { - case s @ Success(_, _) => s - case Failure => Failure - case Error(x) => Error(fx2y(x)) - } - - def >>[Out2, B, X2 >: X](fa2ruleb : A => Out => Result[Out2, B, X2]) = flatMap(fa2ruleb) - - def >->[Out2, B, X2 >: X](fa2resultb : A => Result[Out2, B, X2]) = flatMap { a => any => fa2resultb(a) } - - def >>?[Out2, B, X2 >: X](pf : PartialFunction[A, Rule[Out, Out2, B, X2]]) = filter(pf isDefinedAt _) flatMap pf - - def >>&[B, X2 >: X](fa2ruleb : A => Out => Result[Any, B, X2]) = flatMap { a => out => fa2ruleb(a)(out) mapOut { any => out } } - - def ~[Out2, B, X2 >: X](next : => Rule[Out, Out2, B, X2]) = for (a <- this; b <- next) yield new ~(a, b) - - def ~-[Out2, B, X2 >: X](next : => Rule[Out, Out2, B, X2]) = for (a <- this; b <- next) yield a - - def -~[Out2, B, X2 >: X](next : => Rule[Out, Out2, B, X2]) = for (a <- this; b <- next) yield b - - def ~++[Out2, B >: A, X2 >: X](next : => Rule[Out, Out2, Seq[B], X2]) = for (a <- this; b <- next) yield a :: b.toList - - /** Apply the result of this rule to the function returned by the next rule */ - def ~>[Out2, B, X2 >: X](next : => Rule[Out, Out2, A => B, X2]) = for (a <- this; fa2b <- next) yield fa2b(a) - - /** Apply the result of this rule to the function returned by the previous rule */ - def <~:[InPrev, B, X2 >: X](prev : => Rule[InPrev, In, A => B, X2]) = for (fa2b <- prev; a <- this) yield fa2b(a) - - def ~![Out2, B, X2 >: X](next : => Rule[Out, Out2, B, X2]) = for (a <- this; b <- next orError) yield new ~(a, b) - - def ~-![Out2, B, X2 >: X](next : => Rule[Out, Out2, B, X2]) = for (a <- this; b <- next orError) yield a - - def -~![Out2, B, X2 >: X](next : => Rule[Out, Out2, B, X2]) = for (a <- this; b <- next orError) yield b - - def -[In2 <: In](exclude : => Rule[In2, Any, Any, Any]) = !exclude -~ this - - /** ^~^(f) is equivalent to ^^ { case b1 ~ b2 => f(b1, b2) } - */ - def ^~^[B1, B2, B >: A <% B1 ~ B2, C](f : (B1, B2) => C) = map { a => - (a : B1 ~ B2) match { case b1 ~ b2 => f(b1, b2) } - } - - /** ^~~^(f) is equivalent to ^^ { case b1 ~ b2 ~ b3 => f(b1, b2, b3) } - */ - def ^~~^[B1, B2, B3, B >: A <% B1 ~ B2 ~ B3, C](f : (B1, B2, B3) => C) = map { a => - (a : B1 ~ B2 ~ B3) match { case b1 ~ b2 ~ b3 => f(b1, b2, b3) } - } - - /** ^~~~^(f) is equivalent to ^^ { case b1 ~ b2 ~ b3 ~ b4 => f(b1, b2, b3, b4) } - */ - def ^~~~^[B1, B2, B3, B4, B >: A <% B1 ~ B2 ~ B3 ~ B4, C](f : (B1, B2, B3, B4) => C) = map { a => - (a : B1 ~ B2 ~ B3 ~ B4) match { case b1 ~ b2 ~ b3 ~ b4 => f(b1, b2, b3, b4) } - } - - /** ^~~~~^(f) is equivalent to ^^ { case b1 ~ b2 ~ b3 ~ b4 ~ b5 => f(b1, b2, b3, b4, b5) } - */ - def ^~~~~^[B1, B2, B3, B4, B5, B >: A <% B1 ~ B2 ~ B3 ~ B4 ~ B5, C](f : (B1, B2, B3, B4, B5) => C) = map { a => - (a : B1 ~ B2 ~ B3 ~ B4 ~ B5) match { case b1 ~ b2 ~ b3 ~ b4 ~ b5 => f(b1, b2, b3, b4, b5) } - } - - /** ^~~~~~^(f) is equivalent to ^^ { case b1 ~ b2 ~ b3 ~ b4 ~ b5 ~ b6 => f(b1, b2, b3, b4, b5, b6) } - */ - def ^~~~~~^[B1, B2, B3, B4, B5, B6, B >: A <% B1 ~ B2 ~ B3 ~ B4 ~ B5 ~ B6, C](f : (B1, B2, B3, B4, B5, B6) => C) = map { a => - (a : B1 ~ B2 ~ B3 ~ B4 ~ B5 ~ B6) match { case b1 ~ b2 ~ b3 ~ b4 ~ b5 ~ b6 => f(b1, b2, b3, b4, b5, b6) } - } - - /** ^~~~~~~^(f) is equivalent to ^^ { case b1 ~ b2 ~ b3 ~ b4 ~ b5 ~ b6 => f(b1, b2, b3, b4, b5, b6) } - */ - def ^~~~~~~^[B1, B2, B3, B4, B5, B6, B7, B >: A <% B1 ~ B2 ~ B3 ~ B4 ~ B5 ~ B6 ~ B7, C](f : (B1, B2, B3, B4, B5, B6, B7) => C) = map { a => - (a : B1 ~ B2 ~ B3 ~ B4 ~ B5 ~ B6 ~ B7) match { case b1 ~ b2 ~ b3 ~ b4 ~ b5 ~ b6 ~b7 => f(b1, b2, b3, b4, b5, b6, b7) } - } - - /** >~>(f) is equivalent to >> { case b1 ~ b2 => f(b1, b2) } - */ - def >~>[Out2, B1, B2, B >: A <% B1 ~ B2, C, X2 >: X](f : (B1, B2) => Out => Result[Out2, C, X2]) = flatMap { a => - (a : B1 ~ B2) match { case b1 ~ b2 => f(b1, b2) } - } - - /** ^-^(f) is equivalent to ^^ { b2 => b1 => f(b1, b2) } - */ - def ^-^ [B1, B2 >: A, C](f : (B1, B2) => C) = map { b2 : B2 => b1 : B1 => f(b1, b2) } - - /** ^~>~^(f) is equivalent to ^^ { case b2 ~ b3 => b1 => f(b1, b2, b3) } - */ - def ^~>~^ [B1, B2, B3, B >: A <% B2 ~ B3, C](f : (B1, B2, B3) => C) = map { a => - (a : B2 ~ B3) match { case b2 ~ b3 => b1 : B1 => f(b1, b2, b3) } - } -} - - -trait Choice[-In, +Out, +A, +X] extends Rule[In, Out, A, X] { - def choices : List[Rule[In, Out, A, X]] - - def apply(in : In) = { - def oneOf(list : List[Rule[In, Out, A, X]]) : Result[Out, A, X] = list match { - case Nil => Failure - case first :: rest => first(in) match { - case Failure => oneOf(rest) - case result => result - } - } - oneOf(choices) - } - - override def orElse[In2 <: In, Out2 >: Out, A2 >: A, X2 >: X](other : => Rule[In2, Out2, A2, X2]) : Rule[In2, Out2, A2, X2] = new Choice[In2, Out2, A2, X2] { - val factory = Choice.this.factory - lazy val choices = Choice.this.choices ::: other :: Nil - } -} - - - diff --git a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/Symbol.scala b/src/scalap/scala/tools/scalap/scalax/rules/scalasig/Symbol.scala deleted file mode 100644 index dee1cf84ac..0000000000 --- a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/Symbol.scala +++ /dev/null @@ -1,73 +0,0 @@ -package scala.tools.scalap -package scalax -package rules -package scalasig - -import ScalaSigEntryParsers._ - -trait Symbol extends Flags { - def name : String - def parent : Option[Symbol] - def children : Seq[Symbol] - - def path : String = parent.map(_.path + ".").getOrElse("") + name -} - -case object NoSymbol extends Symbol { - def name = "<no symbol>" - def parent = None - def hasFlag(flag : Long) = false - def children = Nil -} - -abstract class ScalaSigSymbol extends Symbol { - def applyRule[A](rule : EntryParser[A]) : A = expect(rule)(entry) - def applyScalaSigRule[A](rule : ScalaSigParsers.Parser[A]) = ScalaSigParsers.expect(rule)(entry.scalaSig) - - def entry : ScalaSig#Entry - def index = entry.index - - lazy val children : Seq[Symbol] = applyScalaSigRule(ScalaSigParsers.symbols) filter (_.parent == Some(this)) - lazy val attributes : Seq[AttributeInfo] = applyScalaSigRule(ScalaSigParsers.attributes) filter (_.symbol == this) -} - -case class ExternalSymbol(name : String, parent : Option[Symbol], entry : ScalaSig#Entry) extends ScalaSigSymbol { - override def toString = path - def hasFlag(flag : Long) = false -} - -case class SymbolInfo(name : String, owner : Symbol, flags : Int, privateWithin : Option[AnyRef], info : Int, entry : ScalaSig#Entry) { - def symbolString(any : AnyRef) = any match { - case sym : SymbolInfoSymbol => sym.index.toString - case other => other.toString - } - - override def toString = name + ", owner=" + symbolString(owner) + ", flags=" + flags.toHexString + ", info=" + info + (privateWithin match { - case Some(any) => ", privateWithin=" + symbolString(any) - case None => " " - }) -} - -abstract class SymbolInfoSymbol extends ScalaSigSymbol { - def symbolInfo : SymbolInfo - - def entry = symbolInfo.entry - def name = symbolInfo.name - def parent = Some(symbolInfo.owner) - def hasFlag(flag : Long) = (symbolInfo.flags & flag) != 0L - - lazy val infoType = applyRule(parseEntry(typeEntry)(symbolInfo.info)) -} - -case class TypeSymbol(symbolInfo : SymbolInfo) extends SymbolInfoSymbol{ - override def path = name -} - -case class AliasSymbol(symbolInfo : SymbolInfo) extends SymbolInfoSymbol{ - override def path = name -} -case class ClassSymbol(symbolInfo : SymbolInfo, thisTypeRef : Option[Int]) extends SymbolInfoSymbol { - lazy val selfType = thisTypeRef.map{(x: Int) => applyRule(parseEntry(typeEntry)(x))} -} -case class ObjectSymbol(symbolInfo : SymbolInfo) extends SymbolInfoSymbol -case class MethodSymbol(symbolInfo : SymbolInfo, aliasRef : Option[Int]) extends SymbolInfoSymbol diff --git a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/Type.scala b/src/scalap/scala/tools/scalap/scalax/rules/scalasig/Type.scala deleted file mode 100644 index 0444e701f2..0000000000 --- a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/Type.scala +++ /dev/null @@ -1,25 +0,0 @@ -package scala.tools.scalap -package scalax -package rules -package scalasig - -abstract class Type - -case object NoType extends Type -case object NoPrefixType extends Type - -case class ThisType(symbol : Symbol) extends Type -case class SingleType(typeRef : Type, symbol : Symbol) extends Type -case class ConstantType(constant : Any) extends Type -case class TypeRefType(prefix : Type, symbol : Symbol, typeArgs : Seq[Type]) extends Type -case class TypeBoundsType(lower : Type, upper : Type) extends Type -case class RefinedType(classSym : Symbol, typeRefs : List[Type]) extends Type -case class ClassInfoType(symbol : Symbol, typeRefs : Seq[Type]) extends Type -case class ClassInfoTypeWithCons(symbol : Symbol, typeRefs : Seq[Type], cons: String) extends Type -case class MethodType(resultType : Type, paramSymbols : Seq[Symbol]) extends Type -case class NullaryMethodType(resultType : Type) extends Type -case class PolyType(typeRef : Type, symbols : Seq[TypeSymbol]) extends Type -case class PolyTypeWithCons(typeRef : Type, symbols : Seq[TypeSymbol], cons: String) extends Type -case class AnnotatedType(typeRef : Type, attribTreeRefs : List[Int]) extends Type -case class AnnotatedWithSelfType(typeRef : Type, symbol : Symbol, attribTreeRefs : List[Int]) extends Type -case class ExistentialType(typeRef : Type, symbols : Seq[Symbol]) extends Type diff --git a/src/scalap/scala/tools/scalap/scalax/util/StringUtil.scala b/src/scalap/scala/tools/scalap/scalax/util/StringUtil.scala deleted file mode 100644 index 6077eded0f..0000000000 --- a/src/scalap/scala/tools/scalap/scalax/util/StringUtil.scala +++ /dev/null @@ -1,19 +0,0 @@ -package scala.tools.scalap -package scalax -package util - -import java.beans.Introspector - -/** - * @author ilyas - */ - -object StringUtil { - - def trimStart(s: String, prefix: String) = if (s != null && s.startsWith(prefix)) s.substring(prefix.length) else s - - def decapitalize(s: String) = Introspector.decapitalize(s) - - def cutSubstring(dom: String)(s: String) = if (dom != null && s != null) dom.replace(s, "") else dom - -} diff --git a/src/xml/scala/xml/Elem.scala b/src/xml/scala/xml/Elem.scala index 484cf98744..e9b87e516c 100755 --- a/src/xml/scala/xml/Elem.scala +++ b/src/xml/scala/xml/Elem.scala @@ -37,6 +37,7 @@ object Elem { } import scala.sys.process._ + import scala.language.implicitConversions /** Implicitly convert a [[scala.xml.Elem]] into a * [[scala.sys.process.ProcessBuilder]]. This is done by obtaining the text * elements of the element, trimming spaces, and then converting the result diff --git a/test/files/neg/t7325.check b/test/files/neg/t7325.check index 709ab6db3e..d2c40f4df8 100644 --- a/test/files/neg/t7325.check +++ b/test/files/neg/t7325.check @@ -1,19 +1,19 @@ -t7325.scala:2: error: percent signs not directly following splicees must be escaped +t7325.scala:2: error: conversions must follow a splice; use %% for literal %, %n for newline println(f"%") ^ -t7325.scala:4: error: percent signs not directly following splicees must be escaped +t7325.scala:4: error: conversions must follow a splice; use %% for literal %, %n for newline println(f"%%%") ^ -t7325.scala:6: error: percent signs not directly following splicees must be escaped +t7325.scala:6: error: conversions must follow a splice; use %% for literal %, %n for newline println(f"%%%%%") ^ t7325.scala:16: error: wrong conversion string println(f"${0}%") ^ -t7325.scala:19: error: percent signs not directly following splicees must be escaped +t7325.scala:19: error: conversions must follow a splice; use %% for literal %, %n for newline println(f"${0}%%%d") ^ -t7325.scala:21: error: percent signs not directly following splicees must be escaped +t7325.scala:21: error: conversions must follow a splice; use %% for literal %, %n for newline println(f"${0}%%%%%d") ^ 6 errors found diff --git a/test/files/pos/erasure-nsquared.scala b/test/files/pos/erasure-nsquared.scala new file mode 100644 index 0000000000..b0e30ade58 --- /dev/null +++ b/test/files/pos/erasure-nsquared.scala @@ -0,0 +1,35 @@ +trait BigCast { + def bar(x: Int): AnyRef = ( + null + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + ) +} diff --git a/test/files/pos/t7690.scala b/test/files/pos/t7690.scala new file mode 100644 index 0000000000..e8911a93e8 --- /dev/null +++ b/test/files/pos/t7690.scala @@ -0,0 +1,17 @@ +object A +trait B[T] + +object C { + implicit def notUsed[L[x]](in: L[Int]): B[L[Int]] = ??? + + class E(val ls: Int) { + def x(f: Int => Boolean): Boolean = f(ls) + } + implicit def isUsed(ls: Int): E = new E(ls) + + def amethod(in: Int): Boolean = + in.x { i => + import A._ + "asdf" == i.toString + } +}
\ No newline at end of file diff --git a/test/files/run/interpolation.flags b/test/files/run/interpolation.flags deleted file mode 100644 index 48fd867160..0000000000 --- a/test/files/run/interpolation.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental diff --git a/test/files/run/interpolationArgs.check b/test/files/run/interpolationArgs.check index 155991e618..983214cbee 100644 --- a/test/files/run/interpolationArgs.check +++ b/test/files/run/interpolationArgs.check @@ -1,2 +1,2 @@ -java.lang.IllegalArgumentException: wrong number of arguments for interpolated string -java.lang.IllegalArgumentException: wrong number of arguments for interpolated string +java.lang.IllegalArgumentException: wrong number of arguments (1) for interpolated string with 3 parts +java.lang.IllegalArgumentException: wrong number of arguments (1) for interpolated string with 1 parts diff --git a/test/files/run/interpolationArgs.flags b/test/files/run/interpolationArgs.flags deleted file mode 100644 index e1b37447c9..0000000000 --- a/test/files/run/interpolationArgs.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental
\ No newline at end of file diff --git a/test/files/run/interpolationMultiline1.flags b/test/files/run/interpolationMultiline1.flags deleted file mode 100644 index 48fd867160..0000000000 --- a/test/files/run/interpolationMultiline1.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental diff --git a/test/files/run/interpolationMultiline2.flags b/test/files/run/interpolationMultiline2.flags deleted file mode 100644 index e1b37447c9..0000000000 --- a/test/files/run/interpolationMultiline2.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental
\ No newline at end of file diff --git a/test/files/run/repl-javap-app.check b/test/files/run/repl-javap-app.check index db1f09b977..490860585c 100644 --- a/test/files/run/repl-javap-app.check +++ b/test/files/run/repl-javap-app.check @@ -6,14 +6,13 @@ 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 + 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 diff --git a/test/files/run/stream_length.check b/test/files/run/stream_length.check index d1068f3247..e4350aa741 100644 --- a/test/files/run/stream_length.check +++ b/test/files/run/stream_length.check @@ -1,6 +1,5 @@ #partest !avian Length: 970299 - #partest avian !!!TEST SKIPPED!!! See SI-7600 for further information. diff --git a/test/files/run/t7265.scala b/test/files/run/t7265.scala deleted file mode 100644 index c556930303..0000000000 --- a/test/files/run/t7265.scala +++ /dev/null @@ -1,27 +0,0 @@ - -import scala.util.Properties._ - -object Test extends App { - - setProp("java.specification.version", "1.7") - - assert( isJavaAtLeast("1.5")) - assert( isJavaAtLeast("1.6")) - assert( isJavaAtLeast("1.7")) - assert(!isJavaAtLeast("1.8")) - assert(!isJavaAtLeast("1.71")) - - failing(isJavaAtLeast("1.a")) - failing(isJavaAtLeast("1")) - failing(isJavaAtLeast("")) - failing(isJavaAtLeast(".")) - failing(isJavaAtLeast(".5")) - failing(isJavaAtLeast("1.7.1")) - - def failing(u: =>Unit) = try { - u - assert(false, "Expected Exception") - } catch { - case _: NumberFormatException => - } -} diff --git a/test/files/run/tailcalls.check b/test/files/run/tailcalls.check index 10384ac46e..ab54d528ab 100644 --- a/test/files/run/tailcalls.check +++ b/test/files/run/tailcalls.check @@ -52,7 +52,6 @@ test TailCall.b2 was successful test FancyTailCalls.tcTryLocal was successful test FancyTailCalls.differentInstance was successful test PolyObject.tramp was successful - #partest avian test Object .f was successful test Final .f was successful @@ -106,4 +105,4 @@ test TailCall.b1 was successful test TailCall.b2 was successful test FancyTailCalls.tcTryLocal was successful test FancyTailCalls.differentInstance was successful -test PolyObject.tramp was successful
\ No newline at end of file +test PolyObject.tramp was successful diff --git a/test/files/scalacheck/CheckCollections.scala b/test/files/scalacheck/CheckCollections.scala new file mode 100644 index 0000000000..108040b900 --- /dev/null +++ b/test/files/scalacheck/CheckCollections.scala @@ -0,0 +1,59 @@ +import org.scalacheck.{ ConsoleReporter, Properties } +import org.scalacheck.Prop._ + +import scala.reflect.internal.util.Collections._ + +object Test extends Properties("reflect.internal.util.Collections") { + def map2ConserveOld[A <: AnyRef, B](xs: List[A], ys: List[B])(f: (A, B) => A): List[A] = + if (xs.isEmpty || ys.isEmpty) xs + else { + val x1 = f(xs.head, ys.head) + val xs1 = map2Conserve(xs.tail, ys.tail)(f) + if ((x1 eq xs.head) && (xs1 eq xs.tail)) xs + else x1 :: xs1 + } + + val testfun: (String, Int) => String = { case(x, y) => + x.toLowerCase + y.toString + } + val testid: (String, Int) => String = { case (x, y) => x } + + val prop1_map2Conserve = forAll { (xs: List[String], ys: List[Int]) => + val res = map2Conserve(xs, ys)(testid) + res eq xs + } + + val prop2_map2Conserve = forAll { (xs: List[String], ys: List[Int]) => + map2Conserve(xs, ys)(testid) == map2ConserveOld(xs, ys)(testid) && + map2Conserve(xs, ys)(testfun) == map2ConserveOld(xs, ys)(testfun) + } + + def checkStackOverflow() { + var xs: List[String] = Nil + var ys: List[Int] = Nil + for (i <- 0 until 250000) { + xs = "X" :: xs + ys = 1 :: ys + } + map2Conserve(xs, ys){ case(x, y) => x.toLowerCase + y.toString } + } + + + val tests = List( + ("map2Conserve(identity)", prop1_map2Conserve), + ("map2Conserve == old impl", prop2_map2Conserve) + ) + + checkStackOverflow() + + for { + (label, prop) <- tests + } property(label) = prop + + import org.scalacheck.{ Test => STest } + + def runTests() = + STest.checkProperties( + STest.Params(testCallback = ConsoleReporter(0)), this) + +} diff --git a/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala b/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala index 03f8aa58d3..23b6a5fbdb 100644 --- a/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala +++ b/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala @@ -91,7 +91,7 @@ trait ArbitraryTreesAndNames { yield CompoundTypeTree(templ) def genDefDef(size: Int) = - for(mods <- genModifiers; name <- genName; + for(mods <- genModifiers; name <- genTermName; tpt <- genTree(size -1); rhs <- genTree(size - 1); tparams <- smallList(size, genTypeDef(size - 1)); vparamss <- smallList(size, smallList(size, genValDef(size - 1)))) diff --git a/test/files/scalap/abstractClass.check b/test/files/scalap/abstractClass.check index ef1daac23d..95e80ac3c9 100644 --- a/test/files/scalap/abstractClass.check +++ b/test/files/scalap/abstractClass.check @@ -1,4 +1,4 @@ abstract class AbstractClass extends scala.AnyRef { def this() = { /* compiled code */ } - def foo : scala.Predef.String + def foo: scala.Predef.String } diff --git a/test/files/scalap/abstractMethod.check b/test/files/scalap/abstractMethod.check index 40fa02d408..0d0b1b7421 100644 --- a/test/files/scalap/abstractMethod.check +++ b/test/files/scalap/abstractMethod.check @@ -1,5 +1,5 @@ trait AbstractMethod extends scala.AnyRef { - def $init$() : scala.Unit = { /* compiled code */ } - def arity : scala.Int - def isCool : scala.Boolean = { /* compiled code */ } + def $init$(): scala.Unit = { /* compiled code */ } + def arity: scala.Int + def isCool: scala.Boolean = { /* compiled code */ } } diff --git a/test/files/scalap/caseClass.check b/test/files/scalap/caseClass.check index 7d7aa4fd8f..51ad90d9b2 100644 --- a/test/files/scalap/caseClass.check +++ b/test/files/scalap/caseClass.check @@ -1,20 +1,20 @@ -case class CaseClass[A <: scala.Seq[scala.Int]](i : A, s : scala.Predef.String) extends scala.AnyRef with scala.Product with scala.Serializable { - val i : A = { /* compiled code */ } - val s : scala.Predef.String = { /* compiled code */ } - def foo : scala.Int = { /* compiled code */ } - def copy[A <: scala.Seq[scala.Int]](i : A, s : scala.Predef.String) : CaseClass[A] = { /* compiled code */ } - override def productPrefix : java.lang.String = { /* compiled code */ } - def productArity : scala.Int = { /* compiled code */ } - def productElement(x$1 : scala.Int) : scala.Any = { /* compiled code */ } - override def productIterator : scala.collection.Iterator[scala.Any] = { /* compiled code */ } - def canEqual(x$1 : scala.Any) : scala.Boolean = { /* compiled code */ } - override def hashCode() : scala.Int = { /* compiled code */ } - override def toString() : java.lang.String = { /* compiled code */ } - override def equals(x$1 : scala.Any) : scala.Boolean = { /* compiled code */ } +case class CaseClass[A <: scala.Seq[scala.Int]](i: A, s: scala.Predef.String) extends scala.AnyRef with scala.Product with scala.Serializable { + val i: A = { /* compiled code */ } + val s: scala.Predef.String = { /* compiled code */ } + def foo: scala.Int = { /* compiled code */ } + def copy[A <: scala.Seq[scala.Int]](i: A, s: scala.Predef.String): CaseClass[A] = { /* compiled code */ } + override def productPrefix: java.lang.String = { /* compiled code */ } + def productArity: scala.Int = { /* compiled code */ } + def productElement(x$1: scala.Int): scala.Any = { /* compiled code */ } + override def productIterator: scala.collection.Iterator[scala.Any] = { /* compiled code */ } + def canEqual(x$1: scala.Any): scala.Boolean = { /* compiled code */ } + override def hashCode(): scala.Int = { /* compiled code */ } + override def toString(): java.lang.String = { /* compiled code */ } + override def equals(x$1: scala.Any): scala.Boolean = { /* compiled code */ } } object CaseClass extends scala.AnyRef with scala.Serializable { def this() = { /* compiled code */ } - final override def toString() : java.lang.String = { /* compiled code */ } - def apply[A <: scala.Seq[scala.Int]](i : A, s : scala.Predef.String) : CaseClass[A] = { /* compiled code */ } - def unapply[A <: scala.Seq[scala.Int]](x$0 : CaseClass[A]) : scala.Option[scala.Tuple2[A, scala.Predef.String]] = { /* compiled code */ } + final override def toString(): java.lang.String = { /* compiled code */ } + def apply[A <: scala.Seq[scala.Int]](i: A, s: scala.Predef.String): CaseClass[A] = { /* compiled code */ } + def unapply[A <: scala.Seq[scala.Int]](x$0: CaseClass[A]): scala.Option[scala.Tuple2[A, scala.Predef.String]] = { /* compiled code */ } } diff --git a/test/files/scalap/caseObject.check b/test/files/scalap/caseObject.check index 867a4b2162..a342e5ff1a 100644 --- a/test/files/scalap/caseObject.check +++ b/test/files/scalap/caseObject.check @@ -1,10 +1,10 @@ case object CaseObject extends scala.AnyRef with scala.Product with scala.Serializable { - def bar : scala.Int = { /* compiled code */ } - override def productPrefix : java.lang.String = { /* compiled code */ } - def productArity : scala.Int = { /* compiled code */ } - def productElement(x$1 : scala.Int) : scala.Any = { /* compiled code */ } - override def productIterator : scala.collection.Iterator[scala.Any] = { /* compiled code */ } - def canEqual(x$1 : scala.Any) : scala.Boolean = { /* compiled code */ } - override def hashCode() : scala.Int = { /* compiled code */ } - override def toString() : java.lang.String = { /* compiled code */ } + def bar: scala.Int = { /* compiled code */ } + override def productPrefix: java.lang.String = { /* compiled code */ } + def productArity: scala.Int = { /* compiled code */ } + def productElement(x$1: scala.Int): scala.Any = { /* compiled code */ } + override def productIterator: scala.collection.Iterator[scala.Any] = { /* compiled code */ } + def canEqual(x$1: scala.Any): scala.Boolean = { /* compiled code */ } + override def hashCode(): scala.Int = { /* compiled code */ } + override def toString(): java.lang.String = { /* compiled code */ } } diff --git a/test/files/scalap/cbnParam.check b/test/files/scalap/cbnParam.check index 52ecb6ae66..abe01297b9 100644 --- a/test/files/scalap/cbnParam.check +++ b/test/files/scalap/cbnParam.check @@ -1,3 +1,3 @@ class CbnParam extends scala.AnyRef { - def this(s : => scala.Predef.String) = { /* compiled code */ } + def this(s: => scala.Predef.String) = { /* compiled code */ } } diff --git a/test/files/scalap/classPrivate.check b/test/files/scalap/classPrivate.check index ab2d40cdaf..cf0ffe0cb2 100644 --- a/test/files/scalap/classPrivate.check +++ b/test/files/scalap/classPrivate.check @@ -1,10 +1,10 @@ class ClassPrivate extends scala.AnyRef { def this() = { /* compiled code */ } - def baz : scala.Int = { /* compiled code */ } + def baz: scala.Int = { /* compiled code */ } class Outer extends scala.AnyRef { def this() = { /* compiled code */ } - private[ClassPrivate] def qux : scala.Int = { /* compiled code */ } + private[ClassPrivate] def qux: scala.Int = { /* compiled code */ } } - protected def quux : scala.Int = { /* compiled code */ } - private[ClassPrivate] def bar : scala.Int = { /* compiled code */ } + protected def quux: scala.Int = { /* compiled code */ } + private[ClassPrivate] def bar: scala.Int = { /* compiled code */ } } diff --git a/test/files/scalap/classWithExistential.check b/test/files/scalap/classWithExistential.check index caee3fd6de..7df6bfb765 100644 --- a/test/files/scalap/classWithExistential.check +++ b/test/files/scalap/classWithExistential.check @@ -1,4 +1,4 @@ class ClassWithExistential extends scala.AnyRef { def this() = { /* compiled code */ } - def foo[A, B] : scala.Function1[A, B forSome {type A <: scala.Seq[scala.Int]; type B >: scala.Predef.String}] = { /* compiled code */ } + def foo[A, B]: scala.Function1[A, B forSome {type A <: scala.Seq[scala.Int]; type B >: scala.Predef.String}] = { /* compiled code */ } } diff --git a/test/files/scalap/classWithSelfAnnotation.check b/test/files/scalap/classWithSelfAnnotation.check index 82bbd9e8df..7a1c206e33 100644 --- a/test/files/scalap/classWithSelfAnnotation.check +++ b/test/files/scalap/classWithSelfAnnotation.check @@ -1,5 +1,5 @@ class ClassWithSelfAnnotation extends scala.AnyRef { - this : ClassWithSelfAnnotation with java.lang.CharSequence => + this: ClassWithSelfAnnotation with java.lang.CharSequence => def this() = { /* compiled code */ } - def foo : scala.Int = { /* compiled code */ } + def foo: scala.Int = { /* compiled code */ } } diff --git a/test/files/scalap/covariantParam.check b/test/files/scalap/covariantParam.check index f7a3c98966..85b1400fce 100644 --- a/test/files/scalap/covariantParam.check +++ b/test/files/scalap/covariantParam.check @@ -1,4 +1,4 @@ class CovariantParam[+A] extends scala.AnyRef { def this() = { /* compiled code */ } - def foo[A](a : A) : scala.Int = { /* compiled code */ } + def foo[A](a: A): scala.Int = { /* compiled code */ } } diff --git a/test/files/scalap/defaultParameter.check b/test/files/scalap/defaultParameter.check index 0c775ea7b5..4e244d18f1 100644 --- a/test/files/scalap/defaultParameter.check +++ b/test/files/scalap/defaultParameter.check @@ -1,3 +1,3 @@ trait DefaultParameter extends scala.AnyRef { - def foo(s : scala.Predef.String) : scala.Unit + def foo(s: scala.Predef.String): scala.Unit } diff --git a/test/files/scalap/implicitParam.check b/test/files/scalap/implicitParam.check index a2cfd6092d..46e995652e 100644 --- a/test/files/scalap/implicitParam.check +++ b/test/files/scalap/implicitParam.check @@ -1,4 +1,4 @@ class ImplicitParam extends scala.AnyRef { def this() = { /* compiled code */ } - def foo(i : scala.Int)(implicit f : scala.Float, d : scala.Double) : scala.Int = { /* compiled code */ } + def foo(i: scala.Int)(implicit f: scala.Float, d: scala.Double): scala.Int = { /* compiled code */ } } diff --git a/test/files/scalap/packageObject.check b/test/files/scalap/packageObject.check index 5732d92958..d1d0bbf122 100644 --- a/test/files/scalap/packageObject.check +++ b/test/files/scalap/packageObject.check @@ -1,5 +1,5 @@ package object PackageObject extends scala.AnyRef { def this() = { /* compiled code */ } type A = scala.Predef.String - def foo(i : scala.Int) : scala.Int = { /* compiled code */ } + def foo(i: scala.Int): scala.Int = { /* compiled code */ } } diff --git a/test/files/scalap/paramClauses.check b/test/files/scalap/paramClauses.check index 3a141e8faf..11c5e4bbd6 100644 --- a/test/files/scalap/paramClauses.check +++ b/test/files/scalap/paramClauses.check @@ -1,4 +1,4 @@ class ParamClauses extends scala.AnyRef { def this() = { /* compiled code */ } - def foo(i : scala.Int)(s : scala.Predef.String)(t : scala.Double) : scala.Int = { /* compiled code */ } + def foo(i: scala.Int)(s: scala.Predef.String)(t: scala.Double): scala.Int = { /* compiled code */ } } diff --git a/test/files/scalap/paramNames.check b/test/files/scalap/paramNames.check index 85e37f858d..836b3d0e7b 100644 --- a/test/files/scalap/paramNames.check +++ b/test/files/scalap/paramNames.check @@ -1,4 +1,4 @@ class ParamNames extends scala.AnyRef { def this() = { /* compiled code */ } - def foo(s : => scala.Seq[scala.Int], s2 : => scala.Seq[scala.Any]) : scala.Unit = { /* compiled code */ } + def foo(s: => scala.Seq[scala.Int], s2: => scala.Seq[scala.Any]): scala.Unit = { /* compiled code */ } } diff --git a/test/files/scalap/sequenceParam.check b/test/files/scalap/sequenceParam.check index 142d92fea3..f7bf83f6b2 100644 --- a/test/files/scalap/sequenceParam.check +++ b/test/files/scalap/sequenceParam.check @@ -1,3 +1,3 @@ class SequenceParam extends scala.AnyRef { - def this(s : scala.Predef.String, i : scala.Int*) = { /* compiled code */ } + def this(s: scala.Predef.String, i: scala.Int*) = { /* compiled code */ } } diff --git a/test/files/scalap/simpleClass.check b/test/files/scalap/simpleClass.check index 4fdf25d1cf..4675cbf665 100644 --- a/test/files/scalap/simpleClass.check +++ b/test/files/scalap/simpleClass.check @@ -1,4 +1,4 @@ class SimpleClass extends scala.AnyRef { def this() = { /* compiled code */ } - def foo : scala.Int = { /* compiled code */ } + def foo: scala.Int = { /* compiled code */ } } diff --git a/test/files/scalap/traitObject.check b/test/files/scalap/traitObject.check index 104ba14f1a..f7ae4fd2f4 100644 --- a/test/files/scalap/traitObject.check +++ b/test/files/scalap/traitObject.check @@ -1,8 +1,8 @@ trait TraitObject extends scala.AnyRef { - def $init$() : scala.Unit = { /* compiled code */ } - def foo : scala.Int = { /* compiled code */ } + def $init$(): scala.Unit = { /* compiled code */ } + def foo: scala.Int = { /* compiled code */ } } object TraitObject extends scala.AnyRef { def this() = { /* compiled code */ } - def bar : scala.Int = { /* compiled code */ } + def bar: scala.Int = { /* compiled code */ } } diff --git a/test/files/scalap/typeAnnotations.check b/test/files/scalap/typeAnnotations.check index 407b0235c6..cba69f8e41 100644 --- a/test/files/scalap/typeAnnotations.check +++ b/test/files/scalap/typeAnnotations.check @@ -1,8 +1,8 @@ abstract class TypeAnnotations[@scala.specialized R] extends scala.AnyRef { def this() = { /* compiled code */ } @scala.specialized - val x : scala.Int = { /* compiled code */ } + val x: scala.Int = { /* compiled code */ } @scala.specialized type T - def compose[@scala.specialized A](x : A, y : R) : A = { /* compiled code */ } + def compose[@scala.specialized A](x: A, y: R): A = { /* compiled code */ } } diff --git a/test/files/scalap/valAndVar.check b/test/files/scalap/valAndVar.check index e940da9801..98eae5192d 100644 --- a/test/files/scalap/valAndVar.check +++ b/test/files/scalap/valAndVar.check @@ -1,5 +1,5 @@ class ValAndVar extends scala.AnyRef { def this() = { /* compiled code */ } - val foo : java.lang.String = { /* compiled code */ } - var bar : scala.Int = { /* compiled code */ } + val foo: java.lang.String = { /* compiled code */ } + var bar: scala.Int = { /* compiled code */ } } diff --git a/test/files/scalap/wildcardType.check b/test/files/scalap/wildcardType.check index e43261db32..6ea696647e 100644 --- a/test/files/scalap/wildcardType.check +++ b/test/files/scalap/wildcardType.check @@ -1,3 +1,3 @@ class WildcardType extends scala.AnyRef { - def this(f : scala.Function1[scala.Int, _]) = { /* compiled code */ } + def this(f: scala.Function1[scala.Int, _]) = { /* compiled code */ } } diff --git a/test/junit/scala/util/matching/regextract-char.scala b/test/junit/scala/util/matching/regextract-char.scala new file mode 100644 index 0000000000..50fdcd9d46 --- /dev/null +++ b/test/junit/scala/util/matching/regextract-char.scala @@ -0,0 +1,58 @@ + +package scala.util.matching + +import org.junit.Assert._ +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 + +import PartialFunction._ + +/** Regex can match a Char. + * If the pattern includes a group, + * always return a single char. + */ +@RunWith(classOf[JUnit4]) +class CharRegexTest { + implicit class Averrable(val b: Boolean) /*extends AnyVal*/ { + def yes = assert(b) + def no = assert(!b) + } + val c: Char = 'c' // "cat"(0) + val d: Char = 'D' // "Dog"(0) + + @Test def comparesGroupCorrectly(): Unit = { + val r = """(\p{Lower})""".r + cond(c) { case r(x) => true } .yes + cond(c) { case r(_) => true } .yes + cond(c) { case r(_*) => true } .yes + cond(c) { case r() => true } .no + + cond(d) { case r(x) => true } .no + cond(d) { case r(_) => true } .no + cond(d) { case r(_*) => true } .no + cond(d) { case r() => true } .no + } + + @Test def comparesNoGroupCorrectly(): Unit = { + val rnc = """\p{Lower}""".r + cond(c) { case rnc(x) => true } .no + cond(c) { case rnc(_) => true } .no + cond(c) { case rnc(_*) => true } .yes + cond(c) { case rnc() => true } .yes + + cond(d) { case rnc(x) => true } .no + cond(d) { case rnc(_) => true } .no + cond(d) { case rnc(_*) => true } .no + cond(d) { case rnc() => true } .no + } + + @Test(expected = classOf[MatchError]) + def failCorrectly(): Unit = { + val headAndTail = """(\p{Lower})([a-z]+)""".r + val n = "cat"(0) match { + case headAndTail(ht @ _*) => ht.size + } + assert(false, s"Match size $n") + } +} diff --git a/test/pending/junit/scala/util/t7265.scala b/test/junit/scala/util/t7265.scala index 3b8fa80dbe..71f085d21d 100644 --- a/test/pending/junit/scala/util/t7265.scala +++ b/test/junit/scala/util/t7265.scala @@ -30,6 +30,7 @@ class SpecVersionTest { assert(sut isJavaAtLeast "1.6") assert(sut isJavaAtLeast "1.7") assert(!(sut isJavaAtLeast "1.8")) + assert(!(sut isJavaAtLeast "1.71")) } @Test(expected = classOf[NumberFormatException]) def badVersion(): Unit = { @@ -40,6 +41,18 @@ class SpecVersionTest { sut isJavaAtLeast "1" } @Test(expected = classOf[NumberFormatException]) + def noVersion(): Unit = { + sut isJavaAtLeast "" + } + @Test(expected = classOf[NumberFormatException]) + def dotOnly(): Unit = { + sut isJavaAtLeast "." + } + @Test(expected = classOf[NumberFormatException]) + def leadingDot(): Unit = { + sut isJavaAtLeast ".5" + } + @Test(expected = classOf[NumberFormatException]) def notASpec(): Unit = { sut isJavaAtLeast "1.7.1" } diff --git a/test/partest b/test/partest index 0259cdb791..8d94facba3 100755 --- a/test/partest +++ b/test/partest @@ -1,6 +1,5 @@ #!/usr/bin/env bash # - ############################################################################## # Scala test runner 2.10.0 ############################################################################## @@ -11,6 +10,17 @@ # PARTICULAR PURPOSE. ############################################################################## +findScalaHome () { + # see SI-2092 and SI-5792 + local source="${BASH_SOURCE[0]}" + while [ -h "$source" ] ; do + local linked="$(readlink "$source")" + local dir="$( cd -P $(dirname "$source") && cd -P $(dirname "$linked") && pwd )" + source="$dir/$(basename "$linked")" + done + ( ( cd -P "$(dirname "$source")/.." > /dev/null ) && pwd ) +} + # Use tput to detect color-capable terminal. term_colors=$(tput colors 2>/dev/null) if [[ $? == 0 ]] && [[ $term_colors -gt 2 ]]; then @@ -29,23 +39,7 @@ case "`uname`" in esac # Finding the root folder for this Scala distribution -SOURCE=$0; -SCRIPT=`basename "$SOURCE"`; -while [ -h "$SOURCE" ]; do - SCRIPT=`basename "$SOURCE"`; - LOOKUP=`ls -ld "$SOURCE"`; - TARGET=`expr "$LOOKUP" : '.*-> \(.*\)$'`; - if expr "${TARGET:-.}/" : '/.*/$' > /dev/null; then - SOURCE=${TARGET:-.}; - else - SOURCE=`dirname "$SOURCE"`/${TARGET:-.}; - fi; -done; - -# see #2092 -SCALA_HOME=`dirname "$SOURCE"` -SCALA_HOME=`cd "$SCALA_HOME"; pwd -P` -SCALA_HOME=`cd "$SCALA_HOME"/..; pwd` +SCALA_HOME="$(findScalaHome)" if $cygwin; then SCALA_HOME=`cygpath --windows --short-name "$SCALA_HOME"` @@ -125,10 +119,13 @@ if [ ! -z "${PARTEST_DEBUG}" ] ; then partestDebugStr="-Dpartest.debug=${PARTEST_DEBUG}" fi +# note that variables which may intentionally be empty must not +# be quoted: otherwise an empty string will appear as a command line +# argument, and java will think that is the program to run. "${JAVACMD:=java}" \ $JAVA_OPTS -cp "$EXT_CLASSPATH" \ ${partestDebugStr} \ - "$color_opts" \ + ${color_opts} \ -Dfile.encoding=UTF-8 \ -Dscala.home="${SCALA_HOME}" \ -Dpartest.javacmd="${JAVACMD}" \ |