aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-09-07 17:44:47 +0200
committerMartin Odersky <odersky@gmail.com>2016-10-02 16:11:21 +0200
commitbf3345a9d25e464975dd5000186c766de842f020 (patch)
treef1306e03d30e483561ae5d1a7740ada3a25c744d /src
parent4253578c2369708c861c40e52e41e3796a3a2717 (diff)
downloaddotty-bf3345a9d25e464975dd5000186c766de842f020.tar.gz
dotty-bf3345a9d25e464975dd5000186c766de842f020.tar.bz2
dotty-bf3345a9d25e464975dd5000186c766de842f020.zip
Fix ExplicitSelf phase
After inlining we got a Ycheck error of the form: found : `this.asInstanceOf[SelfType].C` expected: `this.C` The fact that it was related inlining was coincidental I think. We fix the problem by expanding to this.asInstanceOf[SelfType & this.type].C instead.
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/transform/ExplicitSelf.scala5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/transform/ExplicitSelf.scala b/src/dotty/tools/dotc/transform/ExplicitSelf.scala
index c6a218157..618a0f108 100644
--- a/src/dotty/tools/dotc/transform/ExplicitSelf.scala
+++ b/src/dotty/tools/dotc/transform/ExplicitSelf.scala
@@ -16,9 +16,10 @@ import Flags._
* where `C` is a class with explicit self type and `C` is not a
* subclass of the owner of `m` to
*
- * C.this.asInstanceOf[S].m
+ * C.this.asInstanceOf[S & C.this.type].m
*
* where `S` is the self type of `C`.
+ * See run/i789.scala for a test case why this is needed.
*/
class ExplicitSelf extends MiniPhaseTransform { thisTransform =>
import ast.tpd._
@@ -30,7 +31,7 @@ class ExplicitSelf extends MiniPhaseTransform { thisTransform =>
val cls = thiz.symbol.asClass
val cinfo = cls.classInfo
if (cinfo.givenSelfType.exists && !cls.derivesFrom(tree.symbol.owner))
- cpy.Select(tree)(thiz.asInstance(cinfo.selfType), name)
+ cpy.Select(tree)(thiz.asInstance(AndType(cinfo.selfType, thiz.tpe)), name)
else tree
case _ => tree
}