aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-02-12 09:58:33 +0100
committerMartin Odersky <odersky@gmail.com>2016-02-12 09:58:41 +0100
commit9b3c727a0faa0e0f693a4053e0bb260c695e62ff (patch)
treeb5c73f83ce89aa77a9e3da2bb9a927d563e6c70d
parent13b61653439700ca6607074bcded4d714131bdc2 (diff)
downloaddotty-9b3c727a0faa0e0f693a4053e0bb260c695e62ff.tar.gz
dotty-9b3c727a0faa0e0f693a4053e0bb260c695e62ff.tar.bz2
dotty-9b3c727a0faa0e0f693a4053e0bb260c695e62ff.zip
Survive class of errors in implicit search
An `C.this` term with erroneous class `C` will get a `NoPrefix` type. A subsequent implicit search on this crashed. This is fixed now. Fixes #324.
-rw-r--r--src/dotty/tools/dotc/typer/Implicits.scala3
-rw-r--r--test/dotc/tests.scala1
-rw-r--r--tests/neg/i324.scala5
3 files changed, 8 insertions, 1 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/test/dotc/tests.scala b/test/dotc/tests.scala
index 361048236..f9860b4aa 100644
--- a/test/dotc/tests.scala
+++ b/test/dotc/tests.scala
@@ -155,6 +155,7 @@ 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)
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
+}