summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbuild.xml2
-rw-r--r--src/actors/scala/actors/Scheduler.scala1
-rw-r--r--src/actors/scala/actors/remote/TcpService.scala2
-rw-r--r--src/compiler/scala/reflect/macros/compiler/DefaultMacroCompiler.scala2
-rw-r--r--src/compiler/scala/reflect/macros/compiler/Validators.scala2
-rw-r--r--src/compiler/scala/reflect/macros/contexts/Context.scala1
-rw-r--r--src/compiler/scala/reflect/macros/contexts/Synthetics.scala66
-rw-r--r--src/compiler/scala/reflect/macros/runtime/JavaReflectionRuntimes.scala2
-rw-r--r--src/compiler/scala/reflect/macros/runtime/MacroRuntimes.scala3
-rw-r--r--src/compiler/scala/reflect/macros/runtime/ScalaReflectionRuntimes.scala2
-rw-r--r--src/compiler/scala/reflect/macros/util/Helpers.scala7
-rw-r--r--src/compiler/scala/tools/ant/sabbus/Settings.scala2
-rw-r--r--src/compiler/scala/tools/cmd/CommandLine.scala6
-rw-r--r--src/compiler/scala/tools/cmd/CommandLineParser.scala10
-rw-r--r--src/compiler/scala/tools/cmd/Opt.scala8
-rw-r--r--src/compiler/scala/tools/cmd/Reference.scala22
-rw-r--r--src/compiler/scala/tools/cmd/gen/AnyVals.scala107
-rw-r--r--src/compiler/scala/tools/cmd/gen/Codegen.scala6
-rw-r--r--src/compiler/scala/tools/cmd/package.scala12
-rw-r--r--src/compiler/scala/tools/nsc/CompilationUnits.scala4
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala181
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Scanners.scala4
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala2
-rw-r--r--src/compiler/scala/tools/nsc/io/DaemonThreadFactory.scala21
-rw-r--r--src/compiler/scala/tools/nsc/io/package.scala14
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala3
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala1
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Macros.scala64
-rw-r--r--src/compiler/scala/tools/reflect/MacroImplementations.scala3
-rw-r--r--src/compiler/scala/tools/reflect/ToolBoxFactory.scala10
-rw-r--r--src/compiler/scala/tools/reflect/quasiquotes/Parsers.scala94
-rw-r--r--src/compiler/scala/tools/reflect/quasiquotes/Placeholders.scala21
-rw-r--r--src/compiler/scala/tools/reflect/quasiquotes/Quasiquotes.scala2
-rw-r--r--src/compiler/scala/tools/util/PathResolver.scala4
-rw-r--r--src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala1
-rw-r--r--src/library/scala/Boolean.scala42
-rw-r--r--src/library/scala/Byte.scala336
-rw-r--r--src/library/scala/Char.scala336
-rw-r--r--src/library/scala/Double.scala325
-rw-r--r--src/library/scala/Float.scala330
-rw-r--r--src/library/scala/Int.scala336
-rw-r--r--src/library/scala/Long.scala336
-rw-r--r--src/library/scala/Short.scala336
-rw-r--r--src/library/scala/StringContext.scala3
-rw-r--r--src/library/scala/Unit.scala9
-rw-r--r--src/library/scala/collection/parallel/mutable/LazyCombiner.scala1
-rw-r--r--src/library/scala/concurrent/Lock.scala1
-rw-r--r--src/library/scala/runtime/ScalaRunTime.scala34
-rw-r--r--src/library/scala/util/Properties.scala7
-rw-r--r--src/library/scala/util/matching/Regex.scala38
-rw-r--r--src/partest/scala/tools/partest/BytecodeTest.scala2
-rw-r--r--src/partest/scala/tools/partest/TestState.scala1
-rw-r--r--src/partest/scala/tools/partest/nest/ConsoleRunner.scala9
-rw-r--r--src/partest/scala/tools/partest/nest/ConsoleRunnerSpec.scala10
-rw-r--r--src/partest/scala/tools/partest/nest/NestUI.scala1
-rw-r--r--src/partest/scala/tools/partest/nest/Runner.scala18
-rw-r--r--src/partest/scala/tools/partest/package.scala6
-rw-r--r--src/reflect/scala/reflect/api/Mirrors.scala12
-rw-r--r--src/reflect/scala/reflect/api/Names.scala4
-rw-r--r--src/reflect/scala/reflect/internal/Kinds.scala22
-rw-r--r--src/reflect/scala/reflect/internal/Trees.scala10
-rw-r--r--src/reflect/scala/reflect/internal/transform/Erasure.scala2
-rw-r--r--src/reflect/scala/reflect/internal/util/ScalaClassLoader.scala4
-rw-r--r--src/reflect/scala/reflect/internal/util/TriState.scala2
-rw-r--r--src/reflect/scala/reflect/internal/util/WeakHashSet.scala31
-rw-r--r--src/reflect/scala/reflect/macros/Context.scala3
-rw-r--r--src/reflect/scala/reflect/macros/Synthetics.scala107
-rw-r--r--src/reflect/scala/reflect/runtime/ReflectSetup.scala2
-rw-r--r--src/repl/scala/tools/nsc/interpreter/ExprTyper.scala26
-rw-r--r--src/repl/scala/tools/nsc/interpreter/IMain.scala119
-rw-r--r--src/repl/scala/tools/nsc/interpreter/JLineCompletion.scala4
-rw-r--r--src/repl/scala/tools/nsc/interpreter/MemberHandlers.scala6
-rw-r--r--src/repl/scala/tools/nsc/interpreter/Power.scala2
-rw-r--r--src/repl/scala/tools/nsc/interpreter/Results.scala2
-rw-r--r--src/repl/scala/tools/nsc/interpreter/package.scala4
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/ScaladocAnalyzer.scala6
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/ScaladocGlobal.scala1
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala9
-rw-r--r--src/scalap/scala/tools/scalap/Arguments.scala1
-rw-r--r--src/scalap/scala/tools/scalap/ByteArrayReader.scala13
-rw-r--r--src/scalap/scala/tools/scalap/Classfile.scala2
-rw-r--r--src/scalap/scala/tools/scalap/Classfiles.scala2
-rw-r--r--src/scalap/scala/tools/scalap/CodeWriter.scala8
-rw-r--r--src/scalap/scala/tools/scalap/Decode.scala30
-rw-r--r--src/scalap/scala/tools/scalap/JavaWriter.scala4
-rw-r--r--src/scalap/scala/tools/scalap/Main.scala18
-rw-r--r--src/scalap/scala/tools/scalap/MetaParser.scala7
-rw-r--r--src/scalap/scala/tools/scalap/Properties.scala3
-rw-r--r--src/scalap/scala/tools/scalap/rules/Memoisable.scala (renamed from src/scalap/scala/tools/scalap/scalax/rules/Memoisable.scala)23
-rw-r--r--src/scalap/scala/tools/scalap/rules/Result.scala69
-rw-r--r--src/scalap/scala/tools/scalap/rules/Rule.scala172
-rw-r--r--src/scalap/scala/tools/scalap/rules/Rules.scala (renamed from src/scalap/scala/tools/scalap/scalax/rules/Rules.scala)62
-rw-r--r--src/scalap/scala/tools/scalap/rules/SeqRule.scala (renamed from src/scalap/scala/tools/scalap/scalax/rules/SeqRule.scala)57
-rw-r--r--src/scalap/scala/tools/scalap/rules/package.scala6
-rw-r--r--src/scalap/scala/tools/scalap/scalasig/ClassFileParser.scala (renamed from src/scalap/scala/tools/scalap/scalax/rules/scalasig/ClassFileParser.scala)93
-rw-r--r--src/scalap/scala/tools/scalap/scalasig/Flags.scala (renamed from src/scalap/scala/tools/scalap/scalax/rules/scalasig/Flags.scala)7
-rw-r--r--src/scalap/scala/tools/scalap/scalasig/ScalaSig.scala (renamed from src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSig.scala)83
-rw-r--r--src/scalap/scala/tools/scalap/scalasig/ScalaSigPrinter.scala (renamed from src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala)51
-rw-r--r--src/scalap/scala/tools/scalap/scalasig/SourceFileAttributeParser.scala (renamed from src/scalap/scala/tools/scalap/scalax/rules/scalasig/SourceFileAttributeParser.scala)12
-rw-r--r--src/scalap/scala/tools/scalap/scalasig/Symbol.scala70
-rw-r--r--src/scalap/scala/tools/scalap/scalasig/Type.scala22
-rw-r--r--src/scalap/scala/tools/scalap/scalax/rules/Result.scala72
-rw-r--r--src/scalap/scala/tools/scalap/scalax/rules/Rule.scala177
-rw-r--r--src/scalap/scala/tools/scalap/scalax/rules/scalasig/Symbol.scala73
-rw-r--r--src/scalap/scala/tools/scalap/scalax/rules/scalasig/Type.scala25
-rw-r--r--src/scalap/scala/tools/scalap/scalax/util/StringUtil.scala19
-rwxr-xr-xsrc/xml/scala/xml/Elem.scala1
-rw-r--r--test/files/neg/quasiquotes-syntax-error-position.check32
-rw-r--r--test/files/neg/quasiquotes-syntax-error-position.scala15
-rw-r--r--test/files/neg/t7325.check10
-rw-r--r--test/files/neg/t7715.check13
-rw-r--r--test/files/neg/t7715.scala18
-rw-r--r--test/files/run/interpolation.flags1
-rw-r--r--test/files/run/interpolationArgs.check4
-rw-r--r--test/files/run/interpolationArgs.flags1
-rw-r--r--test/files/run/interpolationMultiline1.flags1
-rw-r--r--test/files/run/interpolationMultiline2.flags1
-rw-r--r--test/files/run/macro-expand-unapply-b.check2
-rw-r--r--test/files/run/macro-expand-unapply-b.flags1
-rw-r--r--test/files/run/macro-expand-unapply-b/Impls_Macros_1.scala37
-rw-r--r--test/files/run/macro-expand-unapply-b/Test_2.scala8
-rw-r--r--test/files/run/macro-toplevel-companion-a.flags1
-rw-r--r--test/files/run/macro-toplevel-companion-a/Impls_Macros_1.scala14
-rw-r--r--test/files/run/macro-toplevel-companion-a/Test_2.scala8
-rw-r--r--test/files/run/macro-toplevel-companion-b.check4
-rw-r--r--test/files/run/macro-toplevel-companion-b.flags1
-rw-r--r--test/files/run/macro-toplevel-companion-b/Impls_Macros_1.scala15
-rw-r--r--test/files/run/macro-toplevel-companion-b/Test_2.scala11
-rw-r--r--test/files/run/macro-toplevel-companion-c.check3
-rw-r--r--test/files/run/macro-toplevel-companion-c.flags1
-rw-r--r--test/files/run/macro-toplevel-companion-c.scala51
-rw-r--r--test/files/run/macro-toplevel.check2
-rw-r--r--test/files/run/macro-toplevel/Macros_1.scala15
-rw-r--r--test/files/run/macro-toplevel/Test_2.scala6
-rw-r--r--test/files/run/repl-javap-outdir-funs/run-repl_7.scala13
-rw-r--r--test/files/run/t5923a/Macros_1.scala42
-rw-r--r--test/files/run/t5923c.check1
-rw-r--r--test/files/run/t5923c/Macros_1.scala39
-rw-r--r--test/files/run/t5923c/Test_2.scala12
-rw-r--r--test/files/run/t5923d.check (renamed from test/files/run/macro-toplevel-companion-a.check)0
-rw-r--r--test/files/run/t5923d/Macros_1.scala9
-rw-r--r--test/files/run/t5923d/Test_2.scala7
-rw-r--r--test/files/run/t6507.check26
-rw-r--r--test/files/run/t6507.scala14
-rw-r--r--test/files/run/t7265.scala27
-rw-r--r--test/files/run/t7331a.check2
-rw-r--r--test/files/run/t7331a.scala10
-rw-r--r--test/files/run/t7331b.check3
-rw-r--r--test/files/run/t7331b.scala11
-rw-r--r--test/files/run/t7331c.check3
-rw-r--r--test/files/run/t7331c.scala11
-rw-r--r--test/files/run/t7715.check3
-rw-r--r--test/files/run/t7715.scala24
-rw-r--r--test/files/run/tailcalls.check36
-rw-r--r--test/files/scalacheck/quasiquotes/ErrorProps.scala6
-rw-r--r--test/files/scalap/abstractClass.check2
-rw-r--r--test/files/scalap/abstractMethod.check6
-rw-r--r--test/files/scalap/caseClass.check32
-rw-r--r--test/files/scalap/caseObject.check16
-rw-r--r--test/files/scalap/cbnParam.check2
-rw-r--r--test/files/scalap/classPrivate.check8
-rw-r--r--test/files/scalap/classWithExistential.check2
-rw-r--r--test/files/scalap/classWithSelfAnnotation.check4
-rw-r--r--test/files/scalap/covariantParam.check2
-rw-r--r--test/files/scalap/defaultParameter.check2
-rw-r--r--test/files/scalap/implicitParam.check2
-rw-r--r--test/files/scalap/packageObject.check2
-rw-r--r--test/files/scalap/paramClauses.check2
-rw-r--r--test/files/scalap/paramNames.check2
-rw-r--r--test/files/scalap/sequenceParam.check2
-rw-r--r--test/files/scalap/simpleClass.check2
-rw-r--r--test/files/scalap/traitObject.check6
-rw-r--r--test/files/scalap/typeAnnotations.check4
-rw-r--r--test/files/scalap/valAndVar.check4
-rw-r--r--test/files/scalap/wildcardType.check2
-rw-r--r--test/junit/scala/tools/nsc/symtab/CannotHaveAttrsTest.scala67
-rw-r--r--test/junit/scala/tools/nsc/symtab/SymbolTableTest.scala5
-rw-r--r--test/junit/scala/tools/testing/AssertThrowsTest.scala34
-rw-r--r--test/junit/scala/tools/testing/AssertUtil.scala19
-rw-r--r--test/junit/scala/util/matching/regextract-char.scala58
-rw-r--r--test/junit/scala/util/t7265.scala (renamed from test/pending/junit/scala/util/t7265.scala)13
-rwxr-xr-xtest/partest5
184 files changed, 2284 insertions, 3369 deletions
diff --git a/build.xml b/build.xml
index 4bfb0f8ba4..cdcdcee58c 100755
--- a/build.xml
+++ b/build.xml
@@ -395,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/contexts/Context.scala b/src/compiler/scala/reflect/macros/contexts/Context.scala
index bd1d7d5248..1355a839d9 100644
--- a/src/compiler/scala/reflect/macros/contexts/Context.scala
+++ b/src/compiler/scala/reflect/macros/contexts/Context.scala
@@ -14,7 +14,6 @@ abstract class Context extends scala.reflect.macros.Context
with Parsers
with Evals
with ExprUtils
- with Synthetics
with Traces {
val universe: Global
diff --git a/src/compiler/scala/reflect/macros/contexts/Synthetics.scala b/src/compiler/scala/reflect/macros/contexts/Synthetics.scala
deleted file mode 100644
index ada16a8113..0000000000
--- a/src/compiler/scala/reflect/macros/contexts/Synthetics.scala
+++ /dev/null
@@ -1,66 +0,0 @@
-/* NSC -- new Scala compiler
- * Copyright 2005-2013 LAMP/EPFL
- */
-
-package scala.reflect.macros
-package contexts
-
-import scala.reflect.internal.Flags._
-import scala.reflect.internal.util.BatchSourceFile
-import scala.reflect.io.VirtualFile
-
-trait Synthetics {
- self: Context =>
-
- import global._
- import mirror.wrapMissing
-
- // getClassIfDefined and getModuleIfDefined cannot be used here
- // because they don't work for stuff declared in the empty package
- // (as specified in SLS, code inside non-empty packages cannot see
- // declarations from the empty package, so compiler internals
- // default to ignoring contents of the empty package)
- // to the contrast, staticModule and staticClass are designed
- // to be a part of the reflection API and, therefore, they
- // correctly resolve all names
- private def topLevelSymbol(name: Name): Symbol = wrapMissing {
- if (name.isTermName) mirror.staticModule(name.toString)
- else mirror.staticClass(name.toString)
- }
-
- def topLevelDef(name: Name): Tree =
- enclosingRun.units.toList.map(_.body).flatMap {
- // it's okay to check `stat.symbol` here, because currently macros expand strictly after namer
- // which means that by the earliest time one can call this method all top-level definitions will have already been entered
- case PackageDef(_, stats) => stats filter (stat => stat.symbol != NoSymbol && stat.symbol == topLevelSymbol(name))
- case _ => Nil // should never happen, but better be safe than sorry
- }.headOption getOrElse EmptyTree
-
- def topLevelRef(name: Name): Tree = {
- if (topLevelDef(name).nonEmpty) gen.mkUnattributedRef(name)
- else EmptyTree
- }
-
- def introduceTopLevel[T: PackageSpec](packagePrototype: T, definition: universe.ImplDef): RefTree =
- introduceTopLevel(packagePrototype, List(definition)).head
-
- def introduceTopLevel[T: PackageSpec](packagePrototype: T, definitions: universe.ImplDef*): List[RefTree] =
- introduceTopLevel(packagePrototype, definitions.toList)
-
- private def introduceTopLevel[T: PackageSpec](packagePrototype: T, definitions: List[universe.ImplDef]): List[RefTree] = {
- val code @ PackageDef(pid, _) = implicitly[PackageSpec[T]].mkPackageDef(packagePrototype, definitions)
- universe.currentRun.compileLate(code)
- definitions map (definition => Select(pid, definition.name))
- }
-
- protected def mkPackageDef(name: String, stats: List[Tree]) = gen.mkPackageDef(name, stats)
-
- protected def mkPackageDef(name: TermName, stats: List[Tree]) = gen.mkPackageDef(name.toString, stats)
-
- protected def mkPackageDef(tree: RefTree, stats: List[Tree]) = PackageDef(tree, stats)
-
- protected def mkPackageDef(sym: Symbol, stats: List[Tree]) = {
- assert(sym hasFlag PACKAGE, s"expected a package or package class symbol, found: $sym")
- gen.mkPackageDef(sym.fullName.toString, stats)
- }
-}
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/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/CompilationUnits.scala b/src/compiler/scala/tools/nsc/CompilationUnits.scala
index b52e6fdf57..efe436f004 100644
--- a/src/compiler/scala/tools/nsc/CompilationUnits.scala
+++ b/src/compiler/scala/tools/nsc/CompilationUnits.scala
@@ -57,8 +57,8 @@ trait CompilationUnits { self: Global =>
// SBT compatibility (SI-6875)
//
// imagine we have a file named A.scala, which defines a trait named Foo and a module named Main
- // Main contains a call to a macro, which calls c.introduceTopLevel to define a mock for Foo
- // c.introduceTopLevel creates a virtual file Virt35af32.scala, which contains a class named FooMock extending Foo,
+ // Main contains a call to a macro, which calls compileLate to define a mock for Foo
+ // compileLate creates a virtual file Virt35af32.scala, which contains a class named FooMock extending Foo,
// and macro expansion instantiates FooMock. the stage is now set. let's see what happens next.
//
// without this workaround in scalac or without being patched itself, sbt will think that
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index a4093f9afa..94270e4cf3 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -334,22 +334,27 @@ self =>
def parseStartRule: () => Tree
- /** This is the general parse entry point.
- */
- def parse(): Tree = {
- val t = parseStartRule()
+ def parseRule[T](rule: this.type => T): T = {
+ val t = rule(this)
accept(EOF)
t
}
+ /** This is the general parse entry point.
+ */
+ def parse(): Tree = parseRule(_.parseStartRule())
+
+ /** This is alternative entry point for repl, script runner, toolbox and quasiquotes.
+ */
+ def parseStats(): List[Tree] = parseRule(_.templateStats())
+
/** This is the parse entry point for code which is not self-contained, e.g.
* a script which is a series of template statements. They will be
* swaddled in Trees until the AST is equivalent to the one returned
* by compilationUnit().
*/
def scriptBody(): Tree = {
- val stmts = templateStats()
- accept(EOF)
+ val stmts = parseStats()
def mainModuleName = newTermName(settings.script.value)
/* If there is only a single object template in the file and it has a
@@ -563,8 +568,8 @@ self =>
and
}
- def expectedMsg(token: Int): String =
- token2string(token) + " expected but " +token2string(in.token) + " found."
+ def expectedMsgTemplate(exp: String, fnd: String) = s"$exp expected but $fnd found."
+ def expectedMsg(token: Int): String = expectedMsgTemplate(token2string(token), token2string(in.token))
/** Consume one token of the specified type, or signal an error if it is not there. */
def accept(token: Int): Int = {
@@ -627,6 +632,8 @@ self =>
def isAnnotation: Boolean = in.token == AT
+ def isCaseDefStart: Boolean = in.token == CASE
+
def isLocalModifier: Boolean = in.token match {
case ABSTRACT | FINAL | SEALED | IMPLICIT | LAZY => true
case _ => false
@@ -1137,32 +1144,70 @@ self =>
})
}
- private def interpolatedString(inPattern: Boolean): Tree = atPos(in.offset) {
- val start = in.offset
- val interpolator = in.name
+ /** Handle placeholder syntax.
+ * If evaluating the tree produces placeholders, then make it a function.
+ */
+ private def withPlaceholders(tree: =>Tree, isAny: Boolean): Tree = {
+ val savedPlaceholderParams = placeholderParams
+ placeholderParams = List()
+ var res = tree
+ if (placeholderParams.nonEmpty && !isWildcard(res)) {
+ res = atPos(res.pos)(Function(placeholderParams.reverse, res))
+ if (isAny) placeholderParams foreach (_.tpt match {
+ case tpt @ TypeTree() => tpt setType definitions.AnyTpe
+ case _ => // some ascription
+ })
+ placeholderParams = List()
+ }
+ placeholderParams = placeholderParams ::: savedPlaceholderParams
+ res
+ }
- val partsBuf = new ListBuffer[Tree]
- val exprBuf = new ListBuffer[Tree]
+ /** Consume a USCORE and create a fresh synthetic placeholder param. */
+ private def freshPlaceholder(): Tree = {
+ val start = in.offset
+ val pname = freshName("x$")
in.nextToken()
- while (in.token == STRINGPART) {
- partsBuf += literal()
- exprBuf += (
- if (inPattern) dropAnyBraces(pattern())
- else in.token match {
- case IDENTIFIER => atPos(in.offset)(Ident(ident()))
- case LBRACE => expr()
- case THIS => in.nextToken(); atPos(in.offset)(This(tpnme.EMPTY))
- case _ => syntaxErrorOrIncompleteAnd("error in interpolated string: identifier or block expected", skipIt = true)(EmptyTree)
- }
- )
- }
- if (in.token == STRINGLIT) partsBuf += literal()
+ val id = atPos(start)(Ident(pname))
+ val param = atPos(id.pos.focus)(gen.mkSyntheticParam(pname.toTermName))
+ placeholderParams = param :: placeholderParams
+ id
+ }
+
+ private def interpolatedString(inPattern: Boolean): Tree = {
+ def errpolation() = syntaxErrorOrIncompleteAnd("error in interpolated string: identifier or block expected",
+ skipIt = true)(EmptyTree)
+ // Like Swiss cheese, with holes
+ def stringCheese: Tree = atPos(in.offset) {
+ val start = in.offset
+ val interpolator = in.name
- val t1 = atPos(o2p(start)) { Ident(nme.StringContext) }
- val t2 = atPos(start) { Apply(t1, partsBuf.toList) }
- t2 setPos t2.pos.makeTransparent
- val t3 = Select(t2, interpolator) setPos t2.pos
- atPos(start) { Apply(t3, exprBuf.toList) }
+ val partsBuf = new ListBuffer[Tree]
+ val exprBuf = new ListBuffer[Tree]
+ in.nextToken()
+ while (in.token == STRINGPART) {
+ partsBuf += literal()
+ exprBuf += (
+ if (inPattern) dropAnyBraces(pattern())
+ else in.token match {
+ case IDENTIFIER => atPos(in.offset)(Ident(ident()))
+ //case USCORE => freshPlaceholder() // ifonly etapolation
+ case LBRACE => expr() // dropAnyBraces(expr0(Local))
+ case THIS => in.nextToken(); atPos(in.offset)(This(tpnme.EMPTY))
+ case _ => errpolation()
+ }
+ )
+ }
+ if (in.token == STRINGLIT) partsBuf += literal()
+
+ val t1 = atPos(o2p(start)) { Ident(nme.StringContext) }
+ val t2 = atPos(start) { Apply(t1, partsBuf.toList) }
+ t2 setPos t2.pos.makeTransparent
+ val t3 = Select(t2, interpolator) setPos t2.pos
+ atPos(start) { Apply(t3, exprBuf.toList) }
+ }
+ if (inPattern) stringCheese
+ else withPlaceholders(stringCheese, isAny = true) // strinterpolator params are Any* by definition
}
/* ------------- NEW LINES ------------------------------------------------- */
@@ -1260,18 +1305,7 @@ self =>
*/
def expr(): Tree = expr(Local)
- def expr(location: Int): Tree = {
- val savedPlaceholderParams = placeholderParams
- placeholderParams = List()
- var res = expr0(location)
- if (!placeholderParams.isEmpty && !isWildcard(res)) {
- res = atPos(res.pos){ Function(placeholderParams.reverse, res) }
- placeholderParams = List()
- }
- placeholderParams = placeholderParams ::: savedPlaceholderParams
- res
- }
-
+ def expr(location: Int): Tree = withPlaceholders(expr0(location), isAny = false)
def expr0(location: Int): Tree = (in.token: @scala.annotation.switch) match {
case IF =>
@@ -1298,7 +1332,7 @@ self =>
in.nextToken()
if (in.token != LBRACE) catchFromExpr()
else inBracesOrNil {
- if (in.token == CASE) caseClauses()
+ if (isCaseDefStart) caseClauses()
else catchFromExpr()
}
}
@@ -1520,13 +1554,7 @@ self =>
case IDENTIFIER | BACKQUOTED_IDENT | THIS | SUPER =>
path(thisOK = true, typeOK = false)
case USCORE =>
- val start = in.offset
- val pname = freshName("x$")
- in.nextToken()
- val id = atPos(start) (Ident(pname))
- val param = atPos(id.pos.focus){ gen.mkSyntheticParam(pname.toTermName) }
- placeholderParams = param :: placeholderParams
- id
+ freshPlaceholder()
case LPAREN =>
atPos(in.offset)(makeParens(commaSeparated(expr())))
case LBRACE =>
@@ -1613,7 +1641,7 @@ self =>
*/
def blockExpr(): Tree = atPos(in.offset) {
inBraces {
- if (in.token == CASE) Match(EmptyTree, caseClauses())
+ if (isCaseDefStart) Match(EmptyTree, caseClauses())
else block()
}
}
@@ -2605,7 +2633,7 @@ self =>
case EQUALS =>
in.nextToken()
TypeDef(mods, name, tparams, typ())
- case SUPERTYPE | SUBTYPE | SEMI | NEWLINE | NEWLINES | COMMA | RBRACE =>
+ case t if t == SUPERTYPE || t == SUBTYPE || t == COMMA || t == RBRACE || isStatSep(t) =>
TypeDef(mods | Flags.DEFERRED, name, tparams, typeBounds())
case _ =>
syntaxErrorOrIncompleteAnd("`=', `>:', or `<:' expected", skipIt = true)(EmptyTree)
@@ -2906,27 +2934,14 @@ self =>
stats.toList
}
- /** Informal - for the repl and other direct parser accessors.
- */
- def templateStats(): List[Tree] = templateStatSeq(isPre = false)._2 match {
- case Nil => EmptyTree.asList
- case stats => stats
- }
-
/** {{{
- * TemplateStatSeq ::= [id [`:' Type] `=>'] TemplateStat {semi TemplateStat}
- * TemplateStat ::= Import
- * | Annotations Modifiers Def
- * | Annotations Modifiers Dcl
- * | Expr1
- * | super ArgumentExprs {ArgumentExprs}
- * |
+ * TemplateStatSeq ::= [id [`:' Type] `=>'] TemplateStats
* }}}
* @param isPre specifies whether in early initializer (true) or not (false)
*/
def templateStatSeq(isPre : Boolean): (ValDef, List[Tree]) = checkNoEscapingPlaceholders {
var self: ValDef = emptyValDef
- val stats = new ListBuffer[Tree]
+ var firstOpt: Option[Tree] = None
if (isExprIntro) {
in.flushDoc
val first = expr(InTemplate) // @S: first statement is potentially converted so cannot be stubbed.
@@ -2943,10 +2958,25 @@ self =>
}
in.nextToken()
} else {
- stats += first
+ firstOpt = Some(first)
acceptStatSepOpt()
}
}
+ (self, firstOpt ++: templateStats())
+ }
+
+ /** {{{
+ * TemplateStats ::= TemplateStat {semi TemplateStat}
+ * TemplateStat ::= Import
+ * | Annotations Modifiers Def
+ * | Annotations Modifiers Dcl
+ * | Expr1
+ * | super ArgumentExprs {ArgumentExprs}
+ * |
+ * }}}
+ */
+ def templateStats(): List[Tree] = {
+ val stats = new ListBuffer[Tree]
while (!isStatSeqEnd) {
if (in.token == IMPORT) {
in.flushDoc
@@ -2961,7 +2991,14 @@ self =>
}
acceptStatSepOpt()
}
- (self, stats.toList)
+ stats.toList
+ }
+
+ /** Informal - for the repl and other direct parser accessors.
+ */
+ def templateStatsCompat(): List[Tree] = templateStats() match {
+ case Nil => EmptyTree.asList
+ case stats => stats
}
/** {{{
@@ -3026,14 +3063,14 @@ self =>
*/
def blockStatSeq(): List[Tree] = checkNoEscapingPlaceholders {
val stats = new ListBuffer[Tree]
- while (!isStatSeqEnd && in.token != CASE) {
+ while (!isStatSeqEnd && !isCaseDefStart) {
if (in.token == IMPORT) {
stats ++= importClause()
acceptStatSep()
}
else if (isExprIntro) {
stats += statement(InBlock)
- if (in.token != RBRACE && in.token != CASE) acceptStatSep()
+ if (in.token != RBRACE && !isCaseDefStart) acceptStatSep()
}
else if (isDefIntro || isLocalModifier || isAnnotation) {
if (in.token == IMPLICIT) {
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
index 2a8412b105..6957f85689 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
@@ -741,6 +741,10 @@ trait Scanners extends ScannersCommon {
finishStringPart()
nextRawChar()
next.token = LBRACE
+ } else if (ch == '_') {
+ finishStringPart()
+ nextRawChar()
+ next.token = USCORE
} else if (Character.isUnicodeIdentifierStart(ch)) {
finishStringPart()
do {
diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
index 666f19851d..ed694023d7 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
@@ -39,7 +39,7 @@ abstract class TreeBuilder {
* x becomes x @ _
* x: T becomes x @ (_: T)
*/
- private object patvarTransformer extends Transformer {
+ object patvarTransformer extends Transformer {
override def transform(tree: Tree): Tree = tree match {
case Ident(name) if (treeInfo.isVarPattern(tree) && name != nme.WILDCARD) =>
atPos(tree.pos)(Bind(name, atPos(tree.pos.focus) (Ident(nme.WILDCARD))))
diff --git a/src/compiler/scala/tools/nsc/io/DaemonThreadFactory.scala b/src/compiler/scala/tools/nsc/io/DaemonThreadFactory.scala
deleted file mode 100644
index 98c3d27202..0000000000
--- a/src/compiler/scala/tools/nsc/io/DaemonThreadFactory.scala
+++ /dev/null
@@ -1,21 +0,0 @@
-/* NSC -- new Scala compiler
- * Copyright 2005-2013 LAMP/EPFL
- * @author Paul Phillips
- */
-
-package scala.tools.nsc
-package io
-
-import java.util.concurrent._
-
-class DaemonThreadFactory extends ThreadFactory {
- def newThread(r: Runnable): Thread = {
- val thread = new Thread(r)
- thread setDaemon true
- thread
- }
-}
-
-object DaemonThreadFactory {
- def newPool() = Executors.newCachedThreadPool(new DaemonThreadFactory)
-} \ No newline at end of file
diff --git a/src/compiler/scala/tools/nsc/io/package.scala b/src/compiler/scala/tools/nsc/io/package.scala
index 0b2db115fb..5f2f90c284 100644
--- a/src/compiler/scala/tools/nsc/io/package.scala
+++ b/src/compiler/scala/tools/nsc/io/package.scala
@@ -5,8 +5,6 @@
package scala.tools.nsc
-import java.util.concurrent.{ Future, Callable }
-import java.util.{ Timer, TimerTask }
import scala.language.implicitConversions
package object io {
@@ -29,16 +27,4 @@ package object io {
type JFile = java.io.File
implicit def enrichManifest(m: JManifest): Jar.WManifest = Jar.WManifest(m)
- private lazy val daemonThreadPool = DaemonThreadFactory.newPool()
-
- def runnable(body: => Unit): Runnable = new Runnable { override def run() = body }
- def callable[T](body: => T): Callable[T] = new Callable[T] { override def call() = body }
- def spawn[T](body: => T): Future[T] = daemonThreadPool submit callable(body)
-
- def newThread(f: Thread => Unit)(body: => Unit): Thread = {
- val thread = new Thread(runnable(body))
- f(thread)
- thread.start
- thread
- }
}
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/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index 1b6443a4cb..f3a22a2cee 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -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 c87de8839f..4265efc839 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -815,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
}
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/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala
index 6b9537e27d..b3675d6a82 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala
@@ -589,18 +589,23 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
/** Expands a term macro used in apply role as `M(2)(3)` in `val x = M(2)(3)`.
* @see MacroExpander
*/
- def macroExpandApply(typer: Typer, expandee: Tree, mode: Mode, pt: Type) = {
+ def macroExpandApply(typer: Typer, expandee: Tree, mode: Mode, pt: Type): Tree = {
object expander extends TermMacroExpander(APPLY_ROLE, typer, expandee, mode, pt) {
override def onSuccess(expanded: Tree) = {
// prematurely annotate the tree with a macro expansion attachment
// so that adapt called indirectly by typer.typed knows that it needs to apply the existential fixup
linkExpandeeAndExpanded(expandee, expanded)
- var expectedTpe = expandee.tpe
- if (isNullaryInvocation(expandee)) expectedTpe = expectedTpe.finalResultType
+ // approximation is necessary for whitebox macros to guide type inference
+ // read more in the comments for onDelayed below
+ def approximate(tp: Type) = {
+ val undetparams = tp collect { case tp if tp.typeSymbol.isTypeParameter => tp.typeSymbol }
+ deriveTypeWithWildcards(undetparams)(tp)
+ }
+ val macroPtApprox = approximate(if (isNullaryInvocation(expandee)) expandee.tpe.finalResultType else expandee.tpe)
// `macroExpandApply` is called from `adapt`, where implicit conversions are disabled
// therefore we need to re-enable the conversions back temporarily
- if (macroDebugVerbose) println(s"typecheck #1 (against expectedTpe = $expectedTpe): $expanded")
- val expanded1 = typer.context.withImplicitsEnabled(typer.typed(expanded, mode, expectedTpe))
+ if (macroDebugVerbose) println(s"typecheck #1 (against macroPtApprox = $macroPtApprox): $expanded")
+ val expanded1 = typer.context.withImplicitsEnabled(typer.typed(expanded, mode, macroPtApprox))
if (expanded1.isErrorTyped) {
if (macroDebugVerbose) println(s"typecheck #1 has failed: ${typer.context.reportBuffer.errors}")
expanded1
@@ -612,6 +617,8 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
}
}
override def onDelayed(delayed: Tree) = {
+ // =========== THE SITUATION ===========
+ //
// If we've been delayed (i.e. bailed out of the expansion because of undetermined type params present in the expandee),
// then there are two possible situations we're in:
// 1) We're in POLYmode, when the typer tests the waters wrt type inference
@@ -627,12 +634,43 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
// the undetermined type params. Therefore we need to do something ourselves or otherwise this
// expandee will forever remaing not expanded (see SI-5692). A traditional way out of this conundrum
// is to call `instantiate` and let the inferencer try to find the way out. It works for simple cases,
- // but sometimes, if the inferencer lacks information, it will be forced to approximate. This prevents
- // an important class of macros, fundep materializers, from working, which I perceive is a problem we need to solve.
- // For details see SI-7470.
+ // but sometimes, if the inferencer lacks information, it will be forced to approximate.
+ //
+ // =========== THE PROBLEM ===========
+ //
+ // Consider the following example (thanks, Miles!):
+ //
+ // Iso represents an isomorphism between two datatypes:
+ // 1) An arbitrary one (e.g. a random case class)
+ // 2) A uniform representation for all datatypes (e.g. an HList)
+ //
+ // trait Iso[T, U] {
+ // def to(t : T) : U
+ // def from(u : U) : T
+ // }
+ // implicit def materializeIso[T, U]: Iso[T, U] = macro ???
+ //
+ // case class Foo(i: Int, s: String, b: Boolean)
+ // def foo[C, L](c: C)(implicit iso: Iso[C, L]): L = iso.to(c)
+ // foo(Foo(23, "foo", true))
+ //
+ // In the snippet above, even though we know that there's a fundep going from T to U
+ // (in a sense that a datatype's uniform representation is unambiguously determined by the datatype,
+ // e.g. for Foo it will be Int :: String :: Boolean :: HNil), there's no way to convey this information
+ // to the typechecker. Therefore the typechecker will infer Nothing for L, which is hardly what we want.
+ //
+ // =========== THE SOLUTION ===========
+ //
+ // To give materializers a chance to say their word before vanilla inference kicks in,
+ // we infer as much as possible (e.g. in the example above even though L is hopeless, C still can be inferred to Foo)
+ // and then trigger macro expansion with the undetermined type parameters still there.
+ // Thanks to that the materializer can take a look at what's going on and react accordingly.
val shouldInstantiate = typer.context.undetparams.nonEmpty && !mode.inPolyMode
- if (shouldInstantiate) typer.instantiatePossiblyExpectingUnit(delayed, mode, pt)
- else delayed
+ if (shouldInstantiate) {
+ forced += delayed
+ typer.infer.inferExprInstance(delayed, typer.context.extractUndetparams(), pt, keepNothings = false)
+ macroExpandApply(typer, delayed, mode, pt)
+ } else delayed
}
}
expander(expandee)
@@ -750,10 +788,12 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
* 2) undetparams (sym.isTypeParameter && !sym.isSkolem)
*/
var hasPendingMacroExpansions = false
+ private val forced = perRunCaches.newWeakSet[Tree]
private val delayed = perRunCaches.newWeakMap[Tree, scala.collection.mutable.Set[Int]]()
private def isDelayed(expandee: Tree) = delayed contains expandee
private def calculateUndetparams(expandee: Tree): scala.collection.mutable.Set[Int] =
- delayed.get(expandee).getOrElse {
+ if (forced(expandee)) scala.collection.mutable.Set[Int]()
+ else delayed.getOrElse(expandee, {
val calculated = scala.collection.mutable.Set[Symbol]()
expandee foreach (sub => {
def traverse(sym: Symbol) = if (sym != null && (undetparams contains sym.id)) calculated += sym
@@ -762,7 +802,7 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
})
macroLogVerbose("calculateUndetparams: %s".format(calculated))
calculated map (_.id)
- }
+ })
private val undetparams = perRunCaches.newSet[Int]()
def notifyUndetparamsAdded(newUndets: List[Symbol]): Unit = {
undetparams ++= newUndets map (_.id)
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/reflect/ToolBoxFactory.scala b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala
index afaca3396c..8d2f200e99 100644
--- a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala
+++ b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala
@@ -269,17 +269,13 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf =>
}
def parse(code: String): Tree = {
- val run = new Run
reporter.reset()
- val wrappedCode = "object wrapper {" + EOL + code + EOL + "}"
- val file = new BatchSourceFile("<toolbox>", wrappedCode)
+ val file = new BatchSourceFile("<toolbox>", code)
val unit = new CompilationUnit(file)
- phase = run.parserPhase
- val parser = newUnitParser(unit)
- val wrappedTree = parser.parse()
+ val parsed = newUnitParser(unit).parseStats()
throwIfErrors()
- val PackageDef(_, List(ModuleDef(_, _, Template(_, _, _ :: parsed)))) = wrappedTree
parsed match {
+ case Nil => EmptyTree
case expr :: Nil => expr
case stats :+ expr => Block(stats, expr)
}
diff --git a/src/compiler/scala/tools/reflect/quasiquotes/Parsers.scala b/src/compiler/scala/tools/reflect/quasiquotes/Parsers.scala
index 9a6ba56c18..18a806e5ff 100644
--- a/src/compiler/scala/tools/reflect/quasiquotes/Parsers.scala
+++ b/src/compiler/scala/tools/reflect/quasiquotes/Parsers.scala
@@ -17,32 +17,38 @@ trait Parsers { self: Quasiquotes =>
abstract class Parser extends {
val global: self.global.type = self.global
} with ScalaParser {
- /** Wraps given code to obtain a desired parser mode.
- * This way we can just re-use standard parser entry point.
- */
- def wrapCode(code: String): String =
- s"object wrapper { self => $EOL $code $EOL }"
-
- def unwrapTree(wrappedTree: Tree): Tree = {
- val PackageDef(_, List(ModuleDef(_, _, Template(_, _, _ :: parsed)))) = wrappedTree
- parsed match {
- case tree :: Nil => tree
- case stats :+ tree => Block(stats, tree)
- }
- }
-
def parse(code: String): Tree = {
try {
- val wrapped = wrapCode(code)
- debug(s"wrapped code\n=${wrapped}\n")
- val file = new BatchSourceFile(nme.QUASIQUOTE_FILE, wrapped)
- val tree = new QuasiquoteParser(file).parse()
- unwrapTree(tree)
+ val file = new BatchSourceFile(nme.QUASIQUOTE_FILE, code)
+ new QuasiquoteParser(file).parseRule(entryPoint)
} catch {
- case mi: MalformedInput => c.abort(c.macroApplication.pos, s"syntax error: ${mi.msg}")
+ case mi: MalformedInput => c.abort(correspondingPosition(mi.offset), mi.msg)
+ }
+ }
+
+ def correspondingPosition(offset: Int): Position = {
+ val posMapList = posMap.toList
+ def containsOffset(start: Int, end: Int) = start <= offset && offset <= end
+ def fallbackPosition = posMapList match {
+ case (pos1, (start1, end1)) :: _ if start1 > offset => pos1
+ case _ :+ ((pos2, (start2, end2))) if offset > end2 => pos2.withPoint(pos2.point + (end2 - start2))
}
+ posMapList.sliding(2).collect {
+ case (pos1, (start1, end1)) :: _ if containsOffset(start1, end1) => (pos1, offset - start1)
+ case (pos1, (_, end1)) :: (_, (start2, _)) :: _ if containsOffset(end1, start2) => (pos1, end1)
+ case _ :: (pos2, (start2, end2)) :: _ if containsOffset(start2, end2) => (pos2, offset - start2)
+ }.map { case (pos, offset) =>
+ pos.withPoint(pos.point + offset)
+ }.toList.headOption.getOrElse(fallbackPosition)
}
+ override def token2string(token: Int): String = token match {
+ case EOF => "end of quote"
+ case _ => super.token2string(token)
+ }
+
+ def entryPoint: QuasiquoteParser => Tree
+
class QuasiquoteParser(source0: SourceFile) extends SourceFileParser(source0) {
override val treeBuilder = new ParserTreeBuilder {
// q"(..$xs)"
@@ -73,9 +79,11 @@ trait Parsers { self: Quasiquotes =>
} else
super.caseClause()
- def isHole = isIdent && holeMap.contains(in.name)
+ def isHole: Boolean = isIdent && holeMap.contains(in.name)
- override def isAnnotation: Boolean = super.isAnnotation || (isHole && lookingAhead { isAnnotation })
+ override def isAnnotation: Boolean = super.isAnnotation || (isHole && lookingAhead { isAnnotation })
+
+ override def isCaseDefStart: Boolean = super.isCaseDefStart || (in.token == EOF)
override def isModifier: Boolean = super.isModifier || (isHole && lookingAhead { isModifier })
@@ -85,6 +93,12 @@ trait Parsers { self: Quasiquotes =>
override def isDclIntro: Boolean = super.isDclIntro || (isHole && lookingAhead { isDclIntro })
+ override def isStatSep(token: Int) = token == EOF || super.isStatSep(token)
+
+ override def expectedMsg(token: Int): String =
+ if (isHole) expectedMsgTemplate(token2string(token), "splicee")
+ else super.expectedMsg(token)
+
// $mods def foo
// $mods T
override def readAnnots(annot: => Tree): List[Tree] = in.token match {
@@ -101,34 +115,26 @@ trait Parsers { self: Quasiquotes =>
}
}
- object TermParser extends Parser
-
- object CaseParser extends Parser {
- override def wrapCode(code: String) = super.wrapCode("something match { case " + code + " }")
-
- override def unwrapTree(wrappedTree: Tree): Tree = {
- val Match(_, head :: tail) = super.unwrapTree(wrappedTree)
- if (tail.nonEmpty)
- c.abort(c.macroApplication.pos, "Can't parse more than one casedef, consider generating a match tree instead")
- head
+ object TermParser extends Parser {
+ def entryPoint = _.templateStats() match {
+ case Nil => EmptyTree
+ case tree :: Nil => tree
+ case stats :+ tree => Block(stats, tree)
}
}
- object PatternParser extends Parser {
- override def wrapCode(code: String) = super.wrapCode("something match { case " + code + " => }")
-
- override def unwrapTree(wrappedTree: Tree): Tree = {
- val Match(_, List(CaseDef(pat, _, _))) = super.unwrapTree(wrappedTree)
- pat
- }
+ object TypeParser extends Parser {
+ def entryPoint = _.typ()
}
- object TypeParser extends Parser {
- override def wrapCode(code: String) = super.wrapCode("type T = " + code)
+ object CaseParser extends Parser {
+ def entryPoint = _.caseClause()
+ }
- override def unwrapTree(wrappedTree: Tree): Tree = {
- val TypeDef(_, _, _, rhs) = super.unwrapTree(wrappedTree)
- rhs
+ object PatternParser extends Parser {
+ def entryPoint = { parser =>
+ val pat = parser.noSeq.pattern1()
+ parser.treeBuilder.patvarTransformer.transform(pat)
}
}
} \ No newline at end of file
diff --git a/src/compiler/scala/tools/reflect/quasiquotes/Placeholders.scala b/src/compiler/scala/tools/reflect/quasiquotes/Placeholders.scala
index b680c25f76..b3ac1e293a 100644
--- a/src/compiler/scala/tools/reflect/quasiquotes/Placeholders.scala
+++ b/src/compiler/scala/tools/reflect/quasiquotes/Placeholders.scala
@@ -17,18 +17,31 @@ trait Placeholders { self: Quasiquotes =>
// Step 1: Transform Scala source with holes into vanilla Scala source
lazy val holeMap = new HoleMap()
+ lazy val posMap = mutable.ListMap[Position, (Int, Int)]()
lazy val code = {
val sb = new StringBuilder()
val sessionSuffix = randomUUID().toString.replace("-", "").substring(0, 8) + "$"
- foreach2(args, parts.init) { (tree, p) =>
- val (part, cardinality) = parseDots(p)
+ def appendPart(value: String, pos: Position) = {
+ val start = sb.length
+ sb.append(value)
+ val end = sb.length
+ posMap += pos -> (start, end)
+ }
+
+ def appendHole(tree: Tree, cardinality: Cardinality) = {
val placeholderName = c.freshName(TermName(nme.QUASIQUOTE_PREFIX + sessionSuffix))
- sb.append(part)
sb.append(placeholderName)
holeMap(placeholderName) = Hole(tree, cardinality)
}
- sb.append(parts.last)
+
+ foreach2(args, parts.init) { case (tree, (p, pos)) =>
+ val (part, cardinality) = parseDots(p)
+ appendPart(part, pos)
+ appendHole(tree, cardinality)
+ }
+ val (p, pos) = parts.last
+ appendPart(p, pos)
sb.toString
}
diff --git a/src/compiler/scala/tools/reflect/quasiquotes/Quasiquotes.scala b/src/compiler/scala/tools/reflect/quasiquotes/Quasiquotes.scala
index fe954e0bfd..ee99a5e280 100644
--- a/src/compiler/scala/tools/reflect/quasiquotes/Quasiquotes.scala
+++ b/src/compiler/scala/tools/reflect/quasiquotes/Quasiquotes.scala
@@ -17,7 +17,7 @@ abstract class Quasiquotes extends Parsers
lazy val (universe: Tree, args, parts, parse, reify) = c.macroApplication match {
case Apply(Select(Select(Apply(Select(universe0, _), List(Apply(_, parts0))), interpolator0), method0), args0) =>
val parts1 = parts0.map {
- case Literal(Constant(s: String)) => s
+ case lit @ Literal(Constant(s: String)) => s -> lit.pos
case part => c.abort(part.pos, "Quasiquotes can only be used with literal strings")
}
val reify0 = method0 match {
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/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/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 3e28d4e4ad..8189446162 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
@@ -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/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 1d41095fce..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))
}
@@ -490,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 {
@@ -770,7 +763,7 @@ trait DirectRunner {
import PartestDefaults.{ numThreads, waitTime }
setUncaughtHandler
-
+
def runTestsForFiles(kindFiles: List[File], kind: String): List[TestState] = {
NestUI.resetTestNumber(kindFiles.size)
@@ -866,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
@@ -878,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/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 df1ba1e2ea..02bee5e369 100644
--- a/src/reflect/scala/reflect/internal/Trees.scala
+++ b/src/reflect/scala/reflect/internal/Trees.scala
@@ -1017,14 +1017,16 @@ trait Trees extends api.Trees { self: SymbolTable =>
trait CannotHaveAttrs extends Tree {
override def canHaveAttrs = false
- private def unsupported(what: String, args: Any*) =
- throw new UnsupportedOperationException(s"$what($args) inapplicable for "+self.toString)
+ private def requireLegal(value: Any, allowed: Any, what: String) =
+ require(value == allowed, s"can't set $what for $self to value other than $allowed")
super.setPos(NoPosition)
- override def setPos(pos: Position) = unsupported("setPos", pos)
+ override def setPos(pos: Position) = { requireLegal(pos, NoPosition, "pos"); this }
+ override def pos_=(pos: Position) = setPos(pos)
super.setType(NoType)
- override def tpe_=(t: Type) = if (t != NoType) unsupported("tpe_=", t)
+ override def setType(t: Type) = { requireLegal(t, NoType, "tpe"); this }
+ override def tpe_=(t: Type) = setType(t)
}
case object EmptyTree extends TermTree with CannotHaveAttrs { override def isEmpty = true; val asList = List(this) }
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/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/macros/Context.scala b/src/reflect/scala/reflect/macros/Context.scala
index 434b7c1b9c..b0c816f4ad 100644
--- a/src/reflect/scala/reflect/macros/Context.scala
+++ b/src/reflect/scala/reflect/macros/Context.scala
@@ -37,8 +37,7 @@ trait Context extends Aliases
with Typers
with Parsers
with Evals
- with ExprUtils
- with Synthetics {
+ with ExprUtils {
/** The compile-time universe. */
val universe: Universe
diff --git a/src/reflect/scala/reflect/macros/Synthetics.scala b/src/reflect/scala/reflect/macros/Synthetics.scala
deleted file mode 100644
index 5e422ee89f..0000000000
--- a/src/reflect/scala/reflect/macros/Synthetics.scala
+++ /dev/null
@@ -1,107 +0,0 @@
-package scala
-package reflect
-package macros
-
-/**
- * <span class="badge badge-red" style="float: right;">EXPERIMENTAL</span>
- *
- * A slice of [[scala.reflect.macros.Context the Scala macros context]] that
- * exposes functions to introduce synthetic definitions.
- *
- * @define TOPLEVEL_TREE Top-level tree is a tree that represents a non-inner class or object in one of the currently compiled source files.
- * Note that top-level isn't equivalent to [[scala.reflect.api.Symbols#SymbolApi.isStatic]],
- * because static also embraces definitions nested in static objects
- *
- * @define INTRODUCE_TOP_LEVEL Allowed definitions include classes (represented by `ClassDef` trees), traits (represented
- * by `ClassDef` trees having the `TRAIT` flag set in `mods`) and objects (represented by `ModuleDef` trees).
- *
- * The definitions are put into the package with a prototype provided in `packagePrototype`.
- * Supported prototypes are (see [[PackageSpec]] for more details):
- * * Strings and names representing a fully-qualified name of the package
- * * Trees that can work as package ids
- * * Package or package class symbols
- *
- * Typical value for a package prototype is a fully-qualified name in a string.
- * For example, to generate a class available at `foo.bar.Test`, call this method as follows:
- *
- * introduceTopLevel("foo.bar", ClassDef(<mods>, TypeName("Test"), <tparams>, <template>))
- *
- * It is possible to add definitions to the empty package by using `nme.EMPTY_PACKAGE_NAME.toString`, but
- * that's not recommended, since such definitions cannot be seen from outside the empty package.
- *
- * Only the multi-parameter overload of this method can be used to introduce companions.
- * If companions are introduced by two different calls, then they will be put into different virtual files, and `scalac`
- * will show an error about companions being defined in different files. By the way, this also means that there's currently no way
- * to define a companion for an existing class or module
- */
-trait Synthetics {
- self: Context =>
-
- import universe._
-
- /** Looks up a top-level definition tree with a given fully-qualified name
- * (term name for modules, type name for classes). $TOPLEVEL_TREE.
- * If such a tree does not exist, returns `EmptyTree`.
- */
- def topLevelDef(name: Name): Tree
-
- /** Returns a reference to a top-level definition tree with a given fully-qualified name
- * (term name for modules, type name for classes). $TOPLEVEL_TREE.
- * If such a tree does not exist, returns `EmptyTree`.
- */
- def topLevelRef(name: Name): Tree
-
- /** Adds a top-level definition to the compiler's symbol table. $INTRODUCE_TOP_LEVEL.
- *
- * Returns a fully-qualified reference to the introduced definition.
- */
- def introduceTopLevel[T: PackageSpec](packagePrototype: T, definition: ImplDef): RefTree
-
- /** Adds a list of top-level definitions to the compiler's symbol table. $INTRODUCE_TOP_LEVEL.
- *
- * Returns a list of fully-qualified references to the introduced definitions.
- */
- def introduceTopLevel[T: PackageSpec](packagePrototype: T, definitions: ImplDef*): List[RefTree]
-
- /** A factory which can create a package def from a prototype and a list of declarations.
- */
- trait PackageSpec[T] { def mkPackageDef(prototype: T, stats: List[Tree]): PackageDef }
-
- /** Hosts supported package specs.
- */
- object PackageSpec {
- /** Package def can be created from a fully-qualified name and a list of definitions.
- * The name is converted into an Ident or a chain of Selects.
- */
- implicit val stringIsPackageSpec = new PackageSpec[String] {
- def mkPackageDef(prototype: String, stats: List[Tree]): PackageDef = self.mkPackageDef(prototype, stats)
- }
-
- /** Package def can be created from a fully-qualified term name and a list of definitions.
- * The name is converted into an Ident or a chain of Selects.
- */
- implicit val termNameIsPackageSpec = new PackageSpec[TermName] {
- def mkPackageDef(prototype: TermName, stats: List[Tree]): PackageDef = self.mkPackageDef(prototype, stats)
- }
-
- /** Package def can be created from a package id tree and a list of definitions.
- * If the tree is not a valid package id, i.e. is not a term-name ident or a chain of term-name selects,
- * then the produced PackageDef will fail compilation at some point in the future.
- */
- implicit val refTreeIsPackageSpec = new PackageSpec[RefTree] {
- def mkPackageDef(prototype: RefTree, stats: List[Tree]): PackageDef = self.mkPackageDef(prototype, stats)
- }
-
- /** Package def can be created from a package/package class symbol and a list of definitions.
- * If the provided symbol is not a package symbol or a package class symbol, package construction will throw an exception.
- */
- implicit val SymbolIsPackageSpec = new PackageSpec[Symbol] {
- def mkPackageDef(prototype: Symbol, stats: List[Tree]): PackageDef = self.mkPackageDef(prototype, stats)
- }
- }
-
- protected def mkPackageDef(name: String, stats: List[Tree]): PackageDef
- protected def mkPackageDef(name: TermName, stats: List[Tree]): PackageDef
- protected def mkPackageDef(tree: RefTree, stats: List[Tree]): PackageDef
- protected def mkPackageDef(sym: Symbol, stats: List[Tree]): PackageDef
-}
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/repl/scala/tools/nsc/interpreter/ExprTyper.scala b/src/repl/scala/tools/nsc/interpreter/ExprTyper.scala
index 9353215e1e..6406dacc24 100644
--- a/src/repl/scala/tools/nsc/interpreter/ExprTyper.scala
+++ b/src/repl/scala/tools/nsc/interpreter/ExprTyper.scala
@@ -16,32 +16,6 @@ trait ExprTyper {
import syntaxAnalyzer.UnitParser
import naming.freshInternalVarName
- object codeParser {
- val global: repl.global.type = repl.global
- def applyRule[T](code: String, rule: UnitParser => T): T = {
- reporter.reset()
- val scanner = newUnitParser(code)
- val result = rule(scanner)
-
- if (!reporter.hasErrors)
- scanner.accept(EOF)
-
- result
- }
- def stmts(code: String) = applyRule(code, _.templateStats())
- }
-
- /** Parse a line into a sequence of trees. Returns None if the input is incomplete. */
- def parse(line: String): Option[List[Tree]] = debugging(s"""parse("$line")""") {
- var isIncomplete = false
- reporter.withIncompleteHandler((_, _) => isIncomplete = true) {
- val trees = codeParser.stmts(line)
- if (reporter.hasErrors) Some(Nil)
- else if (isIncomplete) None
- else Some(trees)
- }
- }
-
def symbolOfLine(code: String): Symbol = {
def asExpr(): Symbol = {
val name = freshInternalVarName()
diff --git a/src/repl/scala/tools/nsc/interpreter/IMain.scala b/src/repl/scala/tools/nsc/interpreter/IMain.scala
index 3a71930383..ae318697ec 100644
--- a/src/repl/scala/tools/nsc/interpreter/IMain.scala
+++ b/src/repl/scala/tools/nsc/interpreter/IMain.scala
@@ -7,30 +7,23 @@ package scala
package tools.nsc
package interpreter
-import Predef.{ println => _, _ }
-import util.stringFromWriter
-import scala.reflect.internal.util._
-import java.net.URL
-import scala.sys.BooleanProp
-import scala.tools.nsc.io.AbstractFile
-import reporters._
+import scala.language.implicitConversions
+
+import scala.collection.mutable
+
+import scala.concurrent.{ Future, ExecutionContext }
+
+import scala.reflect.runtime.{ universe => ru }
+import scala.reflect.{ BeanProperty, ClassTag, classTag }
+import scala.reflect.internal.util.{ BatchSourceFile, SourceFile }
+
import scala.tools.util.PathResolver
-import scala.tools.nsc.util.ScalaClassLoader
+import scala.tools.nsc.io.AbstractFile
import scala.tools.nsc.typechecker.{ TypeStrings, StructuredTypeStrings }
-import ScalaClassLoader.URLClassLoader
+import scala.tools.nsc.util.{ ScalaClassLoader, stringFromWriter }
import scala.tools.nsc.util.Exceptional.unwrap
-import scala.collection.{ mutable, immutable }
-import scala.reflect.BeanProperty
-import scala.util.Properties.versionString
+
import javax.script.{AbstractScriptEngine, Bindings, ScriptContext, ScriptEngine, ScriptEngineFactory, ScriptException, CompiledScript, Compilable}
-import java.io.{ StringWriter, Reader }
-import java.util.Arrays
-import IMain._
-import java.util.concurrent.Future
-import scala.reflect.runtime.{ universe => ru }
-import scala.reflect.{ ClassTag, classTag }
-import StdReplTags._
-import scala.language.implicitConversions
/** An interpreter for Scala code.
*
@@ -92,7 +85,7 @@ class IMain(@BeanProperty val factory: ScriptEngineFactory, initialSettings: Set
private var _classLoader: util.AbstractFileClassLoader = null // active classloader
private val _compiler: ReplGlobal = newCompiler(settings, reporter) // our private compiler
- def compilerClasspath: Seq[URL] = (
+ def compilerClasspath: Seq[java.net.URL] = (
if (isInitializeComplete) global.classPath.asURLs
else new PathResolver(settings).result.asURLs // the compiler's classpath
)
@@ -142,10 +135,8 @@ class IMain(@BeanProperty val factory: ScriptEngineFactory, initialSettings: Set
def initialize(postInitSignal: => Unit) {
synchronized {
if (_isInitialized == null) {
- _isInitialized = io.spawn {
- try _initialize()
- finally postInitSignal
- }
+ _isInitialized =
+ Future(try _initialize() finally postInitSignal)(ExecutionContext.global)
}
}
}
@@ -241,7 +232,7 @@ class IMain(@BeanProperty val factory: ScriptEngineFactory, initialSettings: Set
lazy val isettings = new ISettings(this)
/** Instantiate a compiler. Overridable. */
- protected def newCompiler(settings: Settings, reporter: Reporter): ReplGlobal = {
+ protected def newCompiler(settings: Settings, reporter: reporters.Reporter): ReplGlobal = {
settings.outputDirs setSingleOutput replOutput.dir
settings.exposeEmptyPackage.value = true
new Global(settings, reporter) with ReplGlobal { override def toString: String = "<global>" }
@@ -334,7 +325,7 @@ class IMain(@BeanProperty val factory: ScriptEngineFactory, initialSettings: Set
private def makeClassLoader(): util.AbstractFileClassLoader =
new TranslatingClassLoader(parentClassLoader match {
case null => ScalaClassLoader fromURLs compilerClasspath
- case p => new URLClassLoader(compilerClasspath, p)
+ case p => new ScalaClassLoader.URLClassLoader(compilerClasspath, p)
})
// Set the current Java "context" class loader to this interpreter's class loader
@@ -446,9 +437,9 @@ class IMain(@BeanProperty val factory: ScriptEngineFactory, initialSettings: Set
private def requestFromLine(line: String, synthetic: Boolean): Either[IR.Result, Request] = {
val content = indentCode(line)
val trees = parse(content) match {
- case None => return Left(IR.Incomplete)
- case Some(Nil) => return Left(IR.Error) // parse error or empty input
- case Some(trees) => trees
+ case parse.Incomplete => return Left(IR.Incomplete)
+ case parse.Error => return Left(IR.Error)
+ case parse.Success(trees) => trees
}
repltrace(
trees map (t => {
@@ -466,7 +457,8 @@ class IMain(@BeanProperty val factory: ScriptEngineFactory, initialSettings: Set
// If the last tree is a bare expression, pinpoint where it begins using the
// AST node position and snap the line off there. Rewrite the code embodied
// by the last tree as a ValDef instead, so we can access the value.
- trees.last match {
+ val last = trees.lastOption.getOrElse(EmptyTree)
+ last match {
case _:Assign => // we don't want to include assignments
case _:TermTree | _:Ident | _:Select => // ... but do want other unnamed terms.
val varName = if (synthetic) freshInternalVarName() else freshUserVarName()
@@ -478,7 +470,7 @@ class IMain(@BeanProperty val factory: ScriptEngineFactory, initialSettings: Set
if (trees.size == 1) "val " + varName + " =\n" + content
else {
// The position of the last tree
- val lastpos0 = earliestPosition(trees.last)
+ val lastpos0 = earliestPosition(last)
// Oh boy, the parser throws away parens so "(2+2)" is mispositioned,
// with increasingly hard to decipher positions as we move on to "() => 5",
// (x: Int) => x + 1, and more. So I abandon attempts to finesse and just
@@ -554,7 +546,7 @@ class IMain(@BeanProperty val factory: ScriptEngineFactory, initialSettings: Set
var code = ""
var bound = false
- @throws(classOf[ScriptException])
+ @throws[ScriptException]
def compile(script: String): CompiledScript = {
if (!bound) {
quietBind("engine" -> this.asInstanceOf[ScriptEngine])
@@ -582,9 +574,9 @@ class IMain(@BeanProperty val factory: ScriptEngineFactory, initialSettings: Set
}
}
- @throws(classOf[ScriptException])
- def compile(reader: Reader): CompiledScript = {
- val writer = new StringWriter()
+ @throws[ScriptException]
+ def compile(reader: java.io.Reader): CompiledScript = {
+ val writer = new java.io.StringWriter()
var c = reader.read()
while(c != -1) {
writer.write(c)
@@ -604,7 +596,7 @@ class IMain(@BeanProperty val factory: ScriptEngineFactory, initialSettings: Set
* escape. We could have wrapped runtime exceptions just like other
* exceptions in ScriptException, this is a choice.
*/
- @throws(classOf[ScriptException])
+ @throws[ScriptException]
def eval(context: ScriptContext): Object = {
val result = req.lineRep.evalEither match {
case Left(e: RuntimeException) => throw e
@@ -737,7 +729,7 @@ class IMain(@BeanProperty val factory: ScriptEngineFactory, initialSettings: Set
val unwrapped = unwrap(t)
withLastExceptionLock[String]({
- directBind[Throwable]("lastException", unwrapped)(tagOfThrowable, classTag[Throwable])
+ directBind[Throwable]("lastException", unwrapped)(StdReplTags.tagOfThrowable, classTag[Throwable])
util.stackTraceString(unwrapped)
}, util.stackTraceString(unwrapped))
}
@@ -838,6 +830,8 @@ class IMain(@BeanProperty val factory: ScriptEngineFactory, initialSettings: Set
def imports = importedSymbols
def value = Some(handlers.last) filter (h => h.definesValue) map (h => definedSymbols(h.definesTerm.get)) getOrElse NoSymbol
+ val printResults = IMain.this.printResults
+
val lineRep = new ReadEvalPrint()
private var _originalLine: String = null
@@ -871,7 +865,7 @@ class IMain(@BeanProperty val factory: ScriptEngineFactory, initialSettings: Set
def fullPath(vname: String) = s"${lineRep.readPath}$accessPath.`$vname`"
/** generate the source code for the object that computes this request */
- private object ObjectSourceCode extends CodeAssembler[MemberHandler] {
+ private object ObjectSourceCode extends IMain.CodeAssembler[MemberHandler] {
def path = originalPath("$intp")
def envLines = {
if (!isReplPower) Nil // power mode only for now
@@ -894,7 +888,7 @@ class IMain(@BeanProperty val factory: ScriptEngineFactory, initialSettings: Set
val generate = (m: MemberHandler) => m extraCodeToEvaluate Request.this
}
- private object ResultObjectSourceCode extends CodeAssembler[MemberHandler] {
+ private object ResultObjectSourceCode extends IMain.CodeAssembler[MemberHandler] {
/** We only want to generate this code when the result
* is a value which can be referred to as-is.
*/
@@ -993,11 +987,11 @@ class IMain(@BeanProperty val factory: ScriptEngineFactory, initialSettings: Set
}
}
- @throws(classOf[ScriptException])
+ @throws[ScriptException]
def eval(script: String, context: ScriptContext): Object = compile(script).eval(context)
- @throws(classOf[ScriptException])
- def eval(reader: Reader, context: ScriptContext): Object = compile(reader).eval(context)
+ @throws[ScriptException]
+ def eval(reader: java.io.Reader, context: ScriptContext): Object = compile(reader).eval(context)
override def finalize = close
@@ -1096,7 +1090,24 @@ class IMain(@BeanProperty val factory: ScriptEngineFactory, initialSettings: Set
val repl: IMain.this.type = imain
} with ExprTyper { }
- def parse(line: String): Option[List[Tree]] = exprTyper.parse(line)
+ /** Parse a line into and return parsing result (error, incomplete or success with list of trees) */
+ object parse {
+ abstract sealed class Result
+ case object Error extends Result
+ case object Incomplete extends Result
+ case class Success(trees: List[Tree]) extends Result
+
+ def apply(line: String): Result = debugging(s"""parse("$line")""") {
+ var isIncomplete = false
+ reporter.withIncompleteHandler((_, _) => isIncomplete = true) {
+ reporter.reset()
+ val trees = newUnitParser(line).parseStats()
+ if (reporter.hasErrors) Error
+ else if (isIncomplete) Incomplete
+ else Success(trees)
+ }
+ }
+ }
def symbolOfLine(code: String): Symbol =
exprTyper.symbolOfLine(code)
@@ -1155,10 +1166,12 @@ class IMain(@BeanProperty val factory: ScriptEngineFactory, initialSettings: Set
*/
def isShow = code.lines exists (_.trim endsWith "// show")
if (isReplDebug || isShow) {
- beSilentDuring(parse(code)) foreach { ts =>
- ts foreach { t =>
- withoutUnwrapping(echo(asCompactString(t)))
- }
+ beSilentDuring(parse(code)) match {
+ case parse.Success(ts) =>
+ ts foreach { t =>
+ withoutUnwrapping(echo(asCompactString(t)))
+ }
+ case _ =>
}
}
}
@@ -1172,6 +1185,8 @@ class IMain(@BeanProperty val factory: ScriptEngineFactory, initialSettings: Set
/** Utility methods for the Interpreter. */
object IMain {
+ import java.util.Arrays.{ asList => asJavaList }
+
class Factory extends ScriptEngineFactory {
@BeanProperty
val engineName = "Scala Interpreter"
@@ -1180,21 +1195,21 @@ object IMain {
val engineVersion = "1.0"
@BeanProperty
- val extensions: JList[String] = Arrays.asList("scala")
+ val extensions: JList[String] = asJavaList("scala")
@BeanProperty
val languageName = "Scala"
@BeanProperty
- val languageVersion = versionString
+ val languageVersion = scala.util.Properties.versionString
def getMethodCallSyntax(obj: String, m: String, args: String*): String = null
@BeanProperty
- val mimeTypes: JList[String] = Arrays.asList("application/x-scala")
+ val mimeTypes: JList[String] = asJavaList("application/x-scala")
@BeanProperty
- val names: JList[String] = Arrays.asList("scala")
+ val names: JList[String] = asJavaList("scala")
def getOutputStatement(toDisplay: String): String = null
diff --git a/src/repl/scala/tools/nsc/interpreter/JLineCompletion.scala b/src/repl/scala/tools/nsc/interpreter/JLineCompletion.scala
index 8b8b668c9f..61db8d1748 100644
--- a/src/repl/scala/tools/nsc/interpreter/JLineCompletion.scala
+++ b/src/repl/scala/tools/nsc/interpreter/JLineCompletion.scala
@@ -190,10 +190,10 @@ class JLineCompletion(val intp: IMain) extends Completion with CompletionOutput
// literal Ints, Strings, etc.
object literals extends CompletionAware {
- def simpleParse(code: String): Tree = newUnitParser(code).templateStats().last
+ def simpleParse(code: String): Option[Tree] = newUnitParser(code).parseStats().lastOption
def completions(verbosity: Int) = Nil
- override def follow(id: String) = simpleParse(id) match {
+ override def follow(id: String) = simpleParse(id).flatMap {
case x: Literal => Some(new LiteralCompletion(x))
case _ => None
}
diff --git a/src/repl/scala/tools/nsc/interpreter/MemberHandlers.scala b/src/repl/scala/tools/nsc/interpreter/MemberHandlers.scala
index c6f0cca481..085a7c6065 100644
--- a/src/repl/scala/tools/nsc/interpreter/MemberHandlers.scala
+++ b/src/repl/scala/tools/nsc/interpreter/MemberHandlers.scala
@@ -107,7 +107,7 @@ trait MemberHandlers {
override def resultExtractionCode(req: Request): String = {
val isInternal = isUserVarName(name) && req.lookupTypeOf(name) == "Unit"
- if (!mods.isPublic || isInternal) ""
+ if (!mods.isPublic || isInternal || !req.printResults) ""
else {
// if this is a lazy val we avoid evaluating it here
val resultString =
@@ -151,11 +151,11 @@ trait MemberHandlers {
"""val %s = %s""".format(name, lhs)
/** Print out lhs instead of the generated varName */
- override def resultExtractionCode(req: Request) = {
+ override def resultExtractionCode(req: Request) = if (req.printResults) {
val lhsType = string2code(req lookupTypeOf name)
val res = string2code(req fullPath name)
""" + "%s: %s = " + %s + "\n" """.format(string2code(lhs.toString), lhsType, res) + "\n"
- }
+ } else ""
}
class ModuleHandler(module: ModuleDef) extends MemberDefHandler(module) {
diff --git a/src/repl/scala/tools/nsc/interpreter/Power.scala b/src/repl/scala/tools/nsc/interpreter/Power.scala
index da6d271a68..f69a5b487d 100644
--- a/src/repl/scala/tools/nsc/interpreter/Power.scala
+++ b/src/repl/scala/tools/nsc/interpreter/Power.scala
@@ -316,7 +316,7 @@ class Power[ReplValsImpl <: ReplVals : ru.TypeTag: ClassTag](val intp: IMain, re
lazy val phased: Phased = new { val global: intp.global.type = intp.global } with Phased { }
def unit(code: String) = newCompilationUnit(code)
- def trees(code: String) = parse(code) getOrElse Nil
+ def trees(code: String) = parse(code) match { case parse.Success(trees) => trees; case _ => Nil }
override def toString = s"""
|** Power mode status **
diff --git a/src/repl/scala/tools/nsc/interpreter/Results.scala b/src/repl/scala/tools/nsc/interpreter/Results.scala
index e400906a58..a4e1e25cbb 100644
--- a/src/repl/scala/tools/nsc/interpreter/Results.scala
+++ b/src/repl/scala/tools/nsc/interpreter/Results.scala
@@ -19,4 +19,4 @@ object Results {
/** The input was incomplete. The caller should request more input.
*/
case object Incomplete extends Result
-}
+} \ No newline at end of file
diff --git a/src/repl/scala/tools/nsc/interpreter/package.scala b/src/repl/scala/tools/nsc/interpreter/package.scala
index f82c38f5e7..5dc9b65436 100644
--- a/src/repl/scala/tools/nsc/interpreter/package.scala
+++ b/src/repl/scala/tools/nsc/interpreter/package.scala
@@ -145,8 +145,8 @@ package object interpreter extends ReplConfig with ReplStrings {
case sym: TypeSymbol => Some(sym)
case _ => None
}
- (typeFromTypeString orElse typeFromNameTreatedAsTerm orElse typeFromFullName orElse typeOfTerm) foreach { sym =>
- val (kind, tpe) = exitingTyper {
+ (typeFromTypeString orElse typeFromNameTreatedAsTerm orElse typeFromFullName orElse typeOfTerm) foreach { sym =>
+ val (kind, tpe) = exitingTyper {
val tpe = sym.tpeHK
(intp.global.inferKind(NoPrefix)(tpe, sym.owner), tpe)
}
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/quasiquotes-syntax-error-position.check b/test/files/neg/quasiquotes-syntax-error-position.check
new file mode 100644
index 0000000000..3bd813b1bb
--- /dev/null
+++ b/test/files/neg/quasiquotes-syntax-error-position.check
@@ -0,0 +1,32 @@
+quasiquotes-syntax-error-position.scala:5: error: '=' expected but identifier found.
+ q"def $a f"
+ ^
+quasiquotes-syntax-error-position.scala:6: error: illegal start of simple expression
+ q"$a("
+ ^
+quasiquotes-syntax-error-position.scala:7: error: '}' expected but end of quote found.
+ q"class $t { def foo = $a"
+ ^
+quasiquotes-syntax-error-position.scala:8: error: '.' expected but splicee found.
+ q"import $t $t"
+ ^
+quasiquotes-syntax-error-position.scala:9: error: illegal start of definition
+ q"package p"
+ ^
+quasiquotes-syntax-error-position.scala:10: error: ';' expected but '@' found.
+ q"foo@$a"
+ ^
+quasiquotes-syntax-error-position.scala:11: error: case classes without a parameter list are not allowed;
+use either case objects or case classes with an explicit `()' as a parameter list.
+ q"case class A"
+ ^
+quasiquotes-syntax-error-position.scala:12: error: identifier expected but ']' found.
+ tq"$t => $t $t]"
+ ^
+quasiquotes-syntax-error-position.scala:13: error: end of quote expected but 'case' found.
+ cq"pattern => body ; case pattern2 =>"
+ ^
+quasiquotes-syntax-error-position.scala:14: error: ')' expected but end of quote found.
+ pq"$a(bar"
+ ^
+10 errors found
diff --git a/test/files/neg/quasiquotes-syntax-error-position.scala b/test/files/neg/quasiquotes-syntax-error-position.scala
new file mode 100644
index 0000000000..b97af52cfc
--- /dev/null
+++ b/test/files/neg/quasiquotes-syntax-error-position.scala
@@ -0,0 +1,15 @@
+import scala.reflect.runtime.universe._
+object test extends App {
+ val a = TermName("a")
+ val t = TypeName("t")
+ q"def $a f"
+ q"$a("
+ q"class $t { def foo = $a"
+ q"import $t $t"
+ q"package p"
+ q"foo@$a"
+ q"case class A"
+ tq"$t => $t $t]"
+ cq"pattern => body ; case pattern2 =>"
+ pq"$a(bar"
+} \ No newline at end of file
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/neg/t7715.check b/test/files/neg/t7715.check
new file mode 100644
index 0000000000..4ee6b6c95d
--- /dev/null
+++ b/test/files/neg/t7715.check
@@ -0,0 +1,13 @@
+t7715.scala:8: error: error in interpolated string: identifier or block expected
+ days map s"On the $_th day of Christmas" foreach println
+ ^
+t7715.scala:10: error: error in interpolated string: identifier or block expected
+ val rf = (n: Int) => s"\\*{$_}"(n).r
+ ^
+t7715.scala:17: error: unbound placeholder parameter
+ days zip days map s"${_: Int} by ${_: Int}".tupled foreach println
+ ^
+t7715.scala:17: error: unbound placeholder parameter
+ days zip days map s"${_: Int} by ${_: Int}".tupled foreach println
+ ^
+four errors found
diff --git a/test/files/neg/t7715.scala b/test/files/neg/t7715.scala
new file mode 100644
index 0000000000..637ab8df6d
--- /dev/null
+++ b/test/files/neg/t7715.scala
@@ -0,0 +1,18 @@
+
+import PartialFunction.cond
+import util._
+
+object Test extends App {
+ val days = (1 to 12).toList
+
+ days map s"On the $_th day of Christmas" foreach println
+
+ val rf = (n: Int) => s"\\*{$_}"(n).r
+ def stars(n: Int)(s: String) = {
+ val r = rf(n)
+ cond(s) { case r(_*) => true }
+ }
+ Console println stars(5)("*****")
+
+ days zip days map s"${_: Int} by ${_: Int}".tupled foreach println
+}
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/macro-expand-unapply-b.check b/test/files/run/macro-expand-unapply-b.check
deleted file mode 100644
index 5272f0d00a..0000000000
--- a/test/files/run/macro-expand-unapply-b.check
+++ /dev/null
@@ -1,2 +0,0 @@
-(1,List(2))
-List(1)
diff --git a/test/files/run/macro-expand-unapply-b.flags b/test/files/run/macro-expand-unapply-b.flags
deleted file mode 100644
index cd66464f2f..0000000000
--- a/test/files/run/macro-expand-unapply-b.flags
+++ /dev/null
@@ -1 +0,0 @@
--language:experimental.macros \ No newline at end of file
diff --git a/test/files/run/macro-expand-unapply-b/Impls_Macros_1.scala b/test/files/run/macro-expand-unapply-b/Impls_Macros_1.scala
deleted file mode 100644
index d0300bdf7e..0000000000
--- a/test/files/run/macro-expand-unapply-b/Impls_Macros_1.scala
+++ /dev/null
@@ -1,37 +0,0 @@
-import language.experimental.macros
-import scala.reflect.macros.Context
-
-object Macros {
- implicit class ContextExtensions(c: StringContext) {
- object q {
- def unapply(x: Any): Option[Any] = macro impl
- }
- }
-
- def impl(c: Context)(x: c.Expr[Any]): c.Expr[Option[Any]] = {
- import c.universe._
- import Flag._
-
- // parts here will be string literals - static parts of the string interpolation
- // e.g. for q"$x, $y" parts will be Literal(Constant("")), Literal(Constant(", ")) and Literal(Constant(""))
- val Apply(Select(Select(Apply(_, List(Apply(_, parts))), _), _), _) = c.macroApplication
- val nresults = parts.length - 1
-
- def results() =
- ((1 to (nresults - 1)).toList map (i => Literal(Constant(i)))) :+ // (n - 1) results of type Int
- Apply(Ident(TermName("List")), List(Literal(Constant(nresults)))) // and also one result of a different type
- def extractorBody() =
- if (nresults == 0) Literal(Constant(true))
- else if (nresults == 1) Apply(Ident(TermName("Some")), results())
- else Apply(Ident(TermName("Some")), List(Apply(Ident(TermName("Tuple" + nresults)), results())))
-
- val name = TermName(java.util.UUID.randomUUID().toString.replace("-", ""))
- val mdef = ModuleDef(NoMods, name, Template(List(Select(Ident(TermName("scala")), TypeName("AnyRef"))), emptyValDef, List(
- DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(),
- Block(List(pendingSuperCall), Literal(Constant(())))),
- DefDef(Modifiers(), TermName("unapply"), List(), List(List(ValDef(Modifiers(PARAM), TermName("x"), Ident(TypeName("Any")), EmptyTree))), TypeTree(),
- extractorBody()))))
- c.introduceTopLevel(nme.EMPTY_PACKAGE_NAME.toString, mdef)
- c.Expr[Option[Any]](Apply(Select(Ident(name), TermName("unapply")), List(x.tree)))
- }
-} \ No newline at end of file
diff --git a/test/files/run/macro-expand-unapply-b/Test_2.scala b/test/files/run/macro-expand-unapply-b/Test_2.scala
deleted file mode 100644
index 5352160dfe..0000000000
--- a/test/files/run/macro-expand-unapply-b/Test_2.scala
+++ /dev/null
@@ -1,8 +0,0 @@
-object Test extends App {
- import Macros._
- def whatever() = null
- val q"$x1, $y1" = whatever()
- println(x1, y1)
- val q"$x2" = whatever()
- println(x2)
-}
diff --git a/test/files/run/macro-toplevel-companion-a.flags b/test/files/run/macro-toplevel-companion-a.flags
deleted file mode 100644
index cd66464f2f..0000000000
--- a/test/files/run/macro-toplevel-companion-a.flags
+++ /dev/null
@@ -1 +0,0 @@
--language:experimental.macros \ No newline at end of file
diff --git a/test/files/run/macro-toplevel-companion-a/Impls_Macros_1.scala b/test/files/run/macro-toplevel-companion-a/Impls_Macros_1.scala
deleted file mode 100644
index 23e8694ddc..0000000000
--- a/test/files/run/macro-toplevel-companion-a/Impls_Macros_1.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-import scala.reflect.macros.Context
-import language.experimental.macros
-
-object Macros {
- def impl(c: Context) = {
- import c.universe._
- val synthetic = reify{ class C { override def toString = "C" }; object C { implicit val c = new C } }.tree
- val defs = synthetic.asInstanceOf[Block].stats.asInstanceOf[List[ImplDef]]
- if (c.topLevelRef(TypeName("C")).isEmpty) c.introduceTopLevel(nme.EMPTY_PACKAGE_NAME.toString, defs: _*)
- c.literalUnit
- }
-
- def foo = macro impl
-} \ No newline at end of file
diff --git a/test/files/run/macro-toplevel-companion-a/Test_2.scala b/test/files/run/macro-toplevel-companion-a/Test_2.scala
deleted file mode 100644
index 78b65b5b1f..0000000000
--- a/test/files/run/macro-toplevel-companion-a/Test_2.scala
+++ /dev/null
@@ -1,8 +0,0 @@
-import Macros._
-
-object Test extends App {
- foo;
- implicitly[C];
- foo;
- implicitly[C];
-} \ No newline at end of file
diff --git a/test/files/run/macro-toplevel-companion-b.check b/test/files/run/macro-toplevel-companion-b.check
deleted file mode 100644
index bd30dc75d3..0000000000
--- a/test/files/run/macro-toplevel-companion-b.check
+++ /dev/null
@@ -1,4 +0,0 @@
-reflective compilation has failed:
-
-Companions 'class C' and 'object C' must be defined in same file:
- Found in <synthetic file name> and <synthetic file name>
diff --git a/test/files/run/macro-toplevel-companion-b.flags b/test/files/run/macro-toplevel-companion-b.flags
deleted file mode 100644
index cd66464f2f..0000000000
--- a/test/files/run/macro-toplevel-companion-b.flags
+++ /dev/null
@@ -1 +0,0 @@
--language:experimental.macros \ No newline at end of file
diff --git a/test/files/run/macro-toplevel-companion-b/Impls_Macros_1.scala b/test/files/run/macro-toplevel-companion-b/Impls_Macros_1.scala
deleted file mode 100644
index f30adc2965..0000000000
--- a/test/files/run/macro-toplevel-companion-b/Impls_Macros_1.scala
+++ /dev/null
@@ -1,15 +0,0 @@
-import scala.reflect.macros.Context
-import language.experimental.macros
-
-object Macros {
- def impl(c: Context) = {
- import c.universe._
- val Block(List(cdef: ClassDef), _) = reify{ class C }.tree
- val classRef = c.topLevelRef(TypeName("C")) orElse c.introduceTopLevel(nme.EMPTY_PACKAGE_NAME.toString, cdef)
- val Block(List(mdef: ModuleDef), _) = reify{ object C }.tree
- val moduleRef = c.topLevelRef(TermName("C")) orElse c.introduceTopLevel(nme.EMPTY_PACKAGE_NAME.toString, mdef)
- c.literalUnit
- }
-
- def foo = macro impl
-} \ No newline at end of file
diff --git a/test/files/run/macro-toplevel-companion-b/Test_2.scala b/test/files/run/macro-toplevel-companion-b/Test_2.scala
deleted file mode 100644
index 4e766bde89..0000000000
--- a/test/files/run/macro-toplevel-companion-b/Test_2.scala
+++ /dev/null
@@ -1,11 +0,0 @@
-import scala.reflect.runtime.universe._
-import scala.reflect.runtime.{universe => ru}
-import scala.reflect.runtime.{currentMirror => cm}
-import scala.tools.reflect.{ToolBox, ToolBoxError}
-import Macros._
-
-object Test extends App {
- val tb = cm.mkToolBox()
- try tb.compile(Select(Ident(TermName("Macros")), TermName("foo")))
- catch { case ToolBoxError(message, _) => println("""(Found in|and) .*?compileLateSynthetic-.*?\.scala""".r.replaceAllIn(message, m => m.group(1) + " <synthetic file name>")) }
-} \ No newline at end of file
diff --git a/test/files/run/macro-toplevel-companion-c.check b/test/files/run/macro-toplevel-companion-c.check
deleted file mode 100644
index 4052c472f8..0000000000
--- a/test/files/run/macro-toplevel-companion-c.check
+++ /dev/null
@@ -1,3 +0,0 @@
-error: Companions 'class C' and 'object C' must be defined in same file:
- Found in <synthetic file name> and newSource1.scala
-
diff --git a/test/files/run/macro-toplevel-companion-c.flags b/test/files/run/macro-toplevel-companion-c.flags
deleted file mode 100644
index cd66464f2f..0000000000
--- a/test/files/run/macro-toplevel-companion-c.flags
+++ /dev/null
@@ -1 +0,0 @@
--language:experimental.macros \ No newline at end of file
diff --git a/test/files/run/macro-toplevel-companion-c.scala b/test/files/run/macro-toplevel-companion-c.scala
deleted file mode 100644
index c315f8b942..0000000000
--- a/test/files/run/macro-toplevel-companion-c.scala
+++ /dev/null
@@ -1,51 +0,0 @@
-import scala.tools.partest._
-import java.io._
-
-object Test extends DirectTest {
- def code = ???
-
- def macros_1 = """
- package test
-
- import scala.reflect.macros.Context
- import language.experimental.macros
-
- object Macros {
- def impl(c: Context) = {
- import c.universe._
- val Block(List(cdef: ClassDef), _) = reify{ class C }.tree
- val ref = c.topLevelRef(TypeName("test.C")) orElse c.introduceTopLevel("test", cdef)
- c.literalUnit
- }
-
- def foo = macro impl
- }
- """
- def compileMacros() = {
- val classpath = List(sys.props("partest.lib"), sys.props("partest.reflect")) mkString sys.props("path.separator")
- compileString(newCompiler("-language:experimental.macros", "-cp", classpath, "-d", testOutput.path))(macros_1)
- }
-
- def test_2 = """
- package test
- object C { Macros.foo }
- """
- def compileTest() = {
- val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator")
- compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(test_2)
- }
-
- def show(): Unit = {
- // redirect err to string, for logging
- val prevErr = System.err
- val baos = new ByteArrayOutputStream()
- System.setErr(new PrintStream(baos))
- log("Compiling Macros_1...")
- if (compileMacros()) {
- log("Compiling Test_2...")
- if (compileTest()) log("Success!") else log("Failed...")
- }
- println("""(Found in|and) .*?compileLateSynthetic-.*?\.scala""".r.replaceAllIn(baos.toString, m => m.group(1) + " <synthetic file name>"))
- System.setErr(prevErr)
- }
-} \ No newline at end of file
diff --git a/test/files/run/macro-toplevel.check b/test/files/run/macro-toplevel.check
deleted file mode 100644
index 257c3764fd..0000000000
--- a/test/files/run/macro-toplevel.check
+++ /dev/null
@@ -1,2 +0,0 @@
-I've been created from Macros.foo
-I've been created from Macros.foo
diff --git a/test/files/run/macro-toplevel/Macros_1.scala b/test/files/run/macro-toplevel/Macros_1.scala
deleted file mode 100644
index f681c86735..0000000000
--- a/test/files/run/macro-toplevel/Macros_1.scala
+++ /dev/null
@@ -1,15 +0,0 @@
-import scala.reflect.macros.Context
-import language.experimental.macros
-
-object Macros {
- def impl(c: Context) = {
- import c.universe._
- val msg = "I've been created from " + c.macroApplication
- val Block(List(synthetic: ClassDef), _) = reify{ class SomeUniqueName { def hello = c.literal(msg).splice } }.tree
- val ref = c.topLevelRef(synthetic.name) orElse c.introduceTopLevel(nme.EMPTY_PACKAGE_NAME.toString, synthetic)
- c.Expr[String](Select(Apply(Select(New(ref), nme.CONSTRUCTOR), List()), TermName("hello")))
- }
-
- def foo = macro impl
- def foo2 = macro impl
-}
diff --git a/test/files/run/macro-toplevel/Test_2.scala b/test/files/run/macro-toplevel/Test_2.scala
deleted file mode 100644
index eee2d6ae13..0000000000
--- a/test/files/run/macro-toplevel/Test_2.scala
+++ /dev/null
@@ -1,6 +0,0 @@
-import Macros._
-
-object Test extends App {
- println(Macros.foo)
- println(Macros.foo2)
-} \ No newline at end of file
diff --git a/test/files/run/repl-javap-outdir-funs/run-repl_7.scala b/test/files/run/repl-javap-outdir-funs/run-repl_7.scala
index dfe3dae270..6c6fe2d515 100644
--- a/test/files/run/repl-javap-outdir-funs/run-repl_7.scala
+++ b/test/files/run/repl-javap-outdir-funs/run-repl_7.scala
@@ -5,8 +5,13 @@ object Test extends JavapTest {
|:javap -fun disktest/Foo.class
""".stripMargin
- override def yah(res: Seq[String]) = {
- def filtered = res filter (_ contains "public final class disktest.Foo")
- 1 == filtered.size
- }
+ override def yah(res: Seq[String]) =
+ // It's currently unknown why this test fails on Avian with
+ // “Failed: No anonfuns found.”, skip it for now. See SI-7630.
+ if (scala.tools.partest.utils.Properties.isAvian)
+ true
+ else {
+ def filtered = res filter (_ contains "public final class disktest.Foo")
+ 1 == filtered.size
+ }
}
diff --git a/test/files/run/t5923a/Macros_1.scala b/test/files/run/t5923a/Macros_1.scala
index 6d21362c4d..97076eb102 100644
--- a/test/files/run/t5923a/Macros_1.scala
+++ b/test/files/run/t5923a/Macros_1.scala
@@ -7,8 +7,46 @@ object C {
}
object Macros {
- def impl[T: c.WeakTypeTag](c: Context) = {
+ def impl[T](c: Context)(ttag: c.WeakTypeTag[T]) = {
import c.universe._
- reify(C[T](c.literal(weakTypeOf[T].toString).splice))
+ val ttag0 = ttag;
+ {
+ // When we're expanding implicitly[C[Nothing]], the type inferencer will see
+ // that foo[T] returns C[T] and that we request an implicit of type C[Nothing].
+ //
+ // Then the type inferencer will try to match C[T] against C[Nothing] and infer everything it can infer
+ // from that match, but not more (e.g. if we were returning Iso[T, U] and the type we were looking at was Iso[Foo, L],
+ // we wouldn't want U to be auto-inferred to Nothing, as it usually happens with normal methods,
+ // but would rather want it to remain unknown, so that our macro could take a stab at inferring it:
+ // see the comments in this commit for more information).
+ //
+ // Equipped with common sense, in our case of C[T] and C[Nothing] we would expect T to be inferred as Nothing, and then we
+ // would expect T in the corresponding macro invocation to be Nothing. Unfortunately it is not that simple.
+ //
+ // Internally the type inferencer uses Nothing as a dummy value, which stands for "don't know how to
+ // infer this type parameter". In the Iso example, matching Iso[T, U] against Iso[Foo, L] would result in
+ // T being inferred as Foo and U being inferred as Nothing (!!). Then the type inferencer will think:
+ // "Aha! U ended up being Nothing. This means that I failed to infer it,
+ // therefore the result of my work is: T -> Foo, U -> still unknown".
+ //
+ // That's all very good and works very well until Nothing is a genuine result of type inference,
+ // as in our original example of inferring T in C[T] from C[Nothing]. In that case, the inferencer becomes confused
+ // and here in the macro implementation we get weakTypeOf[T] equal to some dummy type carrying a type parameter
+ // instead of Nothing.
+ //
+ // This eccentric behavior of the type inferencer is a long-standing problem in scalac,
+ // so the best one can do for now until it's fixed is to work around, manually converting
+ // suspicious T's into Nothings. Of course, this means that we would have to approximate,
+ // because there's no way to know whether having T here stands for a failed attempt to infer Nothing
+ // or for a failed attempt to infer anything, but at least we're in full control of making the best
+ // of this sad situation.
+ implicit def ttag: WeakTypeTag[T] = {
+ val tpe = ttag0.tpe
+ val sym = tpe.typeSymbol.asType
+ if (sym.isParameter && !sym.isSkolem) TypeTag.Nothing.asInstanceOf[TypeTag[T]]
+ else ttag0
+ }
+ reify(C[T](c.literal(weakTypeOf[T].toString).splice))
+ }
}
} \ No newline at end of file
diff --git a/test/files/run/t5923c.check b/test/files/run/t5923c.check
new file mode 100644
index 0000000000..bed7429108
--- /dev/null
+++ b/test/files/run/t5923c.check
@@ -0,0 +1 @@
+(23,foo,true)
diff --git a/test/files/run/t5923c/Macros_1.scala b/test/files/run/t5923c/Macros_1.scala
new file mode 100644
index 0000000000..0b7a3399e2
--- /dev/null
+++ b/test/files/run/t5923c/Macros_1.scala
@@ -0,0 +1,39 @@
+import language.experimental.macros
+import scala.reflect.macros.Context
+
+trait Iso[T, U] {
+ def to(t : T) : U
+ // def from(u : U) : T
+}
+
+object Iso {
+ implicit def materializeIso[T, U]: Iso[T, U] = macro impl[T, U]
+ def impl[T: c.WeakTypeTag, U: c.WeakTypeTag](c: Context): c.Expr[Iso[T, U]] = {
+ import c.universe._
+ import definitions._
+ import Flag._
+
+ val sym = c.weakTypeOf[T].typeSymbol
+ if (!sym.isClass || !sym.asClass.isCaseClass) c.abort(c.enclosingPosition, s"$sym is not a case class")
+ val fields = sym.typeSignature.declarations.toList.collect{ case x: TermSymbol if x.isVal && x.isCaseAccessor => x }
+
+ def mkTpt() = {
+ val core = Ident(TupleClass(fields.length) orElse UnitClass)
+ if (fields.length == 0) core
+ else AppliedTypeTree(core, fields map (f => TypeTree(f.typeSignature)))
+ }
+
+ def mkFrom() = {
+ if (fields.length == 0) Literal(Constant(Unit))
+ else Apply(Ident(newTermName("Tuple" + fields.length)), fields map (f => Select(Ident(newTermName("f")), newTermName(f.name.toString.trim))))
+ }
+
+ val evidenceClass = ClassDef(Modifiers(FINAL), newTypeName("$anon"), List(), Template(
+ List(AppliedTypeTree(Ident(newTypeName("Iso")), List(Ident(sym), mkTpt()))),
+ emptyValDef,
+ List(
+ DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List())), Literal(Constant(())))),
+ DefDef(Modifiers(), newTermName("to"), List(), List(List(ValDef(Modifiers(PARAM), newTermName("f"), Ident(sym), EmptyTree))), TypeTree(), mkFrom()))))
+ c.Expr[Iso[T, U]](Block(List(evidenceClass), Apply(Select(New(Ident(newTypeName("$anon"))), nme.CONSTRUCTOR), List())))
+ }
+}
diff --git a/test/files/run/t5923c/Test_2.scala b/test/files/run/t5923c/Test_2.scala
new file mode 100644
index 0000000000..a00f4ed7db
--- /dev/null
+++ b/test/files/run/t5923c/Test_2.scala
@@ -0,0 +1,12 @@
+// see the comments for macroExpandApply.onDelayed for an explanation of what's tested here
+object Test extends App {
+ case class Foo(i: Int, s: String, b: Boolean)
+ def foo[C, L](c: C)(implicit iso: Iso[C, L]): L = iso.to(c)
+
+ {
+ val equiv = foo(Foo(23, "foo", true))
+ def typed[T](t: => T) {}
+ typed[(Int, String, Boolean)](equiv)
+ println(equiv)
+ }
+} \ No newline at end of file
diff --git a/test/files/run/macro-toplevel-companion-a.check b/test/files/run/t5923d.check
index e69de29bb2..e69de29bb2 100644
--- a/test/files/run/macro-toplevel-companion-a.check
+++ b/test/files/run/t5923d.check
diff --git a/test/files/run/t5923d/Macros_1.scala b/test/files/run/t5923d/Macros_1.scala
new file mode 100644
index 0000000000..f32d1af704
--- /dev/null
+++ b/test/files/run/t5923d/Macros_1.scala
@@ -0,0 +1,9 @@
+import scala.language.experimental.macros
+import scala.reflect.macros.Context
+
+trait MappedRow
+trait RowMapper[T <: MappedRow]
+object RowMapper {
+ implicit def mapper[T <: MappedRow]: RowMapper[T] = macro impl[T]
+ def impl[T <: MappedRow : c.WeakTypeTag](c: Context) = c.universe.reify(new RowMapper[T]{})
+} \ No newline at end of file
diff --git a/test/files/run/t5923d/Test_2.scala b/test/files/run/t5923d/Test_2.scala
new file mode 100644
index 0000000000..6be10227c2
--- /dev/null
+++ b/test/files/run/t5923d/Test_2.scala
@@ -0,0 +1,7 @@
+class RowA extends MappedRow
+class RowB extends MappedRow
+
+object Test extends App {
+ implicitly[RowMapper[RowA]]
+ implicitly[RowMapper[RowB]]
+} \ No newline at end of file
diff --git a/test/files/run/t6507.check b/test/files/run/t6507.check
new file mode 100644
index 0000000000..336db0aeaf
--- /dev/null
+++ b/test/files/run/t6507.check
@@ -0,0 +1,26 @@
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala>
+
+scala> :silent
+Switched off result printing.
+
+scala> class A { override def toString() = { println("!"); "A" } }
+
+scala> val a = new A
+
+scala> var b: A = new A
+
+scala> b = new A
+
+scala> new A
+
+scala> :silent
+Switched on result printing.
+
+scala> res0
+!
+res1: A = A
+
+scala>
diff --git a/test/files/run/t6507.scala b/test/files/run/t6507.scala
new file mode 100644
index 0000000000..25f0a73e04
--- /dev/null
+++ b/test/files/run/t6507.scala
@@ -0,0 +1,14 @@
+import scala.tools.partest.ReplTest
+
+object Test extends ReplTest {
+ def code = """
+:silent
+class A { override def toString() = { println("!"); "A" } }
+val a = new A
+var b: A = new A
+b = new A
+new A
+:silent
+res0
+"""
+}
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/t7331a.check b/test/files/run/t7331a.check
new file mode 100644
index 0000000000..a59b400344
--- /dev/null
+++ b/test/files/run/t7331a.check
@@ -0,0 +1,2 @@
+source-<toolbox>,line-1,offset=0
+2 \ No newline at end of file
diff --git a/test/files/run/t7331a.scala b/test/files/run/t7331a.scala
new file mode 100644
index 0000000000..1851945e63
--- /dev/null
+++ b/test/files/run/t7331a.scala
@@ -0,0 +1,10 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
+
+object Test extends App {
+ val tb = cm.mkToolBox()
+ val tree = tb.parse("x")
+ println(tree.pos)
+ println(tree.pos.source.content.length)
+} \ No newline at end of file
diff --git a/test/files/run/t7331b.check b/test/files/run/t7331b.check
new file mode 100644
index 0000000000..7034a95a3f
--- /dev/null
+++ b/test/files/run/t7331b.check
@@ -0,0 +1,3 @@
+reflective compilation has failed:
+
+')' expected but eof found.
diff --git a/test/files/run/t7331b.scala b/test/files/run/t7331b.scala
new file mode 100644
index 0000000000..052656d11b
--- /dev/null
+++ b/test/files/run/t7331b.scala
@@ -0,0 +1,11 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.{ToolBox, ToolBoxError}
+
+object Test extends App {
+ val tb = cm.mkToolBox()
+ try tb.parse("f(x")
+ catch {
+ case ToolBoxError(msg, _) => println(msg)
+ }
+} \ No newline at end of file
diff --git a/test/files/run/t7331c.check b/test/files/run/t7331c.check
new file mode 100644
index 0000000000..fd3ac1d9ef
--- /dev/null
+++ b/test/files/run/t7331c.check
@@ -0,0 +1,3 @@
+ClassDef(Modifiers(), TypeName("C"), List(), Template(List(Select(Ident(scala), TypeName("AnyRef"))), emptyValDef, List(DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(pendingSuperCall), Literal(Constant(())))))))
+source-<toolbox>,line-1,offset=6
+NoPosition
diff --git a/test/files/run/t7331c.scala b/test/files/run/t7331c.scala
new file mode 100644
index 0000000000..75873afcd0
--- /dev/null
+++ b/test/files/run/t7331c.scala
@@ -0,0 +1,11 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
+
+object Test extends App {
+ val tb = cm.mkToolBox()
+ val tree = tb.parse("class C").asInstanceOf[ClassDef]
+ println(showRaw(tree))
+ println(tree.pos)
+ println(tree.impl.self.pos)
+} \ No newline at end of file
diff --git a/test/files/run/t7715.check b/test/files/run/t7715.check
new file mode 100644
index 0000000000..592d7fe2ea
--- /dev/null
+++ b/test/files/run/t7715.check
@@ -0,0 +1,3 @@
+6
+4
+4
diff --git a/test/files/run/t7715.scala b/test/files/run/t7715.scala
new file mode 100644
index 0000000000..0ad3913016
--- /dev/null
+++ b/test/files/run/t7715.scala
@@ -0,0 +1,24 @@
+
+import PartialFunction.cond
+import util._
+
+object Test extends App {
+
+ object I { def unapply(x: String): Option[Int] = Try(x.toInt).toOption }
+ implicit class RX(val sc: StringContext) {
+ def rx = sc.parts.mkString("(.+)").r
+ }
+
+ Console println ("2 by 4" match {
+ case rx"${I(a)} by ${I(b)}" => a+b
+ case _ => -1
+ })
+ Console println ("2 by 4" match {
+ case rx"${_} by ${I(b)}" => b // pattern placeholder
+ case _ => -1
+ })
+ Console println ("2 by 4" match {
+ case rx"$_ by ${I(b)}" => b // is permitted this way, too
+ case _ => -1
+ })
+}
diff --git a/test/files/run/tailcalls.check b/test/files/run/tailcalls.check
index ab54d528ab..7607921856 100644
--- a/test/files/run/tailcalls.check
+++ b/test/files/run/tailcalls.check
@@ -53,27 +53,27 @@ 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
-test Class .f was successful
+test Object .f was successful
+test Final .f was successful
+test Class .f was successful
test SubClass .f was successful
-test Sealed .f was successful
+test Sealed .f was successful
test SubSealed.f was successful
-test O .f was successful
-test c .f was successful
-test O.O .f was successful
-test O.c .f was successful
-test c.O .f was successful
-test c.c .f was successful
-test O.O.O .f was successful
-test O.O.c .f was successful
-test O.c.O .f was successful
-test O.c.c .f was successful
-test c.O.O .f was successful
-test c.O.c .f was successful
-test c.c.O .f was successful
-test c.c.c .f was successful
+test O .f was successful
+test c .f was successful
+test O.O .f was successful
+test O.c .f was successful
+test c.O .f was successful
+test c.c .f was successful
+test O.O.O .f was successful
+test O.O.c .f was successful
+test O.c.O .f was successful
+test O.c.c .f was successful
+test c.O.O .f was successful
+test c.O.c .f was successful
+test c.c.O .f was successful
+test c.c.c .f was successful
test O.O.O.O.f was successful
test O.O.O.c.f was successful
test O.O.c.O.f was successful
diff --git a/test/files/scalacheck/quasiquotes/ErrorProps.scala b/test/files/scalacheck/quasiquotes/ErrorProps.scala
index 044a332a04..b9e69e0e88 100644
--- a/test/files/scalacheck/quasiquotes/ErrorProps.scala
+++ b/test/files/scalacheck/quasiquotes/ErrorProps.scala
@@ -188,12 +188,6 @@ object ErrorProps extends QuasiquoteProperties("errors") {
val q"$m1 $m2 def foo" = EmptyTree
""")
- property("can't parse more than one casedef") = fails(
- "Can't parse more than one casedef, consider generating a match tree instead",
- """
- cq"1 => 2 case 3 => 5"
- """)
-
// // Make sure a nice error is reported in this case
// { import Flag._; val mods = NoMods; q"lazy $mods val x: Int" }
} \ No newline at end of file
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/tools/nsc/symtab/CannotHaveAttrsTest.scala b/test/junit/scala/tools/nsc/symtab/CannotHaveAttrsTest.scala
new file mode 100644
index 0000000000..355771bf04
--- /dev/null
+++ b/test/junit/scala/tools/nsc/symtab/CannotHaveAttrsTest.scala
@@ -0,0 +1,67 @@
+package scala.tools.nsc
+package symtab
+
+import org.junit.Assert._
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+import scala.tools.testing.AssertUtil.assertThrows
+import scala.reflect.internal.util.OffsetPosition
+
+@RunWith(classOf[JUnit4])
+class CannotHaveAttrsTest {
+ object symbolTable extends SymbolTableForUnitTesting {
+ object CHA extends CannotHaveAttrs {
+ def canEqual(that: Any): Boolean = ???
+ def productArity: Int = ???
+ def productElement(n: Int): Any = ???
+ }
+ val attrlessTrees = List(CHA, EmptyTree, emptyValDef, pendingSuperCall)
+ }
+ import symbolTable._
+
+ @Test
+ def canHaveAttrsIsFalse =
+ attrlessTrees.foreach { t =>
+ assertFalse(t.canHaveAttrs)
+ }
+
+ @Test
+ def defaultPosAssignment =
+ attrlessTrees.foreach { t =>
+ assertEquals(t.pos, NoPosition)
+ t.pos = NoPosition
+ assertEquals(t.pos, NoPosition)
+ t.setPos(NoPosition)
+ assertEquals(t.pos, NoPosition)
+ }
+
+ @Test
+ def defaultTpeAssignment =
+ attrlessTrees.foreach { t =>
+ assertEquals(t.tpe, NoType)
+ t.tpe = NoType
+ assertEquals(t.tpe, NoType)
+ t.setType(NoType)
+ assertEquals(t.tpe, NoType)
+ }
+
+ @Test
+ def nonDefaultPosAssignmentFails = {
+ val pos = new OffsetPosition(null, 0)
+ attrlessTrees.foreach { t =>
+ assertThrows[IllegalArgumentException] { t.pos = pos }
+ assertThrows[IllegalArgumentException] { t.setPos(pos) }
+ }
+ }
+
+ @Test
+ def nonDefaultTpeAssignmentFails = {
+ val tpe = typeOf[Int]
+ attrlessTrees.foreach { t =>
+ assertThrows[IllegalArgumentException] { t.tpe = tpe }
+ assertThrows[IllegalArgumentException] { t.setType(tpe) }
+ }
+ }
+}
diff --git a/test/junit/scala/tools/nsc/symtab/SymbolTableTest.scala b/test/junit/scala/tools/nsc/symtab/SymbolTableTest.scala
index 537cb93ef3..11e955a4bb 100644
--- a/test/junit/scala/tools/nsc/symtab/SymbolTableTest.scala
+++ b/test/junit/scala/tools/nsc/symtab/SymbolTableTest.scala
@@ -9,17 +9,15 @@ import org.junit.runners.JUnit4
@RunWith(classOf[JUnit4])
class SymbolTableTest {
- private def createSymbolTable: SymbolTable = new SymbolTableForUnitTesting
+ object symbolTable extends SymbolTableForUnitTesting
@Test
def initDefinitions = {
- val symbolTable = createSymbolTable
symbolTable.definitions.init()
}
@Test
def basicSubTypeCheck = {
- val symbolTable = createSymbolTable
symbolTable.definitions.init()
val listClassTpe = symbolTable.definitions.ListClass.tpe
val seqClassTpe = symbolTable.definitions.SeqClass.tpe
@@ -32,7 +30,6 @@ class SymbolTableTest {
*/
@Test
def customClassesSubTypeCheck: Unit = {
- val symbolTable = createSymbolTable
import symbolTable._
symbolTable.definitions.init()
val rootClass = symbolTable.rootMirror.RootClass
diff --git a/test/junit/scala/tools/testing/AssertThrowsTest.scala b/test/junit/scala/tools/testing/AssertThrowsTest.scala
new file mode 100644
index 0000000000..a70519e63c
--- /dev/null
+++ b/test/junit/scala/tools/testing/AssertThrowsTest.scala
@@ -0,0 +1,34 @@
+package scala.tools
+package testing
+
+import org.junit.Assert._
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import AssertUtil.assertThrows
+
+@RunWith(classOf[JUnit4])
+class AssertThrowsTest {
+ class Foo extends Exception
+ class SubFoo extends Foo
+ class Bar extends Exception
+
+ @Test
+ def catchFoo = assertThrows[Foo] { throw new Foo }
+
+ @Test
+ def catchSubclass = assertThrows[Foo] { throw new SubFoo }
+
+ @Test
+ def rethrowBar =
+ assertTrue("exception wasn't rethrown", {
+ try {
+ assertThrows[Foo] { throw new Bar }
+ false
+ } catch {
+ case bar: Bar => true
+ case e: Throwable => fail(s"expected Bar but got $e"); false
+ }
+ })
+
+} \ No newline at end of file
diff --git a/test/junit/scala/tools/testing/AssertUtil.scala b/test/junit/scala/tools/testing/AssertUtil.scala
new file mode 100644
index 0000000000..9efac64a97
--- /dev/null
+++ b/test/junit/scala/tools/testing/AssertUtil.scala
@@ -0,0 +1,19 @@
+package scala.tools
+package testing
+
+/** This module contains additional higher-level assert statements
+ * that are ultimately based on junit.Assert primitives.
+ */
+object AssertUtil {
+ /** Check if exception T (or a subclass) was thrown during evaluation of f.
+ * If any other exception or throwable is found instead it will be re-thrown.
+ */
+ def assertThrows[T <: Exception](f: => Any)(implicit manifest: Manifest[T]): Unit =
+ try f
+ catch {
+ case e: Exception =>
+ val clazz = manifest.erasure.asInstanceOf[Class[T]]
+ if (!clazz.isAssignableFrom(e.getClass))
+ throw e
+ }
+} \ No newline at end of file
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 b74e04a208..8d94facba3 100755
--- a/test/partest
+++ b/test/partest
@@ -119,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}" \