summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2015-05-01 15:33:30 +1000
committerJason Zaugg <jzaugg@gmail.com>2015-05-01 15:33:30 +1000
commite596d1a65d81a81a54847d90d2d90be3ffbb3d92 (patch)
treed6c86e80b08b47271e65bccfe734e80bc531be8f
parent4210262867a541d4cbf0aaf2b06bedeef9520c2b (diff)
parent6a185e3c97b79716576725f1ecf0ba629e83951d (diff)
downloadscala-e596d1a65d81a81a54847d90d2d90be3ffbb3d92.tar.gz
scala-e596d1a65d81a81a54847d90d2d90be3ffbb3d92.tar.bz2
scala-e596d1a65d81a81a54847d90d2d90be3ffbb3d92.zip
Merge remote-tracking branch 'origin/2.11.x' into merge/2.11.x-to-2.12.x-20150501
-rw-r--r--.gitignore6
-rw-r--r--README.md9
-rw-r--r--build.sbt443
-rwxr-xr-xbuild.xml8
-rw-r--r--compare-build-dirs-ignore-patterns8
-rwxr-xr-xcompare-build-dirs.sh5
-rw-r--r--project/ScalaTool.scala44
-rw-r--r--project/build.properties1
-rw-r--r--project/plugins.sbt1
-rw-r--r--spec/01-lexical-syntax.md348
-rw-r--r--spec/02-identifiers-names-and-scopes.md4
-rw-r--r--spec/03-types.md26
-rw-r--r--spec/04-basic-declarations-and-definitions.md4
-rw-r--r--spec/05-classes-and-objects.md10
-rw-r--r--spec/06-expressions.md20
-rw-r--r--spec/07-implicits.md (renamed from spec/07-implicit-parameters-and-views.md)12
-rw-r--r--spec/08-pattern-matching.md6
-rw-r--r--spec/10-xml-expressions-and-patterns.md2
-rw-r--r--spec/11-annotations.md (renamed from spec/11-user-defined-annotations.md)31
-rw-r--r--spec/12-the-scala-standard-library.md6
-rw-r--r--spec/13-syntax-summary.md6
-rw-r--r--spec/15-changelog.md823
-rw-r--r--spec/README.md2
-rw-r--r--spec/_includes/numbering.css2
-rw-r--r--spec/_layouts/default.yml72
-rw-r--r--spec/_layouts/toc.yml26
-rw-r--r--spec/index.md21
-rw-r--r--spec/public/fonts/Heuristica-Bold.woffbin0 -> 106188 bytes
-rw-r--r--spec/public/fonts/Heuristica-BoldItalic.woffbin0 -> 104316 bytes
-rw-r--r--spec/public/fonts/Heuristica-Regular.woffbin0 -> 141416 bytes
-rw-r--r--spec/public/fonts/Heuristica-RegularItalic.woffbin0 -> 104700 bytes
-rw-r--r--spec/public/fonts/LuxiMono-Bold.woffbin0 -> 26560 bytes
-rw-r--r--spec/public/fonts/LuxiMono-BoldOblique.woffbin0 -> 29480 bytes
-rw-r--r--spec/public/fonts/LuxiMono-Regular.woffbin0 -> 26432 bytes
-rw-r--r--spec/public/fonts/LuxiMono-RegularOblique.woffbin0 -> 29300 bytes
-rw-r--r--spec/public/fonts/LuxiSans-Bold.woffbin0 -> 13592 bytes
-rw-r--r--spec/public/fonts/LuxiSans-Regular.woffbin0 -> 13568 bytes
-rw-r--r--spec/public/images/github-logo@2x.pngbin0 -> 1753 bytes
-rw-r--r--spec/public/images/scala-logo-red-spiral-dark.pngbin13021 -> 0 bytes
-rw-r--r--spec/public/images/scala-spiral-white.pngbin0 -> 1442 bytes
-rw-r--r--spec/public/scripts/LICENSE-highlight (renamed from spec/public/highlight/LICENSE)4
-rw-r--r--spec/public/scripts/LICENSE-toc18
-rw-r--r--spec/public/scripts/highlight.pack.js (renamed from spec/public/highlight/highlight.pack.js)0
-rw-r--r--spec/public/scripts/main.js57
-rw-r--r--spec/public/scripts/navigation.js70
-rw-r--r--spec/public/scripts/toc.js128
-rw-r--r--spec/public/stylesheets/fonts.css73
-rw-r--r--spec/public/stylesheets/screen-small.css57
-rw-r--r--spec/public/stylesheets/screen-toc.css37
-rw-r--r--spec/public/stylesheets/screen.css225
-rw-r--r--src/compiler/scala/reflect/quasiquotes/Reifiers.scala2
-rwxr-xr-xsrc/compiler/scala/tools/ant/templates/tool-unix.tmpl10
-rw-r--r--src/compiler/scala/tools/nsc/PhaseAssembly.scala2
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala8
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BCodeAsmCommon.scala6
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala4
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala10
-rw-r--r--src/compiler/scala/tools/nsc/transform/Constructors.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/Delambdafy.scala4
-rw-r--r--src/compiler/scala/tools/nsc/transform/LazyVals.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/Mixin.scala4
-rw-r--r--src/compiler/scala/tools/nsc/transform/SampleTransform.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/AnalyzerPlugins.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala8
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala2
-rw-r--r--src/interactive/scala/tools/nsc/interactive/CompilerControl.scala2
-rw-r--r--src/interactive/scala/tools/nsc/interactive/Global.scala2
-rw-r--r--src/interactive/scala/tools/nsc/interactive/Lexer.scala2
-rw-r--r--src/library/scala/Mutable.scala2
-rw-r--r--src/library/scala/Predef.scala4
-rw-r--r--src/library/scala/collection/SeqLike.scala2
-rw-r--r--src/library/scala/collection/concurrent/Map.scala2
-rw-r--r--src/library/scala/collection/immutable/Stream.scala2
-rw-r--r--src/library/scala/collection/mutable/AVLTree.scala4
-rw-r--r--src/library/scala/collection/mutable/HashTable.scala2
-rw-r--r--src/library/scala/collection/mutable/UnrolledBuffer.scala14
-rw-r--r--src/library/scala/collection/mutable/WrappedArray.scala2
-rw-r--r--src/library/scala/concurrent/JavaConversions.scala2
-rw-r--r--src/library/scala/concurrent/duration/Duration.scala5
-rw-r--r--src/library/scala/math/BigDecimal.scala2
-rw-r--r--src/library/scala/sys/process/BasicIO.scala2
-rw-r--r--src/library/scala/sys/process/ProcessLogger.scala2
-rw-r--r--src/library/scala/util/control/Exception.scala2
-rw-r--r--src/library/scala/util/hashing/MurmurHash3.scala2
-rw-r--r--src/library/scala/util/matching/Regex.scala2
-rw-r--r--src/partest-extras/scala/tools/partest/ASMConverters.scala2
-rw-r--r--src/reflect/scala/reflect/api/Quasiquotes.scala2
-rw-r--r--src/reflect/scala/reflect/internal/Definitions.scala2
-rw-r--r--src/reflect/scala/reflect/internal/ReificationSupport.scala2
-rw-r--r--src/reflect/scala/reflect/internal/Symbols.scala2
-rw-r--r--src/reflect/scala/reflect/internal/TreeGen.scala2
-rw-r--r--src/reflect/scala/reflect/internal/Types.scala4
-rw-r--r--src/reflect/scala/reflect/internal/tpe/FindMembers.scala2
-rw-r--r--src/repl/scala/tools/nsc/interpreter/ConsoleReaderHelper.scala15
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/Index.scala2
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/html/HtmlFactory.scala2
-rwxr-xr-xsrc/scaladoc/scala/tools/nsc/doc/html/page/DeprecatedIndex.scala58
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/html/page/Index.scala7
-rwxr-xr-xsrc/scaladoc/scala/tools/nsc/doc/model/IndexModelFactory.scala8
-rw-r--r--test/files/jvm/inner.scala2
-rw-r--r--test/files/jvm/javaReflection/Test.scala4
-rw-r--r--test/files/pos/t7815.scala2
-rw-r--r--test/files/run/classfile-format-51.scala2
-rw-r--r--test/files/run/classfile-format-52.scala2
-rw-r--r--test/files/run/t7741a/Test.scala2
-rw-r--r--test/files/run/t9268.check5
-rw-r--r--test/files/run/t9268/Java.java12
-rw-r--r--test/files/run/t9268/Test.scala40
-rw-r--r--test/files/run/valueClassSelfType.scala52
-rw-r--r--test/junit/scala/collection/mutable/UnrolledBufferTest.scala25
-rw-r--r--test/junit/scala/collection/mutable/VectorTest.scala1
-rw-r--r--test/junit/scala/concurrent/duration/SerializationTest.scala24
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala2
-rw-r--r--test/junit/scala/tools/nsc/interpreter/TabulatorTest.scala20
-rw-r--r--test/pending/jvm/javasigs.scala2
-rw-r--r--test/scaladoc/resources/SI-4476.scala9
-rw-r--r--test/scaladoc/resources/Trac4420.scala2
-rw-r--r--test/scaladoc/scalacheck/DeprecatedIndexTest.scala50
-rw-r--r--test/scaladoc/scalacheck/IndexTest.scala8
-rwxr-xr-xtools/scaladoc-compare2
127 files changed, 2561 insertions, 575 deletions
diff --git a/.gitignore b/.gitignore
index 20d700dd12..d6571a377f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -48,3 +48,9 @@
# Standard symbolic link to build/quick/bin
/qbin
+
+# Sbt's target directories
+/target/
+/project/target/
+/project/project/target
+/build-sbt/
diff --git a/README.md b/README.md
index 830dfa8d6c..1651333188 100644
--- a/README.md
+++ b/README.md
@@ -138,6 +138,15 @@ The Scala build system is based on Apache Ant. Most required pre-compiled
libraries are part of the repository (in 'lib/'). The following however is
assumed to be installed on the build machine:
+## Building with Sbt (EXPERIMENTAL)
+
+The experimental sbt-based build definition has arrived! Run `sbt package`
+to build the compiler. You can run `sbt test` to run unit (JUnit) tests.
+Use `sbt test/it:test` to run integration (partest) tests.
+
+We would like to migrate to sbt build as quickly as possible. If you would
+like to help please contact scala-internals@ mailing list to discuss your
+ideas and coordinate your effort with others.
### Tips and tricks
diff --git a/build.sbt b/build.sbt
new file mode 100644
index 0000000000..0df2e6a800
--- /dev/null
+++ b/build.sbt
@@ -0,0 +1,443 @@
+/*
+ * The new, sbt-based build definition for Scala.
+ *
+ * What you see below is very much work-in-progress. Basics like compiling and packaging jars
+ * (into right location) work. Everything else is missing:
+ * building docs, placing shell scripts in right locations (so you can run compiler easily),
+ * running partest test, compiling and running JUnit test, and many, many other things.
+ *
+ * You'll notice that this build definition is much more complicated than your typical sbt build.
+ * The main reason is that we are not benefiting from sbt's conventions when it comes project
+ * layout. For that reason we have to configure a lot more explicitly. I've tried explain in
+ * comments the less obvious settings.
+ *
+ * This nicely leads me to explaining goal and non-goals of this build definition. Goals are:
+ *
+ * - to be easy to tweak it in case a bug or small inconsistency is found
+ * - to mimic Ant's behavior as closely as possible
+ * - to be super explicit about any departure from standard sbt settings
+ * - to achieve functional parity with Ant build as quickly as possible
+ * - to be readable and not necessarily succinct
+ * - to provide the nicest development experience for people hacking on Scala
+ *
+ * Non-goals are:
+ *
+ * - to have the shortest sbt build definition possible; we'll beat Ant definition
+ * easily and that will thrill us already
+ * - to remove irregularities from our build process right away
+ * - to modularize the Scala compiler or library further
+ *
+ * It boils down to simple rules:
+ *
+ * - project layout is set in stone for now
+ * - if you need to work on convincing sbt to follow non-standard layout then
+ * explain everything you did in comments
+ * - constantly check where Ant build produces class files, artifacts, what kind of other
+ * files generates and port all of that to here
+ *
+ * Note on bootstrapping:
+ *
+ * Let's start with reminder what bootstrapping means in our context. It's an answer
+ * to this question: which version of Scala are using to compile Scala? The fact that
+ * the question sounds circular suggests trickiness. Indeed, bootstrapping Scala
+ * compiler is a tricky process.
+ *
+ * Ant build used to have involved system of bootstrapping Scala. It would consist of
+ * three layers: starr, locker and quick. The sbt build for Scala ditches layering
+ * and strives to be as standard sbt project as possible. This means that we are simply
+ * building Scala with latest stable release of Scala.
+ * See this discussion for more details behind this decision:
+ * https://groups.google.com/d/topic/scala-internals/gp5JsM1E0Fo/discussion
+ */
+
+val bootstrapScalaVersion = "2.11.5"
+
+def withoutScalaLang(moduleId: ModuleID): ModuleID = moduleId exclude("org.scala-lang", "*")
+
+// exclusion of the scala-library transitive dependency avoids eviction warnings during `update`.
+val scalaParserCombinatorsDep = withoutScalaLang("org.scala-lang.modules" %% "scala-parser-combinators" % versionNumber("scala-parser-combinators"))
+val scalaXmlDep = withoutScalaLang("org.scala-lang.modules" %% "scala-xml" % versionNumber("scala-xml"))
+val partestDep = withoutScalaLang("org.scala-lang.modules" %% "scala-partest" % versionNumber("partest"))
+val partestInterfaceDep = withoutScalaLang("org.scala-lang.modules" %% "scala-partest-interface" % "0.5.0")
+val junitDep = "junit" % "junit" % "4.11"
+val junitIntefaceDep = "com.novocode" % "junit-interface" % "0.11" % "test"
+val jlineDep = "jline" % "jline" % versionProps("jline.version")
+val antDep = "org.apache.ant" % "ant" % "1.9.4"
+val scalacheckDep = withoutScalaLang("org.scalacheck" %% "scalacheck" % "1.11.4")
+
+lazy val commonSettings = clearSourceAndResourceDirectories ++ Seq[Setting[_]](
+ organization := "org.scala-lang",
+ version := "2.11.6-SNAPSHOT",
+ scalaVersion := bootstrapScalaVersion,
+ // we don't cross build Scala itself
+ crossPaths := false,
+ // do not add Scala library jar as a dependency automatically
+ autoScalaLibrary := false,
+ // we also do not add scala instance automatically because it introduces
+ // a circular instance, see: https://github.com/sbt/sbt/issues/1872
+ managedScalaInstance := false,
+ // this is a way to workaround issue described in https://github.com/sbt/sbt/issues/1872
+ // check it out for more details
+ scalaInstance := ScalaInstance(scalaVersion.value, appConfiguration.value.provider.scalaProvider.launcher getScala scalaVersion.value),
+ // we always assume that Java classes are standalone and do not have any dependency
+ // on Scala classes
+ compileOrder := CompileOrder.JavaThenScala,
+ javacOptions in Compile ++= Seq("-g", "-source", "1.5", "-target", "1.6"),
+ // we don't want any unmanaged jars; as a reminder: unmanaged jar is a jar stored
+ // directly on the file system and it's not resolved through Ivy
+ // Ant's build stored unmanaged jars in `lib/` directory
+ unmanagedJars in Compile := Seq.empty,
+ sourceDirectory in Compile := baseDirectory.value,
+ unmanagedSourceDirectories in Compile := List(baseDirectory.value),
+ scalaSource in Compile := (sourceDirectory in Compile).value,
+ javaSource in Compile := (sourceDirectory in Compile).value,
+ // resources are stored along source files in our current layout
+ resourceDirectory in Compile := (sourceDirectory in Compile).value,
+ // each subproject has to ask specifically for files they want to include
+ includeFilter in unmanagedResources in Compile := NothingFilter,
+ target := (baseDirectory in ThisBuild).value / "target" / thisProject.value.id,
+ target in Compile in doc := buildDirectory.value / "scaladoc" / thisProject.value.id,
+ classDirectory in Compile := buildDirectory.value / "quick/classes" / thisProject.value.id,
+ // given that classDirectory is overriden to be _outside_ of target directory, we have
+ // to make sure its being cleaned properly
+ cleanFiles += (classDirectory in Compile).value,
+ fork in run := true
+)
+
+// disable various tasks that are not needed for projects that are used
+// only for compiling code and not publishing it as a standalone artifact
+// we disable those tasks by overriding them and returning bogus files when
+// needed. This is a bit sketchy but I haven't found any better way.
+val disableDocsAndPublishingTasks = Seq[Setting[_]](
+ doc := file("!!! NO DOCS !!!"),
+ publishLocal := {},
+ publish := {},
+ packageBin in Compile := file("!!! NO PACKAGING !!!")
+)
+
+lazy val setJarLocation: Setting[_] =
+ artifactPath in packageBin in Compile := {
+ // two lines below are copied over from sbt's sources:
+ // https://github.com/sbt/sbt/blob/0.13/main/src/main/scala/sbt/Defaults.scala#L628
+ //val resolvedScalaVersion = ScalaVersion((scalaVersion in artifactName).value, (scalaBinaryVersion in artifactName).value)
+ //val resolvedArtifactName = artifactName.value(resolvedScalaVersion, projectID.value, artifact.value)
+ // if you would like to get a jar with version number embedded in it (as normally sbt does)
+ // uncomment the other definition of the `resolvedArtifactName`
+ val resolvedArtifact = artifact.value
+ val resolvedArtifactName = s"${resolvedArtifact.name}.${resolvedArtifact.extension}"
+ buildDirectory.value / "pack/lib" / resolvedArtifactName
+ }
+lazy val scalaSubprojectSettings: Seq[Setting[_]] = commonSettings :+ setJarLocation
+
+lazy val generatePropertiesFileSettings = Seq[Setting[_]](
+ copyrightString := "Copyright 2002-2013, LAMP/EPFL",
+ resourceGenerators in Compile += generateVersionPropertiesFile.map(file => Seq(file)).taskValue,
+ generateVersionPropertiesFile := generateVersionPropertiesFileImpl.value
+)
+
+val libIncludes: FileFilter = "*.tmpl" | "*.xml" | "*.js" | "*.css" | "rootdoc.txt"
+
+lazy val library = configureAsSubproject(project)
+ .settings(generatePropertiesFileSettings: _*)
+ .settings(
+ name := "scala-library",
+ scalacOptions in Compile ++= Seq[String]("-sourcepath", (scalaSource in Compile).value.toString),
+ // Workaround for a bug in `scaladoc` that it seems to not respect the `-sourcepath` option
+ // as a result of this bug, the compiler cannot even initialize Definitions without
+ // binaries of the library on the classpath. Specifically, we get this error:
+ // (library/compile:doc) scala.reflect.internal.FatalError: package class scala does not have a member Int
+ // Ant build does the same thing always: it puts binaries for documented classes on the classpath
+ // sbt never does this by default (which seems like a good default)
+ dependencyClasspath in Compile in doc += (classDirectory in Compile).value,
+ scalacOptions in Compile in doc ++= {
+ val libraryAuxDir = (baseDirectory in ThisBuild).value / "src/library-aux"
+ Seq("-doc-no-compile", libraryAuxDir.toString)
+ },
+ includeFilter in unmanagedResources in Compile := libIncludes)
+ .dependsOn (forkjoin)
+
+lazy val reflect = configureAsSubproject(project)
+ .settings(generatePropertiesFileSettings: _*)
+ .settings(name := "scala-reflect")
+ .dependsOn(library)
+
+val compilerIncludes: FileFilter =
+ "*.tmpl" | "*.xml" | "*.js" | "*.css" | "*.html" | "*.properties" | "*.swf" |
+ "*.png" | "*.gif" | "*.gif" | "*.txt"
+
+lazy val compiler = configureAsSubproject(project)
+ .settings(generatePropertiesFileSettings: _*)
+ .settings(
+ name := "scala-compiler",
+ libraryDependencies += antDep,
+ // this a way to make sure that classes from interactive and scaladoc projects
+ // end up in compiler jar (that's what Ant build does)
+ // we need to use LocalProject references (with strings) to deal with mutual recursion
+ mappings in Compile in packageBin :=
+ (mappings in Compile in packageBin).value ++
+ (mappings in Compile in packageBin in LocalProject("interactive")).value ++
+ (mappings in Compile in packageBin in LocalProject("scaladoc")).value ++
+ (mappings in Compile in packageBin in LocalProject("repl")).value,
+ includeFilter in unmanagedResources in Compile := compilerIncludes)
+ .dependsOn(library, reflect, asm)
+
+lazy val interactive = configureAsSubproject(project)
+ .settings(disableDocsAndPublishingTasks: _*)
+ .dependsOn(compiler)
+
+lazy val repl = configureAsSubproject(project)
+ .settings(libraryDependencies += jlineDep)
+ .settings(disableDocsAndPublishingTasks: _*)
+ .dependsOn(compiler)
+
+lazy val scaladoc = configureAsSubproject(project)
+ .settings(
+ libraryDependencies ++= Seq(scalaXmlDep, scalaParserCombinatorsDep, partestDep)
+ )
+ .settings(disableDocsAndPublishingTasks: _*)
+ .dependsOn(compiler)
+
+lazy val scalap = configureAsSubproject(project).
+ dependsOn(compiler)
+
+// deprecated Scala Actors project
+// TODO: it packages into actors.jar but it should be scala-actors.jar
+lazy val actors = configureAsSubproject(project)
+ .settings(generatePropertiesFileSettings: _*)
+ .settings(name := "scala-actors")
+ .dependsOn(library)
+
+lazy val forkjoin = configureAsForkOfJavaProject(project)
+
+lazy val asm = configureAsForkOfJavaProject(project)
+
+lazy val partestExtras = configureAsSubproject(Project("partest-extras", file(".") / "src" / "partest-extras"))
+ .dependsOn(repl)
+ .settings(clearSourceAndResourceDirectories: _*)
+ .settings(
+ libraryDependencies += partestDep,
+ unmanagedSourceDirectories in Compile := List(baseDirectory.value)
+ )
+
+lazy val junit = project.in(file("test") / "junit")
+ .dependsOn(library, reflect, compiler, partestExtras, scaladoc)
+ .settings(clearSourceAndResourceDirectories: _*)
+ .settings(commonSettings: _*)
+ .settings(
+ fork in Test := true,
+ libraryDependencies ++= Seq(junitDep, junitIntefaceDep),
+ testOptions += Tests.Argument(TestFrameworks.JUnit, "-a", "-v"),
+ unmanagedSourceDirectories in Test := List(baseDirectory.value)
+ )
+
+lazy val partestJavaAgent = (project in file(".") / "src" / "partest-javaagent").
+ dependsOn(asm).
+ settings(commonSettings: _*).
+ settings(
+ doc := file("!!! NO DOCS !!!"),
+ publishLocal := {},
+ publish := {},
+ // Setting name to "scala-partest-javaagent" so that the jar file gets that name, which the Runner relies on
+ name := "scala-partest-javaagent",
+ // writing jar file to $buildDirectory/pack/lib because that's where it's expected to be found
+ setJarLocation,
+ // add required manifest entry - previously included from file
+ packageOptions in (Compile, packageBin) +=
+ Package.ManifestAttributes( "Premain-Class" -> "scala.tools.partest.javaagent.ProfilingAgent" ),
+ // we need to build this to a JAR
+ exportJars := true
+ )
+
+lazy val test = project.
+ dependsOn(compiler, interactive, actors, repl, scalap, partestExtras, partestJavaAgent, asm, scaladoc).
+ configs(IntegrationTest).
+ settings(disableDocsAndPublishingTasks: _*).
+ settings(commonSettings: _*).
+ settings(Defaults.itSettings: _*).
+ settings(
+ libraryDependencies ++= Seq(partestDep, scalaXmlDep, partestInterfaceDep, scalacheckDep),
+ unmanagedBase in Test := baseDirectory.value / "files" / "lib",
+ unmanagedJars in Test <+= (unmanagedBase) (j => Attributed.blank(j)) map(identity),
+ // no main sources
+ sources in Compile := Seq.empty,
+ // test sources are compiled in partest run, not here
+ sources in IntegrationTest := Seq.empty,
+ fork in IntegrationTest := true,
+ javaOptions in IntegrationTest += "-Xmx1G",
+ testFrameworks += new TestFramework("scala.tools.partest.Framework"),
+ testOptions in IntegrationTest += Tests.Setup( () => root.base.getAbsolutePath + "/pull-binary-libs.sh" ! ),
+ definedTests in IntegrationTest += (
+ new sbt.TestDefinition(
+ "partest",
+ // marker fingerprint since there are no test classes
+ // to be discovered by sbt:
+ new sbt.testing.AnnotatedFingerprint {
+ def isModule = true
+ def annotationName = "partest"
+ }, true, Array())
+ )
+ )
+
+lazy val root = (project in file(".")).
+ aggregate(library, forkjoin, reflect, compiler, asm, interactive, repl,
+ scaladoc, scalap, actors, partestExtras, junit).settings(
+ sources in Compile := Seq.empty,
+ onLoadMessage := """|*** Welcome to the sbt build definition for Scala! ***
+ |This build definition has an EXPERIMENTAL status. If you are not
+ |interested in testing or working on the build itself, please use
+ |the Ant build definition for now. Check README.md for more information.""".stripMargin
+ )
+
+lazy val dist = (project in file("dist")).settings(
+ mkBin := mkBinImpl.value
+)
+
+/**
+ * Configures passed project as a subproject (e.g. compiler or repl)
+ * with common settings attached to it.
+ *
+ * Typical usage is:
+ *
+ * lazy val mySubproject = configureAsSubproject(project)
+ *
+ * We pass `project` as an argument which is in fact a macro call. This macro determines
+ * project.id based on the name of the lazy val on the left-hand side.
+ */
+def configureAsSubproject(project: Project): Project = {
+ val base = file(".") / "src" / project.id
+ (project in base).settings(scalaSubprojectSettings: _*)
+}
+
+/**
+ * Configuration for subprojects that are forks of some Java projects
+ * we depend on. At the moment there are just two: asm and forkjoin.
+ *
+ * We do not publish artifacts for those projects but we package their
+ * binaries in a jar of other project (compiler or library).
+ *
+ * For that reason we disable docs generation, packaging and publishing.
+ */
+def configureAsForkOfJavaProject(project: Project): Project = {
+ val base = file(".") / "src" / project.id
+ (project in base).
+ settings(commonSettings: _*).
+ settings(disableDocsAndPublishingTasks: _*).
+ settings(
+ sourceDirectory in Compile := baseDirectory.value,
+ javaSource in Compile := (sourceDirectory in Compile).value,
+ sources in Compile in doc := Seq.empty,
+ classDirectory in Compile := buildDirectory.value / "libs/classes" / thisProject.value.id
+ )
+}
+
+lazy val buildDirectory = settingKey[File]("The directory where all build products go. By default ./build")
+lazy val copyrightString = settingKey[String]("Copyright string.")
+lazy val generateVersionPropertiesFile = taskKey[File]("Generating version properties file.")
+lazy val mkBin = taskKey[Seq[File]]("Generate shell script (bash or Windows batch).")
+
+lazy val generateVersionPropertiesFileImpl: Def.Initialize[Task[File]] = Def.task {
+ val propFile = (resourceManaged in Compile).value / s"${thisProject.value.id}.properties"
+ val props = new java.util.Properties
+
+ /**
+ * Regexp that splits version number split into two parts: version and suffix.
+ * Examples of how the split is performed:
+ *
+ * "2.11.5": ("2.11.5", null)
+ * "2.11.5-acda7a": ("2.11.5", "-acda7a")
+ * "2.11.5-SNAPSHOT": ("2.11.5", "-SNAPSHOT")
+ *
+ */
+ val versionSplitted = """([\w+\.]+)(-[\w+\.]+)??""".r
+
+ val versionSplitted(ver, suffixOrNull) = version.value
+ val osgiSuffix = suffixOrNull match {
+ case null => "-VFINAL"
+ case "-SNAPSHOT" => ""
+ case suffixStr => suffixStr
+ }
+
+ def executeTool(tool: String) = {
+ val cmd =
+ if (System.getProperty("os.name").toLowerCase.contains("windows"))
+ s"cmd.exe /c tools\\$tool.bat -p"
+ else s"tools/$tool"
+ Process(cmd).lines.head
+ }
+
+ val commitDate = executeTool("get-scala-commit-date")
+ val commitSha = executeTool("get-scala-commit-sha")
+
+ props.put("version.number", s"${version.value}-$commitDate-$commitSha")
+ props.put("maven.version.number", s"${version.value}")
+ props.put("osgi.version.number", s"$ver.v$commitDate$osgiSuffix-$commitSha")
+ props.put("copyright.string", copyrightString.value)
+
+ // unfortunately, this will write properties in arbitrary order
+ // this makes it harder to test for stability of generated artifacts
+ // consider using https://github.com/etiennestuder/java-ordered-properties
+ // instead of java.util.Properties
+ IO.write(props, null, propFile)
+
+ propFile
+}
+
+// Defining these settings is somewhat redundant as we also redefine settings that depend on them.
+// However, IntelliJ's project import works better when these are set correctly.
+def clearSourceAndResourceDirectories = Seq(Compile, Test).flatMap(config => inConfig(config)(Seq(
+ unmanagedSourceDirectories := Nil,
+ managedSourceDirectories := Nil,
+ unmanagedResourceDirectories := Nil,
+ managedResourceDirectories := Nil
+)))
+
+lazy val mkBinImpl: Def.Initialize[Task[Seq[File]]] = Def.task {
+ def mkScalaTool(mainCls: String, classpath: Seq[Attributed[File]]): ScalaTool =
+ ScalaTool(mainClass = mainCls,
+ classpath = classpath.toList.map(_.data.getAbsolutePath),
+ properties = Map.empty,
+ javaOpts = "-Xmx256M -Xms32M",
+ toolFlags = "")
+ val rootDir = (classDirectory in Compile in compiler).value
+ def writeScripts(scalaTool: ScalaTool, file: String, outDir: File): Seq[File] =
+ Seq(
+ scalaTool.writeScript(file, "unix", rootDir, outDir),
+ scalaTool.writeScript(file, "windows", rootDir, outDir)
+ )
+ def mkQuickBin(file: String, mainCls: String, classpath: Seq[Attributed[File]]): Seq[File] = {
+ val scalaTool = mkScalaTool(mainCls, classpath)
+ val outDir = buildDirectory.value / "quick/bin"
+ writeScripts(scalaTool, file, outDir)
+ }
+
+ def mkPackBin(file: String, mainCls: String): Seq[File] = {
+ val scalaTool = mkScalaTool(mainCls, classpath = Nil)
+ val outDir = buildDirectory.value / "pack/bin"
+ writeScripts(scalaTool, file, outDir)
+ }
+
+ def mkBin(file: String, mainCls: String, classpath: Seq[Attributed[File]]): Seq[File] =
+ mkQuickBin(file, mainCls, classpath) ++ mkPackBin(file, mainCls)
+
+ mkBin("scala" , "scala.tools.nsc.MainGenericRunner", (fullClasspath in Compile in repl).value) ++
+ mkBin("scalac" , "scala.tools.nsc.Main", (fullClasspath in Compile in compiler).value) ++
+ mkBin("fsc" , "scala.tools.nsc.CompileClient", (fullClasspath in Compile in compiler).value) ++
+ mkBin("scaladoc" , "scala.tools.nsc.ScalaDoc", (fullClasspath in Compile in scaladoc).value) ++
+ mkBin("scalap" , "scala.tools.scalap.Main", (fullClasspath in Compile in scalap).value)
+}
+
+buildDirectory in ThisBuild := (baseDirectory in ThisBuild).value / "build-sbt"
+
+lazy val versionProps: Map[String, String] = {
+ import java.io.FileInputStream
+ import java.util.Properties
+ val props = new Properties()
+ val in = new FileInputStream(file("versions.properties"))
+ try props.load(in)
+ finally in.close()
+ import scala.collection.JavaConverters._
+ props.asScala.toMap
+}
+
+def versionNumber(name: String): String =
+ versionProps(s"$name.version.number")
diff --git a/build.xml b/build.xml
index f21423f46b..ca3f517c5e 100755
--- a/build.xml
+++ b/build.xml
@@ -165,7 +165,7 @@ TODO:
<property name="build.dir" value="${basedir}/build"/>
<property name="build-deps.dir" value="${build.dir}/deps"/>
<property name="build-libs.dir" value="${build.dir}/libs"/>
- <property name="build-asm.dir" value="${build.dir}/asm"/>
+ <property name="build-asm.dir" value="${build-libs.dir}"/>
<property name="build-forkjoin.dir" value="${build-libs.dir}"/>
<property name="build-locker.dir" value="${build.dir}/locker"/>
<property name="build-quick.dir" value="${build.dir}/quick"/>
@@ -573,8 +573,8 @@ TODO:
</propertyfile>
</then></if>
- <path id="forkjoin.classpath" path="${build-libs.dir}/classes/forkjoin"/>
- <path id="asm.classpath" path="${build-asm.dir}/classes"/>
+ <path id="forkjoin.classpath" path="${build-forkjoin.dir}/classes/forkjoin"/>
+ <path id="asm.classpath" path="${build-asm.dir}/classes/asm"/>
<property name="forkjoin-classes" refid="forkjoin.classpath"/>
<property name="asm-classes" refid="asm.classpath"/>
@@ -1017,7 +1017,7 @@ TODO:
============================================================================ -->
<target name="asm.done" depends="init"> <simple-javac project="asm" jar="no"/> </target>
- <target name="forkjoin.done" depends="init"> <simple-javac project="forkjoin" args="-XDignore.symbol.file"/></target>
+ <target name="forkjoin.done" depends="init"> <simple-javac project="forkjoin" args="-XDignore.symbol.file" jar="no"/></target>
<!-- For local development only. We only allow released versions of Scala for STARR.
This builds quick (core only) and publishes it with a generated version number,
diff --git a/compare-build-dirs-ignore-patterns b/compare-build-dirs-ignore-patterns
new file mode 100644
index 0000000000..8c8160ba15
--- /dev/null
+++ b/compare-build-dirs-ignore-patterns
@@ -0,0 +1,8 @@
+.DS_Store
+*.complete
+locker
+deps
+scala-continuations-*.jar
+scala-parser-combinators*.jar
+scala-swing*.jar
+scala-xml*.jar
diff --git a/compare-build-dirs.sh b/compare-build-dirs.sh
new file mode 100755
index 0000000000..f6806dd422
--- /dev/null
+++ b/compare-build-dirs.sh
@@ -0,0 +1,5 @@
+# Compares build directories generated by Ant and sbt build definitions
+# This let's us to see how far are we from achieving perfect parity
+# between the builds
+
+diff -X compare-build-dirs-ignore-patterns -qr build/ build-sbt/
diff --git a/project/ScalaTool.scala b/project/ScalaTool.scala
new file mode 100644
index 0000000000..559b215c18
--- /dev/null
+++ b/project/ScalaTool.scala
@@ -0,0 +1,44 @@
+import sbt._
+import org.apache.commons.lang3.StringUtils.replaceEach
+
+/**
+ * A class that generates a shell or batch script to execute a Scala program.
+ *
+ * This is a simplified copy of Ant task (see scala.tools.ant.ScalaTool).
+ */
+case class ScalaTool(mainClass: String,
+ classpath: List[String],
+ properties: Map[String, String],
+ javaOpts: String,
+ toolFlags: String) {
+ // For classpath, the platform specific
+ // demarcation of any script variables (e.g. `${SCALA_HOME}` or
+ // `%SCALA_HOME%`) can be specified in a platform independent way (e.g.
+ // `@SCALA_HOME@`) and automatically translated for you.
+ def patchedToolScript(template: String, platform: String) = {
+ val varRegex = """@(\w+)@""" // the group should be able to capture each of the keys of the map below
+
+ val variables = Map(
+ ("@@" -> "@"), // for backwards compatibility
+ ("@class@" -> mainClass),
+ ("@properties@" -> (properties map { case (k, v) => s"""-D$k="$v""""} mkString " ")),
+ ("@javaflags@" -> javaOpts),
+ ("@toolflags@" -> toolFlags),
+ ("@classpath@" -> (platform match {
+ case "unix" => classpath.mkString(":").replace('\\', '/').replaceAll(varRegex, """\${$1}""")
+ case "windows" => classpath.mkString(";").replace('/', '\\').replaceAll(varRegex, "%$1%")
+ }))
+ )
+
+ val (from, to) = variables.unzip
+ replaceEach(template, from.toArray, to.toArray)
+ }
+
+ def writeScript(file: String, platform: String, rootDir: File, outDir: File): File = {
+ val templatePath = s"scala/tools/ant/templates/tool-$platform.tmpl"
+ val suffix = platform match { case "windows" => ".bat" case _ => "" }
+ val scriptFile = outDir / s"$file$suffix"
+ IO.write(scriptFile, patchedToolScript(IO.read(rootDir / templatePath), platform))
+ scriptFile
+ }
+}
diff --git a/project/build.properties b/project/build.properties
new file mode 100644
index 0000000000..748703f770
--- /dev/null
+++ b/project/build.properties
@@ -0,0 +1 @@
+sbt.version=0.13.7
diff --git a/project/plugins.sbt b/project/plugins.sbt
new file mode 100644
index 0000000000..dc266a8db1
--- /dev/null
+++ b/project/plugins.sbt
@@ -0,0 +1 @@
+libraryDependencies += "org.apache.commons" % "commons-lang3" % "3.3.2" \ No newline at end of file
diff --git a/spec/01-lexical-syntax.md b/spec/01-lexical-syntax.md
index 3972961f58..e26cb796c8 100644
--- a/spec/01-lexical-syntax.md
+++ b/spec/01-lexical-syntax.md
@@ -101,19 +101,18 @@ _ : = => <- <: <% >: # @
The Unicode operators `\u21D2` ‘$\Rightarrow$’ and `\u2190` ‘$\leftarrow$’, which have the ASCII
equivalents `=>` and `<-`, are also reserved.
-### Example
-Here are examples of identifiers:
-```scala
- x Object maxIndex p2p empty_?
- + `yield` αρετη _y dot_product_*
- __system _MAX_LEN_
-```
+> Here are examples of identifiers:
+> ```scala
+> x Object maxIndex p2p empty_?
+> + `yield` αρετη _y dot_product_*
+> __system _MAX_LEN_
+> ```
+
+<!-- -->
-### Example
-When one needs to access Java identifiers that are reserved words in Scala, use backquote-enclosed strings.
-For instance, the statement `Thread.yield()` is illegal, since
-`yield` is a reserved word in Scala. However, here's a
-work-around: `` Thread.`yield`() ``
+> When one needs to access Java identifiers that are reserved words in Scala, use backquote-enclosed strings.
+> For instance, the statement `Thread.yield()` is illegal, since `yield` is a reserved word in Scala.
+> However, here's a work-around: `` Thread.`yield`() ``
## Newline Characters
@@ -205,99 +204,96 @@ A single new line token is accepted
- after an [infix operator](06-expressions.html#prefix,-infix,-and-postfix-operations),
if the first token on the next line can start an expression,
- in front of a [parameter clause](04-basic-declarations-and-definitions.html#function-declarations-and-definitions), and
-- after an [annotation](11-user-defined-annotations.html#user-defined-annotations).
-
-### Example
-
-The newline tokens between the two lines are not
-treated as statement separators.
-
-```scala
-if (x > 0)
- x = x - 1
-
-while (x > 0)
- x = x / 2
-
-for (x <- 1 to 10)
- println(x)
-
-type
- IntList = List[Int]
-```
-
-### Example
-
-```scala
-new Iterator[Int]
-{
- private var x = 0
- def hasNext = true
- def next = { x += 1; x }
-}
-```
-
-With an additional newline character, the same code is interpreted as
-an object creation followed by a local block:
-
-```scala
-new Iterator[Int]
-
-{
- private var x = 0
- def hasNext = true
- def next = { x += 1; x }
-}
-```
-
-### Example
-
-```scala
- x < 0 ||
- x > 10
-```
-
-With an additional newline character, the same code is interpreted as
-two expressions:
-
-```scala
- x < 0 ||
-
- x > 10
-```
-
-### Example
-
-```scala
-def func(x: Int)
- (y: Int) = x + y
-```
-
-With an additional newline character, the same code is interpreted as
-an abstract function definition and a syntactically illegal statement:
-
-```scala
-def func(x: Int)
-
- (y: Int) = x + y
-```
-
-### Example
-
-```scala
-@serializable
-protected class Data { ... }
-```
-
-With an additional newline character, the same code is interpreted as
-an attribute and a separate statement (which is syntactically
-illegal).
-
-```scala
-@serializable
-
-protected class Data { ... }
-```
+- after an [annotation](11-annotations.html#user-defined-annotations).
+
+> The newline tokens between the two lines are not
+> treated as statement separators.
+>
+> ```scala
+> if (x > 0)
+> x = x - 1
+>
+> while (x > 0)
+> x = x / 2
+>
+> for (x <- 1 to 10)
+> println(x)
+>
+> type
+> IntList = List[Int]
+> ```
+
+<!-- -->
+
+> ```scala
+> new Iterator[Int]
+> {
+> private var x = 0
+> def hasNext = true
+> def next = { x += 1; x }
+> }
+> ```
+>
+> With an additional newline character, the same code is interpreted as
+> an object creation followed by a local block:
+>
+> ```scala
+> new Iterator[Int]
+>
+> {
+> private var x = 0
+> def hasNext = true
+> def next = { x += 1; x }
+> }
+> ```
+
+<!-- -->
+
+> ```scala
+> x < 0 ||
+> x > 10
+> ```
+>
+> With an additional newline character, the same code is interpreted as
+> two expressions:
+>
+> ```scala
+> x < 0 ||
+>
+> x > 10
+> ```
+
+<!-- -->
+
+> ```scala
+> def func(x: Int)
+> (y: Int) = x + y
+> ```
+>
+> With an additional newline character, the same code is interpreted as
+> an abstract function definition and a syntactically illegal statement:
+>
+> ```scala
+> def func(x: Int)
+>
+> (y: Int) = x + y
+> ```
+
+<!-- -->
+
+> ```scala
+> @serializable
+> protected class Data { ... }
+> ```
+>
+> With an additional newline character, the same code is interpreted as
+> an attribute and a separate statement (which is syntactically illegal).
+>
+> ```scala
+> @serializable
+>
+> protected class Data { ... }
+> ```
## Literals
@@ -351,11 +347,9 @@ is _pt_. The numeric ranges given by these types are:
|`Short` | $-2\^{15}$ to $2\^{15}-1$|
|`Char` | $0$ to $2\^{16}-1$ |
-### Example
-
-```scala
-0 21 0xFFFFFFFF -42L
-```
+> ```scala
+> 0 21 0xFFFFFFFF -42L
+> ```
### Floating Point Literals
@@ -379,20 +373,18 @@ If a floating point literal in a program is followed by a token
starting with a letter, there must be at least one intervening
whitespace character between the two tokens.
-### Example
+> ```scala
+> 0.0 1e30f 3.14159f 1.0e-100 .1
+> ```
-```scala
-0.0 1e30f 3.14159f 1.0e-100 .1
-```
+<!-- -->
-### Example
+> The phrase `1.toString` parses as three different tokens:
+> the integer literal `1`, a `.`, and the identifier `toString`.
-The phrase `1.toString` parses as three different tokens:
-the integer literal `1`, a `.`, and the identifier `toString`.
+<!-- -->
-### Example
-
-`1.` is not a valid floating point literal because the mandatory digit after the `.` is missing.
+> `1.` is not a valid floating point literal because the mandatory digit after the `.` is missing.
### Boolean Literals
@@ -413,11 +405,9 @@ A character literal is a single character enclosed in quotes.
The character is either a printable unicode character or is described
by an [escape sequence](#escape-sequences).
-### Example
-
-```scala
-'a' '\u0041' '\n' '\t'
-```
+> ```scala
+> 'a' '\u0041' '\n' '\t'
+> ```
Note that `'\u000A'` is _not_ a valid character literal because
Unicode conversion is done before literal parsing and the Unicode
@@ -439,12 +429,10 @@ contains a double quote character, it must be escaped,
i.e. `"\""`. The value of a string literal is an instance of
class `String`.
-### Example
-
-```scala
-"Hello,\nWorld!"
-"This string contains a \" character."
-```
+> ```scala
+> "Hello,\nWorld!"
+> "This string contains a \" character."
+> ```
#### Multi-Line String Literals
@@ -461,45 +449,43 @@ must not necessarily be printable; newlines or other
control characters are also permitted. Unicode escapes work as everywhere else, but none
of the escape sequences [here](#escape-sequences) are interpreted.
-### Example
-
-```scala
- """the present string
- spans three
- lines."""
-```
-
-This would produce the string:
-
-```scala
-the present string
- spans three
- lines.
-```
-
-The Scala library contains a utility method `stripMargin`
-which can be used to strip leading whitespace from multi-line strings.
-The expression
-
-```scala
- """the present string
- |spans three
- |lines.""".stripMargin
-```
-
-evaluates to
-
-```scala
-the present string
-spans three
-lines.
-```
-
-Method `stripMargin` is defined in class
-[scala.collection.immutable.StringLike](http://www.scala-lang.org/api/current/#scala.collection.immutable.StringLike).
-Because there is a predefined
-[implicit conversion](06-expressions.html#implicit-conversions) from `String` to
-`StringLike`, the method is applicable to all strings.
+> ```scala
+> """the present string
+> spans three
+> lines."""
+> ```
+>
+> This would produce the string:
+>
+> ```scala
+> the present string
+> spans three
+> lines.
+> ```
+>
+> The Scala library contains a utility method `stripMargin`
+> which can be used to strip leading whitespace from multi-line strings.
+> The expression
+>
+> ```scala
+> """the present string
+> |spans three
+> |lines.""".stripMargin
+> ```
+>
+> evaluates to
+>
+> ```scala
+> the present string
+> spans three
+> lines.
+> ```
+>
+> Method `stripMargin` is defined in class
+> [scala.collection.immutable.StringLike](http://www.scala-lang.org/api/current/#scala.collection.immutable.StringLike).
+> Because there is a predefined
+> [implicit conversion](06-expressions.html#implicit-conversions) from `String` to
+> `StringLike`, the method is applicable to all strings.
### Escape Sequences
@@ -587,15 +573,13 @@ The scanner switches from XML mode to Scala mode if either
Note that no Scala tokens are constructed in XML mode, and that comments are interpreted
as text.
-### Example
-
-The following value definition uses an XML literal with two embedded
-Scala expressions:
-
-```scala
-val b = <book>
- <title>The Scala Language Specification</title>
- <version>{scalaBook.version}</version>
- <authors>{scalaBook.authors.mkList("", ", ", "")}</authors>
- </book>
-```
+> The following value definition uses an XML literal with two embedded
+> Scala expressions:
+>
+> ```scala
+> val b = <book>
+> <title>The Scala Language Specification</title>
+> <version>{scalaBook.version}</version>
+> <authors>{scalaBook.authors.mkList("", ", ", "")}</authors>
+> </book>
+> ```
diff --git a/spec/02-identifiers-names-and-scopes.md b/spec/02-identifiers-names-and-scopes.md
index 62d326934f..0a9c5dfe77 100644
--- a/spec/02-identifiers-names-and-scopes.md
+++ b/spec/02-identifiers-names-and-scopes.md
@@ -1,5 +1,5 @@
---
-title: Identifiers, Names and Scopes
+title: Identifiers, Names & Scopes
layout: default
chapter: 2
---
@@ -69,7 +69,7 @@ the member of the type $T$ of $e$ which has the name $x$ in the same
namespace as the identifier. It is an error if $T$ is not a [value type](03-types.html#value-types).
The type of $e.x$ is the member type of the referenced entity in $T$.
-### Example
+###### Example
Assume the following two definitions of objects named `X` in packages `P` and `Q`.
diff --git a/spec/03-types.md b/spec/03-types.md
index 5658e15f44..94b7916634 100644
--- a/spec/03-types.md
+++ b/spec/03-types.md
@@ -147,7 +147,7 @@ A qualified type designator has the form `p.t` where `p` is
a [path](#paths) and _t_ is a type name. Such a type designator is
equivalent to the type projection `p.type#t`.
-### Example
+###### Example
Some type designators and their expansions are listed below. We assume
a local type parameter $t$, a value `maintable`
@@ -178,7 +178,8 @@ well-formed if each actual type parameter
_conforms to its bounds_, i.e. $\sigma L_i <: T_i <: \sigma U_i$ where $\sigma$ is the
substitution $[ a_1 := T_1 , \ldots , a_n := T_n ]$.
-### Example Parameterized Types
+###### Example Parameterized Types
+
Given the partial type definitions:
```scala
@@ -202,7 +203,7 @@ F[List, Int]
G[S, String]
```
-### Example
+###### Example
Given the [above type definitions](#example-parameterized-types),
the following types are ill-formed:
@@ -255,10 +256,10 @@ AnnotType ::= SimpleType {Annotation}
```
An annotated type $T$ $a_1, \ldots, a_n$
-attaches [annotations](11-user-defined-annotations.html#user-defined-annotations)
+attaches [annotations](11-annotations.html#user-defined-annotations)
$a_1 , \ldots , a_n$ to the type $T$.
-### Example
+###### Example
The following type adds the `@suspendable` annotation to the type `String`:
@@ -304,7 +305,7 @@ A compound type may also consist of just a refinement
$\\{ R \\}$ with no preceding component types. Such a type is
equivalent to `AnyRef` $\\{ R \\}$.
-### Example
+###### Example
The following example shows how to declare and use a method which
a parameter type that contains a refinement with structural declarations.
@@ -500,7 +501,7 @@ or [tuple types](#tuple-types).
Their expansion is then the expansion in the equivalent parameterized
type.
-### Example
+###### Example
Assume the class definitions
@@ -524,7 +525,7 @@ An alternative formulation of the first type above using wildcard syntax is:
Ref[_ <: java.lang.Number]
```
-### Example
+###### Example
The type `List[List[_]]` is equivalent to the existential type
@@ -532,7 +533,7 @@ The type `List[List[_]]` is equivalent to the existential type
List[List[t] forSome { type t }] .
```
-### Example
+###### Example
Assume a covariant type
@@ -658,7 +659,7 @@ same name, we model
An overloaded type consisting of type alternatives $T_1 \commadots T_n (n \geq 2)$ is denoted internally $T_1 \overload \ldots \overload T_n$.
-### Example
+###### Example
```
def println: Unit
def println(s: String): Unit = $\ldots$
@@ -676,7 +677,7 @@ println: => Unit $\overload$
[A] (A) (A => String) Unit
```
-### Example
+###### Example
```
def f(x: T): T = $\ldots$
val f = 0
@@ -834,8 +835,7 @@ transitive relation that satisfies the following conditions.
- For every type constructor $T$ (with any number of type parameters),
`scala.Nothing <: $T$ <: scala.Any`.
-- For every class type $T$ such that `$T$ <: scala.AnyRef` and not
- `$T$ <: scala.NotNull` one has `scala.Null <: $T$`.
+- For every class type $T$ such that `$T$ <: scala.AnyRef` one has `scala.Null <: $T$`.
- A type variable or abstract type $t$ conforms to its upper bound and
its lower bound conforms to $t$.
- A class type or parameterized type conforms to any of its base-types.
diff --git a/spec/04-basic-declarations-and-definitions.md b/spec/04-basic-declarations-and-definitions.md
index 65d79dd5f4..7fb5427d36 100644
--- a/spec/04-basic-declarations-and-definitions.md
+++ b/spec/04-basic-declarations-and-definitions.md
@@ -1,5 +1,5 @@
---
-title: Basic Declarations and Definitions
+title: Basic Declarations & Definitions
layout: default
chapter: 4
---
@@ -563,7 +563,7 @@ abstract class Sequence[+A] {
}
```
-### Example
+###### Example
```scala
abstract class OutputChannel[-A] {
diff --git a/spec/05-classes-and-objects.md b/spec/05-classes-and-objects.md
index 8681c93193..a6908ba39f 100644
--- a/spec/05-classes-and-objects.md
+++ b/spec/05-classes-and-objects.md
@@ -1,5 +1,5 @@
---
-title: Classes and Objects
+title: Classes & Objects
layout: default
chapter: 5
---
@@ -368,7 +368,7 @@ it is possible to add new defaults (if the corresponding parameter in the
superclass does not have a default) or to override the defaults of the
superclass (otherwise).
-### Example
+###### Example
Consider the definitions:
@@ -699,7 +699,7 @@ Here,
parameter section is called _polymorphic_, otherwise it is called
_monomorphic_.
- $as$ is a possibly empty sequence of
- [annotations](11-user-defined-annotations.html#user-defined-annotations).
+ [annotations](11-annotations.html#user-defined-annotations).
If any annotations are given, they apply to the primary constructor of the
class.
- $m$ is an [access modifier](#modifiers) such as
@@ -744,7 +744,7 @@ which when applied to parameters conforming to types $\mathit{ps}$
initializes instances of type `$c$[$\mathit{tps}\,$]` by evaluating the template
$t$.
-### Example
+###### Example
The following example illustrates `val` and `var` parameters of a class `C`:
```scala
@@ -990,7 +990,7 @@ it is not statically known at the time the trait is defined.
If $D$ is not a trait, then its actual supertype is simply its
least proper supertype (which is statically known).
-### Example
+###### Example
The following trait defines the property
of being comparable to objects of some type. It contains an abstract
method `<` and default implementations of the other
diff --git a/spec/06-expressions.md b/spec/06-expressions.md
index 133ec3c8e5..da9e21f267 100644
--- a/spec/06-expressions.md
+++ b/spec/06-expressions.md
@@ -148,10 +148,6 @@ The selection $e.x$ is evaluated by first evaluating the qualifier
expression $e$, which yields an object $r$, say. The selection's
result is then the member of $r$ that is either defined by $m$ or defined
by a definition overriding $m$.
-If that member has a type which
-conforms to `scala.NotNull`, the member's value must be initialized
-to a value different from `null`, otherwise a `scala.UnitializedError`
-is thrown.
## This and Super
@@ -205,7 +201,7 @@ to the type or method of $x$ in the parent trait of $C$ whose simple
name is $T$. That member must be uniquely defined. If it is a method,
it must be concrete.
-### Example
+###### Example
Consider the following class definitions
```scala
@@ -778,7 +774,7 @@ Expr1 ::= PostfixExpr `:' Annotation {Annotation}
```
An annotated expression `$e$: @$a_1$ $\ldots$ @$a_n$`
-attaches [annotations](11-user-defined-annotations.html#user-defined-annotations) $a_1 , \ldots , a_n$ to the
+attaches [annotations](11-annotations.html#user-defined-annotations) $a_1 , \ldots , a_n$ to the
expression $e$.
## Assignments
@@ -815,7 +811,7 @@ Here are some assignment expressions and their equivalent expansions.
|`x.f(i) = e` | `x.f.update(i, e)` |
|`x.f(i, j) = e` | `x.f.update(i, j, e)`|
-### Example Imperative Matrix Multiplication
+###### Example Imperative Matrix Multiplication
Here is the usual imperative code for matrix multiplication.
@@ -1221,9 +1217,9 @@ In that case, a fresh name for the parameter is chosen arbitrarily.
A named parameter of an anonymous function may be optionally preceded
by an `implicit` modifier. In that case the parameter is
-labeled [`implicit`](07-implicit-parameters-and-views.html#implicit-parameters-and-views); however the
+labeled [`implicit`](07-implicits.html#implicit-parameters-and-views); however the
parameter section itself does not count as an implicit parameter
-section in the sense defined [here](07-implicit-parameters-and-views.html#implicit-parameters). Hence, arguments to
+section in the sense defined [here](07-implicits.html#implicit-parameters). Hence, arguments to
anonymous functions always have to be given explicitly.
###### Example
@@ -1341,7 +1337,7 @@ available implicit conversions are given in the next two sub-sections.
We say, a type $T$ is _compatible_ to a type $U$ if $T$ weakly conforms
to $U$ after applying [eta-expansion](#eta-expansion) and
-[view applications](07-implicit-parameters-and-views.html#views).
+[view applications](07-implicits.html#views).
### Value Conversions
@@ -1389,7 +1385,7 @@ term `{ $e$; () }`.
###### View Application
If none of the previous conversions applies, and $e$'s type
does not conform to the expected type $\mathit{pt}$, it is attempted to convert
-$e$ to the expected type with a [view](07-implicit-parameters-and-views.html#views).
+$e$ to the expected type with a [view](07-implicits.html#views).
###### Dynamic Member Selection
If none of the previous conversions applies, and $e$ is a prefix
@@ -1408,7 +1404,7 @@ type $T$ by evaluating the expression to which $m$ is bound.
###### Implicit Application
If the method takes only implicit parameters, implicit
-arguments are passed following the rules [here](07-implicit-parameters-and-views.html#implicit-parameters).
+arguments are passed following the rules [here](07-implicits.html#implicit-parameters).
###### Eta Expansion
Otherwise, if the method is not a constructor,
diff --git a/spec/07-implicit-parameters-and-views.md b/spec/07-implicits.md
index 27a50cf058..5e10373959 100644
--- a/spec/07-implicit-parameters-and-views.md
+++ b/spec/07-implicits.md
@@ -1,10 +1,10 @@
---
-title: Implicit Parameters and Views
+title: Implicits
layout: default
chapter: 7
---
-# Implicit Parameters and Views
+# Implicits
## The Implicit Modifier
@@ -19,7 +19,8 @@ and can be used as implicit conversions called [views](#views).
The `implicit` modifier is illegal for all
type members, as well as for [top-level objects](09-top-level-definitions.html#packagings).
-### Example Monoid
+###### Example Monoid
+
The following code defines an abstract class of monoids and
two concrete implementations, `StringMonoid` and
`IntMonoid`. The two implementations are marked implicit.
@@ -180,7 +181,7 @@ To prevent such infinite expansions, the compiler keeps track of
a stack of “open implicit types” for which implicit arguments are currently being
searched. Whenever an implicit argument for type $T$ is searched, the
“core type” of $T$ is added to the stack. Here, the _core type_
-of $T$ is $T$ with aliases expanded, top-level type [annotations](11-user-defined-annotations.html#user-defined-annotations) and
+of $T$ is $T$ with aliases expanded, top-level type [annotations](11-annotations.html#user-defined-annotations) and
[refinements](03-types.html#compound-types) removed, and occurrences
of top-level existentially bound variables replaced by their upper
bounds. The core type is removed from the stack once the search for
@@ -284,7 +285,8 @@ As for implicit parameters, overloading resolution is applied
if there are several possible candidates (of either the call-by-value
or the call-by-name category).
-### Example Ordered
+###### Example Ordered
+
Class `scala.Ordered[A]` contains a method
```scala
diff --git a/spec/08-pattern-matching.md b/spec/08-pattern-matching.md
index e75bddc096..c494fbcef5 100644
--- a/spec/08-pattern-matching.md
+++ b/spec/08-pattern-matching.md
@@ -371,7 +371,7 @@ bound type variables in a typed pattern or constructor
pattern. Inference takes into account the expected type of the
pattern.
-### Type parameter inference for typed patterns.
+### Type parameter inference for typed patterns
Assume a typed pattern $p: T'$. Let $T$ result from $T'$ where all wildcards in
$T'$ are renamed to fresh variable names. Let $a_1 , \ldots , a_n$ be
@@ -437,7 +437,7 @@ complexity of inferred bounds. Minimality and maximality of types have
to be understood relative to the set of types of acceptable
complexity.
-#### Type parameter inference for constructor patterns.
+### Type parameter inference for constructor patterns
Assume a constructor pattern $C(p_1 , \ldots , p_n)$ where class $C$
has type type parameters $a_1 , \ldots , a_n$. These type parameters
are inferred in the same way as for the typed pattern
@@ -593,7 +593,7 @@ the compilation of pattern matching can emit warnings which diagnose
that a given set of patterns is not exhaustive, i.e. that there is a
possibility of a `MatchError` being raised at run-time.
-### Example
+###### Example
Consider the following definitions of arithmetic terms:
diff --git a/spec/10-xml-expressions-and-patterns.md b/spec/10-xml-expressions-and-patterns.md
index 407b2b9a67..b70fb86471 100644
--- a/spec/10-xml-expressions-and-patterns.md
+++ b/spec/10-xml-expressions-and-patterns.md
@@ -1,5 +1,5 @@
---
-title: XML Expressions and Patterns
+title: XML
layout: default
chapter: 10
---
diff --git a/spec/11-user-defined-annotations.md b/spec/11-annotations.md
index 2c5830c103..d66f24abf8 100644
--- a/spec/11-user-defined-annotations.md
+++ b/spec/11-annotations.md
@@ -1,17 +1,19 @@
---
-title: User-Defined Annotations
+title: Annotations
layout: default
chapter: 11
---
-# User-Defined Annotations
+# Annotations
```ebnf
Annotation ::= ‘@’ SimpleType {ArgumentExprs}
ConstrAnnotation ::= ‘@’ SimpleType ArgumentExprs
```
-User-defined annotations associate meta-information with definitions.
+## Definition
+
+Annotations associate meta-information with definitions.
A simple annotation has the form `@$c$` or `@$c(a_1 , \ldots , a_n)$`.
Here, $c$ is a constructor of a class $C$, which must conform
to the class `scala.Annotation`.
@@ -33,6 +35,10 @@ String @local // Type annotation
(e: @unchecked) match { ... } // Expression annotation
```
+## Predefined Annotations
+
+### Java Platform Annotations
+
The meaning of annotation clauses is implementation-dependent. On the
Java platform, the following annotations have a standard meaning.
@@ -61,7 +67,7 @@ Java platform, the following annotations have a standard meaning.
clause for the method or constructor must mention the class of that exception
or one of the superclasses of the class of that exception.
-## Java Beans Annotations
+### Java Beans Annotations
* `@scala.beans.BeanProperty` When prefixed to a definition of some variable `X`, this
annotation causes getter and setter methods `getX`, `setX`
@@ -76,18 +82,21 @@ Java platform, the following annotations have a standard meaning.
* `@scala.beans.BooleanBeanProperty` This annotation is equivalent to `scala.reflect.BeanProperty`, but
the generated getter method is named `isX` instead of `getX`.
-## Deprecation Annotations
+### Deprecation Annotations
- * `@deprecated(<stringlit>)` Marks a definition as deprecated. Accesses to the
+ * `@deprecated(message: <stringlit>, since: <stringlit>)`<br/>
+ Marks a definition as deprecated. Accesses to the
defined entity will then cause a deprecated warning mentioning the
- message `<stringlit>` to be issued from the compiler. Deprecated
- warnings are suppressed in code that belongs itself to a definition
+ _message_ `<stringlit>` to be issued from the compiler.
+ The argument _since_ documents since when the definition should be considered deprecated.<br/>
+ Deprecated warnings are suppressed in code that belongs itself to a definition
that is labeled deprecated.
- * `@deprecatedName(name: <symbollit>)` Marks a formal parameter name as deprecated. Invocations of this entity
+ * `@deprecatedName(name: <symbollit>)`<br/>
+ Marks a formal parameter name as deprecated. Invocations of this entity
using named parameter syntax refering to the deprecated parameter name cause a deprecation warning.
-## Scala Compiler Annotations
+### Scala Compiler Annotations
* `@unchecked` When applied to the selector of a `match` expression,
this attribute suppresses any warnings about non-exhaustive pattern
@@ -141,6 +150,8 @@ Java platform, the following annotations have a standard meaning.
a definition, the compiler will instead use the specialized version.
See the [specialization sid](http://docs.scala-lang.org/sips/completed/scala-specialization.html) for more details of the implementation.
+## User-defined Annotations
+
Other annotations may be interpreted by platform- or
application-dependent tools. Class `scala.Annotation` has two
sub-traits which are used to indicate how these annotations are
diff --git a/spec/12-the-scala-standard-library.md b/spec/12-the-scala-standard-library.md
index 988d9804ec..e76035f458 100644
--- a/spec/12-the-scala-standard-library.md
+++ b/spec/12-the-scala-standard-library.md
@@ -1,5 +1,5 @@
---
-title: The Scala Standard Library
+title: Standard Library
layout: default
chapter: 12
---
@@ -233,7 +233,7 @@ for type `Int` and for all subrange types.
The `toString` method displays its receiver as an integer or
floating point number.
-### Example
+###### Example
This is the signature of the numeric value type `Int`:
@@ -332,7 +332,7 @@ The `toString` method returns `"()"`.
## Standard Reference Classes
This section presents some standard Scala reference classes which are
-treated in a special way by the Scala compiler -- either Scala provides
+treated in a special way by the Scala compiler – either Scala provides
syntactic sugar for them, or the Scala compiler generates special code
for their operations. Other classes in the standard Scala library are
documented in the Scala library documentation by HTML pages.
diff --git a/spec/13-syntax-summary.md b/spec/13-syntax-summary.md
index 2b9571cc73..7f73e107de 100644
--- a/spec/13-syntax-summary.md
+++ b/spec/13-syntax-summary.md
@@ -15,6 +15,8 @@ UnicodeEscape ::= ‘\‘ ‘u‘ {‘u‘} hexDigit hexDigit hexDigit hexDigit
hexDigit ::= ‘0’ | … | ‘9’ | ‘A’ | … | ‘F’ | ‘a’ | … | ‘f’
```
+## Lexical Syntax
+
The lexical syntax of Scala is given by the following grammar in EBNF form:
```ebnf
@@ -72,8 +74,10 @@ nl ::= $\mathit{“new line character”}$
semi ::= ‘;’ | nl {nl}
```
+## Context-free Syntax
+
The context-free syntax of Scala is given by the following EBNF
-grammar.
+grammar:
```ebnf
Literal ::= [‘-’] integerLiteral
diff --git a/spec/15-changelog.md b/spec/15-changelog.md
new file mode 100644
index 0000000000..54310c921c
--- /dev/null
+++ b/spec/15-changelog.md
@@ -0,0 +1,823 @@
+---
+title: Changelog
+layout: default
+chapter: 15
+---
+
+# Changelog
+
+Changes in Version 2.8.0
+------------------------
+
+#### Trailing commas
+
+Trailing commas in expression, argument, type or pattern sequences are
+no longer supported.
+
+Changes in Version 2.8
+----------------------
+
+Changed visibility rules for nested packages (where done?)
+
+Changed [visibility rules](02-identifiers-names-and-scopes.html)
+so that packages are no longer treated specially.
+
+Added section on [weak conformance](03-types.html#weak-conformance).
+Relaxed type rules for conditionals,
+match expressions, try expressions to compute their result type using
+least upper bound wrt weak conformance. Relaxed type rule for local type
+inference so that argument types need only weekly conform to inferred
+formal parameter types. Added section on
+[numeric widening](06-expressions.html#numeric-widening) to support
+weak conformance.
+
+Tightened rules to avoid accidential [overrides](05-classes-and-objects.html#overriding).
+
+Removed class literals.
+
+Added section on [context bounds](07-implicits.html#context-bounds-and-view-bounds).
+
+Clarified differences between [`isInstanceOf` and pattern matches](12-the-scala-standard-library.html#root-classes).
+
+Allowed [`implicit` modifier on function literals](06-expressions.html#anonymous-functions) with a single parameter.
+
+Changes in Version 2.7.2
+------------------------
+
+_(10-Nov-2008)_
+
+#### Precedence of Assignment Operators
+
+The [precedence of assignment operators](06-expressions.html#prefix,-infix,-and-postfix-operations)
+has been brought in line with. From now on `+=`, has the same precedence as `=`.
+
+#### Wildcards as function parameters
+
+A formal parameter to an anonymous fucntion may now be a
+[wildcard represented by an underscore](06-expressions.html#placeholder-syntax-for-anonymous-functions).
+
+> _ => 7 // The function that ignores its argument
+> // and always returns 7.
+
+#### Unicode alternative for left arrow
+
+The Unicode glyph ‘\\(\leftarrow\\)’ \\(`\u2190`\\) is now treated as a reserved
+identifier, equivalent to the ASCII symbol ‘`<-`’.
+
+Changes in Version 2.7.1
+------------------------
+
+_(09-April-2008)_
+
+#### Change in Scoping Rules for Wildcard Placeholders in Types
+
+A wildcard in a type now binds to the closest enclosing type
+application. For example `List[List[_]]` is now equivalent to this
+existential type:
+
+ List[List[t] forSome { type t }]
+
+In version 2.7.0, the type expanded instead to:
+
+ List[List[t]] forSome { type t }
+
+The new convention corresponds exactly to the way wildcards in Java are
+interpreted.
+
+#### No Contractiveness Requirement for Implicits
+
+The contractiveness requirement for
+[implicit method definitions](07-implicits.html#implicit-parameters)
+has been dropped. Instead it is checked for each implicit expansion individually
+that the expansion does not result in a cycle or a tree of infinitely
+growing types.
+
+Changes in Version 2.7.0
+------------------------
+
+_(07-Feb-2008)_
+
+#### Java Generics
+
+Scala now supports Java generic types by default:
+
+- A generic type in Java such as `ArrayList<String>` is translated to
+ a generic type in Scala: `ArrayList[String]`.
+
+- A wildcard type such as `ArrayList<? extends Number>` is translated
+ to `ArrayList[_ <: Number]`. This is itself a shorthand for the
+ existential type `ArrayList[T] forSome { type T <: Number }`.
+
+- A raw type in Java such as `ArrayList` is translated to
+ `ArrayList[_]`, which is a shorthand for
+ `ArrayList[T] forSome { type T }`.
+
+This translation works if `-target:jvm-1.5` is specified, which is the
+new default. For any other target, Java generics are not recognized. To
+ensure upgradability of Scala codebases, extraneous type parameters for
+Java classes under `-target:jvm-1.4` are simply ignored. For instance,
+when compiling with `-target:jvm-1.4`, a Scala type such as
+`ArrayList[String]` is simply treated as the unparameterized type
+`ArrayList`.
+
+#### Changes to Case Classes
+
+The Scala compiler generates now for every case class a companion
+extractor object (). For instance, given the case class:
+
+ case class X(elem: String)
+
+the following companion object is generated:
+
+ object X {
+ def unapply(x: X): Some[String] = Some(x.elem)
+ def apply(s: String): X = new X(s)
+ }
+
+If the object exists already, only the `apply` and `unapply` methods are
+added to it.
+
+Three restrictions on case classes have been removed.
+
+1. Case classes can now inherit from other case classes.
+
+2. Case classes may now be `abstract`.
+
+3. Case classes may now come with companion objects.
+
+Changes in Version 2.6.1
+------------------------
+
+_(30-Nov-2007)_
+
+#### Mutable variables introduced by pattern binding
+
+Mutable variables can now be introduced by a pattern matching definition
+(), just like values can. Examples:
+
+ var (x, y) = if (positive) (1, 2) else (-1, -3)
+ var hd :: tl = mylist
+
+#### Self-types
+
+Self types can now be introduced without defining an alias name for
+`this` (). Example:
+
+ class C {
+ type T <: Trait
+ trait Trait { this: T => ... }
+ }
+
+Changes in Version 2.6
+----------------------
+
+_(27-July-2007)_
+
+#### Existential types
+
+It is now possible to define existential types (). An existential type
+has the form `T forSome {Q}` where `Q` is a sequence of value and/or
+type declarations. Given the class definitions
+
+ class Ref[T]
+ abstract class Outer { type T }
+
+one may for example write the following existential types
+
+ Ref[T] forSome { type T <: java.lang.Number }
+ Ref[x.T] forSome { val x: Outer }
+
+#### Lazy values
+
+It is now possible to define lazy value declarations using the new
+modifier `lazy` (). A `lazy` value definition evaluates its right hand
+side \\(e\\) the first time the value is accessed. Example:
+
+ import compat.Platform._
+ val t0 = currentTime
+ lazy val t1 = currentTime
+ val t2 = currentTime
+
+ println("t0 <= t2: " + (t0 <= t2)) //true
+ println("t1 <= t2: " + (t1 <= t2)) //false (lazy evaluation of t1)
+
+#### Structural types
+
+It is now possible to declare structural types using type refinements
+(). For example:
+
+ class File(name: String) {
+ def getName(): String = name
+ def open() { /*..*/ }
+ def close() { println("close file") }
+ }
+ def test(f: { def getName(): String }) { println(f.getName) }
+
+ test(new File("test.txt"))
+ test(new java.io.File("test.txt"))
+
+There’s also a shorthand form for creating values of structural types.
+For instance,
+
+ new { def getName() = "aaron" }
+
+is a shorthand for
+
+ new AnyRef{ def getName() = "aaron" }
+
+Changes in Version 2.5
+----------------------
+
+_(02-May-2007)_
+
+#### Type constructor polymorphism[^1]
+
+Type parameters () and abstract type members () can now also abstract
+over type constructors ().
+
+This allows a more precise `Iterable` interface:
+
+ trait Iterable[+T] {
+ type MyType[+T] <: Iterable[T] // MyType is a type constructor
+
+ def filter(p: T => Boolean): MyType[T] = ...
+ def map[S](f: T => S): MyType[S] = ...
+ }
+
+ abstract class List[+T] extends Iterable[T] {
+ type MyType[+T] = List[T]
+ }
+
+This definition of `Iterable` makes explicit that mapping a function
+over a certain structure (e.g., a `List`) will yield the same structure
+(containing different elements).
+
+#### Early object initialization
+
+It is now possible to initialize some fields of an object before any
+parent constructors are called (). This is particularly useful for
+traits, which do not have normal constructor parameters. Example:
+
+ trait Greeting {
+ val name: String
+ val msg = "How are you, "+name
+ }
+ class C extends {
+ val name = "Bob"
+ } with Greeting {
+ println(msg)
+ }
+
+In the code above, the field is initialized before the constructor of is
+called. Therefore, field `msg` in class is properly initialized to .
+
+#### For-comprehensions, revised
+
+The syntax of for-comprehensions has changed (). In the new syntax,
+generators do not start with a anymore, but filters start with an (and
+are called guards). A semicolon in front of a guard is optional. For
+example:
+
+ for (val x <- List(1, 2, 3); x % 2 == 0) println(x)
+
+is now written
+
+ for (x <- List(1, 2, 3) if x % 2 == 0) println(x)
+
+The old syntax is still available but will be deprecated in the future.
+
+#### Implicit anonymous functions
+
+It is now possible to define anonymous functions using underscores in
+parameter position (). For instance, the expressions in the left column
+are each function values which expand to the anonymous functions on
+their right.
+
+ _ + 1 x => x + 1
+ _ * _ (x1, x2) => x1 * x2
+ (_: int) * 2 (x: int) => (x: int) * 2
+ if (_) x else y z => if (z) x else y
+ _.map(f) x => x.map(f)
+ _.map(_ + 1) x => x.map(y => y + 1)
+
+As a special case (), a partially unapplied method is now designated
+ `m _`   instead of the previous notation  `&m`.
+
+The new notation will displace the special syntax forms `.m()` for
+abstracting over method receivers and `&m` for treating an unapplied
+method as a function value. For the time being, the old syntax forms are
+still available, but they will be deprecated in the future.
+
+#### Pattern matching anonymous functions, refined
+
+It is now possible to use case clauses to define a function value
+directly for functions of arities greater than one (). Previously, only
+unary functions could be defined that way. Example:
+
+ def scalarProduct(xs: Array[Double], ys: Array[Double]) =
+ (0.0 /: (xs zip ys)) {
+ case (a, (b, c)) => a + b * c
+ }
+
+Changes in Version 2.4
+----------------------
+
+_(09-Mar-2007)_
+
+#### Object-local private and protected
+
+The `private` and `protected` modifiers now accept a `[this]` qualifier
+(). A definition \\(M\\) which is labelled `private[this]` is private,
+and in addition can be accessed only from within the current object.
+That is, the only legal prefixes for \\(M\\) are `this` or `$C$.this`.
+Analogously, a definition \\(M\\) which is labelled `protected[this]` is
+protected, and in addition can be accessed only from within the current
+object.
+
+#### Tuples, revised
+
+The syntax for [tuples](06-expressions.html#tuples) has been changed from \\(\\{…\\}\\) to
+\\((…)\\). For any sequence of types \\(T_1 , … , T_n\\),
+
+\\((T_1 , … , T_n)\\) is a shorthand for `Tuple$n$[$T_1 , … , T_n$]`.
+
+Analogously, for any sequence of expressions or patterns \\(x_1
+, … , x_n\\),
+
+\\((x_1 , … , x_n)\\) is a shorthand for `Tuple$n$($x_1 , … , x_n$)`.
+
+#### Access modifiers for primary constructors
+
+The primary constructor of a class can now be marked or (). If such an
+access modifier is given, it comes between the name of the class and its
+value parameters. Example:
+
+ class C[T] private (x: T) { ... }
+
+#### Annotations
+
+The support for attributes has been extended and its syntax changed ().
+Attributes are now called <span>*annotations*</span>. The syntax has
+been changed to follow Java’s conventions, e.g. `@attribute` instead of
+`[attribute]`. The old syntax is still available but will be deprecated
+in the future.
+
+Annotations are now serialized so that they can be read by compile-time
+or run-time tools. Class has two sub-traits which are used to indicate
+how annotations are retained. Instances of an annotation class
+inheriting from trait will be stored in the generated class files.
+Instances of an annotation class inheriting from trait will be visible
+to the Scala type-checker in every compilation unit where the annotated
+symbol is accessed.
+
+#### Decidable subtyping
+
+The implementation of subtyping has been changed to prevent infinite
+recursions. Termination of subtyping is now ensured by a new restriction
+of class graphs to be finitary ().
+
+#### Case classes cannot be abstract
+
+It is now explicitly ruled out that case classes can be abstract (). The
+specification was silent on this point before, but did not explain how
+abstract case classes were treated. The Scala compiler allowed the
+idiom.
+
+#### New syntax for self aliases and self types
+
+It is now possible to give an explicit alias name and/or type for the
+self reference (). For instance, in
+
+ class C { self: D =>
+ ...
+ }
+
+the name is introduced as an alias for within and the self type () of is
+assumed to be . This construct is introduced now in order to replace
+eventually both the qualified this construct and the clause in Scala.
+
+#### Assignment Operators
+
+It is now possible to combine operators with assignments (). Example:
+
+ var x: int = 0
+ x += 1
+
+Changes in Version 2.3.2
+------------------------
+
+_(23-Jan-2007)_
+
+#### Extractors
+
+It is now possible to define patterns independently of case classes,
+using methods in extractor objects (). Here is an example:
+
+ object Twice {
+ def apply(x:Int): int = x*2
+ def unapply(z:Int): Option[int] = if (z%2==0) Some(z/2) else None
+ }
+ val x = Twice(21)
+ x match { case Twice(n) => Console.println(n) } // prints 21
+
+In the example, `Twice` is an extractor object with two methods:
+
+- The method is used to build even numbers.
+
+- The method is used to decompose an even number; it is in a sense the
+ reverse of . `unapply` methods return option types: for a match that
+ suceeds, for a match that fails. Pattern variables are returned as
+ the elements of . If there are several variables, they are grouped
+ in a tuple.
+
+In the second-to-last line, ’s method is used to construct a number . In
+the last line, is tested against the pattern . This pattern succeeds for
+even numbers and assigns to the variable one half of the number that was
+tested. The pattern match makes use of the method of object . More
+details on extractors can be found in the paper “Matching Objects with
+Patterns” by Emir, Odersky and Williams.
+
+#### Tuples
+
+A new lightweight syntax for tuples has been introduced (). For any
+sequence of types \\(T_1 , … , T_n\\),
+
+\\(\{T_1 , … , T_n \}\\) is a shorthand for `Tuple$n$[$T_1 , … , T_n$]`.
+
+Analogously, for any sequence of expressions or patterns \\(x_1, … , x_n\\),
+
+\\(\{x_1 , … , x_n \}\\) is a shorthand for `Tuple$n$($x_1 , … , x_n$)`.
+
+#### Infix operators of greater arities
+
+It is now possible to use methods which have more than one parameter as
+infix operators (). In this case, all method arguments are written as a
+normal parameter list in parentheses. Example:
+
+ class C {
+ def +(x: int, y: String) = ...
+ }
+ val c = new C
+ c + (1, "abc")
+
+#### Deprecated attribute
+
+A new standard attribute `deprecated` is available (11-annotations.html#deprecation-annotations). If a member
+definition is marked with this attribute, any reference to the member
+will cause a “deprecated” warning message to be emitted.
+
+Changes in Version 2.3
+----------------------
+
+_(23-Nov-2006)_
+
+#### Procedures
+
+A simplified syntax for functions returning `unit` has been introduced
+(). Scala now allows the following shorthands:
+
+`def f(params)` \\(\mbox{for}\\) `def f(params): unit`
+`def f(params) { ... }` \\(\mbox{for}\\) `def f(params): unit = { ... }`
+
+#### Type Patterns
+
+The syntax of types in patterns has been refined (). Scala now
+distinguishes between type variables (starting with a lower case letter)
+and types as type arguments in patterns. Type variables are bound in the
+pattern. Other type arguments are, as in previous versions, erased. The
+Scala compiler will now issue an “unchecked” warning at places where
+type erasure might compromise type-safety.
+
+#### Standard Types
+
+The recommended names for the two bottom classes in Scala’s type
+hierarchy have changed as follows:
+
+ All ==> Nothing
+ AllRef ==> Null
+
+The old names are still available as type aliases.
+
+Changes in Version 2.1.8
+------------------------
+
+_(23-Aug-2006)_
+
+#### Visibility Qualifier for protected
+
+Protected members can now have a visibility qualifier (), e.g.
+`protected[<qualifier>]`. In particular, one can now simulate package
+protected access as in Java writing
+
+ protected[P] def X ...
+
+where would name the package containing .
+
+#### Relaxation of Private Acess
+
+Private members of a class can now be referenced from the companion
+module of the class and vice versa ()
+
+#### Implicit Lookup
+
+The lookup method for implicit definitions has been generalized (). When
+searching for an implicit definition matching a type \\(T\\), now are
+considered
+
+1. all identifiers accessible without prefix, and
+
+2. all members of companion modules of classes associated with \\(T\\).
+
+(The second clause is more general than before). Here, a class is
+<span>*associated*</span> with a type \\(T\\) if it is referenced by
+some part of \\(T\\), or if it is a base class of some part of \\(T\\).
+For instance, to find implicit members corresponding to the type
+
+ HashSet[List[Int], String]
+
+one would now look in the companion modules (aka static parts) of , , ,
+and . Before, it was just the static part of .
+
+#### Tightened Pattern Match
+
+A typed pattern match with a singleton type now tests whether the
+selector value is reference-equal to p (). Example:
+
+ val p = List(1, 2, 3)
+ val q = List(1, 2)
+ val r = q
+ r match {
+ case _: p.type => Console.println("p")
+ case _: q.type => Console.println("q")
+ }
+
+This will match the second case and hence will print “”. Before, the
+singleton types were erased to , and therefore the first case would have
+matched, which is non-sensical.
+
+Changes in Version 2.1.7
+------------------------
+
+_(19-Jul-2006)_
+
+#### Multi-Line string literals
+
+It is now possible to write multi-line string-literals enclosed in
+triple quotes (). Example:
+
+ """this is a
+ multi-line
+ string literal"""
+
+No escape substitutions except for unicode escapes are performed in such
+string literals.
+
+#### Closure Syntax
+
+The syntax of closures has been slightly restricted (). The form
+
+ x: T => E
+
+is valid only when enclosed in braces, i.e.  `{ x: T => E }`. The
+following is illegal, because it might be read as the value x typed with
+the type T =\> E:
+
+ val f = x: T => E
+
+Legal alternatives are:
+
+ val f = { x: T => E }
+ val f = (x: T) => E
+
+Changes in Version 2.1.5
+------------------------
+
+_(24-May-2006)_
+
+#### Class Literals
+
+There is a new syntax for class literals (): For any class type \\(C\\),
+`classOf[$C$]` designates the run-time representation of \\(C\\).
+
+Changes in Version 2.0
+----------------------
+
+_(12-Mar-2006)_
+
+Scala in its second version is different in some details from the first
+version of the language. There have been several additions and some old
+idioms are no longer supported. This appendix summarizes the main
+changes.
+
+#### New Keywords
+
+The following three words are now reserved; they cannot be used as
+identifiers ()
+
+ implicit match requires
+
+#### Newlines as Statement Separators
+
+Newlines can now be used as statement separators in place of semicolons
+()
+
+#### Syntax Restrictions
+
+There are some other situations where old constructs no longer work:
+
+##### *Pattern matching expressions*
+
+The `match` keyword now appears only as infix operator between a
+selector expression and a number of cases, as in:
+
+ expr match {
+ case Some(x) => ...
+ case None => ...
+ }
+
+Variants such as ` expr.match {...} ` or just ` match {...} ` are no
+longer supported.
+
+##### *“With” in extends clauses*
+
+The idiom
+
+ class C with M { ... }
+
+is no longer supported. A `with` connective is only allowed following an
+`extends` clause. For instance, the line above would have to be written
+
+ class C extends AnyRef with M { ... } .
+
+However, assuming `M` is a trait (see [sec:traits]), it is also legal to
+write
+
+ class C extends M { ... }
+
+The latter expression is treated as equivalent to
+
+ class C extends S with M { ... }
+
+where `S` is the superclass of `M`.
+
+##### *Regular Expression Patterns*
+
+The only form of regular expression pattern that is currently supported
+is a sequence pattern, which might end in a sequence wildcard . Example:
+
+ case List(1, 2, _*) => ... // will match all lists starting with \code{1,2}.
+
+It is at current not clear whether this is a permanent restriction. We
+are evaluating the possibility of re-introducing full regular expression
+patterns in Scala.
+
+#### Selftype Annotations
+
+The recommended syntax of selftype annotations has changed.
+
+ class C: T extends B { ... }
+
+becomes
+
+ class C requires T extends B { ... }
+
+That is, selftypes are now indicated by the new `requires` keyword. The
+old syntax is still available but is considered deprecated.
+
+#### For-comprehensions
+
+For-comprehensions () now admit value and pattern definitions. Example:
+
+ for {
+ val x <- List.range(1, 100)
+ val y <- List.range(1, x)
+ val z = x + y
+ isPrime(z)
+ } yield Pair(x, y)
+
+Note the definition  `val z = x + y` as the third item in the
+for-comprehension.
+
+#### Conversions
+
+The rules for implicit conversions of methods to functions () have been
+tightened. Previously, a parameterized method used as a value was always
+implicitly converted to a function. This could lead to unexpected
+results when method arguments where forgotten. Consider for instance the
+statement below:
+
+ show(x.toString)
+
+where `show` is defined as follows:
+
+ def show(x: String) = Console.println(x) .
+
+Most likely, the programmer forgot to supply an empty argument list `()`
+to `toString`. The previous Scala version would treat this code as a
+partially applied method, and expand it to:
+
+ show(() => x.toString())
+
+As a result, the address of a closure would be printed instead of the
+value of `s`.
+
+Scala version 2.0 will apply a conversion from partially applied method
+to function value only if the expected type of the expression is indeed
+a function type. For instance, the conversion would not be applied in
+the code above because the expected type of `show`’s parameter is
+`String`, not a function type.
+
+The new convention disallows some previously legal code. Example:
+
+ def sum(f: int => double)(a: int, b: int): double =
+ if (a > b) 0 else f(a) + sum(f)(a + 1, b)
+
+ val sumInts = sum(x => x) // error: missing arguments
+
+The partial application of `sum` in the last line of the code above will
+not be converted to a function type. Instead, the compiler will produce
+an error message which states that arguments for method `sum` are
+missing. The problem can be fixed by providing an expected type for the
+partial application, for instance by annotating the definition of
+`sumInts` with its type:
+
+ val sumInts: (int, int) => double = sum(x => x) // OK
+
+On the other hand, Scala version 2.0 now automatically applies methods
+with empty parameter lists to `()` argument lists when necessary. For
+instance, the `show` expression above will now be expanded to
+
+ show(x.toString()) .
+
+Scala version 2.0 also relaxes the rules of overriding with respect to
+empty parameter lists. The revised definition of <span>*matching
+members*</span> () makes it now possible to override a method with an
+explicit, but empty parameter list `()` with a parameterless method, and
+<span>*vice versa*</span>. For instance, the following class definition
+is now legal:
+
+ class C {
+ override def toString: String = ...
+ }
+
+Previously this definition would have been rejected, because the
+`toString` method as inherited from `java.lang.Object` takes an empty
+parameter list.
+
+#### Class Parameters
+
+A class parameter may now be prefixed by `val` or `var` ().
+
+#### Private Qualifiers
+
+Previously, Scala had three levels of visibility:
+<span>*private*</span>, <span>*protected*</span> and
+<span>*public*</span>. There was no way to restrict accesses to members
+of the current package, as in Java. Scala 2 now defines access
+qualifiers that let one express this level of visibility, among others.
+In the definition
+
+ private[C] def f(...)
+
+access to `f` is restricted to all code within the class or package `C`
+(which must contain the definition of `f`) ()
+
+#### Changes in the Mixin Model
+
+The model which details mixin composition of classes has changed
+significantly. The main differences are:
+
+1. We now distinguish between <span>*traits*</span> that are used as
+ mixin classes and normal classes. The syntax of traits has been
+ generalized from version 1.0, in that traits are now allowed to have
+ mutable fields. However, as in version 1.0, traits still may not
+ have constructor parameters.
+
+2. Member resolution and super accesses are now both defined in terms
+ of a <span>*class linearization*</span>.
+
+3. Scala’s notion of method overloading has been generalized; in
+ particular, it is now possible to have overloaded variants of the
+ same method in a subclass and in a superclass, or in several
+ different mixins. This makes method overloading in Scala
+ conceptually the same as in Java.
+
+The new mixin model is explained in more detail in .
+
+#### Implicit Parameters
+
+Views in Scala 1.0 have been replaced by the more general concept of
+implicit parameters ()
+
+#### Flexible Typing of Pattern Matching
+
+The new version of Scala implements more flexible typing rules when it
+comes to pattern matching over heterogeneous class hierarchies (). A
+<span>*heterogeneous class hierarchy*</span> is one where subclasses
+inherit a common superclass with different parameter types. With the new
+rules in Scala version 2.0 one can perform pattern matches over such
+hierarchies with more precise typings that keep track of the information
+gained by comparing the types of a selector and a matching pattern ().
+This gives Scala capabilities analogous to guarded algebraic data types.
+
+[^1]: Implemented by Adriaan Moors
diff --git a/spec/README.md b/spec/README.md
index 97c3fdf832..2f582dec5c 100644
--- a/spec/README.md
+++ b/spec/README.md
@@ -8,7 +8,7 @@ Third, we'd like to support different output formats. An html page per chapter w
## Editing
-We use redcarpet 3.1 and jekyll 2 (currently in alpha) to generate the html. Essentially, this is what github pages use.
+We use redcarpet 3.1 and jekyll 2 to generate the html. Essentially, this is what github pages use.
## Building
diff --git a/spec/_includes/numbering.css b/spec/_includes/numbering.css
index 8df08098bc..2a22ce28b5 100644
--- a/spec/_includes/numbering.css
+++ b/spec/_includes/numbering.css
@@ -1,4 +1,3 @@
-// based on http://philarcher.org/css/numberheadings.css,
h1 {
/* must reset here */
counter-reset: chapter {{ page.chapter }};
@@ -40,7 +39,6 @@ h3:before {
display: inline;
margin-right: 1em;
}
-
h3[id*='example'] {
/* must increment here */
counter-increment: example;
diff --git a/spec/_layouts/default.yml b/spec/_layouts/default.yml
index 64ba4a1639..69791d26ad 100644
--- a/spec/_layouts/default.yml
+++ b/spec/_layouts/default.yml
@@ -16,75 +16,31 @@
});
</script>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/2.3-latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
+ <script src="//code.jquery.com/jquery-2.1.3.min.js"></script>
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.2/styles/default.min.css">
- <link rel="stylesheet" href="public/octicons/octicons.css">
- <script src="public/highlight/highlight.pack.js"></script>
- <script src="public/scripts/navigation.js"></script>
-
<!-- need to use include to see value of page.chapter variable -->
<style type="text/css">
{% include numbering.css %}
-
- /* proper rendering of MathJax into highlighted code blocks */
- .fixws { white-space: pre; }
- .fixws .math { white-space: nowrap; }
</style>
- <script type="text/javascript">
- // clear content of H3 nodes that start with "Example:"
- // the content is only there to determine ID of the H3 element (redcarpet doesn't let us set css id)
- $( document ).ready(function(){ $("h3[id*='example']").text("") })
-
- // no language auto-detect so that EBDF isn't detected as scala
- hljs.configure({
- languages: []
- });
-
- // syntax highlighting after mathjax is loaded so that mathjax can be used in code blocks
- MathJax.Hub.Queue(function () {
- hljs.initHighlighting();
- $("pre nobr").addClass("fixws");
- })
-
- // and finally TOC generation
- $(document).ready(function() {
- $('.toc').navigation();
- })
- </script>
-
<link rel="stylesheet" type="text/css" href="public/stylesheets/screen.css">
+ <link rel="stylesheet" type="text/css" media="(max-width: 1400px), (orientation: portrait)" href="public/stylesheets/screen-small.css">
<link rel="stylesheet" type="text/css" media="print" href="public/stylesheets/print.css">
+ <link rel="stylesheet" type="text/css" href="public/stylesheets/fonts.css">
<title>{{ page.title }}</title>
</head>
<body>
-<div id="header">
-<a alt="The Scala Language Specification" href="{{site.baseurl}}/"><img id="scala-logo" src="public/images/scala-logo-red-spiral-dark.png" />
-<h1 class="no-numbering">Language Specification</h1></a>
-</div>
-<div id="container">
-<div id="navigation">
-<ol>
- {% assign sorted_pages = site.pages | sort:"name" %}
- {% for post in sorted_pages %}
- {% if post.chapter >= 0 %}
- {% if page.url == post.url %}
- <li class="active-page">
- <a href="{{site.baseurl}}{{ post.url }}"> {{ post.title }}</a>
- <div class="toc"></div>
- </li>
- {% else %}
- <li>
- <a href="{{site.baseurl}}{{ post.url }}"> {{ post.title }}</a>
- </li>
- {% endif %}
- {% endif %}
- {% endfor %}
-</ol>
-</div>
-<div id="content-container">
+ <header>
+ <nav id="chapters"><a id="github" href="https://github.com/scala/scala/tree/2.11.x/spec"><img src="public/images/github-logo@2x.png" alt="Edit at Github"></a>{% assign sorted_pages = site.pages | sort:"name" %}{% for post in sorted_pages %}{% if post.chapter >= 0 %}<a href="{{site.baseurl}}{{ post.url }}">{{post.chapter}} {{ post.title }}</a>{% endif %}{% endfor %}</nav>
+ </header>
+ <aside class="left"><nav id="toc"></nav></aside>
+
+ <main id="content">
{{ content }}
-</div>
-</div>
+ </main>
+
+ <script src="public/scripts/toc.js"></script>
+ <script src="public/scripts/highlight.pack.js"></script>
+ <script src="public/scripts/main.js"></script>
</body>
</html>
diff --git a/spec/_layouts/toc.yml b/spec/_layouts/toc.yml
index caf0be1a3a..4da7d41bea 100644
--- a/spec/_layouts/toc.yml
+++ b/spec/_layouts/toc.yml
@@ -6,23 +6,25 @@
<link rel="icon" type="image/png" href="public/favicon.ico">
<link rel="shortcut icon" type="image/png" href="public/favicon.ico">
- <link rel="stylesheet" type="text/css" href="public/stylesheets/screen.css">
- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
+ <script src="//code.jquery.com/jquery-2.1.3.min.js"></script>
<title>{{ page.title }}</title>
- <script type="text/javascript">
- $(document).ready(function() {
- $('#the-scala-language-specification').css('display','none');
- })
- </script>
+ <link rel="stylesheet" type="text/css" href="public/stylesheets/screen.css">
+ <link rel="stylesheet" type="text/css" href="public/stylesheets/screen-toc.css">
+ <link rel="stylesheet" type="text/css" href="public/stylesheets/fonts.css">
</head>
<body>
-<div id="header">
-<a alt="The Scala Language Specification" href="{{site.baseurl}}/"><img id="scala-logo" src="public/images/scala-logo-red-spiral-dark.png" />
-<h1 class="no-numbering">Language Specification</h1></a>
-</div>
+<header>
+ <div id="header-main">
+ <img id="scala-logo" src="public/images/scala-spiral-white.png" />
+ <span id="title">Scala Language Specification</span>
+ <a id="github" href="https://github.com/scala/scala/tree/2.11.x/spec"><img src="public/images/github-logo@2x.png" alt="Edit at Github"></a>
+ </div>
+ <div id="header-sub">Version 2.11</div>
+</header>
+<main>
{{ content }}
-
+</main>
</body>
</html>
diff --git a/spec/index.md b/spec/index.md
index ee9c2a5f78..d7e79dafb7 100644
--- a/spec/index.md
+++ b/spec/index.md
@@ -1,18 +1,9 @@
---
-title: Scala Language Reference
+title: Scala Language Specification
layout: toc
---
-# The Scala Language Specification
-# Version 2.11
-
-### Maintained online at [https://github.com/scala/scala/tree/2.11.x/spec](https://github.com/scala/scala/tree/2.11.x/spec)
-
-### Martin Odersky, Philippe Altherr, Vincent Cremet, Gilles Dubochet, Burak Emir, Philipp Haller, Stéphane Micheloud, Nikolay Mihaylov, Adriaan Moors, Lukas Rytz, Michel Schinz, Erik Stenman, Matthias Zenger
-
-### Markdown Conversion by Iain McGinniss.
-
-## Table of Contents
+# Table of Contents
<ol>
{% assign sorted_pages = site.pages | sort:"name" %}
@@ -27,7 +18,13 @@ layout: toc
{% endfor %}
</ol>
-## Preface
+#### Authors and Contributors
+
+Martin Odersky, Philippe Altherr, Vincent Cremet, Gilles Dubochet, Burak Emir, Philipp Haller, Stéphane Micheloud, Nikolay Mihaylov, Adriaan Moors, Lukas Rytz, Michel Schinz, Erik Stenman, Matthias Zenger
+
+Markdown Conversion by Iain McGinniss.
+
+#### Preface
Scala is a Java-like programming language which unifies
object-oriented and functional programming. It is a pure
diff --git a/spec/public/fonts/Heuristica-Bold.woff b/spec/public/fonts/Heuristica-Bold.woff
new file mode 100644
index 0000000000..904579683d
--- /dev/null
+++ b/spec/public/fonts/Heuristica-Bold.woff
Binary files differ
diff --git a/spec/public/fonts/Heuristica-BoldItalic.woff b/spec/public/fonts/Heuristica-BoldItalic.woff
new file mode 100644
index 0000000000..a3c5234453
--- /dev/null
+++ b/spec/public/fonts/Heuristica-BoldItalic.woff
Binary files differ
diff --git a/spec/public/fonts/Heuristica-Regular.woff b/spec/public/fonts/Heuristica-Regular.woff
new file mode 100644
index 0000000000..f5c1f8b2db
--- /dev/null
+++ b/spec/public/fonts/Heuristica-Regular.woff
Binary files differ
diff --git a/spec/public/fonts/Heuristica-RegularItalic.woff b/spec/public/fonts/Heuristica-RegularItalic.woff
new file mode 100644
index 0000000000..d2c8664593
--- /dev/null
+++ b/spec/public/fonts/Heuristica-RegularItalic.woff
Binary files differ
diff --git a/spec/public/fonts/LuxiMono-Bold.woff b/spec/public/fonts/LuxiMono-Bold.woff
new file mode 100644
index 0000000000..8581bb5aa4
--- /dev/null
+++ b/spec/public/fonts/LuxiMono-Bold.woff
Binary files differ
diff --git a/spec/public/fonts/LuxiMono-BoldOblique.woff b/spec/public/fonts/LuxiMono-BoldOblique.woff
new file mode 100644
index 0000000000..607ccf5cd0
--- /dev/null
+++ b/spec/public/fonts/LuxiMono-BoldOblique.woff
Binary files differ
diff --git a/spec/public/fonts/LuxiMono-Regular.woff b/spec/public/fonts/LuxiMono-Regular.woff
new file mode 100644
index 0000000000..a478ad9ef2
--- /dev/null
+++ b/spec/public/fonts/LuxiMono-Regular.woff
Binary files differ
diff --git a/spec/public/fonts/LuxiMono-RegularOblique.woff b/spec/public/fonts/LuxiMono-RegularOblique.woff
new file mode 100644
index 0000000000..26999f990f
--- /dev/null
+++ b/spec/public/fonts/LuxiMono-RegularOblique.woff
Binary files differ
diff --git a/spec/public/fonts/LuxiSans-Bold.woff b/spec/public/fonts/LuxiSans-Bold.woff
new file mode 100644
index 0000000000..162621568b
--- /dev/null
+++ b/spec/public/fonts/LuxiSans-Bold.woff
Binary files differ
diff --git a/spec/public/fonts/LuxiSans-Regular.woff b/spec/public/fonts/LuxiSans-Regular.woff
new file mode 100644
index 0000000000..89d980218f
--- /dev/null
+++ b/spec/public/fonts/LuxiSans-Regular.woff
Binary files differ
diff --git a/spec/public/images/github-logo@2x.png b/spec/public/images/github-logo@2x.png
new file mode 100644
index 0000000000..285b0fee2f
--- /dev/null
+++ b/spec/public/images/github-logo@2x.png
Binary files differ
diff --git a/spec/public/images/scala-logo-red-spiral-dark.png b/spec/public/images/scala-logo-red-spiral-dark.png
deleted file mode 100644
index 09b66b5e6a..0000000000
--- a/spec/public/images/scala-logo-red-spiral-dark.png
+++ /dev/null
Binary files differ
diff --git a/spec/public/images/scala-spiral-white.png b/spec/public/images/scala-spiral-white.png
new file mode 100644
index 0000000000..46aaf80824
--- /dev/null
+++ b/spec/public/images/scala-spiral-white.png
Binary files differ
diff --git a/spec/public/highlight/LICENSE b/spec/public/scripts/LICENSE-highlight
index 422deb7350..fe2f67b162 100644
--- a/spec/public/highlight/LICENSE
+++ b/spec/public/scripts/LICENSE-highlight
@@ -8,8 +8,8 @@ modification, are permitted provided that the following conditions are met:
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- * Neither the name of highlight.js nor the names of its contributors
- may be used to endorse or promote products derived from this software
+ * Neither the name of highlight.js nor the names of its contributors
+ may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
diff --git a/spec/public/scripts/LICENSE-toc b/spec/public/scripts/LICENSE-toc
new file mode 100644
index 0000000000..4e236e8696
--- /dev/null
+++ b/spec/public/scripts/LICENSE-toc
@@ -0,0 +1,18 @@
+(The MIT License)
+Copyright (c) 2013 Greg Allen
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file
diff --git a/spec/public/highlight/highlight.pack.js b/spec/public/scripts/highlight.pack.js
index bfeca09abb..bfeca09abb 100644
--- a/spec/public/highlight/highlight.pack.js
+++ b/spec/public/scripts/highlight.pack.js
diff --git a/spec/public/scripts/main.js b/spec/public/scripts/main.js
new file mode 100644
index 0000000000..f0509aba41
--- /dev/null
+++ b/spec/public/scripts/main.js
@@ -0,0 +1,57 @@
+function currentChapter() {
+ var path = document.location.pathname;
+ var idx = path.lastIndexOf("/") + 1;
+ var chap = path.substring(idx, idx + 2);
+ return parseInt(chap, 10);
+}
+
+function heading(i, heading, $heading) {
+ var currentLevel = parseInt(heading.tagName.substring(1));
+ var result = "";
+ if (currentLevel === this.headerLevel) {
+ this.headerCounts[this.headerLevel] += 1;
+ return "" + this.headerCounts[this.headerLevel] + " " + $heading.text();
+ } else if (currentLevel < this.headerLevel) {
+ while(currentLevel < this.headerLevel) {
+ this.headerCounts[this.headerLevel] = 1;
+ this.headerLevel -= 1;
+ }
+ this.headerCounts[this.headerLevel] += 1;
+ return "" + this.headerCounts[this.headerLevel]+ " " + $heading.text();
+ } else {
+ while(currentLevel > this.headerLevel) {
+ this.headerLevel += 1;
+ this.headerCounts[this.headerLevel] = 1;
+ }
+ return "" + this.headerCounts[this.headerLevel]+ " " + $heading.text();
+ }
+}
+
+$('#toc').toc(
+ {
+ 'selectors': 'h1,h2,h3',
+ 'smoothScrolling': false,
+ 'chapter': currentChapter(),
+ 'headerLevel': 1,
+ 'headerCounts': [-1, currentChapter() - 1, 1, 1],
+ 'headerText': heading
+ }
+);
+
+// no language auto-detect so that EBNF isn't detected as scala
+hljs.configure({
+ languages: []
+});
+
+// syntax highlighting after mathjax is loaded so that mathjax can be used in code blocks
+MathJax.Hub.Queue(function () {
+ hljs.initHighlighting();
+ $("pre nobr").addClass("fixws");
+})
+
+$("#chapters a").each(function (index) {
+ if (document.location.pathname.endsWith($(this).attr("href")))
+ $(this).addClass("chapter-active");
+ else
+ $(this).removeClass("chapter-active");
+});
diff --git a/spec/public/scripts/navigation.js b/spec/public/scripts/navigation.js
deleted file mode 100644
index c046bf4d54..0000000000
--- a/spec/public/scripts/navigation.js
+++ /dev/null
@@ -1,70 +0,0 @@
-(function($){ $.fn.navigation = function() {
-
- // the TOC already contains H1 so we start at H2
- var headers = $('h2, h3, h4, h5').filter(function() {
- // exclude examples
- if (this.id.substr(0, 7) == 'example') {
- return false;
- }
-
- // get all headers with an id
- return this.id;
- });
-
- var output = $(this);
-
- var get_level = function(n) { return parseInt(n.nodeName.replace('H', ''), 10); }
-
- var back_to_top = '<span title="Return to top" class="to_top octicon octicon-chevron-up"></span>';
-
- if (headers.length && output.length) {
- var level = get_level(headers[0]);
- var current_level;
- var html = '<ol>';
-
- headers.each(function(_, header) {
- current_level = get_level(header);
-
- if (current_level === level) {
- // same level as before
- html += '<li><a href="#' + header.id + '">' + header.innerHTML + '</a>';
- } else if (current_level <= level) {
- // higher level, we go back up and chose intermediary lists
- for(i = current_level; i < level; i++) {
- html += '</li></ol>';
- }
- html += '<li><a href="#' + header.id + '">' + header.innerHTML + '</a>';
- } else if (current_level > level) {
- // lower level, we open new nested lists
- for(i = current_level; i > level; i--) {
- html += '<ol><li>';
- }
- html += '<a href="#' + header.id + '">' + header.innerHTML + '</a>';
- }
-
- var header_link = '<a class="anchor" href="#' + header.id + '"><span class="octicon octicon-link"></span></a>';
- $(header).prepend(header_link);
-
- if (!$(header).prev().is('h1')) {
- $(header).after(back_to_top);
- }
-
- level = current_level;
- });
-
- html += '</ol>';
-
- output.html(html);
- }
-
- // back to top links
- $(document).on('click', '.to_top', function() {
- $(window).scrollTop(0);
- window.location.hash = '';
- });
-
- // we add one more at the end of the document
- $('#content-container').append(back_to_top);
-
-};})(jQuery);
-
diff --git a/spec/public/scripts/toc.js b/spec/public/scripts/toc.js
new file mode 100644
index 0000000000..070d7b7a93
--- /dev/null
+++ b/spec/public/scripts/toc.js
@@ -0,0 +1,128 @@
+/*!
+ * toc - jQuery Table of Contents Plugin
+ * v0.3.2
+ * http://projects.jga.me/toc/
+ * copyright Greg Allen 2014
+ * MIT License
+*/
+(function($) {
+var verboseIdCache = {};
+$.fn.toc = function(options) {
+ var self = this;
+ var opts = $.extend({}, jQuery.fn.toc.defaults, options);
+
+ var container = $(opts.container);
+ var headings = $(opts.selectors, container);
+ var headingOffsets = [];
+ var activeClassName = opts.activeClass;
+
+ var scrollTo = function(e, callback) {
+ $('li', self).removeClass(activeClassName);
+ $(e.target).parent().addClass(activeClassName);
+ };
+
+ //highlight on scroll
+ var timeout;
+ var highlightOnScroll = function(e) {
+ if (timeout) {
+ clearTimeout(timeout);
+ }
+ timeout = setTimeout(function() {
+ var top = $(window).scrollTop(),
+ highlighted, closest = Number.MAX_VALUE, index = 0;
+
+ for (var i = 0, c = headingOffsets.length; i < c; i++) {
+ var currentClosest = Math.abs(headingOffsets[i] - top);
+ if (currentClosest < closest) {
+ index = i;
+ closest = currentClosest;
+ }
+ }
+
+ $('li', self).removeClass(activeClassName);
+ highlighted = $('li:eq('+ index +')', self).addClass(activeClassName);
+ opts.onHighlight(highlighted);
+ }, 50);
+ };
+ if (opts.highlightOnScroll) {
+ $(window).bind('scroll', highlightOnScroll);
+ highlightOnScroll();
+ }
+
+ return this.each(function() {
+ //build TOC
+ var el = $(this);
+ var ul = $(opts.listType);
+
+ headings.each(function(i, heading) {
+ var $h = $(heading);
+ headingOffsets.push($h.offset().top - opts.highlightOffset);
+
+ var anchorName = opts.anchorName(i, heading, opts.prefix);
+
+ //add anchor
+ if(heading.id !== anchorName) {
+ var anchor = $('<span/>').attr('id', anchorName).insertBefore($h);
+ }
+
+ //build TOC item
+ var a = $('<a/>')
+ .text(opts.headerText(i, heading, $h))
+ .attr('href', '#' + anchorName)
+ .bind('click', function(e) {
+ $(window).unbind('scroll', highlightOnScroll);
+ scrollTo(e, function() {
+ $(window).bind('scroll', highlightOnScroll);
+ });
+ el.trigger('selected', $(this).attr('href'));
+ });
+
+ var li = $('<li/>')
+ .addClass(opts.itemClass(i, heading, $h, opts.prefix))
+ .append(a);
+
+ ul.append(li);
+ });
+ el.html(ul);
+ });
+};
+
+
+jQuery.fn.toc.defaults = {
+ container: 'body',
+ listType: '<ul/>',
+ selectors: 'h1,h2,h3',
+ prefix: 'toc',
+ activeClass: 'toc-active',
+ onHighlight: function() {},
+ highlightOnScroll: true,
+ highlightOffset: 100,
+ anchorName: function(i, heading, prefix) {
+ if(heading.id.length) {
+ return heading.id;
+ }
+
+ var candidateId = $(heading).text().replace(/[^a-z0-9]/ig, ' ').replace(/\s+/g, '-').toLowerCase();
+ if (verboseIdCache[candidateId]) {
+ var j = 2;
+
+ while(verboseIdCache[candidateId + j]) {
+ j++;
+ }
+ candidateId = candidateId + '-' + j;
+
+ }
+ verboseIdCache[candidateId] = true;
+
+ return prefix + '-' + candidateId;
+ },
+ headerText: function(i, heading, $heading) {
+ return $heading.text();
+ },
+ itemClass: function(i, heading, $heading, prefix) {
+ return prefix + '-' + $heading[0].tagName.toLowerCase();
+ }
+
+};
+
+})(jQuery);
diff --git a/spec/public/stylesheets/fonts.css b/spec/public/stylesheets/fonts.css
new file mode 100644
index 0000000000..36efb2bbd5
--- /dev/null
+++ b/spec/public/stylesheets/fonts.css
@@ -0,0 +1,73 @@
+@font-face {
+ font-family: 'Luxi Sans';
+ src: local('Luxi Sans Regular'),
+ url('../fonts/LuxiSans-Regular.woff') format('woff');
+ font-weight: normal;
+ font-style: normal;
+}
+
+@font-face {
+ font-family: 'Luxi Sans';
+ src: local('Luxi Sans Bold'),
+ url('../fonts/LuxiSans-Bold.woff') format('woff');
+ font-weight: bold;
+ font-style: normal;
+}
+
+@font-face {
+ font-family: 'Luxi Mono';
+ src: local('Luxi Mono Regular'),
+ url('../fonts/LuxiMono-Regular.woff') format('woff');
+ font-weight: normal;
+ font-style: normal;
+}
+@font-face {
+ font-family: 'Luxi Mono';
+ src: local('Luxi Mono Oblique'),
+ url('../fonts/LuxiMono-BoldOblique.woff') format('woff');
+ font-weight: normal;
+ font-style: oblique;
+}
+@font-face {
+ font-family: 'Luxi Mono';
+ src: local('Luxi Mono Bold'),
+ url('../fonts/LuxiMono-Bold.woff') format('woff');
+ font-weight: bold;
+ font-style: normal;
+}
+@font-face {
+ font-family: 'Luxi Mono';
+ src: local('Luxi Mono Bold Oblique'),
+ url('../fonts/LuxiMono-BoldOblique.woff') format('woff');
+ font-weight: bold;
+ font-style: oblique;
+}
+
+@font-face {
+ font-family: 'Heuristica';
+ src: local('Heuristica Regular'),
+ url('../fonts/Heuristica-Regular.woff') format('woff');
+ font-weight: normal;
+ font-style: normal;
+}
+@font-face {
+ font-family: 'Heuristica';
+ src: local('Heuristica Italic'),
+ url('../fonts/Heuristica-RegularItalic.woff') format('woff');
+ font-weight: normal;
+ font-style: italic;
+}
+@font-face {
+ font-family: 'Heuristica';
+ src: local('Heuristica Bold'),
+ url('../fonts/Heuristica-Bold.woff') format('woff');
+ font-weight: bold;
+ font-style: normal;
+}
+@font-face {
+ font-family: 'Heuristica';
+ src: local('Heuristica Bold Italic'),
+ url('../fonts/Heuristica-BoldItalic.woff') format('woff');
+ font-weight: bold;
+ font-style: italic;
+}
diff --git a/spec/public/stylesheets/screen-small.css b/spec/public/stylesheets/screen-small.css
new file mode 100644
index 0000000000..674db7c490
--- /dev/null
+++ b/spec/public/stylesheets/screen-small.css
@@ -0,0 +1,57 @@
+body {
+ padding: 0px;
+ margin: 0px;
+}
+aside.left {
+ position: relative;
+ margin: 0px auto;
+ overflow: visible;
+ height: inherit;
+ margin-bottom: 40px;
+ background-color: #073642;
+}
+header {
+ position: relative;
+ height: inherit;
+ min-height: 32px;
+}
+main {
+ max-width: 1000px;
+ min-width: 600px;
+ margin: 0 auto;
+}
+
+#chapters a {
+ font-size: 14px;
+ max-height: 32px;
+ padding: 4px 8px;
+ white-space: nowrap;
+ display: inline-block;
+}
+#chapters > #github {
+ padding: 14px;
+}
+
+#toc {
+ overflow: visible;
+}
+#toc .toc-active {
+ background: inherit;
+}
+#toc .toc-h1 {
+ display: inherit;
+}
+#toc .toc-h1 a {
+ padding-left: 10px;
+ color: #FFFFFF;
+ background: #72D0EB;
+}
+#toc .toc-h2 a {
+ padding-left: 30px;
+}
+#toc .toc-h3 a {
+ padding-left: 50px;
+}
+#toc a {
+ font-size: 14px;
+}
diff --git a/spec/public/stylesheets/screen-toc.css b/spec/public/stylesheets/screen-toc.css
new file mode 100644
index 0000000000..7a04bd00f9
--- /dev/null
+++ b/spec/public/stylesheets/screen-toc.css
@@ -0,0 +1,37 @@
+body {
+ padding: 0px;
+ margin: 0px;
+}
+header {
+ height: 96px;
+ padding: 0px;
+ width: 100%;
+ position: relative;
+ color: #FFFFFF;
+}
+#header-main {
+ height: 68px;
+ line-height: 1.2;
+ font-size: 32px;
+}
+#header-sub {
+ padding-left: 64px;
+ height: 28px;
+ background-color:#72D0EB;
+ vertical-align: middle;
+}
+#scala-logo {
+ padding: 10px;
+}
+#title {
+ vertical-align: middle;
+}
+#github {
+ height: 40px;
+ padding: 14px;
+ float: right;
+ font-size: 0px;
+}
+li {
+ margin: 5px;
+}
diff --git a/spec/public/stylesheets/screen.css b/spec/public/stylesheets/screen.css
index dbb3ebe1b3..fdddba0b45 100644
--- a/spec/public/stylesheets/screen.css
+++ b/spec/public/stylesheets/screen.css
@@ -1,8 +1,8 @@
/* from https://gist.github.com/andyferra/2554919 */
body {
- font-family: Helvetica, arial, sans-serif;
- font-size: 14px;
+ font-family:Heuristica,Georgia,serif;
+ color: #222222;
line-height: 1.6;
padding-bottom: 10px;
@@ -18,7 +18,11 @@ body {
}
a {
- color: #4183C4;
+ color: #08C;
+ text-decoration: none;
+}
+a:hover, a:focus {
+
}
a.absent {
color: #cc0000;
@@ -41,13 +45,21 @@ a.anchor span {
}
h1, h2, h3, h4, h5, h6 {
- margin: 20px 0 10px;
+ margin: 30px 0 0px;
+ padding: 0;
+ /* Fix anchor position due to header */
+ padding-top: 32px;
+ margin-top: -32px;
font-weight: bold;
-webkit-font-smoothing: antialiased;
cursor: text;
position: relative;
}
+h1, h2 {
+ font-weight: normal;
+}
+
h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor, h5:hover a.anchor, h6:hover a.anchor {
text-decoration: none;
}
@@ -95,7 +107,6 @@ h1 {
h2 {
font-size: 24px;
- border-bottom: 1px solid #cccccc;
color: black;
}
@@ -117,7 +128,7 @@ h6 {
}
p, blockquote, ul, ol, dl, li, table, pre {
- margin: 15px 0;
+ margin: 5px 0 15px;
-moz-font-feature-settings: "onum";
-ms-font-feature-settings: "onum";
-webkit-font-feature-settings: "onum";
@@ -125,7 +136,7 @@ p, blockquote, ul, ol, dl, li, table, pre {
}
hr {
- background: transparent url("../../images/modules/pulls/dirty-shade.png") repeat-x 0 0;
+ background: transparent repeat-x 0 0;
border: 0 none;
color: #cccccc;
height: 4px;
@@ -207,7 +218,7 @@ dl dd > :last-child {
blockquote {
border-left: 4px solid #dddddd;
padding: 0 15px;
- color: #777777;
+ color: #222222;
}
blockquote > :first-child {
margin-top: 0;
@@ -215,31 +226,34 @@ blockquote > :first-child {
blockquote > :last-child {
margin-bottom: 0;
}
+blockquote:before {
+ content: "Example";
+ color: #777777;
+ font-size: 14px;
+ font-weight: bold;
+}
table {
padding: 0;
+ margin: 0;
+ border: none;
+ border-collapse: collapse;
}
table tr {
- border-top: 1px solid #cccccc;
background-color: white;
- margin: 0;
- padding: 0;
}
table tr:nth-child(2n) {
background-color: #f8f8f8;
}
table tr th {
+ background-color: #EAEAEA;
font-weight: bold;
- border: 1px solid #cccccc;
text-align: left;
- margin: 0;
- padding: 6px 13px;
+ padding: 5px 13px;
}
table tr td {
- border: 1px solid #cccccc;
text-align: left;
- margin: 0;
- padding: 6px 13px;
+ padding: 5px 13px;
}
table tr th :first-child, table tr td :first-child {
margin-top: 0;
@@ -327,11 +341,14 @@ span.float-right > span {
text-align: right;
}
+pre, code, tt {
+ font:14px "Luxi Mono", 'andale mono', 'lucida console', monospace;
+ line-height:1.5;
+}
+
.highlight pre {
- border: 1px solid #eaeaea;
- background-color: #f8f8f8;
+ background-color: #F8F8F8;
border-radius: 3px;
- line-height: 19px;
overflow: auto;
padding: 6px 10px;
white-space: nowrap;
@@ -343,86 +360,144 @@ code {
margin: 0;
padding: 0;
white-space: pre;
- font-size: 16px;
}
-#navigation {
- margin-right: 10px;
- float: right;
- width: 26%;
- display: inline;
- color: #8B8B8B;
- font-size: 15px;
- font-weight: bold;
- background-color: #F3F4F4;
+aside.left {
+ height: 100%;
+ position: fixed;
+ direction: rtl;
+ overflow: auto;
+ left: 0px;
+ width: 320px;
+ bottom: -32px;
+ font-family: "Luxi Sans", serif;
+ background-color: #073642;
}
-#content-container {
- float: left;
- width: 70%;
- display: inline;
+aside.left > nav {
+ direction: ltr;
+ top: 32px;
+ padding-bottom: 32px;
}
-#container {
- padding-top: 10px;
- width: 100%;
+article, aside, details, figcaption, figure, footer, header, hgroup, main, nav, section, summary {
+ display: block;
}
-#navigation a {
- text-decoration: none;
- color: #8B8B8B;
+audio, canvas, img, svg, video {
+ vertical-align: middle;
}
-#navigation a:hover {
- text-decoration: underline;
+audio, canvas, progress, video {
+ display: inline-block;
+ vertical-align: baseline;
}
-.active-page {
- color: #171717;
+main {
+ position: relative;
+ top: 32px;
+ margin: 0 0 0 320px;
+ padding: 0px 32px;
+ max-width: 800px;
+ min-width: 800px;
+ min-height: 580px;
+ background-color: #FFF;
}
-.active-page a {
- color: #171717 !important;
+header {
+ position: fixed;
+ top: 0px;
+ left: 0px;
+ height: 32px;
+ width: 100%;
+ background-color: #002B36;
+ margin: 0px 0px;
+ padding: 0px 0px;
+ font-family: "Luxi Sans", serif;
+ font-weight: bold;
+ z-index: 10;
+ overflow: hidden;
+ text-shadow: 1px 1px 0px rgba(0, 43, 54, 0.15);
}
-.to_top {
- position: absolute;
- margin-top: -35px;
- right: 27%;
- color: gray;
- cursor: pointer;
- width: 16px; height: 16px;
- display: block;
+#chapters a {
+ color: #FFFFFF;
+ text-decoration: none;
+ font-size: 0.63vw;
+ padding: 100% 8px;
}
-.to_top:hover {
- color: black;
+#chapters a:hover, #chapters a:focus, #github:hover, #github:focus {
+ background: #DC322F;
+ -webkit-transition: background .2s ease-in;
+ -moz-transition: background .2s ease-in;
+ -ms-transition: background .2s ease-in;
+ -o-transition: background .2s ease-in;
+ transition: background .2s ease-in;
}
-#scala-logo {
- float: left;
- width: 168px;
- height: 48px;
- margin-right: 25px;
+#chapters a.chapter-active {
+ background: #72D0EB;
}
-#header {
- padding-top: 16px;
- padding-bottom: 10px;
- margin-bottom: 10px;
- height: 64px;
- border-bottom: 1px solid #cccccc;
+
+#toc ul {
+ margin: 0;
+ padding: 0;
+ list-style: none;
}
-#header a {
- height: 100%;
- display: block;
+#toc li {
+ margin: 0;
+ padding: 0;
+}
+
+#toc a {
+ color: #FFFFFF; /*#073642;*/
+ font-weight: bold;
+ font-size: 12px;
+ display: block;
+ text-shadow: 1px 1px 0px rgba(0, 43, 54, 0.15);
+}
+
+#toc a:hover, #toc a:focus {
+ background: #DC322F;
text-decoration: none;
+ -webkit-transition: background .2s ease-in;
+ -moz-transition: background .2s ease-in;
+ -ms-transition: background .2s ease-in;
+ -o-transition: background .2s ease-in;
+ transition: background .2s ease-in;
}
-#header h1 {
- cursor: pointer;
- padding-top: 6px;
- margin-bottom: 0px;
- font-size: 30px;
+#toc .toc-h1 {
+ display: none;
+}
+
+#toc .toc-h2 a {
+ padding-left: 10px;
+}
+
+#toc .toc-h3 a {
+ padding-left: 30px;
+}
+
+#toc .toc-active {
+ background: #72D0EB;
+}
+
+#toc .toc-active a {
+ color: #FFFFFF;
+}
+
+#chapters > #github {
+ padding: 0px;
+ float: right;
+}
+
+.hljs{
+ background: #f8f8f8;
}
+/* proper rendering of MathJax into highlighted code blocks */
+.fixws { white-space: pre; }
+.fixws .math { white-space: nowrap; }
diff --git a/src/compiler/scala/reflect/quasiquotes/Reifiers.scala b/src/compiler/scala/reflect/quasiquotes/Reifiers.scala
index 7c0e7dfbb8..e753c9787a 100644
--- a/src/compiler/scala/reflect/quasiquotes/Reifiers.scala
+++ b/src/compiler/scala/reflect/quasiquotes/Reifiers.scala
@@ -317,7 +317,7 @@ trait Reifiers { self: Quasiquotes =>
* Reification of non-trivial list is done in two steps:
*
* 1. split the list into groups where every placeholder is always
- * put in a group of it's own and all subsquent non-holeMap are
+ * put in a group of its own and all subsquent non-holeMap are
* grouped together; element is considered to be a placeholder if it's
* in the domain of the fill function;
*
diff --git a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
index 9862ea7987..6e91a2a202 100755
--- a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
+++ b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
@@ -137,8 +137,8 @@ while [[ $# -gt 0 ]]; do
-D*)
# pass to scala as well: otherwise we lose it sometimes when we
# need it, e.g. communicating with a server compiler.
- java_args=("${java_args[@@]}" "$1")
- scala_args=("${scala_args[@@]}" "$1")
+ java_args+=("$1")
+ scala_args+=("$1")
# respect user-supplied -Dscala.usejavacp
case "$1" in -Dscala.usejavacp*) OVERRIDE_USEJAVACP="";; esac
shift
@@ -146,8 +146,8 @@ while [[ $# -gt 0 ]]; do
-J*)
# as with -D, pass to scala even though it will almost
# never be used.
- java_args=("${java_args[@@]}" "${1:2}")
- scala_args=("${scala_args[@@]}" "$1")
+ java_args+=("${1:2}")
+ scala_args+=("$1")
shift
;;
-toolcp)
@@ -167,7 +167,7 @@ while [[ $# -gt 0 ]]; do
shift
;;
*)
- scala_args=("${scala_args[@@]}" "$1")
+ scala_args+=("$1")
shift
;;
esac
diff --git a/src/compiler/scala/tools/nsc/PhaseAssembly.scala b/src/compiler/scala/tools/nsc/PhaseAssembly.scala
index e1cfa63960..4b32aab5ee 100644
--- a/src/compiler/scala/tools/nsc/PhaseAssembly.scala
+++ b/src/compiler/scala/tools/nsc/PhaseAssembly.scala
@@ -127,7 +127,7 @@ trait PhaseAssembly {
}
/* Find all edges in the given graph that are hard links. For each hard link we
- * need to check that its the only dependency. If not, then we will promote the
+ * need to check that it's the only dependency. If not, then we will promote the
* other dependencies down
*/
def validateAndEnforceHardlinks() {
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index 1036dc853b..b76fb3d823 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -1268,7 +1268,7 @@ self =>
atPos(start) { Apply(t3, exprsBuf.toList) }
}
if (inPattern) stringCheese
- else withPlaceholders(stringCheese, isAny = true) // strinterpolator params are Any* by definition
+ else withPlaceholders(stringCheese, isAny = true) // string interpolator params are Any* by definition
}
/* ------------- NEW LINES ------------------------------------------------- */
diff --git a/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala b/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala
index 0cdf629ce1..843648282b 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala
@@ -109,7 +109,7 @@ abstract class ICodeCheckers {
/** Only called when m1 < m2, so already known that (m1 ne m2).
*/
- private def isConfict(m1: IMember, m2: IMember, canOverload: Boolean) = (
+ private def isConflict(m1: IMember, m2: IMember, canOverload: Boolean) = (
(m1.symbol.name == m2.symbol.name) &&
(!canOverload || (m1.symbol.tpe =:= m2.symbol.tpe))
)
@@ -119,11 +119,11 @@ abstract class ICodeCheckers {
clasz = cls
for (f1 <- cls.fields ; f2 <- cls.fields ; if f1 < f2)
- if (isConfict(f1, f2, canOverload = false))
+ if (isConflict(f1, f2, canOverload = false))
icodeError("Repetitive field name: " + f1.symbol.fullName)
for (m1 <- cls.methods ; m2 <- cls.methods ; if m1 < m2)
- if (isConfict(m1, m2, canOverload = true))
+ if (isConflict(m1, m2, canOverload = true))
icodeError("Repetitive method: " + m1.symbol.fullName)
clasz.methods foreach check
@@ -471,7 +471,7 @@ abstract class ICodeCheckers {
pushStack(local.kind)
case LOAD_FIELD(field, isStatic) =>
- // the symbol's owner should contain it's field, but
+ // the symbol's owner should contain its field, but
// this is already checked by the type checker, no need
// to redo that here
if (isStatic) ()
diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala
index b0ad5bdaf9..058b6a161d 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala
@@ -572,7 +572,7 @@ abstract class TypeFlowAnalysis {
- `inlined` : These blocks were spliced into the method's CFG as part of inlining. Being new blocks, they haven't been visited yet by the typeflow analysis.
- - `staleIn` : These blocks are what `doInline()` calls `afterBlock`s, ie the new home for instructions that previously appearead
+ - `staleIn` : These blocks are what `doInline()` calls `afterBlock`s, ie the new home for instructions that previously appeared
after a callsite in a `staleOut` block.
Based on the above information, we have to bring up-to-date the caches that `forwardAnalysis` and `blockTransfer` use to skip blocks and instructions.
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeAsmCommon.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeAsmCommon.scala
index 162da4236a..eadc404bee 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeAsmCommon.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeAsmCommon.scala
@@ -329,10 +329,12 @@ final class BCodeAsmCommon[G <: Global](val global: G) {
* Build the [[InlineInfo]] for a class symbol.
*/
def buildInlineInfoFromClassSymbol(classSym: Symbol, classSymToInternalName: Symbol => InternalName, methodSymToDescriptor: Symbol => String): InlineInfo = {
- val selfType = {
+ val traitSelfType = if (classSym.isTrait && !classSym.isImplClass) {
// The mixin phase uses typeOfThis for the self parameter in implementation class methods.
val selfSym = classSym.typeOfThis.typeSymbol
if (selfSym != classSym) Some(classSymToInternalName(selfSym)) else None
+ } else {
+ None
}
val isEffectivelyFinal = classSym.isEffectivelyFinal
@@ -394,6 +396,6 @@ final class BCodeAsmCommon[G <: Global](val global: G) {
}
}).toMap
- InlineInfo(selfType, isEffectivelyFinal, methodInlineInfos, warning)
+ InlineInfo(traitSelfType, isEffectivelyFinal, methodInlineInfos, warning)
}
}
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala b/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala
index d690542f0e..e61190bf3a 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala
@@ -315,7 +315,7 @@ abstract class BTypes {
case ArrayBType(component) =>
if (other == ObjectReference || other == jlCloneableReference || other == jioSerializableReference) true
else other match {
- case ArrayBType(otherComponoent) => component.conformsTo(otherComponoent).orThrow
+ case ArrayBType(otherComponent) => component.conformsTo(otherComponent).orThrow
case _ => false
}
diff --git a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala
index 3704acb055..1b6631e7a4 100644
--- a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala
+++ b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala
@@ -173,7 +173,7 @@ abstract class DeadCodeElimination extends SubComponent {
moveToWorkList()
case LOAD_FIELD(sym, isStatic) if isStatic || !inliner.isClosureClass(sym.owner) =>
- // static load may trigger static initization.
+ // static load may trigger static initialization.
// non-static load can throw NPE (but we know closure fields can't be accessed via a
// null reference.
moveToWorkList()
@@ -191,7 +191,7 @@ abstract class DeadCodeElimination extends SubComponent {
case LOAD_EXCEPTION(_) | DUP(_) | LOAD_MODULE(_) => true
case _ =>
dropOf((bb1, idx1)) = (bb,idx) :: dropOf.getOrElse((bb1, idx1), Nil)
- debuglog("DROP is innessential: " + i + " because of: " + bb1(idx1) + " at " + bb1 + ":" + idx1)
+ debuglog("DROP is inessential: " + i + " because of: " + bb1(idx1) + " at " + bb1 + ":" + idx1)
false
}
}
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
index 994bcd8359..a59b9d3f48 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
@@ -1141,16 +1141,12 @@ abstract class ClassfileParser {
private def innerSymbol(entry: InnerClassEntry): Symbol = {
val name = entry.originalName.toTypeName
val enclosing = entry.enclosing
- def getMember = (
+ val member = (
if (enclosing == clazz) entry.scope lookup name
else lookupMemberAtTyperPhaseIfPossible(enclosing, name)
)
- getMember
- /* There used to be an assertion that this result is not NoSymbol; changing it to an error
- * revealed it had been going off all the time, but has been swallowed by a catch t: Throwable
- * in Repository.scala. Since it has been accomplishing nothing except misleading anyone who
- * thought it wasn't triggering, I removed it entirely.
- */
+ def newStub = enclosing.newStubSymbol(name, s"Unable to locate class corresponding to inner class entry for $name in owner ${entry.outerName}")
+ member.orElse(newStub)
}
}
diff --git a/src/compiler/scala/tools/nsc/transform/Constructors.scala b/src/compiler/scala/tools/nsc/transform/Constructors.scala
index d0fca12e6a..86685d46de 100644
--- a/src/compiler/scala/tools/nsc/transform/Constructors.scala
+++ b/src/compiler/scala/tools/nsc/transform/Constructors.scala
@@ -315,7 +315,7 @@ abstract class Constructors extends Statics with Transform with ast.TreeDSL {
}
def rewriteDelayedInit() {
- /* XXX This is not corect: remainingConstrStats.nonEmpty excludes too much,
+ /* XXX This is not correct: remainingConstrStats.nonEmpty excludes too much,
* but excluding it includes too much. The constructor sequence being mimicked
* needs to be reproduced with total fidelity.
*
diff --git a/src/compiler/scala/tools/nsc/transform/Delambdafy.scala b/src/compiler/scala/tools/nsc/transform/Delambdafy.scala
index 2d33b35241..45a89ac594 100644
--- a/src/compiler/scala/tools/nsc/transform/Delambdafy.scala
+++ b/src/compiler/scala/tools/nsc/transform/Delambdafy.scala
@@ -77,7 +77,7 @@ abstract class Delambdafy extends Transform with TypingTransformers with ast.Tre
// the result of the transformFunction method.
sealed abstract class TransformedFunction
- // A class definition for the lambda, an expression insantiating the lambda class
+ // A class definition for the lambda, an expression instantiating the lambda class
case class DelambdafyAnonClass(lambdaClassDef: ClassDef, newExpr: Tree) extends TransformedFunction
// here's the main entry point of the transform
@@ -86,7 +86,7 @@ abstract class Delambdafy extends Transform with TypingTransformers with ast.Tre
case fun @ Function(_, _) =>
transformFunction(fun) match {
case DelambdafyAnonClass(lambdaClassDef, newExpr) =>
- // a lambda beccomes a new class, an instantiation expression
+ // a lambda becomes a new class, an instantiation expression
val pkg = lambdaClassDef.symbol.owner
// we'll add the lambda class to the package later
diff --git a/src/compiler/scala/tools/nsc/transform/LazyVals.scala b/src/compiler/scala/tools/nsc/transform/LazyVals.scala
index 38671ebaae..df622d4d1d 100644
--- a/src/compiler/scala/tools/nsc/transform/LazyVals.scala
+++ b/src/compiler/scala/tools/nsc/transform/LazyVals.scala
@@ -219,7 +219,7 @@ abstract class LazyVals extends Transform with TypingTransformers with ast.TreeD
* l$
* } or
* <rhs> when the lazy value has type Unit (for which there is no field
- * to cache it's value.
+ * to cache its value.
*
* Similarly as for normal lazy val members (see Mixin), the result will be a tree of the form
* { if ((bitmap&n & MASK) == 0) this.l$compute()
diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala
index 408f4466e1..11f9483f77 100644
--- a/src/compiler/scala/tools/nsc/transform/Mixin.scala
+++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala
@@ -26,7 +26,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL {
*/
private val treatedClassInfos = perRunCaches.newMap[Symbol, Type]() withDefaultValue NoType
- /** Map a lazy, mixedin field accessor to it's trait member accessor */
+ /** Map a lazy, mixedin field accessor to its trait member accessor */
private val initializer = perRunCaches.newMap[Symbol, Symbol]()
// --------- helper functions -----------------------------------------------
@@ -886,7 +886,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL {
}
/* Complete lazy field accessors. Applies only to classes,
- * for it's own (non inherited) lazy fields. If 'checkinit'
+ * for its own (non inherited) lazy fields. If 'checkinit'
* is enabled, getters that check for the initialized bit are
* generated, and the class constructor is changed to set the
* initialized bits.
diff --git a/src/compiler/scala/tools/nsc/transform/SampleTransform.scala b/src/compiler/scala/tools/nsc/transform/SampleTransform.scala
index cffb483072..ba303f7c2b 100644
--- a/src/compiler/scala/tools/nsc/transform/SampleTransform.scala
+++ b/src/compiler/scala/tools/nsc/transform/SampleTransform.scala
@@ -27,7 +27,7 @@ abstract class SampleTransform extends Transform {
tree1 match {
case Block(List(), expr) => // a simple optimization
expr
- case Block(defs, sup @ Super(qual, mix)) => // A hypthothetic transformation, which replaces
+ case Block(defs, sup @ Super(qual, mix)) => // A hypothetical transformation, which replaces
// {super} by {super.sample}
treeCopy.Block( // `copy` is the usual lazy tree copier
tree1, defs,
diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
index 086512677e..1a24c668ba 100644
--- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
+++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
@@ -610,7 +610,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
exitingSpecialize(sClass setInfo specializedInfoType)
val fullEnv = outerEnv ++ env
- /* Enter 'sym' in the scope of the current specialized class. It's type is
+ /* Enter 'sym' in the scope of the current specialized class. Its type is
* mapped through the active environment, binding type variables to concrete
* types. The existing typeEnv for `sym` is composed with the current active
* environment
@@ -1368,7 +1368,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
)
def specializeCalls(unit: CompilationUnit) = new TypingTransformer(unit) {
- /** Map a specializable method to it's rhs, when not deferred. */
+ /** Map a specializable method to its rhs, when not deferred. */
val body = perRunCaches.newMap[Symbol, Tree]()
/** Map a specializable method to its value parameter symbols. */
diff --git a/src/compiler/scala/tools/nsc/typechecker/AnalyzerPlugins.scala b/src/compiler/scala/tools/nsc/typechecker/AnalyzerPlugins.scala
index 2c27bdb03a..0574869714 100644
--- a/src/compiler/scala/tools/nsc/typechecker/AnalyzerPlugins.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/AnalyzerPlugins.scala
@@ -57,7 +57,7 @@ trait AnalyzerPlugins { self: Analyzer =>
* `analyzer.transformed` hash map, indexed by the definition's rhs tree.
*
* NOTE: Invoking the type checker can lead to cyclic reference errors. For instance, if this
- * method is called from the type completer of a recursive method, type checking the mehtod
+ * method is called from the type completer of a recursive method, type checking the method
* rhs will invoke the same completer again. It might be possible to avoid this situation by
* assigning `tpe` to `defTree.symbol` (untested) - the final type computed by this method
* will then be assigned to the definition's symbol by monoTypeCompleter (in Namers).
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index 98289f6a3c..d5a3fba76f 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -167,7 +167,7 @@ trait Contexts { self: Analyzer =>
* afterwards errors are thrown. This is configured in `rootContext`. Additionally, more
* fine grained control is needed based on the kind of error; ambiguity errors are often
* suppressed during exploratory typing, such as determining whether `a == b` in an argument
- * position is an assignment or a named argument, when `Infererencer#isApplicableSafe` type checks
+ * position is an assignment or a named argument, when `Inferencer#isApplicableSafe` type checks
* applications with and without an expected type, or whtn `Typer#tryTypedApply` tries to fit arguments to
* a function type with/without implicit views.
*
@@ -1064,10 +1064,10 @@ trait Contexts { self: Analyzer =>
//
// A type-import-on-demand declaration never causes any other declaration to be shadowed.
//
- // Scala: Bindings of different kinds have a precedence defined on them:
+ // Scala: Bindings of different kinds have a precedence defined on them:
//
- // 1) Definitions and declarations that are local, inherited, or made available by a
- // package clause in the same compilation unit where the definition occurs have
+ // 1) Definitions and declarations that are local, inherited, or made available by a
+ // package clause in the same compilation unit where the definition occurs have
// highest precedence.
// 2) Explicit imports have next highest precedence.
def depthOk(imp: ImportInfo) = (
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index e18b9c10f0..ab6b2a0b9d 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -376,7 +376,7 @@ trait Infer extends Checkable {
}
/** Overload which allocates fresh type vars.
* The other one exists because apparently inferExprInstance needs access to the typevars
- * after the call, and its wasteful to return a tuple and throw it away almost every time.
+ * after the call, and it's wasteful to return a tuple and throw it away almost every time.
*/
private def exprTypeArgs(tparams: List[Symbol], restpe: Type, pt: Type, useWeaklyCompatible: Boolean): List[Type] =
exprTypeArgs(tparams map freshVar, tparams, restpe, pt, useWeaklyCompatible)
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index 24238b8e41..77c49a862a 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -1125,7 +1125,7 @@ trait Namers extends MethodSynthesis {
for (vparam <- vparams) {
if (vparam.tpt.isEmpty) {
val overriddenParamTp = overriddenParams.head.tpe
- // references to type parameteres in overriddenParamTp link to the type skolems, so the
+ // references to type parameters in overriddenParamTp link to the type skolems, so the
// assigned type is consistent with the other / existing parameter types in vparamSymss.
vparam.symbol setInfo overriddenParamTp
vparam.tpt defineType overriddenParamTp setPos vparam.pos.focus
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 5abfbe850f..a3a4c70d1e 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -584,7 +584,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
!other.isDeferred && other.isJavaDefined && !sym.enclClass.isSubClass(other.enclClass) && {
// #3622: erasure operates on uncurried types --
// note on passing sym in both cases: only sym.isType is relevant for uncurry.transformInfo
- // !!! erasure.erasure(sym, uncurry.transformInfo(sym, tp)) gives erreneous of inaccessible type - check whether that's still the case!
+ // !!! erasure.erasure(sym, uncurry.transformInfo(sym, tp)) gives erroneous or inaccessible type - check whether that's still the case!
def uncurryAndErase(tp: Type) = erasure.erasure(sym)(uncurry.transformInfo(sym, tp))
val tp1 = uncurryAndErase(clazz.thisType.memberType(sym))
val tp2 = uncurryAndErase(clazz.thisType.memberType(other))
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 010b924ba0..8b792998d4 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -4288,7 +4288,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
val selector1 = atPos(tree.pos.focusStart) { if (arity == 1) ids.head else gen.mkTuple(ids) }
// SI-8120 If we don't duplicate the cases, the original Match node will share trees with ones that
// receive symbols owned by this function. However if, after a silent mode session, we discard
- // this Function and try a different approach (e.g. applying a view to the reciever) we end up
+ // this Function and try a different approach (e.g. applying a view to the receiver) we end up
// with orphaned symbols which blows up far down the pipeline (or can be detected with -Ycheck:typer).
val body = treeCopy.Match(tree, selector1, (cases map duplicateAndKeepPositions).asInstanceOf[List[CaseDef]])
typed1(atPos(tree.pos) { Function(params, body) }, mode, pt)
diff --git a/src/interactive/scala/tools/nsc/interactive/CompilerControl.scala b/src/interactive/scala/tools/nsc/interactive/CompilerControl.scala
index 2e4f6b08e9..9caebb711d 100644
--- a/src/interactive/scala/tools/nsc/interactive/CompilerControl.scala
+++ b/src/interactive/scala/tools/nsc/interactive/CompilerControl.scala
@@ -302,7 +302,7 @@ trait CompilerControl { self: Global =>
abstract class WorkItem extends (() => Unit) {
val onCompilerThread = self.onCompilerThread
- /** Raise a MissingReponse, if the work item carries a response. */
+ /** Raise a MissingResponse, if the work item carries a response. */
def raiseMissing(): Unit
}
diff --git a/src/interactive/scala/tools/nsc/interactive/Global.scala b/src/interactive/scala/tools/nsc/interactive/Global.scala
index b6290eb3d3..e79c1a01ab 100644
--- a/src/interactive/scala/tools/nsc/interactive/Global.scala
+++ b/src/interactive/scala/tools/nsc/interactive/Global.scala
@@ -304,7 +304,7 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
private val NoResponse: Response[_] = new Response[Any]
/** The response that is currently pending, i.e. the compiler
- * is working on providing an asnwer for it.
+ * is working on providing an answer for it.
*/
private var pendingResponse: Response[_] = NoResponse
diff --git a/src/interactive/scala/tools/nsc/interactive/Lexer.scala b/src/interactive/scala/tools/nsc/interactive/Lexer.scala
index 82e8de3f3d..7daf24c204 100644
--- a/src/interactive/scala/tools/nsc/interactive/Lexer.scala
+++ b/src/interactive/scala/tools/nsc/interactive/Lexer.scala
@@ -195,7 +195,7 @@ class Lexer(rd: Reader) {
case 'n' => putAcceptString("null"); token = NullLit
case '"' => getString()
case '-' | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' => getNumber()
- case _ => error("unrecoginezed start of token: '"+ch+"'")
+ case _ => error("unrecognized start of token: '"+ch+"'")
}
//println("["+token+"]")
}
diff --git a/src/library/scala/Mutable.scala b/src/library/scala/Mutable.scala
index 8ef0424db6..43f98ee4df 100644
--- a/src/library/scala/Mutable.scala
+++ b/src/library/scala/Mutable.scala
@@ -11,7 +11,7 @@
package scala
/**
- * A marker trait for mutable datatructures such as mutable collections
+ * A marker trait for mutable data structures such as mutable collections
*
* @since 2.8
*/
diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala
index 060ecbfead..3cc83654b7 100644
--- a/src/library/scala/Predef.scala
+++ b/src/library/scala/Predef.scala
@@ -58,7 +58,7 @@ import scala.io.StdIn
* condition fails, then the caller of the function is to blame rather than a
* logical error having been made within `addNaturals` itself. `ensures` is a
* form of `assert` that declares the guarantee the function is providing with
- * regards to it's return value.
+ * regards to its return value.
*
* === Implicit Conversions ===
* A number of commonly applied implicit conversions are also defined here, and
@@ -85,7 +85,7 @@ object Predef extends LowPriorityImplicits with DeprecatedPredef {
type String = java.lang.String
type Class[T] = java.lang.Class[T]
- // miscelleaneous -----------------------------------------------------
+ // miscellaneous -----------------------------------------------------
scala.`package` // to force scala package object to be seen.
scala.collection.immutable.List // to force Nil, :: to be seen.
diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala
index 66fce0f902..b775480532 100644
--- a/src/library/scala/collection/SeqLike.scala
+++ b/src/library/scala/collection/SeqLike.scala
@@ -413,7 +413,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[
* @inheritdoc
*
* Another way to express this
- * is that `xs union ys` computes the order-presevring multi-set union of `xs` and `ys`.
+ * is that `xs union ys` computes the order-preserving multi-set union of `xs` and `ys`.
* `union` is hence a counter-part of `diff` and `intersect` which also work on multi-sets.
*
* $willNotTerminateInf
diff --git a/src/library/scala/collection/concurrent/Map.scala b/src/library/scala/collection/concurrent/Map.scala
index f0a5f57225..f27dfd57fc 100644
--- a/src/library/scala/collection/concurrent/Map.scala
+++ b/src/library/scala/collection/concurrent/Map.scala
@@ -49,7 +49,7 @@ trait Map[A, B] extends scala.collection.mutable.Map[A, B] {
def putIfAbsent(k: A, v: B): Option[B]
/**
- * Removes the entry for the specified key if its currently mapped to the
+ * Removes the entry for the specified key if it's currently mapped to the
* specified value.
*
* $atomicop
diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala
index 5fff727c36..ada3533a60 100644
--- a/src/library/scala/collection/immutable/Stream.scala
+++ b/src/library/scala/collection/immutable/Stream.scala
@@ -360,7 +360,7 @@ self =>
* `List(BigInt(12)) ++ fibs`.
*
* @tparam B The element type of the returned collection.'''That'''
- * @param that The [[scala.collection.GenTraversableOnce]] the be contatenated
+ * @param that The [[scala.collection.GenTraversableOnce]] the be concatenated
* to this `Stream`.
* @return A new collection containing the result of concatenating `this` with
* `that`.
diff --git a/src/library/scala/collection/mutable/AVLTree.scala b/src/library/scala/collection/mutable/AVLTree.scala
index cc2acb74d4..b63d0aae33 100644
--- a/src/library/scala/collection/mutable/AVLTree.scala
+++ b/src/library/scala/collection/mutable/AVLTree.scala
@@ -27,7 +27,7 @@ private[mutable] sealed trait AVLTree[+A] extends Serializable {
/**
* Returns a new tree containing the given element.
- * Thows an IllegalArgumentException if element is already present.
+ * Throws an IllegalArgumentException if element is already present.
*
*/
def insert[B >: A](value: B, ordering: Ordering[B]): AVLTree[B] = Node(value, Leaf, Leaf)
@@ -95,7 +95,7 @@ private case class Node[A](data: A, left: AVLTree[A], right: AVLTree[A]) extends
/**
* Returns a new tree containing the given element.
- * Thows an IllegalArgumentException if element is already present.
+ * Throws an IllegalArgumentException if element is already present.
*
*/
override def insert[B >: A](value: B, ordering: Ordering[B]) = {
diff --git a/src/library/scala/collection/mutable/HashTable.scala b/src/library/scala/collection/mutable/HashTable.scala
index 65d9c35052..b48a32fa37 100644
--- a/src/library/scala/collection/mutable/HashTable.scala
+++ b/src/library/scala/collection/mutable/HashTable.scala
@@ -449,7 +449,7 @@ private[collection] object HashTable {
// h
/* OLD VERSION
- * quick, but bad for sequence 0-10000 - little enthropy in higher bits
+ * quick, but bad for sequence 0-10000 - little entropy in higher bits
* since 2003 */
// var h: Int = hcode + ~(hcode << 9)
// h = h ^ (h >>> 14)
diff --git a/src/library/scala/collection/mutable/UnrolledBuffer.scala b/src/library/scala/collection/mutable/UnrolledBuffer.scala
index 693c47d86e..2212486bcf 100644
--- a/src/library/scala/collection/mutable/UnrolledBuffer.scala
+++ b/src/library/scala/collection/mutable/UnrolledBuffer.scala
@@ -85,7 +85,7 @@ extends scala.collection.mutable.AbstractBuffer[T]
def classTagCompanion = UnrolledBuffer
- /** Concatenates the targer unrolled buffer to this unrolled buffer.
+ /** Concatenates the target unrolled buffer to this unrolled buffer.
*
* The specified buffer `that` is cleared after this operation. This is
* an O(1) operation.
@@ -208,7 +208,7 @@ object UnrolledBuffer extends ClassTagTraversableFactory[UnrolledBuffer] {
def newBuilder[T](implicit t: ClassTag[T]): Builder[T, UnrolledBuffer[T]] = new UnrolledBuffer[T]
val waterline = 50
- val waterlineDelim = 100
+ val waterlineDelim = 100 // TODO -- fix this name! It's a denominator, not a delimiter. (But it's part of the API so we can't just change it.)
private[collection] val unrolledlength = 32
/** Unrolled buffer node.
@@ -319,13 +319,15 @@ object UnrolledBuffer extends ClassTagTraversableFactory[UnrolledBuffer] {
for (elem <- t) curr = curr append elem
curr.next = newnextnode
- // try to merge the last node of this with the newnextnode
+ // try to merge the last node of this with the newnextnode and fix tail pointer if needed
if (curr.tryMergeWithNext()) buffer.lastPtr = curr
+ else if (newnextnode.next eq null) buffer.lastPtr = newnextnode
}
- else if (idx == size) {
+ else if (idx == size || (next eq null)) {
var curr = this
for (elem <- t) curr = curr append elem
- } else insertAll(idx - size, t, buffer)
+ }
+ else next.insertAll(idx - size, t, buffer)
}
private def nullout(from: Int, until: Int) {
var idx = from
@@ -344,7 +346,7 @@ object UnrolledBuffer extends ClassTagTraversableFactory[UnrolledBuffer] {
tryMergeWithNext()
}
- override def toString = array.take(size).mkString("Unrolled[" + array.length + "](", ", ", ")") + " -> " + (if (next ne null) next.toString else "")
+ override def toString = array.take(size).mkString("Unrolled@%08x".format(System.identityHashCode(this)) + "[" + size + "/" + array.length + "](", ", ", ")") + " -> " + (if (next ne null) next.toString else "")
}
}
diff --git a/src/library/scala/collection/mutable/WrappedArray.scala b/src/library/scala/collection/mutable/WrappedArray.scala
index 53fca9f779..8740bda835 100644
--- a/src/library/scala/collection/mutable/WrappedArray.scala
+++ b/src/library/scala/collection/mutable/WrappedArray.scala
@@ -93,7 +93,7 @@ object WrappedArray {
def empty[T <: AnyRef]: WrappedArray[T] = EmptyWrappedArray.asInstanceOf[WrappedArray[T]]
// If make is called explicitly we use whatever we're given, even if it's
- // empty. This may be unnecesssary (if WrappedArray is to honor the collections
+ // empty. This may be unnecessary (if WrappedArray is to honor the collections
// contract all empty ones must be equal, so discriminating based on the reference
// equality of an empty array should not come up) but we may as well be
// conservative since wrapRefArray contributes most of the unnecessary allocations.
diff --git a/src/library/scala/concurrent/JavaConversions.scala b/src/library/scala/concurrent/JavaConversions.scala
index 3d0597ca22..91e55d30cb 100644
--- a/src/library/scala/concurrent/JavaConversions.scala
+++ b/src/library/scala/concurrent/JavaConversions.scala
@@ -11,7 +11,7 @@ package scala.concurrent
import java.util.concurrent.{ExecutorService, Executor}
import scala.language.implicitConversions
-/** The `JavaConversions` object provides implicit converstions supporting
+/** The `JavaConversions` object provides implicit conversions supporting
* interoperability between Scala and Java concurrency classes.
*
* @author Philipp Haller
diff --git a/src/library/scala/concurrent/duration/Duration.scala b/src/library/scala/concurrent/duration/Duration.scala
index 3697950e2e..8b7d81d1c4 100644
--- a/src/library/scala/concurrent/duration/Duration.scala
+++ b/src/library/scala/concurrent/duration/Duration.scala
@@ -182,6 +182,7 @@ object Duration {
def compare(other: Duration) = if (other eq this) 0 else 1
def unary_- : Duration = this
def toUnit(unit: TimeUnit): Double = Double.NaN
+ private def readResolve(): AnyRef = Undefined // Instructs deserialization to use this same instance
}
sealed abstract class Infinite extends Duration {
@@ -230,7 +231,7 @@ object Duration {
* but itself. This value closely corresponds to Double.PositiveInfinity,
* matching its semantics in arithmetic operations.
*/
- val Inf: Infinite = new Infinite {
+ val Inf: Infinite = new Infinite {
override def toString = "Duration.Inf"
def compare(other: Duration) = other match {
case x if x eq Undefined => -1 // Undefined != Undefined
@@ -239,6 +240,7 @@ object Duration {
}
def unary_- : Duration = MinusInf
def toUnit(unit: TimeUnit): Double = Double.PositiveInfinity
+ private def readResolve(): AnyRef = Inf // Instructs deserialization to use this same instance
}
/**
@@ -251,6 +253,7 @@ object Duration {
def compare(other: Duration) = if (other eq this) 0 else -1
def unary_- : Duration = Inf
def toUnit(unit: TimeUnit): Double = Double.NegativeInfinity
+ private def readResolve(): AnyRef = MinusInf // Instructs deserialization to use this same instance
}
// Java Factories
diff --git a/src/library/scala/math/BigDecimal.scala b/src/library/scala/math/BigDecimal.scala
index cf95f945ba..d6e2963ad8 100644
--- a/src/library/scala/math/BigDecimal.scala
+++ b/src/library/scala/math/BigDecimal.scala
@@ -431,7 +431,7 @@ extends ScalaNumber with ScalaNumericConversions with Serializable {
* with unequal `hashCode`s. These hash codes agree with `BigInt`
* for whole numbers up ~4934 digits (the range of IEEE 128 bit floating
* point). Beyond this, hash codes will disagree; this prevents the
- * explicit represention of the `BigInt` form for `BigDecimal` values
+ * explicit representation of the `BigInt` form for `BigDecimal` values
* with large exponents.
*/
override def hashCode(): Int = {
diff --git a/src/library/scala/sys/process/BasicIO.scala b/src/library/scala/sys/process/BasicIO.scala
index 866dac4458..640f7e68c2 100644
--- a/src/library/scala/sys/process/BasicIO.scala
+++ b/src/library/scala/sys/process/BasicIO.scala
@@ -203,7 +203,7 @@ object BasicIO {
/** Returns a `ProcessIO` connected to stdout and stderr, and, optionally, stdin. */
def standard(connectInput: Boolean): ProcessIO = standard(input(connectInput))
- /** Retruns a `ProcessIO` connected to stdout, stderr and the provided `in` */
+ /** Returns a `ProcessIO` connected to stdout, stderr and the provided `in` */
def standard(in: OutputStream => Unit): ProcessIO = new ProcessIO(in, toStdOut, toStdErr)
/** Send all the input from the stream to stderr, and closes the input stream
diff --git a/src/library/scala/sys/process/ProcessLogger.scala b/src/library/scala/sys/process/ProcessLogger.scala
index ae347221ef..6072894007 100644
--- a/src/library/scala/sys/process/ProcessLogger.scala
+++ b/src/library/scala/sys/process/ProcessLogger.scala
@@ -88,7 +88,7 @@ object ProcessLogger {
/** Creates a [[scala.sys.process.ProcessLogger]] that sends all output to the corresponding
* function.
*
- * @param fout This function will receive standard outpout.
+ * @param fout This function will receive standard output.
*
* @param ferr This function will receive standard error.
*/
diff --git a/src/library/scala/util/control/Exception.scala b/src/library/scala/util/control/Exception.scala
index be6d03a145..aa30887ba0 100644
--- a/src/library/scala/util/control/Exception.scala
+++ b/src/library/scala/util/control/Exception.scala
@@ -155,7 +155,7 @@ object Exception {
/** A `Catch` object which catches everything. */
final def allCatch[T]: Catch[T] = new Catch(allCatcher[T]) withDesc "<everything>"
- /** A `Catch` object witch catches non-fatal exceptions. */
+ /** A `Catch` object which catches non-fatal exceptions. */
final def nonFatalCatch[T]: Catch[T] = new Catch(nonFatalCatcher[T]) withDesc "<non-fatal>"
/** Creates a `Catch` object which will catch any of the supplied exceptions.
diff --git a/src/library/scala/util/hashing/MurmurHash3.scala b/src/library/scala/util/hashing/MurmurHash3.scala
index 1bfaeb255b..4e5537954f 100644
--- a/src/library/scala/util/hashing/MurmurHash3.scala
+++ b/src/library/scala/util/hashing/MurmurHash3.scala
@@ -191,7 +191,7 @@ private[hashing] class MurmurHash3 {
* This is based on the earlier MurmurHash3 code by Rex Kerr, but the
* MurmurHash3 algorithm was since changed by its creator Austin Appleby
* to remedy some weaknesses and improve performance. This represents the
- * latest and supposedly final version of the algortihm (revision 136).
+ * latest and supposedly final version of the algorithm (revision 136).
*
* @see [[http://code.google.com/p/smhasher]]
*/
diff --git a/src/library/scala/util/matching/Regex.scala b/src/library/scala/util/matching/Regex.scala
index 5c4e706dc1..6d3d015b1a 100644
--- a/src/library/scala/util/matching/Regex.scala
+++ b/src/library/scala/util/matching/Regex.scala
@@ -477,7 +477,7 @@ class Regex private[matching](val pattern: Pattern, groupNames: String*) extends
/**
* Replaces some of the matches using a replacer function that returns an [[scala.Option]].
* The replacer function takes a [[scala.util.matching.Regex.Match]] so that extra
- * information can be btained from the match. For example:
+ * information can be obtained from the match. For example:
*
* {{{
* import scala.util.matching.Regex._
diff --git a/src/partest-extras/scala/tools/partest/ASMConverters.scala b/src/partest-extras/scala/tools/partest/ASMConverters.scala
index 67a4e8ae01..f6e2d2a9ec 100644
--- a/src/partest-extras/scala/tools/partest/ASMConverters.scala
+++ b/src/partest-extras/scala/tools/partest/ASMConverters.scala
@@ -89,7 +89,7 @@ object ASMConverters {
private def lst[T](xs: java.util.List[T]): List[T] = if (xs == null) Nil else xs.asScala.toList
- // Heterogenous List[Any] is used in FrameNode: type information about locals / stack values
+ // Heterogeneous List[Any] is used in FrameNode: type information about locals / stack values
// are stored in a List[Any] (Integer, String or LabelNode), see Javadoc of MethodNode#visitFrame.
// Opcodes (eg Opcodes.INTEGER) and Reference types (eg "java/lang/Object") are returned unchanged,
// LabelNodes are mapped to their LabelEntry.
diff --git a/src/reflect/scala/reflect/api/Quasiquotes.scala b/src/reflect/scala/reflect/api/Quasiquotes.scala
index eaae05bed5..554b43afaf 100644
--- a/src/reflect/scala/reflect/api/Quasiquotes.scala
+++ b/src/reflect/scala/reflect/api/Quasiquotes.scala
@@ -3,7 +3,7 @@ package api
trait Quasiquotes { self: Universe =>
- /** Implicit class that introduces `q`, `tq`, `cq,` `p` and `fq` string interpolators
+ /** Implicit class that introduces `q`, `tq`, `cq,` `pq` and `fq` string interpolators
* that are also known as quasiquotes. With their help you can easily manipulate
* Scala reflection ASTs.
*
diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala
index 756ed870ca..c86d08e925 100644
--- a/src/reflect/scala/reflect/internal/Definitions.scala
+++ b/src/reflect/scala/reflect/internal/Definitions.scala
@@ -936,7 +936,7 @@ trait Definitions extends api.StandardDefinitions {
// TODO these aren't final! They are now overridden in AnyRef/Object. Prior to the fix
// for SI-8129, they were actually *overloaded* by the members in AnyRef/Object.
// We should unfinalize these, override in AnyValClass, and make the overrides final.
- // Refchecks never actually looks at these, so its just for consistency.
+ // Refchecks never actually looks at these, so it's just for consistency.
lazy val Any_== = enterNewMethod(AnyClass, nme.EQ, AnyTpe :: Nil, BooleanTpe, FINAL)
lazy val Any_!= = enterNewMethod(AnyClass, nme.NE, AnyTpe :: Nil, BooleanTpe, FINAL)
diff --git a/src/reflect/scala/reflect/internal/ReificationSupport.scala b/src/reflect/scala/reflect/internal/ReificationSupport.scala
index c418321234..eddfec82e7 100644
--- a/src/reflect/scala/reflect/internal/ReificationSupport.scala
+++ b/src/reflect/scala/reflect/internal/ReificationSupport.scala
@@ -292,7 +292,7 @@ trait ReificationSupport { self: SymbolTable =>
if (ctorMods.isTrait)
result(ctorMods, Nil, edefs, body)
else {
- // undo conversion from (implicit ... ) to ()(implicit ... ) when its the only parameter section
+ // undo conversion from (implicit ... ) to ()(implicit ... ) when it's the only parameter section
val vparamssRestoredImplicits = ctorVparamss match {
case Nil :: (tail @ ((head :: _) :: _)) if head.mods.isImplicit => tail
case other => other
diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala
index 6adfb4b104..2b6c73c8eb 100644
--- a/src/reflect/scala/reflect/internal/Symbols.scala
+++ b/src/reflect/scala/reflect/internal/Symbols.scala
@@ -2067,7 +2067,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
*/
final def outerClass: Symbol =
if (this == NoSymbol) {
- // ideally we shouldn't get here, but its better to harden against this than suffer the infinite loop in SI-9133
+ // ideally we shouldn't get here, but it's better to harden against this than suffer the infinite loop in SI-9133
devWarningDumpStack("NoSymbol.outerClass", 15)
NoSymbol
} else if (owner.isClass) owner
diff --git a/src/reflect/scala/reflect/internal/TreeGen.scala b/src/reflect/scala/reflect/internal/TreeGen.scala
index 4025df7ac5..894038dd0a 100644
--- a/src/reflect/scala/reflect/internal/TreeGen.scala
+++ b/src/reflect/scala/reflect/internal/TreeGen.scala
@@ -365,7 +365,7 @@ abstract class TreeGen {
DefDef(NoMods, nme.MIXIN_CONSTRUCTOR, Nil, ListOfNil, TypeTree(), Block(lvdefs, Literal(Constant(()))))))
}
else {
- // convert (implicit ... ) to ()(implicit ... ) if its the only parameter section
+ // convert (implicit ... ) to ()(implicit ... ) if it's the only parameter section
if (vparamss1.isEmpty || !vparamss1.head.isEmpty && vparamss1.head.head.mods.isImplicit)
vparamss1 = List() :: vparamss1
val superCall = pendingSuperCall // we can't know in advance which of the parents will end up as a superclass
diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala
index b6c4ef322f..6ded3bcbe3 100644
--- a/src/reflect/scala/reflect/internal/Types.scala
+++ b/src/reflect/scala/reflect/internal/Types.scala
@@ -3672,7 +3672,7 @@ trait Types
// JZ: We used to register this as a perRunCache so it would be cleared eagerly at
// the end of the compilation run. But, that facility didn't actually clear this map (SI-8129)!
// When i fixed that bug, run/tpeCache-tyconCache.scala started failing. Why was that?
- // I've removed the registration for now. I don't think its particularly harmful anymore
+ // I've removed the registration for now. I don't think it's particularly harmful anymore
// as a) this is now a weak set, and b) it is discarded completely before the next run.
uniqueRunId = currentRunId
}
@@ -4549,7 +4549,7 @@ trait Types
/** Adds the @uncheckedBound annotation if the given `tp` has type arguments */
final def uncheckedBounds(tp: Type): Type = {
- if (tp.typeArgs.isEmpty || UncheckedBoundsClass == NoSymbol) tp // second condition for backwards compatibilty with older scala-reflect.jar
+ if (tp.typeArgs.isEmpty || UncheckedBoundsClass == NoSymbol) tp // second condition for backwards compatibility with older scala-reflect.jar
else tp.withAnnotation(AnnotationInfo marker UncheckedBoundsClass.tpe)
}
diff --git a/src/reflect/scala/reflect/internal/tpe/FindMembers.scala b/src/reflect/scala/reflect/internal/tpe/FindMembers.scala
index 42b13944f6..83a5d23e7c 100644
--- a/src/reflect/scala/reflect/internal/tpe/FindMembers.scala
+++ b/src/reflect/scala/reflect/internal/tpe/FindMembers.scala
@@ -155,7 +155,7 @@ trait FindMembers {
&& ( (member.owner eq other.owner) // same owner, therefore overload
|| (member.flags & PRIVATE) != 0 // (unqualified) private members never participate in overriding
|| (other.flags & PRIVATE) != 0 // ... as overrider or overridee.
- || !(memberTypeLow(member) matches memberTypeHi(other)) // do the member types match? If so, its an override. Otherwise it's an overload.
+ || !(memberTypeLow(member) matches memberTypeHi(other)) // do the member types match? If so, it's an override. Otherwise it's an overload.
)
)
diff --git a/src/repl/scala/tools/nsc/interpreter/ConsoleReaderHelper.scala b/src/repl/scala/tools/nsc/interpreter/ConsoleReaderHelper.scala
index d8efcda8b5..a8d537e314 100644
--- a/src/repl/scala/tools/nsc/interpreter/ConsoleReaderHelper.scala
+++ b/src/repl/scala/tools/nsc/interpreter/ConsoleReaderHelper.scala
@@ -112,8 +112,12 @@ trait VariColumnTabulator extends Tabulator {
def layout(ncols: Int): Option[(Int, Seq[Int], Seq[Seq[String]])] = {
val nrows = items.size /% ncols
val xwise = isAcross || ncols >= items.length
- def maxima(sss: Seq[Seq[String]]) =
- (0 until (ncols min items.size)) map (i => (sss map (ss => ss(i).length)).max)
+ // max width item in each column
+ def maxima(rows: Seq[Seq[String]]) =
+ (0 until (ncols min items.size)) map { col =>
+ val widths = for (r <- rows if r.size > col) yield r(col).length
+ widths.max
+ }
def resulting(rows: Seq[Seq[String]]) = {
val columnWidths = maxima(rows) map (_ + marginSize)
val linelen = columnWidths.sum
@@ -124,9 +128,10 @@ trait VariColumnTabulator extends Tabulator {
else if (xwise) resulting((items grouped ncols).toSeq)
else {
val cols = (items grouped nrows).toList
- val rows = for (i <- 0 until nrows) yield
- for (j <- 0 until ncols) yield
- if (j < cols.size && i < cols(j).size) cols(j)(i) else ""
+ val rows =
+ for (i <- 0 until nrows) yield
+ for (j <- 0 until ncols) yield
+ if (j < cols.size && i < cols(j).size) cols(j)(i) else ""
resulting(rows)
}
}
diff --git a/src/scaladoc/scala/tools/nsc/doc/Index.scala b/src/scaladoc/scala/tools/nsc/doc/Index.scala
index 84545e9201..a11ca38a86 100644
--- a/src/scaladoc/scala/tools/nsc/doc/Index.scala
+++ b/src/scaladoc/scala/tools/nsc/doc/Index.scala
@@ -11,4 +11,6 @@ trait Index {
type SymbolMap = SortedMap[String, SortedSet[model.MemberEntity]]
def firstLetterIndex: Map[Char, SymbolMap]
+
+ def hasDeprecatedMembers: Boolean
}
diff --git a/src/scaladoc/scala/tools/nsc/doc/html/HtmlFactory.scala b/src/scaladoc/scala/tools/nsc/doc/html/HtmlFactory.scala
index 61ab18d42d..8313d842e5 100644
--- a/src/scaladoc/scala/tools/nsc/doc/html/HtmlFactory.scala
+++ b/src/scaladoc/scala/tools/nsc/doc/html/HtmlFactory.scala
@@ -123,6 +123,8 @@ class HtmlFactory(val universe: doc.Universe, index: doc.Index) {
new page.Index(universe, index) writeFor this
new page.IndexScript(universe, index) writeFor this
+ if (index.hasDeprecatedMembers)
+ new page.DeprecatedIndex(universe, index) writeFor this
try {
writeTemplates(_ writeFor this)
for (letter <- index.firstLetterIndex) {
diff --git a/src/scaladoc/scala/tools/nsc/doc/html/page/DeprecatedIndex.scala b/src/scaladoc/scala/tools/nsc/doc/html/page/DeprecatedIndex.scala
new file mode 100755
index 0000000000..f257153bd7
--- /dev/null
+++ b/src/scaladoc/scala/tools/nsc/doc/html/page/DeprecatedIndex.scala
@@ -0,0 +1,58 @@
+/* NSC -- new Scala compiler
+ * Copyright 2007-2013 LAMP/EPFL
+ */
+
+package scala
+package tools
+package nsc
+package doc
+package html
+package page
+
+import doc.model._
+
+class DeprecatedIndex(universe: Universe, index: doc.Index) extends HtmlPage {
+
+ def path = List("deprecated-list.html")
+
+ def title = {
+ val s = universe.settings
+ ( if (!s.doctitle.isDefault) s.doctitle.value else "" ) +
+ ( if (!s.docversion.isDefault) (" " + s.docversion.value) else "" )
+ }
+
+ def headers =
+ <xml:group>
+ <link href={ relativeLinkTo(List("ref-index.css", "lib")) } media="screen" type="text/css" rel="stylesheet"/>
+ <script type="text/javascript" src={ relativeLinkTo{List("jquery.js", "lib")} }></script>
+ </xml:group>
+
+
+ private def entry(name: String, methods: Iterable[MemberEntity]) = {
+ val occurrences = methods.filter(_.deprecation.isDefined).map(method =>
+ templateToHtml(method.inDefinitionTemplates.head)
+ ).toList.distinct
+
+ <div class="entry">
+ <div class="name">{ name }</div>
+ <div class="occurrences">{
+ for (owner <- occurrences) yield owner ++ scala.xml.Text(" ")
+ }</div>
+ </div>
+ }
+
+ def deprecatedEntries = {
+ val available = ('_' +: ('a' to 'z')).flatMap(index.firstLetterIndex.get)
+
+ for (group <- available;
+ value <- group if value._2.find(_.deprecation.isDefined).isDefined)
+ yield value
+ }
+
+ def body =
+ <body>{
+ for(value <- deprecatedEntries) yield
+ entry(value._1, value._2.view)
+ }</body>
+
+}
diff --git a/src/scaladoc/scala/tools/nsc/doc/html/page/Index.scala b/src/scaladoc/scala/tools/nsc/doc/html/page/Index.scala
index ce3a5eb1fc..6bfe480e33 100644
--- a/src/scaladoc/scala/tools/nsc/doc/html/page/Index.scala
+++ b/src/scaladoc/scala/tools/nsc/doc/html/page/Index.scala
@@ -61,12 +61,17 @@ class Index(universe: doc.Universe, val index: doc.Index) extends HtmlPage {
}
}
+ def deprecated: NodeSeq = if (index.hasDeprecatedMembers)
+ <a target="template" href="deprecated-list.html">deprecated</a>
+ else
+ <span>deprecated</span>
+
def browser =
<div id="browser" class="ui-layout-west">
<div class="ui-west-center">
<div id="filter">
<div id="textfilter"></div>
- <div id="letters">{ letters }</div>
+ <div id="letters">{ letters } &#8211; { deprecated }</div>
</div>
<div class="pack" id="tpl">{
def packageElem(pack: model.Package): NodeSeq = {
diff --git a/src/scaladoc/scala/tools/nsc/doc/model/IndexModelFactory.scala b/src/scaladoc/scala/tools/nsc/doc/model/IndexModelFactory.scala
index 643a089aae..ad53dc6bfa 100755
--- a/src/scaladoc/scala/tools/nsc/doc/model/IndexModelFactory.scala
+++ b/src/scaladoc/scala/tools/nsc/doc/model/IndexModelFactory.scala
@@ -14,10 +14,12 @@ object IndexModelFactory {
def makeIndex(universe: Universe): Index = new Index {
- lazy val firstLetterIndex: Map[Char, SymbolMap] = {
+ lazy val (firstLetterIndex, hasDeprecatedMembers): (Map[Char, SymbolMap], Boolean) = {
object result extends mutable.HashMap[Char,SymbolMap] {
+ var deprecated = false
+
/* symbol name ordering */
implicit def orderingMap = math.Ordering.String
@@ -32,6 +34,8 @@ object IndexModelFactory {
val members = letter.get(d.name).getOrElse {
SortedSet.empty[MemberEntity](Ordering.by { _.toString })
} + d
+ if (!deprecated && members.find(_.deprecation.isDefined).isDefined)
+ deprecated = true
this(firstLetter) = letter + (d.name -> members)
}
}
@@ -50,7 +54,7 @@ object IndexModelFactory {
gather(universe.rootPackage)
- result.toMap
+ (result.toMap, result.deprecated)
}
}
}
diff --git a/test/files/jvm/inner.scala b/test/files/jvm/inner.scala
index c05e803449..dc01b124c5 100644
--- a/test/files/jvm/inner.scala
+++ b/test/files/jvm/inner.scala
@@ -77,7 +77,7 @@ object Scalatest {
def java(cname: String) =
exec(javacmd, "-cp", classpath, cname)
- /** Execute cmd, wait for the process to end and pipe it's output to stdout */
+ /** Execute cmd, wait for the process to end and pipe its output to stdout */
private def exec(args: String*) {
val proc = Runtime.getRuntime().exec(args.toArray)
val inp = new BufferedReader(new InputStreamReader(proc.getInputStream))
diff --git a/test/files/jvm/javaReflection/Test.scala b/test/files/jvm/javaReflection/Test.scala
index 5b6ef1b573..ae5a36eeb2 100644
--- a/test/files/jvm/javaReflection/Test.scala
+++ b/test/files/jvm/javaReflection/Test.scala
@@ -124,8 +124,8 @@ object Test {
// exclude files from Test.scala, just take those from Classes_1.scala
case s if !s.startsWith("Test") && s.endsWith(".class") => s.substring(0, s.length - 6)
}).sortWith((a, b) => {
- // sort such that first there are all anonymous funcitions, then all other classes.
- // within those cathegories, sort lexically.
+ // sort such that first there are all anonymous functions, then all other classes.
+ // within those categories, sort lexically.
// this makes the check file smaller: it differs for anonymous functions between -Ydelambdafy:inline/method.
// the other classes are the same.
if (isAnonFunClassName(a)) !isAnonFunClassName(b) || a < b
diff --git a/test/files/pos/t7815.scala b/test/files/pos/t7815.scala
index 12a434c5b0..0a126f9faa 100644
--- a/test/files/pos/t7815.scala
+++ b/test/files/pos/t7815.scala
@@ -21,7 +21,7 @@ object Foo {
object Main extends App {
def mapWithFoo[A <: AnyRef, B](as: List[A])(implicit foo: Foo.Aux[A, B]) = {
// Should be Eta expandable because the result type of `f` is not
- // dependant on the value, it is just `B`.
+ // dependent on the value, it is just `B`.
as map foo.f
as map foo.g
as map foo.m
diff --git a/test/files/run/classfile-format-51.scala b/test/files/run/classfile-format-51.scala
index 4351757a64..da322bb5d9 100644
--- a/test/files/run/classfile-format-51.scala
+++ b/test/files/run/classfile-format-51.scala
@@ -11,7 +11,7 @@ import Opcodes._
// it runs a normal compile on the source in the 'code' field that refers to
// DynamicInvoker. Any failure will be dumped to std out.
//
-// By it's nature the test can only work on JDK 7+ because under JDK 6 some of the
+// By its nature the test can only work on JDK 7+ because under JDK 6 some of the
// classes referred to by DynamicInvoker won't be available and DynamicInvoker won't
// verify. So the test includes a version check that short-circuites the whole test
// on JDK 6
diff --git a/test/files/run/classfile-format-52.scala b/test/files/run/classfile-format-52.scala
index 6646e081c4..e278d40b8b 100644
--- a/test/files/run/classfile-format-52.scala
+++ b/test/files/run/classfile-format-52.scala
@@ -10,7 +10,7 @@ import Opcodes._
// HasDefaultMethod. Then it runs a normal compile on Scala source that extends that
// interface. Any failure will be dumped to std out.
//
-// By it's nature the test can only work on JDK 8+ because under JDK 7- the
+// By its nature the test can only work on JDK 8+ because under JDK 7- the
// interface won't verify.
object Test extends DirectTest {
override def extraSettings: String = "-optimise -usejavacp -d " + testOutput.path + " -cp " + testOutput.path
diff --git a/test/files/run/t7741a/Test.scala b/test/files/run/t7741a/Test.scala
index a75cb6c9eb..cdba1cccf8 100644
--- a/test/files/run/t7741a/Test.scala
+++ b/test/files/run/t7741a/Test.scala
@@ -25,7 +25,7 @@ object Test extends DirectTest {
// interface GroovyInterface {
//
// // This is the line that causes scalac to choke.
- // // It results in a GroovyInterface$1 class, which is a non-static inner class but it's constructor does not
+ // // It results in a GroovyInterface$1 class, which is a non-static inner class but its constructor does not
// // include the implicit parameter that is the immediate enclosing instance.
// // See http://jira.codehaus.org/browse/GROOVY-7312
// //
diff --git a/test/files/run/t9268.check b/test/files/run/t9268.check
new file mode 100644
index 0000000000..90ef940eb3
--- /dev/null
+++ b/test/files/run/t9268.check
@@ -0,0 +1,5 @@
+Compiling Client1
+pos: NoPosition Class Waiter not found - continuing with a stub. WARNING
+Compiling Client2
+pos: NoPosition Class Waiter not found - continuing with a stub. WARNING
+pos: NoPosition Unable to locate class corresponding to inner class entry for Predicate in owner Waiter ERROR
diff --git a/test/files/run/t9268/Java.java b/test/files/run/t9268/Java.java
new file mode 100644
index 0000000000..c9a0bec3ff
--- /dev/null
+++ b/test/files/run/t9268/Java.java
@@ -0,0 +1,12 @@
+public class Java {
+}
+
+class Partial {
+ public <E extends java.lang.Exception> long waitFor(long l, Waiter.Predicate<E> pred) throws E {
+ return 0L;
+ }
+}
+
+class Waiter {
+ interface Predicate<E> {}
+}
diff --git a/test/files/run/t9268/Test.scala b/test/files/run/t9268/Test.scala
new file mode 100644
index 0000000000..813cbe7b60
--- /dev/null
+++ b/test/files/run/t9268/Test.scala
@@ -0,0 +1,40 @@
+import scala.tools.partest._
+import java.io.File
+
+object Test extends StoreReporterDirectTest {
+ def code = ???
+
+ def compileCode(code: String) = {
+ val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator")
+ compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(code)
+ }
+
+ def client1 = """
+ class Client1 { def p(p: Partial) = p.toString }
+ """
+
+ def client2 = """
+ class Client2 { def p(p: Partial) = p.waitFor() }
+ """
+
+ def deleteClass(s: String) = {
+ val f = new File(testOutput.path, s + ".class")
+ assert(f.exists)
+ f.delete()
+ }
+
+ def show(): Unit = {
+ deleteClass("Waiter")
+ deleteClass("Waiter$Predicate")
+
+ // Used to crash in Java Generic Signature parsing
+ println("Compiling Client1")
+ compileCode(client1)
+ println(storeReporter.infos.mkString("\n"))
+ storeReporter.reset()
+ println("Compiling Client2")
+ compileCode(client2)
+ println(storeReporter.infos.mkString("\n"))
+ }
+}
+
diff --git a/test/files/run/valueClassSelfType.scala b/test/files/run/valueClassSelfType.scala
new file mode 100644
index 0000000000..47a3764b0a
--- /dev/null
+++ b/test/files/run/valueClassSelfType.scala
@@ -0,0 +1,52 @@
+trait T
+
+class V1(val l: Long) extends AnyVal { self: T =>
+ def foo: V1 = self
+ def bar: T = self
+}
+
+class V2(val l: Long) extends AnyVal { self =>
+ def foo: V2 = self
+}
+
+class V3(val l: Long) extends AnyVal { self: Long =>
+ def foo: V3 = self
+ def bar: Long = self
+}
+
+// non-value classes
+
+class C1(val l: Long) { self: T =>
+ def foo: C1 = self
+ def bar: T = self
+}
+
+class C2(val l: Long) { self =>
+ def foo: C2 = self
+}
+
+class C3(val l: Long) { self: Long =>
+ def foo: C3 = self
+ def bar: Long = self
+}
+
+object Test extends App {
+ // Rejected: superclass V1 is not a subclass of the superclass Object of the mixin trait T
+ // new V1(1l) with T
+
+ assert(new V2(1l).foo.l == 1l)
+
+ // Rejected: V3 does not conform to its self-type V3 with Long
+ // new V3(1l)
+
+ val c2 = new C1(2l) with T
+ assert(c2.foo.l + c2.bar.asInstanceOf[C1].l == 4l)
+
+ assert(new C2(3l).foo.l == 3l)
+
+ // Rejected: C3 does not conform to its self-type C3 with Long
+ // new C3(4l)
+
+ // Rejected: class Long needs to be a trait to be mixed in
+ // new C3(4l) with Long
+}
diff --git a/test/junit/scala/collection/mutable/UnrolledBufferTest.scala b/test/junit/scala/collection/mutable/UnrolledBufferTest.scala
new file mode 100644
index 0000000000..8660b6cbc1
--- /dev/null
+++ b/test/junit/scala/collection/mutable/UnrolledBufferTest.scala
@@ -0,0 +1,25 @@
+package scala.collection.mutable
+
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import org.junit.Test
+
+@RunWith(classOf[JUnit4])
+class UnrolledBufferTestTest {
+ @Test
+ def test_SI9254_original() {
+ val b = new UnrolledBuffer[Int]()
+ (1 to 16).foreach(i => b append i)
+ b.insert(0,-1)
+ b append 17
+ assert(b sameElements (Seq(-1) ++ (1 to 16) ++ Seq(17)))
+ }
+
+ @Test
+ def test_SI9254_additional() {
+ val b = new UnrolledBuffer[Int]()
+ (1 to 100).foreach(i => b append i)
+ b.insert(40, -1)
+ assert(b sameElements((1 to 40) ++ Seq(-1) ++ (41 to 100)))
+ }
+}
diff --git a/test/junit/scala/collection/mutable/VectorTest.scala b/test/junit/scala/collection/mutable/VectorTest.scala
index e9c4d44a72..b3219d1b02 100644
--- a/test/junit/scala/collection/mutable/VectorTest.scala
+++ b/test/junit/scala/collection/mutable/VectorTest.scala
@@ -38,7 +38,6 @@ class VectorTest {
def iteratorCat() {
def its = vecs.map(_.toList.toIterator)
val cats = vecs.map(a => its.map(a ++ _))
- println(cats)
assert( cats == ans )
}
diff --git a/test/junit/scala/concurrent/duration/SerializationTest.scala b/test/junit/scala/concurrent/duration/SerializationTest.scala
new file mode 100644
index 0000000000..af90a10984
--- /dev/null
+++ b/test/junit/scala/concurrent/duration/SerializationTest.scala
@@ -0,0 +1,24 @@
+package scala.concurrent.duration
+
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import org.junit.Test
+
+
+@RunWith(classOf[JUnit4])
+class SerializationTest {
+ @Test
+ def test_SI9197 {
+ def ser(a: AnyRef): Array[Byte] = {
+ val bais = new java.io.ByteArrayOutputStream
+ (new java.io.ObjectOutputStream(bais)).writeObject(a)
+ bais.toByteArray
+ }
+ def des(ab: Array[Byte]): AnyRef =
+ (new java.io.ObjectInputStream(new java.io.ByteArrayInputStream(ab))).readObject
+
+ assert(Duration.Undefined eq des(ser(Duration.Undefined)))
+ assert(Duration.Inf eq des(ser(Duration.Inf)))
+ assert(Duration.MinusInf eq des(ser(Duration.MinusInf)))
+ }
+}
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala
index 17724aecb1..0fc3601603 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala
@@ -720,7 +720,7 @@ class InlinerTest extends ClearAfterClass {
|final class D extends C
|object E extends C
|class T {
- | def t1(d: D) = d.f + d.g + E.f + E.g // d.f can be inlined because the reciever type is D, which is final.
+ | def t1(d: D) = d.f + d.g + E.f + E.g // d.f can be inlined because the receiver type is D, which is final.
|} // so d.f can be resolved statically. same for E.f
""".stripMargin
val List(c, d, e, eModule, t) = compile(code)
diff --git a/test/junit/scala/tools/nsc/interpreter/TabulatorTest.scala b/test/junit/scala/tools/nsc/interpreter/TabulatorTest.scala
index 21e338eac0..263265026a 100644
--- a/test/junit/scala/tools/nsc/interpreter/TabulatorTest.scala
+++ b/test/junit/scala/tools/nsc/interpreter/TabulatorTest.scala
@@ -82,4 +82,24 @@ class TabulatorTest {
assert(rows(0).size == 1)
assert(rows(0)(0).size == "efg".length + sut.marginSize) // 6
}
+ @Test def badFit() = {
+ val sut = VTabby(isAcross = true)
+ val items = ('a' until 'z').map(_.toString).toList
+ val rows = sut tabulate items
+ assert(rows.size == 2)
+ assert(rows(0).size == 20) // 20 * 4 = 80
+ assert(rows(1)(0).dropRight(sut.marginSize) == "u")
+ }
+ @Test def badFitter() = {
+ val sut = VTabby(isAcross = true)
+ val items = List (
+ "%", "&", "*", "+", "-", "/", ">", ">=", ">>", ">>>", "^",
+ "asInstanceOf", "isInstanceOf", "toByte", "toChar", "toDouble", "toFloat",
+ "toInt", "toLong", "toShort", "toString", "unary_+", "unary_-", "unary_~", "|"
+ )
+ val rows = sut tabulate items
+ assert(rows.size == 4)
+ assert(rows(3).size == 4) // 7 cols
+ assert(rows(3)(0).dropRight(sut.marginSize) == "unary_+")
+ }
}
diff --git a/test/pending/jvm/javasigs.scala b/test/pending/jvm/javasigs.scala
index 8da59ab0a0..d18a4e6fb5 100644
--- a/test/pending/jvm/javasigs.scala
+++ b/test/pending/jvm/javasigs.scala
@@ -32,7 +32,7 @@ object Scalatest {
}
- /** Execute cmd, wait for the process to end and pipe it's output to stdout */
+ /** Execute cmd, wait for the process to end and pipe its output to stdout */
def exec(cmd: String) {
val proc = Runtime.getRuntime().exec(cmd)
val inp = new BufferedReader(new InputStreamReader(proc.getInputStream))
diff --git a/test/scaladoc/resources/SI-4476.scala b/test/scaladoc/resources/SI-4476.scala
new file mode 100644
index 0000000000..eb35ef45e7
--- /dev/null
+++ b/test/scaladoc/resources/SI-4476.scala
@@ -0,0 +1,9 @@
+package foo
+
+@deprecated("","")
+class A
+
+class B {
+ @deprecated("","")
+ def bar = 1
+}
diff --git a/test/scaladoc/resources/Trac4420.scala b/test/scaladoc/resources/Trac4420.scala
index dbe053f3da..d8e207876b 100644
--- a/test/scaladoc/resources/Trac4420.scala
+++ b/test/scaladoc/resources/Trac4420.scala
@@ -1,7 +1,7 @@
import java.io.File
/**
- * @define PP This class is an instance of XXX so it's members are not called directly.
+ * @define PP This class is an instance of XXX so its members are not called directly.
* Instead these classes are instantiated via a driver's ''process''. See YYY for more details. */
abstract class test
diff --git a/test/scaladoc/scalacheck/DeprecatedIndexTest.scala b/test/scaladoc/scalacheck/DeprecatedIndexTest.scala
new file mode 100644
index 0000000000..4a5a2001d4
--- /dev/null
+++ b/test/scaladoc/scalacheck/DeprecatedIndexTest.scala
@@ -0,0 +1,50 @@
+import org.scalacheck._
+import org.scalacheck.Prop._
+
+import scala.tools.nsc.doc
+import scala.tools.nsc.doc.html.page.DeprecatedIndex
+import java.net.{URLClassLoader, URLDecoder}
+
+object Test extends Properties("IndexScript") {
+
+ def getClasspath = {
+ // these things can be tricky
+ // this test previously relied on the assumption that the current thread's classloader is an url classloader and contains all the classpaths
+ // does partest actually guarantee this? to quote Leonard Nimoy: The answer, of course, is no.
+ // this test _will_ fail again some time in the future.
+ // Footnote: java.lang.ClassCastException: org.apache.tools.ant.loader.AntClassLoader5 cannot be cast to java.net.URLClassLoader
+ val loader = Thread.currentThread.getContextClassLoader.asInstanceOf[URLClassLoader]
+ val paths = loader.getURLs.map(u => URLDecoder.decode(u.getPath))
+ paths mkString java.io.File.pathSeparator
+ }
+
+ val docFactory = {
+ val settings = new doc.Settings({Console.err.println(_)})
+ settings.scaladocQuietRun = true
+ settings.nowarn.value = true
+ settings.classpath.value = getClasspath
+ val reporter = new scala.tools.nsc.reporters.ConsoleReporter(settings)
+ new doc.DocFactory(reporter, settings)
+ }
+
+ val indexModelFactory = doc.model.IndexModelFactory
+
+ def createDeprecatedScript(path: String) =
+ docFactory.makeUniverse(Left(List(path))) match {
+ case Some(universe) => {
+ val index = new DeprecatedIndex(universe, indexModelFactory.makeIndex(universe))
+ Some(index)
+ }
+ case _ =>
+ None
+ }
+
+ property("deprecated-list page lists deprecated members") = {
+ createDeprecatedScript("test/scaladoc/resources/SI-4476.scala") match {
+ case Some(p) =>
+ p.deprecatedEntries.find(_._1 == "A").isDefined &&
+ p.deprecatedEntries.find(_._1 == "bar").isDefined
+ case None => false
+ }
+ }
+}
diff --git a/test/scaladoc/scalacheck/IndexTest.scala b/test/scaladoc/scalacheck/IndexTest.scala
index abc0e5da01..7dbd2103a6 100644
--- a/test/scaladoc/scalacheck/IndexTest.scala
+++ b/test/scaladoc/scalacheck/IndexTest.scala
@@ -71,7 +71,7 @@ object Test extends Properties("Index") {
case None => false
}
}
- property("browser contants a script element") = {
+ property("browser contains a script element") = {
createIndex("src/scaladoc/scala/tools/nsc/doc/html/page/Index.scala") match {
case Some(index) =>
(index.browser \ "script").size == 1
@@ -86,4 +86,10 @@ object Test extends Properties("Index") {
case None => false
}
}
+ property("index should report if there are deprecated members") = {
+ createIndex("test/scaladoc/resources/SI-4476.scala") match {
+ case Some(indexPage) => indexPage.index.hasDeprecatedMembers
+ case None => false
+ }
+ }
}
diff --git a/tools/scaladoc-compare b/tools/scaladoc-compare
index 74fbfd1dd4..46e1b75a19 100755
--- a/tools/scaladoc-compare
+++ b/tools/scaladoc-compare
@@ -7,7 +7,7 @@ if [ $# -ne 2 ]
then
echo
echo "scaladoc-compare will compare the scaladoc-generated pages in two different locations and output the diff"
- echo "it's main purpose is to track changes to scaladoc and prevent updates that break things."
+ echo "its main purpose is to track changes to scaladoc and prevent updates that break things."
echo
echo "This script is meant to be used with the scaladoc -raw-output option, as it compares .html.raw files "
echo "instead of markup-heavy .html files."