Skip to content

Commit f006688

Browse files
committed
Fix to avoidance of singleton type arguments
Bring in line with comparisons. Fixes z1720 for good.
1 parent f4ab855 commit f006688

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

src/dotty/tools/dotc/typer/TypeAssigner.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ trait TypeAssigner {
5959
case _ => false
6060
}
6161
def apply(tp: Type): Type = tp match {
62-
case tp: TermRef if toAvoid(tp) && variance > 0 =>
62+
case tp: TermRef
63+
if toAvoid(tp) && (variance > 0 || tp.info.widenExpr <:< tp) =>
64+
// Can happen if `x: y.type`, then `x.type =:= y.type`, hence we can widen `x.type`
65+
// to y.type in all contexts, not just covariant ones.
6366
apply(tp.info.widenExpr)
6467
case tp: TypeRef if toAvoid(tp) =>
6568
tp.info match {

tests/pending/pos/spec-t5545/S_1.scala

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/pending/pos/spec-t5545/S_2.scala

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)