aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-08-18 09:12:04 +0200
committerMartin Odersky <odersky@gmail.com>2016-08-18 10:10:01 +0200
commitf006688d34e18553c8df800951cfa73c1aee4ea7 (patch)
treed70966523417a9075e57a3c7b7db6e949aeaba46
parentf4ab855b03e9fc0fac31018bf9383220d2399697 (diff)
downloaddotty-f006688d34e18553c8df800951cfa73c1aee4ea7.tar.gz
dotty-f006688d34e18553c8df800951cfa73c1aee4ea7.tar.bz2
dotty-f006688d34e18553c8df800951cfa73c1aee4ea7.zip
Fix to avoidance of singleton type arguments
Bring in line with comparisons. Fixes z1720 for good.
-rw-r--r--src/dotty/tools/dotc/typer/TypeAssigner.scala5
-rw-r--r--tests/pending/pos/spec-t5545/S_1.scala4
-rw-r--r--tests/pending/pos/spec-t5545/S_2.scala4
3 files changed, 4 insertions, 9 deletions
diff --git a/src/dotty/tools/dotc/typer/TypeAssigner.scala b/src/dotty/tools/dotc/typer/TypeAssigner.scala
index e0a9dbafc..a6e2deb23 100644
--- a/src/dotty/tools/dotc/typer/TypeAssigner.scala
+++ b/src/dotty/tools/dotc/typer/TypeAssigner.scala
@@ -59,7 +59,10 @@ trait TypeAssigner {
case _ => false
}
def apply(tp: Type): Type = tp match {
- case tp: TermRef if toAvoid(tp) && variance > 0 =>
+ case tp: TermRef
+ if toAvoid(tp) && (variance > 0 || tp.info.widenExpr <:< tp) =>
+ // Can happen if `x: y.type`, then `x.type =:= y.type`, hence we can widen `x.type`
+ // to y.type in all contexts, not just covariant ones.
apply(tp.info.widenExpr)
case tp: TypeRef if toAvoid(tp) =>
tp.info match {
diff --git a/tests/pending/pos/spec-t5545/S_1.scala b/tests/pending/pos/spec-t5545/S_1.scala
deleted file mode 100644
index 59ec1fd85..000000000
--- a/tests/pending/pos/spec-t5545/S_1.scala
+++ /dev/null
@@ -1,4 +0,0 @@
-trait F[@specialized(Int) T1, R] {
- def f(v1: T1): R
- def g = v1 => f(v1)
-}
diff --git a/tests/pending/pos/spec-t5545/S_2.scala b/tests/pending/pos/spec-t5545/S_2.scala
deleted file mode 100644
index 59ec1fd85..000000000
--- a/tests/pending/pos/spec-t5545/S_2.scala
+++ /dev/null
@@ -1,4 +0,0 @@
-trait F[@specialized(Int) T1, R] {
- def f(v1: T1): R
- def g = v1 => f(v1)
-}