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--test/dotc/tests.scala2
-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
6 files changed, 22 insertions, 2 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/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/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
+}