Skip to content

Commit b9350f4

Browse files
authored
Merge pull request #1760 from dotty-staging/fix-#1753
Fix #1753: Better comparison of path types
2 parents 3f7614a + eab74a3 commit b9350f4

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,9 +541,11 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
541541
/** if `tp2 == p.type` and `p: q.type` then try `tp1 <:< q.type` as a last effort.*/
542542
def comparePaths = tp2 match {
543543
case tp2: TermRef =>
544-
tp2.info.widenExpr match {
544+
tp2.info.widenExpr.dealias match {
545545
case tp2i: SingletonType =>
546-
isSubType(tp1, tp2i) // see z1720.scala for a case where this can arise even in typer.
546+
isSubType(tp1, tp2i)
547+
// see z1720.scala for a case where this can arise even in typer.
548+
// Also, i1753.scala, to show why the dealias above is necessary.
547549
case _ => false
548550
}
549551
case _ =>

tests/pos/i1753.scala

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
abstract class BackendInterface {
2+
type Symbol >: Null
3+
type ClassDef >: Null
4+
}
5+
6+
class BTypesFromSymbols[I <: BackendInterface](val int: I) {
7+
def isRemote(s: int.Symbol) = println("might've been remote")
8+
}
9+
10+
trait BCodeIdiomatic {
11+
val int: BackendInterface
12+
final lazy val bTypes = new BTypesFromSymbols[int.type](int)
13+
}
14+
15+
trait BCodeSkelBuilder extends BCodeIdiomatic {
16+
import int._
17+
import bTypes._
18+
val b: BTypesFromSymbols[int.type] = bTypes
19+
val x: int.type = bTypes.int
20+
val y: bTypes.int.type = int
21+
def getPlainClass(cd: ClassDef) = bTypes.isRemote(null: Symbol)
22+
}

0 commit comments

Comments
 (0)