aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/typer/Implicits.scala3
-rw-r--r--src/dotty/tools/dotc/typer/TypeAssigner.scala7
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala2
-rw-r--r--test/dotc/tests.scala2
-rw-r--r--test/dotty/partest/DPConfig.scala8
-rw-r--r--test/dotty/partest/DPConsoleRunner.scala5
-rw-r--r--tests/neg/amp.scala (renamed from tests/pending/run/amp.scala)0
-rw-r--r--tests/neg/i324.scala5
-rw-r--r--tests/pos/i324.scala7
9 files changed, 34 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/typer/Implicits.scala b/src/dotty/tools/dotc/typer/Implicits.scala
index 6cb1f1271..e3dd113c2 100644
--- a/src/dotty/tools/dotc/typer/Implicits.scala
+++ b/src/dotty/tools/dotc/typer/Implicits.scala
@@ -402,7 +402,8 @@ trait Implicits { self: Typer =>
|| (to isRef defn.ObjectClass)
|| (to isRef defn.UnitClass)
|| (from.tpe isRef defn.NothingClass)
- || (from.tpe isRef defn.NullClass)) NoImplicitMatches
+ || (from.tpe isRef defn.NullClass)
+ || (from.tpe eq NoPrefix)) NoImplicitMatches
else
try inferImplicit(to.stripTypeVar.widenExpr, from, from.pos)
catch {
diff --git a/src/dotty/tools/dotc/typer/TypeAssigner.scala b/src/dotty/tools/dotc/typer/TypeAssigner.scala
index 42ee513cd..ac46ee723 100644
--- a/src/dotty/tools/dotc/typer/TypeAssigner.scala
+++ b/src/dotty/tools/dotc/typer/TypeAssigner.scala
@@ -8,6 +8,7 @@ import Scopes._, Contexts._, Constants._, Types._, Symbols._, Names._, Flags._,
import ErrorReporting._, Annotations._, Denotations._, SymDenotations._, StdNames._, TypeErasure._
import util.Positions._
import config.Printers._
+import NameOps._
trait TypeAssigner {
import tpd._
@@ -16,7 +17,11 @@ trait TypeAssigner {
* @param packageOk The qualifier may refer to a package.
*/
def qualifyingClass(tree: untpd.Tree, qual: Name, packageOK: Boolean)(implicit ctx: Context): Symbol = {
- def qualifies(sym: Symbol) = sym.isClass && (qual.isEmpty || sym.name == qual)
+ def qualifies(sym: Symbol) =
+ sym.isClass && (
+ qual.isEmpty ||
+ sym.name == qual ||
+ sym.is(Module) && sym.name.stripModuleClassSuffix == qual)
ctx.outersIterator.map(_.owner).find(qualifies) match {
case Some(c) if packageOK || !(c is Package) =>
c
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index dd75e960e..6a2ff30fa 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -1068,7 +1068,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
val packageContext =
if (pkg is Package) ctx.fresh.setOwner(pkg.moduleClass).setTree(tree)
else {
- ctx.error(d"$pkg is not a package", tree.pos)
+ ctx.error(d"$pkg is already defined, cannot be a package", tree.pos)
ctx
}
val stats1 = typedStats(tree.stats, pkg.moduleClass)(packageContext)
diff --git a/test/dotc/tests.scala b/test/dotc/tests.scala
index 361048236..12b830738 100644
--- a/test/dotc/tests.scala
+++ b/test/dotc/tests.scala
@@ -155,9 +155,11 @@ class tests extends CompilerTest {
@Test def neg_i0091_infpaths = compileFile(negDir, "i0091-infpaths", xerrors = 3)
@Test def neg_i0248_inherit_refined = compileFile(negDir, "i0248-inherit-refined", xerrors = 4)
@Test def neg_i0281 = compileFile(negDir, "i0281-null-primitive-conforms", xerrors = 3)
+ @Test def neg_i324 = compileFile(negDir, "i324", xerrors = 2)
@Test def neg_i583 = compileFile(negDir, "i0583-skolemize", xerrors = 2)
@Test def neg_i941 = compileFile(negDir, "i941", xerrors = 3)
@Test def neg_finalSealed = compileFile(negDir, "final-sealed", xerrors = 2)
+ @Test def neg_i645 = compileFile(negDir, "amp", xerrors = 4)
@Test def neg_i705 = compileFile(negDir, "i705-inner-value-class", xerrors = 7)
@Test def neg_i803 = compileFile(negDir, "i803", xerrors = 2)
@Test def neg_i866 = compileFile(negDir, "i866", xerrors = 2)
diff --git a/test/dotty/partest/DPConfig.scala b/test/dotty/partest/DPConfig.scala
index 12453b450..79f41340c 100644
--- a/test/dotty/partest/DPConfig.scala
+++ b/test/dotty/partest/DPConfig.scala
@@ -4,6 +4,8 @@ import scala.collection.JavaConversions._
import scala.reflect.io.Path
import java.io.File
+import scala.tools.partest.PartestDefaults
+
/** Dotty Partest runs all tests in the provided testDirs located under
* testRoot. There can be several directories with pos resp. neg tests, as
@@ -15,6 +17,12 @@ import java.io.File
* otherwise pos/__defaultFlags.flags are used if the file exists).
*/
object DPConfig {
+ /** Options used for _running_ the run tests.
+ * Note that this is different from the options used when _compiling_ tests,
+ * those are determined by the sbt configuration.
+ */
+ val runJVMOpts = s"-Xms64M -Xmx1024M ${PartestDefaults.javaOpts}"
+
val testRoot = (Path(".") / Path("tests") / Path("partest-generated")).toString
val genLog = Path(testRoot) / Path("gen.log")
diff --git a/test/dotty/partest/DPConsoleRunner.scala b/test/dotty/partest/DPConsoleRunner.scala
index fa6256398..baa62579c 100644
--- a/test/dotty/partest/DPConsoleRunner.scala
+++ b/test/dotty/partest/DPConsoleRunner.scala
@@ -65,8 +65,9 @@ class DPSuiteRunner(testSourcePath: String, // relative path, like "files", or "
consoleArgs: String,
javaCmdPath: String = PartestDefaults.javaCmd,
javacCmdPath: String = PartestDefaults.javacCmd,
- scalacExtraArgs: Seq[String] = Seq.empty)
-extends SuiteRunner(testSourcePath, fileManager, updateCheck, failed, javaCmdPath, javacCmdPath, scalacExtraArgs) {
+ scalacExtraArgs: Seq[String] = Seq.empty,
+ javaOpts: String = DPConfig.runJVMOpts)
+extends SuiteRunner(testSourcePath, fileManager, updateCheck, failed, javaCmdPath, javacCmdPath, scalacExtraArgs, javaOpts) {
if (!DPConfig.runTestsInParallel)
sys.props("partest.threads") = "1"
diff --git a/tests/pending/run/amp.scala b/tests/neg/amp.scala
index da35242a9..da35242a9 100644
--- a/tests/pending/run/amp.scala
+++ b/tests/neg/amp.scala
diff --git a/tests/neg/i324.scala b/tests/neg/i324.scala
new file mode 100644
index 000000000..1d03a4d02
--- /dev/null
+++ b/tests/neg/i324.scala
@@ -0,0 +1,5 @@
+class O
+object O {
+ val x: this.type = OO.this
+ val y: O = OO.this
+}
diff --git a/tests/pos/i324.scala b/tests/pos/i324.scala
new file mode 100644
index 000000000..5461379be
--- /dev/null
+++ b/tests/pos/i324.scala
@@ -0,0 +1,7 @@
+class O
+object O {
+ val x: this.type = O.this
+}
+object O2 {
+ val x: this.type = O2.this
+}