Skip to content

Commit 5095b1e

Browse files
committed
Merge remote-tracking branch 'origin/2.12.x' into 2.13.x
only trivial merge conflict involving a method renaming * d1d700e - (origin/HEAD, origin/2.12.x) Merge pull request scala#5754 from Philippus/issue/html-tag-in-hover (2 days ago) <Lukas Rytz> |\ | * cf64718 - pattern for entitylink was too narrow, cleaned up the tests (3 days ago) <Philippus Baalman> * | f771395 - Merge pull request scala#5671 from retronym/topic/stubby-2 (3 days ago) <Lukas Rytz> |\ \ | * | ad13063 - Remove non-essential fix for stub symbol failure (4 days ago) <Jason Zaugg> | * | 7f2d1fa - Avoid forcing info transforms of primitive methods (2 weeks ago) <Jason Zaugg> | * | 37a0eb7 - Avoid stub symbol related crash in backend (2 weeks ago) <Jason Zaugg> * | | 96a7617 - Merge pull request scala#5622 from edmundnoble/extra-errs (4 days ago) <Adriaan Moors> |\ \ \ | * | | 466e52b - Match error lengths (4 weeks ago) <Edmund Noble> | * | | d1fc983 - Improved error messages for identically named, differently prefixed types (9 weeks ago) <Edmund Noble> | / / * | | f2e05c2 - Merge pull request scala#5728 from Philippus/issue/html-tag-in-hover (4 days ago) <Lukas Rytz> |\ \ \ | | |/ | |/| | * | e3c5df8 - added missing Inline matches to inlineToStr so it is now exhaustive scala.xml.XML.loadString(tag).text will remove all html tags inside the HtmlTag (9 days ago) <Philippus Baalman> * | | 920bc4e - Merge pull request scala#5743 from som-snytt/issue/10207-bad-update (7 days ago) <Lukas Rytz> |\ \ \ | * | | 094f7f9 - SI-10207 Error before update conversion (8 days ago) <Som Snytt> * | | | 1b4d36f - Merge pull request scala#5746 from paulp/pr/partest (7 days ago) <Lukas Rytz> |\ \ \ \ | |/ / / |/| | | | * | | eac00e1 - Add partest paths to the list of watched sources. (8 days ago) <Paul Phillips> |/ / / * | | 5f1a638 - Merge pull request scala#5732 from retronym/topic/build-info-malarkey (10 days ago) <Adriaan Moors> |\ \ \ | * | | 5e9acac - More predictable performance of SBT build startup, reload (11 days ago) <Jason Zaugg> | / / * | | 759a7b7 - Merge pull request scala#5735 from SethTisue/sd-313 (10 days ago) <Adriaan Moors> |\ \ \ | * | | ed4ddf5 - increase timeouts on some sys.process tests (11 days ago) <Seth Tisue> * | | | e2aaf2c - Merge pull request scala#5723 from dragos/issue/regression-assert-ide (11 days ago) <Lukas Rytz> |\ \ \ \ | |/ / / |/| | | | * | | e5c957e - Fix regression in 5751763 (12 days ago) <Iulian Dragos> * | | | f174bfb - Merge pull request scala#5731 from janekdb/issue/scalaGH-644/fix-spec-latex-rendering (11 days ago) <Seth Tisue> |\ \ \ \ | * | | | ba4c6d4 - scalaGH-644: Remove static html styling of spec code blocks (11 days ago) <Janek Bogucki> |/ / / / * | | | 8e40bef - Merge pull request scala#5729 from scala/revert-5658-topic/hashhash (12 days ago) <Adriaan Moors> |\ \ \ \ | |_|/ / |/| | | | * | | 86cd70f - (origin/revert-5658-topic/hashhash) Revert "Fix erasure of the qualifier of ##" (12 days ago) <Adriaan Moors> |/ / / * | | cbf7daa - Merge pull request scala#5681 from Philippus/issue/9704 (13 days ago) <Lukas Rytz> |\ \ \ | * | | b8a8ac1 - moved Pattern and TagsNotToClose to a HtmlTag companion object (13 days ago) <Philippus Baalman> | * | | a019082 - SI-9704 don't add a closed HtmlTag if it is already closed (4 weeks ago) <Philippus Baalman> | / / * | | effde0c - Merge pull request scala#5726 from scala/revert-5629-issue/10120-quote-err (13 days ago) <Adriaan Moors> |\ \ \ | * | | d60f6e3 - (origin/revert-5629-issue/10120-quote-err) Revert "SI-10133 Require escaped single quote char lit" (13 days ago) <Adriaan Moors> |/ / / * | | a8c4a54 - Merge pull request scala#5663 from gourlaysama/ticket/sd-256-enable-repl-colors-unix-2 (13 days ago) <Adriaan Moors> |\ \ \ | * | | 6411170 - SD-256 enable colored output by default on unix (13 days ago) <Antoine Gourlay> * | | | c96a977 - Merge pull request scala#5658 from retronym/topic/hashhash (13 days ago) <Lukas Rytz> |\ \ \ \ | |/ / / |/| | | | * | | f85c62e - Fix erasure of the qualifier of ## (6 weeks ago) <Jason Zaugg> | / / * | | 76bfb9e - Merge pull request scala#5708 from szeiger/issue/si10194 (13 days ago) <Lukas Rytz> |\ \ \ | * | | 1d22ee4 - SI-10194: Fix abstract type resolution for overloaded HOFs (13 days ago) <Stefan Zeiger> | / / * | | dabec1a - Merge pull request scala#5700 from retronym/ticket/10154-refactor (13 days ago) <Lukas Rytz> |\ \ \ | * | | 06eee79 - Refactor implementation of lookupCompanion (2 weeks ago) <Jason Zaugg> | / / * | | 2f1e0c2 - Merge pull request scala#5704 from som-snytt/issue/10190-elide-string (13 days ago) <Lukas Rytz> |\ \ \ | * | | 6fb3825 - SI-10190 Elide string to empty instead of null (3 weeks ago) <Som Snytt> | / / * | | 13f7b2a - Merge pull request scala#5640 from optimizely/repl-import-handler (2 weeks ago) <Adriaan Moors> |\ \ \ | * | | aa7e335 - Fix ImportHandler's reporting of importedNames and importedSymbols (8 weeks ago) <Hao Xia> | * | | c89d821 - Fix SIOOBE in Name#pos for substrings of length 1 (8 weeks ago) <Jason Zaugg> | / / * | | 023a96a - Merge pull request scala#5629 from som-snytt/issue/10120-quote-err (2 weeks ago) <Adriaan Moors> |\ \ \ | * | | 05cc3e2 - SI-10120 ReplReporter handles message indent (7 weeks ago) <Som Snytt> | * | | 939abf1 - SI-10120 Extra advice on unclosed char literal (8 weeks ago) <Som Snytt> | * | | 855492c - SI-10133 Require escaped single quote char lit (8 weeks ago) <Som Snytt> | / / * | | e21ab42 - Merge pull request scala#5660 from som-snytt/issue/9464-spec (2 weeks ago) <Adriaan Moors> |\ \ \ | * | | a6dcceb - SI-9464 Clarify spec on no final trait (6 weeks ago) <Som Snytt> | / / * | | e87a436 - Merge pull request scala#5659 from retronym/ticket/10026 (2 weeks ago) <Adriaan Moors> |\ \ \ | |/ / |/| | | * | 777a0e5 - SI-10026 Fix endless cycle in runtime reflection (2 weeks ago) <Jason Zaugg> | |/ * | 23e5ed9 - Merge pull request scala#5707 from retronym/topic/java9-prepare (2 weeks ago) <Lukas Rytz> |\ \ | * | 96e8e97 - Workaround bug in Scala runtime reflection on JDK 9 (3 weeks ago) <Jason Zaugg> | * | fe2d9a4 - Avoid ambiguous overload on JDK 9 (3 weeks ago) <Jason Zaugg> | * | 6bba8f7 - Adapt to change in ClassLoader in JDK 9 (3 weeks ago) <Jason Zaugg> | * | 8136057 - Bump scala-asm version (3 weeks ago) <Jason Zaugg> | / * | cad3c3d - Merge pull request scala#5709 from adriaanm/sam_wild_bound (2 weeks ago) <Lukas Rytz> |\ \ | * | c396e96 - Ignore BoundedWildcardType in erasure type map (2 weeks ago) <Adriaan Moors> * | | 3e9df41 - Merge pull request scala#5711 from retronym/ticket/jrt (2 weeks ago) <Lukas Rytz> |\ \ \ | * | | 09c7edc - Faster and simpler Java 9 classpath implementation (2 weeks ago) <Jason Zaugg> | / / * | | 7b9d3cc - Merge pull request scala#5713 from janekdb/issue/scalaGH-644/sync-jekyll-README-to-Gemfile (2 weeks ago) <Lukas Rytz> |\ \ \ | * | | 5e5ec9a - scalaGH-644: Expand note regarding Jekyll versions (2 weeks ago) <Janek Bogucki> | / / * | | 144f7e0 - Merge pull request scala#5714 from dragos/issue/usage-sterr-SI-10178 (2 weeks ago) <Lukas Rytz> |\ \ \ | |/ / |/| | | * | 640c85e - SI-10178 Route reporter.echo to stdout (2 weeks ago) <Iulian Dragos> | / * | 2fec08b - Merge pull request scala#5717 from som-snytt/issue/10148-followup (2 weeks ago) <Adriaan Moors> |\ \ | |/ |/| | * f3d271b - SI-10148 Accept verbose zero (2 weeks ago) <Som Snytt> * 147e5dd - Merge pull request scala#5716 from adriaanm/i296 (2 weeks ago) <Jason Zaugg> * 12437a0 - Ensure ordering for args to `choose` in DurationTest (2 weeks ago) <Adriaan Moors>
2 parents 9f06766 + d1d700e commit 5095b1e

File tree

78 files changed

+798
-242
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+798
-242
lines changed

bincompat-backward.whitelist.conf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ filter {
3333
matchName="scala.sys.process.ProcessImpl#CompoundProcess.getExitValue"
3434
problemName=DirectMissingMethodProblem
3535
},
36+
{
37+
matchName="scala.reflect.runtime.SynchronizedOps.scala$reflect$runtime$SynchronizedOps$$super$newMappedBaseTypeSeq"
38+
problemName=ReversedMissingMethodProblem
39+
},
40+
{
41+
matchName="scala.reflect.runtime.SynchronizedOps#SynchronizedBaseTypeSeq.lateMap"
42+
problemName=DirectMissingMethodProblem
43+
},
3644
{
3745
matchName="scala.collection.immutable.HashMap.contains0"
3846
problemName=DirectMissingMethodProblem

bincompat-forward.whitelist.conf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ filter {
4343
matchName="scala.util.hashing.MurmurHash3.wrappedArrayHash"
4444
problemName=DirectMissingMethodProblem
4545
},
46+
{
47+
matchName="scala.reflect.runtime.SynchronizedOps.newMappedBaseTypeSeq"
48+
problemName=DirectMissingMethodProblem
49+
},
50+
{
51+
matchName="scala.reflect.runtime.JavaUniverse.newMappedBaseTypeSeq"
52+
problemName=DirectMissingMethodProblem
53+
},
4654
{
4755
matchName="scala.collection.immutable.HashMap.contains0"
4856
problemName=DirectMissingMethodProblem
@@ -415,6 +423,14 @@ filter {
415423
{
416424
matchName="scala.annotation.showAsInfix"
417425
problemName=MissingClassProblem
426+
},
427+
{
428+
matchName="scala.util.PropertiesTrait.coloredOutputEnabled"
429+
problemName=DirectMissingMethodProblem
430+
},
431+
{
432+
matchName="scala.util.Properties.coloredOutputEnabled"
433+
problemName=DirectMissingMethodProblem
418434
}
419435
]
420436
}

build.sbt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
* - to modularize the Scala compiler or library further
3333
*/
3434

35+
import scala.build._
3536
import VersionUtil._
3637

3738
// Scala dependencies:
@@ -1019,6 +1020,9 @@ commands += Command("partest")(_ => PartestUtil.partestParser((baseDirectory in
10191020
("test/it:testOnly -- " + parsed) :: state
10201021
}
10211022

1023+
// Watch the test files also so ~partest triggers on test case changes
1024+
watchSources ++= PartestUtil.testFilePaths((baseDirectory in ThisBuild).value, (baseDirectory in ThisBuild).value / "test")
1025+
10221026
// Add tab completion to scalac et al.
10231027
commands ++= {
10241028
val commands =

project/BuildSettings.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package scala.build
2+
13
import sbt._
24

35
/** This object defines keys that should be visible with an unqualified name in all .sbt files and the command line */

project/GenerateAnyVals.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package scala.build
2+
13
/** Code generation of the AnyVal types and their companions. */
24
trait GenerateAnyValReps {
35
self: GenerateAnyVals =>

project/JarJar.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package scala.build
2+
13
import org.pantsbuild.jarjar
24
import org.pantsbuild.jarjar._
35
import org.pantsbuild.jarjar.util._

project/MiMa.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package scala.build
2+
13
// It would be nice to use sbt-mima-plugin here, but the plugin is missing
24
// at least two features we need:
35
// * ability to run MiMa twice, swapping `curr` and `prev`, to detect

project/Osgi.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package scala.build
2+
13
import aQute.bnd.osgi.Builder
24
import aQute.bnd.osgi.Constants._
35
import java.util.Properties

project/ParserUtil.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package scala.build
2+
13
import sbt._
24
import sbt.complete.Parser._
35
import sbt.complete.Parsers._

project/PartestUtil.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package scala.build
2+
13
import sbt._
24
import sbt.complete._, Parser._, Parsers._
35

@@ -24,6 +26,10 @@ object PartestUtil {
2426
isParentOf(testBase / srcPath, f, 2) || isParentOf(f, testBase / srcPath, Int.MaxValue)
2527
}
2628
}
29+
30+
def testFilePaths(globalBase: File, testBase: File): Seq[java.io.File] =
31+
(new TestFiles("files", globalBase, testBase)).allTestCases.map(_._1)
32+
2733
/** A parser for the custom `partest` command */
2834
def partestParser(globalBase: File, testBase: File): Parser[String] = {
2935
val knownUnaryOptions = List(

project/Quiet.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package scala.build
2+
13
import sbt._
24
import Keys._
35

project/ScalaOptionParser.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package scala.build
2+
13
import ParserUtil._
24
import sbt._
35
import sbt.complete.Parser._

project/ScalaTool.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package scala.build
2+
13
import sbt._
24
import org.apache.commons.lang3.SystemUtils
35
import org.apache.commons.lang3.StringUtils.replaceEach

project/ScriptCommands.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package scala.build
2+
13
import sbt._
24
import Keys._
35
import BuildSettings.autoImport._

project/VersionUtil.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package scala.build
2+
13
import sbt._
24
import Keys._
35
import java.util.Properties

project/plugins.sbt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ buildInfoKeys := Seq[BuildInfoKey](buildClasspath)
2020
buildInfoPackage := "scalabuild"
2121

2222
libraryDependencies += "com.typesafe" %% "mima-reporter" % "0.1.13"
23+
24+
concurrentRestrictions in Global := Seq(
25+
Tags.limitAll(1) // workaround for https://github.com/sbt/sbt/issues/2970
26+
)

spec/05-classes-and-objects.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -597,10 +597,12 @@ overridden in subclasses. A `final` class may not be inherited by
597597
a template. `final` is redundant for object definitions. Members
598598
of final classes or objects are implicitly also final, so the
599599
`final` modifier is generally redundant for them, too. Note, however, that
600-
[constant value definitions](04-basic-declarations-and-definitions.html#value-declarations-and-definitions) do require
601-
an explicit `final` modifier, even if they are defined in a final class or
602-
object. `final` may not be applied to incomplete members, and it may not be
603-
combined in one modifier list with `sealed`.
600+
[constant value definitions](04-basic-declarations-and-definitions.html#value-declarations-and-definitions)
601+
do require an explicit `final` modifier,
602+
even if they are defined in a final class or object.
603+
`final` is permitted for abstract classes
604+
but it may not be applied to traits or incomplete members,
605+
and it may not be combined in one modifier list with `sealed`.
604606

605607
### `sealed`
606608
The `sealed` modifier applies to class definitions. A

spec/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ Third, we'd like to support different output formats. An html page per chapter w
88

99
## Editing
1010

11-
We use Jekyll 2 and [Redcarpet](https://github.com/vmg/redcarpet) to generate the html. Essentially, this is what github pages use.
11+
At the time of writing we are using Jekyll 3.3.0 and [Redcarpet 3.3.2](https://github.com/vmg/redcarpet) to generate the html.
12+
13+
Check `Gemfile` for the current versions.
14+
15+
We aim to track the configuration GitHub Pages use but at times differences will arise as GitHub Pages evolves.
1216

1317
## Building
1418

spec/_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
baseurl: /files/archive/spec/2.13
22
safe: true
33
lsi: false
4-
highlighter: null
4+
highlighter: false
55
markdown: redcarpet
66
encoding: utf-8
77
redcarpet:

src/compiler/scala/tools/nsc/Global.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,10 +953,11 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
953953
definitions.isDefinitionsInitialized
954954
&& rootMirror.isMirrorInitialized
955955
)
956-
override def isPastTyper = (
956+
override def isPastTyper = isPast(currentRun.typerPhase)
957+
def isPast(phase: Phase) = (
957958
(curRun ne null)
958959
&& isGlobalInitialized // defense against init order issues
959-
&& (globalPhase.id > currentRun.typerPhase.id)
960+
&& (globalPhase.id > phase.id)
960961
)
961962

962963
// TODO - trim these to the absolute minimum.

src/compiler/scala/tools/nsc/ast/parser/Scanners.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -983,15 +983,16 @@ trait Scanners extends ScannersCommon {
983983

984984
def intVal: Long = intVal(negated = false)
985985

986+
private val zeroFloat = raw"[0.]+(?:[eE][+-]?[0-9]+)?[fFdD]?".r
987+
986988
/** Convert current strVal, base to float value.
987989
*/
988990
def floatVal(negated: Boolean): Float = {
989991
try {
990992
val value: Float = java.lang.Float.parseFloat(strVal)
991993
if (value > Float.MaxValue)
992994
syntaxError("floating point number too large")
993-
val zeroly = "0.fF"
994-
if (value == 0.0f && strVal.exists(c => !zeroly.contains(c)))
995+
if (value == 0.0f && !zeroFloat.pattern.matcher(strVal).matches)
995996
syntaxError("floating point number too small")
996997
if (negated) -value else value
997998
} catch {
@@ -1010,8 +1011,7 @@ trait Scanners extends ScannersCommon {
10101011
val value: Double = java.lang.Double.parseDouble(strVal)
10111012
if (value > Double.MaxValue)
10121013
syntaxError("double precision floating point number too large")
1013-
val zeroly = "0.dD"
1014-
if (value == 0.0d && strVal.exists(c => !zeroly.contains(c)))
1014+
if (value == 0.0d && !zeroFloat.pattern.matcher(strVal).matches)
10151015
syntaxError("double precision floating point number too small")
10161016
if (negated) -value else value
10171017
} catch {

src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,9 +446,10 @@ abstract class ScalaPrimitives {
446446
inform(s"Unknown primitive method $cls.$method")
447447
else alts foreach (s =>
448448
addPrimitive(s,
449-
s.info.paramTypes match {
450-
case tp :: _ if code == ADD && tp =:= StringTpe => CONCAT
451-
case _ => code
449+
if (code != ADD) code
450+
else exitingTyper(s.info).paramTypes match {
451+
case tp :: _ if tp =:= StringTpe => CONCAT
452+
case _ => code
452453
}
453454
)
454455
)

src/compiler/scala/tools/nsc/classpath/DirectoryClassPath.scala

Lines changed: 57 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import java.util.function.IntFunction
1010
import java.util
1111
import java.util.Comparator
1212

13-
import scala.reflect.io.{AbstractFile, PlainFile}
13+
import scala.reflect.io.{AbstractFile, PlainFile, PlainNioFile}
1414
import scala.tools.nsc.util.{ClassPath, ClassRepresentation}
1515
import FileUtils._
16+
import scala.collection.JavaConverters._
1617

1718
/**
1819
* A trait allowing to look for classpath entries in directories. It provides common logic for
@@ -121,51 +122,78 @@ trait JFileDirectoryLookup[FileEntryType <: ClassRepresentation] extends Directo
121122
def asClassPathStrings: Seq[String] = Seq(dir.getPath)
122123
}
123124

124-
object JImageDirectoryLookup {
125-
import java.nio.file._, java.net.URI, scala.collection.JavaConverters._
126-
def apply(): List[ClassPath] = {
125+
object JrtClassPath {
126+
import java.nio.file._, java.net.URI
127+
def apply(): Option[ClassPath] = {
127128
try {
128129
val fs = FileSystems.getFileSystem(URI.create("jrt:/"))
129-
val dir: Path = fs.getPath("/modules")
130-
val modules = Files.list(dir).iterator().asScala.toList
131-
modules.map(m => new JImageDirectoryLookup(fs, m.getFileName.toString))
130+
Some(new JrtClassPath(fs))
132131
} catch {
133132
case _: ProviderNotFoundException | _: FileSystemNotFoundException =>
134-
Nil
133+
None
135134
}
136135
}
137136
}
138-
class JImageDirectoryLookup(fs: java.nio.file.FileSystem, module: String) extends DirectoryLookup[ClassFileEntryImpl] with NoSourcePaths {
137+
138+
/**
139+
* Implementation `ClassPath` based on the JDK 9 encapsulated runtime modules (JEP-220)
140+
*
141+
* https://bugs.openjdk.java.net/browse/JDK-8066492 is the most up to date reference
142+
* for the structure of the jrt:// filesystem.
143+
*
144+
* The implementation assumes that no classes exist in the empty package.
145+
*/
146+
final class JrtClassPath(fs: java.nio.file.FileSystem) extends ClassPath with NoSourcePaths {
139147
import java.nio.file.Path, java.nio.file._
140148
type F = Path
141-
val dir: Path = fs.getPath("/modules/" + module)
149+
private val dir: Path = fs.getPath("/packages")
142150

143-
protected def emptyFiles: Array[Path] = Array.empty
144-
protected def getSubDir(packageDirName: String): Option[Path] = {
145-
val packageDir = dir.resolve(packageDirName)
146-
if (Files.exists(packageDir) && Files.isDirectory(packageDir)) Some(packageDir)
147-
else None
151+
// e.g. "java.lang" -> Seq("/modules/java.base")
152+
private val packageToModuleBases: Map[String, Seq[Path]] = {
153+
val ps = Files.newDirectoryStream(dir).iterator().asScala
154+
def lookup(pack: Path): Seq[Path] = {
155+
Files.list(pack).iterator().asScala.map(l => if (Files.isSymbolicLink(l)) Files.readSymbolicLink(l) else l).toList
156+
}
157+
ps.map(p => (p.toString.stripPrefix("/packages/"), lookup(p))).toMap
148158
}
149-
protected def listChildren(dir: Path, filter: Option[Path => Boolean]): Array[Path] = {
150-
import scala.collection.JavaConverters._
151-
val f = filter.getOrElse((p: Path) => true)
152-
Files.list(dir).iterator().asScala.filter(f).toArray[Path]
159+
160+
override private[nsc] def packages(inPackage: String): Seq[PackageEntry] = {
161+
def matches(packageDottedName: String) =
162+
if (packageDottedName.contains("."))
163+
packageOf(packageDottedName) == inPackage
164+
else inPackage == ""
165+
packageToModuleBases.keysIterator.filter(matches).map(PackageEntryImpl(_)).toVector
166+
}
167+
private[nsc] def classes(inPackage: String): Seq[ClassFileEntry] = {
168+
if (inPackage == "") Nil
169+
else {
170+
packageToModuleBases.getOrElse(inPackage, Nil).flatMap(x =>
171+
Files.list(x.resolve(inPackage.replace('.', '/'))).iterator().asScala.filter(_.getFileName.toString.endsWith(".class"))).map(x =>
172+
ClassFileEntryImpl(new PlainNioFile(x))).toVector
173+
}
153174
}
154-
protected def getName(f: Path): String = f.getFileName.toString
155-
protected def toAbstractFile(f: Path): AbstractFile = new scala.reflect.io.PlainNioFile(f)
156-
protected def isPackage(f: Path): Boolean = Files.isDirectory(f) && maybeValidPackage(f.getFileName.toString)
175+
176+
override private[nsc] def list(inPackage: String): ClassPathEntries =
177+
if (inPackage == "") ClassPathEntries(packages(inPackage), Nil)
178+
else ClassPathEntries(packages(inPackage), classes(inPackage))
157179

158180
def asURLs: Seq[URL] = Seq(dir.toUri.toURL)
159-
def asClassPathStrings: Seq[String] = asURLs.map(_.toString)
181+
// We don't yet have a scheme to represent the JDK modules in our `-classpath`.
182+
// java models them as entries in the new "module path", we'll probably need to follow this.
183+
def asClassPathStrings: Seq[String] = Nil
160184

161185
def findClassFile(className: String): Option[AbstractFile] = {
162-
val relativePath = FileUtils.dirPath(className) + ".class"
163-
val classFile = dir.resolve(relativePath)
164-
if (Files.exists(classFile)) Some(new scala.reflect.io.PlainNioFile(classFile)) else None
186+
if (!className.contains(".")) None
187+
else {
188+
val inPackage = packageOf(className)
189+
packageToModuleBases.getOrElse(inPackage, Nil).iterator.flatMap{x =>
190+
val file = x.resolve(className.replace('.', '/') + ".class")
191+
if (Files.exists(file)) new scala.reflect.io.PlainNioFile(file) :: Nil else Nil
192+
}.take(1).toList.headOption
193+
}
165194
}
166-
override protected def createFileEntry(file: AbstractFile): ClassFileEntryImpl = ClassFileEntryImpl(file)
167-
override protected def isMatchingFile(f: Path): Boolean = Files.isRegularFile(f) && f.getFileName.toString.endsWith(".class")
168-
override private[nsc] def classes(inPackage: String): Seq[ClassFileEntry] = files(inPackage)
195+
private def packageOf(dottedClassName: String): String =
196+
dottedClassName.substring(0, dottedClassName.lastIndexOf("."))
169197
}
170198

171199
case class DirectoryClassPath(dir: File) extends JFileDirectoryLookup[ClassFileEntryImpl] with NoSourcePaths {

src/compiler/scala/tools/nsc/classpath/FileUtils.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import scala.reflect.io.AbstractFile
1313
*/
1414
object FileUtils {
1515
implicit class AbstractFileOps(val file: AbstractFile) extends AnyVal {
16-
def isPackage: Boolean = file.isDirectory && maybeValidPackage(file.name)
16+
def isPackage: Boolean = file.isDirectory && mayBeValidPackage(file.name)
1717

1818
def isClass: Boolean = !file.isDirectory && file.hasExtension("class")
1919

@@ -30,7 +30,7 @@ object FileUtils {
3030
}
3131

3232
implicit class FileOps(val file: JFile) extends AnyVal {
33-
def isPackage: Boolean = file.isDirectory && maybeValidPackage(file.getName)
33+
def isPackage: Boolean = file.isDirectory && mayBeValidPackage(file.getName)
3434

3535
def isClass: Boolean = file.isFile && file.getName.endsWith(".class")
3636
}
@@ -63,7 +63,7 @@ object FileUtils {
6363

6464
// probably it should match a pattern like [a-z_]{1}[a-z0-9_]* but it cannot be changed
6565
// because then some tests in partest don't pass
66-
def maybeValidPackage(dirName: String): Boolean =
66+
def mayBeValidPackage(dirName: String): Boolean =
6767
(dirName != "META-INF") && (dirName != "") && (dirName.charAt(0) != '.')
6868

6969
def mkFileFilter(f: JFile => Boolean) = new FileFilter {

0 commit comments

Comments
 (0)