diff options
-rw-r--r-- | compiler/src/dotty/tools/dotc/core/TypeComparer.scala | 6 | ||||
-rw-r--r-- | tests/pos/i1753.scala | 22 |
2 files changed, 26 insertions, 2 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index f78820fff..fd954c688 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -541,9 +541,11 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { /** if `tp2 == p.type` and `p: q.type` then try `tp1 <:< q.type` as a last effort.*/ def comparePaths = tp2 match { case tp2: TermRef => - tp2.info.widenExpr match { + tp2.info.widenExpr.dealias match { case tp2i: SingletonType => - isSubType(tp1, tp2i) // see z1720.scala for a case where this can arise even in typer. + isSubType(tp1, tp2i) + // see z1720.scala for a case where this can arise even in typer. + // Also, i1753.scala, to show why the dealias above is necessary. case _ => false } case _ => diff --git a/tests/pos/i1753.scala b/tests/pos/i1753.scala new file mode 100644 index 000000000..e5ad743aa --- /dev/null +++ b/tests/pos/i1753.scala @@ -0,0 +1,22 @@ +abstract class BackendInterface { + type Symbol >: Null + type ClassDef >: Null +} + +class BTypesFromSymbols[I <: BackendInterface](val int: I) { + def isRemote(s: int.Symbol) = println("might've been remote") +} + +trait BCodeIdiomatic { + val int: BackendInterface + final lazy val bTypes = new BTypesFromSymbols[int.type](int) +} + +trait BCodeSkelBuilder extends BCodeIdiomatic { + import int._ + import bTypes._ + val b: BTypesFromSymbols[int.type] = bTypes + val x: int.type = bTypes.int + val y: bTypes.int.type = int + def getPlainClass(cd: ClassDef) = bTypes.isRemote(null: Symbol) +} |