aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)
-}