aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala2
-rw-r--r--compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala17
-rw-r--r--compiler/src/dotty/tools/io/ClassPath.scala14
-rw-r--r--compiler/test/dotty/tools/dotc/ParallelTesting.scala5
-rw-r--r--doc-tool/resources/css/dottydoc.css20
-rw-r--r--docs/docs/contributing/testing.md89
-rw-r--r--docs/docs/contributing/workflow.md16
-rw-r--r--docs/docs/internals/higher-kinded-v2.md9
-rw-r--r--docs/sidebar.yml2
-rw-r--r--tests/run/i2156.scala37
10 files changed, 179 insertions, 32 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
index bc140c26b..e0b233ce8 100644
--- a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
+++ b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
@@ -661,7 +661,7 @@ class ClassfileParser(
for (entry <- innerClasses.values) {
// create a new class member for immediate inner classes
if (entry.outerName == currentClassName) {
- val file = ctx.platform.classPath.findSourceFile(entry.externalName.toString) getOrElse {
+ val file = ctx.platform.classPath.findBinaryFile(entry.externalName.toString) getOrElse {
throw new AssertionError(entry.externalName)
}
enterClassAndModule(entry, file, entry.jflags)
diff --git a/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala b/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala
index 7576ccc05..b0ae36612 100644
--- a/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala
+++ b/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala
@@ -848,13 +848,14 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {
val nextBinder = afterTest.asTerm
- def needsOuterTest(patType: Type, selType: Type, currentOwner: Symbol): Boolean = {
+ def outerTestNeeded(implicit ctx: Context): Boolean = {
// See the test for SI-7214 for motivation for dealias. Later `treeCondStrategy#outerTest`
// generates an outer test based on `patType.prefix` with automatically dealises.
- patType.dealias match {
- case tref @ TypeRef(pre, name) =>
- (pre ne NoPrefix) && tref.symbol.isClass &&
- ExplicitOuter.needsOuterIfReferenced(tref.symbol.asClass)
+ expectedTp.dealias match {
+ case tref @ TypeRef(pre: SingletonType, name) =>
+ val s = tref
+ s.symbol.isClass &&
+ ExplicitOuter.needsOuterIfReferenced(s.symbol.asClass)
case _ =>
false
}
@@ -862,12 +863,6 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {
override lazy val introducedRebindings = NoRebindings
- def outerTestNeeded = {
- val np = expectedTp.normalizedPrefix
- val ts = np.termSymbol
- (ts ne NoSymbol) && needsOuterTest(expectedTp, testedBinder.info, ctx.owner)
- }
-
// the logic to generate the run-time test that follows from the fact that
// a `prevBinder` is expected to have type `expectedTp`
// the actual tree-generation logic is factored out, since the analyses generate Cond(ition)s rather than Trees
diff --git a/compiler/src/dotty/tools/io/ClassPath.scala b/compiler/src/dotty/tools/io/ClassPath.scala
index 3afbed838..5e77c1b61 100644
--- a/compiler/src/dotty/tools/io/ClassPath.scala
+++ b/compiler/src/dotty/tools/io/ClassPath.scala
@@ -240,22 +240,16 @@ abstract class ClassPath {
def findClass(name: String): Option[AnyClassRep] =
name.splitWhere(_ == '.', doDropIndex = true) match {
case Some((pkg, rest)) =>
- val rep = packages find (_.name == pkg) flatMap (_ findClass rest)
- rep map {
- case x: ClassRep => x
- case x => throw new FatalError("Unexpected ClassRep '%s' found searching for name '%s'".format(x, name))
- }
+ packages find (_.name == pkg) flatMap (_ findClass rest)
case _ =>
classes find (_.name == name)
}
- def findSourceFile(name: String): Option[AbstractFile] =
- findClass(name) match {
- case Some(ClassRep(Some(x: AbstractFile), _)) => Some(x)
- case _ => None
- }
+ def findBinaryFile(name: String): Option[AbstractFile] =
+ findClass(name).flatMap(_.binary)
def sortString = join(split(asClasspathString).sorted: _*)
+
override def equals(that: Any) = that match {
case x: ClassPath => this.sortString == x.sortString
case _ => false
diff --git a/compiler/test/dotty/tools/dotc/ParallelTesting.scala b/compiler/test/dotty/tools/dotc/ParallelTesting.scala
index c1da7807b..2b20887e3 100644
--- a/compiler/test/dotty/tools/dotc/ParallelTesting.scala
+++ b/compiler/test/dotty/tools/dotc/ParallelTesting.scala
@@ -954,9 +954,8 @@ trait ParallelTesting { self =>
private def compilationTargets(sourceDir: JFile): (List[JFile], List[JFile]) =
sourceDir.listFiles.foldLeft((List.empty[JFile], List.empty[JFile])) { case ((dirs, files), f) =>
if (f.isDirectory) (f :: dirs, files)
- else if (f.getName.endsWith(".check")) (dirs, files)
- else if (f.getName.endsWith(".flags")) (dirs, files)
- else (dirs, f :: files)
+ else if (isSourceFile(f)) (dirs, f :: files)
+ else (dirs, files)
}
/** Gets the name of the calling method via reflection.
diff --git a/doc-tool/resources/css/dottydoc.css b/doc-tool/resources/css/dottydoc.css
index 0b833830c..a89e23375 100644
--- a/doc-tool/resources/css/dottydoc.css
+++ b/doc-tool/resources/css/dottydoc.css
@@ -334,3 +334,23 @@ blockquote {
color: #777;
border-left: 0.25em solid #ddd;
}
+
+aside {
+ padding: 15px;
+ margin: 10px 0;
+}
+
+aside.warning {
+ border-left: 3px solid #d62c2c;
+ background-color: #ffe4e4;
+}
+
+aside.notice {
+ border-left: 3px solid #4c97e4;
+ background-color: #e4ebff;
+}
+
+aside.success {
+ border-left: 3px solid #36bf1d;
+ background-color: #ebfddd;
+}
diff --git a/docs/docs/contributing/testing.md b/docs/docs/contributing/testing.md
new file mode 100644
index 000000000..07aab1918
--- /dev/null
+++ b/docs/docs/contributing/testing.md
@@ -0,0 +1,89 @@
+---
+layout: doc-page
+title: Testing in Dotty
+---
+
+<aside class="warning">
+This page should be updated as soon as scala-partest is removed
+</aside>
+
+Running all tests in Dotty is as simple as:
+
+```bash
+$ sbt test
+```
+
+There are currently several forms of tests in Dotty. These can be split into
+two categories:
+
+## Unit tests
+These tests can be found in `<sub-project>/test` and are used to check
+functionality of specific parts of the codebase in isolation e.g: parsing,
+scanning and message errors.
+
+Running a single unit test class from sbt is as simple as:
+
+```bash
+> testOnly absolute.path.to.TestClass
+```
+
+You can further restrict the executed tests to a subset of `TestClass` methods
+as follows:
+
+```bash
+> testOnly absolute.path.to.TestClass -- *methodName
+```
+
+## Integration tests
+These tests are Scala source files expected to compile with Dotty (pos tests),
+along with their expected output (run tests) or errors (neg tests).
+
+All of these tests are contained in the `./tests/*` directories.
+
+## scala-partest
+Historically these tests needed a structure which was generated by running the
+unit tests, and then that structure was in turn used by
+[scala-partest](http://github.com/scala/scala-partest) to run compilation tests
+in parallel.
+
+This test suite can still be used (and is currently a part of the CI to check
+that it has the same outcome as the new test suite). It is invoked from sbt by
+running one of the following commands:
+
+```bash
+> partest-only-no-bootstrap
+> partest-only
+> partest
+```
+
+- `partest-only-no-bootstrap` will only run the integration tests
+- `partest-only` will bootstrap the compiler and run the integration tests
+- `partest` will bootstrap the compiler, run the unit tests and then the
+ integration tests
+
+## dotty parallel test suite
+The new test suite will soon become the standard integration test runner. It
+has several advantages over the old implementation:
+
+- integrates with JUnit, without the need for setup
+- reuses the same VM for compilation
+- allows filtering of tests
+- runs much faster (almost 2x)
+
+Currently to run these tests you need to invoke from sbt:
+
+```bash
+> testOnly dotty.tools.dotc.CompilationTests
+```
+
+This might be aliased in the future. It is also possible to run tests filtered
+by using:
+
+```bash
+> filterTest .*i2147.scala
+```
+
+This will run both the test `./tests/pos/i2147.scala` and
+`./tests/partest-test/i2147.scala` since both of these match the given regular
+expression. This also means that you could run `filterTest .*` to run all
+integration tests.
diff --git a/docs/docs/contributing/workflow.md b/docs/docs/contributing/workflow.md
index 6e7f5b9a0..3c654e8f6 100644
--- a/docs/docs/contributing/workflow.md
+++ b/docs/docs/contributing/workflow.md
@@ -57,11 +57,21 @@ $ sbt
To test a specific test tests/x/y.scala (for example tests/pos/t210.scala):
```bash
-> partest-only-no-bootstrap --show-diff --verbose tests/partest-generated/x/y.scala
+> filterTest .*pos/t210.scala
```
-Currently this will re-run some unit tests and do some preprocessing because of
-the way partest has been set up.
+The filterTest task takes a regular expression as its argument. For example,
+you could run a negative and a positive test with:
+
+```bash
+> filterTest (.*pos/t697.scala)|(.*neg/i2101.scala)
+```
+
+or if they have the same name, the equivalent can be achieved with:
+
+```bash
+> filterTest .*/i2101.scala
+```
## Inspecting Trees with Type Stealer ##
diff --git a/docs/docs/internals/higher-kinded-v2.md b/docs/docs/internals/higher-kinded-v2.md
index 4676d3ebd..3c857d4d5 100644
--- a/docs/docs/internals/higher-kinded-v2.md
+++ b/docs/docs/internals/higher-kinded-v2.md
@@ -3,10 +3,11 @@ layout: doc-page
title: "Higher-Kinded Types in Dotty"
---
-**This page is out of date and preserved for posterity. Please see [Implementing
-Higher-Kinded Types in
-Dotty](http://guillaume.martres.me/publications/dotty-hk.pdf) for a more up to
-date version**
+<aside class="warning">
+ This page is out of date and preserved for posterity. Please see
+ <a href="http://guillaume.martres.me/publications/dotty-hk.pdf">
+ Implementing Higher-Kinded Types in Dotty</a> for a more up to date version
+</aside>
Higher-Kinded Types in Dotty V2
===============================
diff --git a/docs/sidebar.yml b/docs/sidebar.yml
index 7ffa1f5b7..4065cff20 100644
--- a/docs/sidebar.yml
+++ b/docs/sidebar.yml
@@ -23,6 +23,8 @@ sidebar:
url: docs/contributing/intellij-idea.html
- title: Workflow
url: docs/contributing/workflow.html
+ - title: Testing
+ url: docs/contributing/testing.html
- title: Internals
subsection:
- title: Backend
diff --git a/tests/run/i2156.scala b/tests/run/i2156.scala
new file mode 100644
index 000000000..12ce8fa88
--- /dev/null
+++ b/tests/run/i2156.scala
@@ -0,0 +1,37 @@
+class Outer {
+
+ case class Inner()
+
+ val inner: Inner = new Inner
+
+ def checkInstance(o: Outer) =
+ o.inner.isInstanceOf[this.Inner]
+
+ def checkPattern1(i: Any) =
+ i match {
+ case _: Inner => true
+ case _ => false
+ }
+
+ def checkPattern2(i: Any) =
+ i match {
+ case Inner() => true
+ case _ => false
+ }
+
+ def checkEquals(o: Outer) =
+ o.inner == inner
+}
+
+object Test {
+
+ def main(args: Array[String]) = {
+ val o1 = new Outer
+ val o2 = new Outer
+ assert(o1.checkInstance(o2)) // ok
+ assert(!o1.checkPattern1(o2.inner)) // ok under scalac, fails for dotc-compiled code
+ assert(!o1.checkPattern2(o2.inner)) // ok under scalac, fails for dotc-compiled code
+ assert(!o1.checkEquals(o2)) // ok under scalac, fails for dotc-compiled code
+ }
+}
+