aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2016-11-30 17:10:03 +0100
committerGitHub <noreply@github.com>2016-11-30 17:10:03 +0100
commitb9350f40990ce07ba7614a0448a98abd7075abe8 (patch)
tree17c409b2f67a6a9924d10367ca723716dbe2225a
parent3f7614ae60263c937f7b2d97f45ef6e7c803ec01 (diff)
parenteab74a33579636f385d4687e30e811f262d13a0e (diff)
downloaddotty-b9350f40990ce07ba7614a0448a98abd7075abe8.tar.gz
dotty-b9350f40990ce07ba7614a0448a98abd7075abe8.tar.bz2
dotty-b9350f40990ce07ba7614a0448a98abd7075abe8.zip
Merge pull request #1760 from dotty-staging/fix-#1753
Fix #1753: Better comparison of path types
-rw-r--r--compiler/src/dotty/tools/dotc/core/TypeComparer.scala6
-rw-r--r--tests/pos/i1753.scala22
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)
+}