aboutsummaryrefslogtreecommitdiff
path: root/src/dotty
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-07-21 18:41:52 +0200
committerMartin Odersky <odersky@gmail.com>2014-07-21 18:41:52 +0200
commita9aa810472b5ee117b0865350a06b28a06b27c5c (patch)
treef433aeeabde2c6c5d84184f5f9fdcad32f3a59ae /src/dotty
parent9e1759f34dcfa90f688ef560c90f209dcb9b1374 (diff)
downloaddotty-a9aa810472b5ee117b0865350a06b28a06b27c5c.tar.gz
dotty-a9aa810472b5ee117b0865350a06b28a06b27c5c.tar.bz2
dotty-a9aa810472b5ee117b0865350a06b28a06b27c5c.zip
Fix of FullParameterization
Avoid substitituting A.this if A is a globally accesisble mdoule.
Diffstat (limited to 'src/dotty')
-rw-r--r--src/dotty/tools/dotc/core/Types.scala4
-rw-r--r--src/dotty/tools/dotc/transform/FullParameterization.scala4
2 files changed, 6 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 289515ae1..85211fca5 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -832,6 +832,10 @@ object Types {
final def substThis(cls: ClassSymbol, tp: Type)(implicit ctx: Context): Type =
ctx.substThis(this, cls, tp, null)
+ /** As substThis, but only is class is a static owner (i.e. a globally accessible object) */
+ final def substThisUnlessStatic(cls: ClassSymbol, tp: Type)(implicit ctx: Context): Type =
+ if (cls.isStaticOwner) this else ctx.substThis(this, cls, tp, null)
+
/** Substitute all occurrences of `RefinedThis(rt)` by `tp` */
final def substThis(rt: RefinedType, tp: Type)(implicit ctx: Context): Type =
ctx.substThis(this, rt, tp, null)
diff --git a/src/dotty/tools/dotc/transform/FullParameterization.scala b/src/dotty/tools/dotc/transform/FullParameterization.scala
index fea0482a0..e21a10492 100644
--- a/src/dotty/tools/dotc/transform/FullParameterization.scala
+++ b/src/dotty/tools/dotc/transform/FullParameterization.scala
@@ -98,7 +98,7 @@ trait FullParameterization {
def resultType(mapClassParams: Type => Type) = {
val thisParamType = mapClassParams(clazz.classInfo.selfType)
MethodType(nme.SELF :: Nil, thisParamType :: Nil)(mt =>
- mapClassParams(origResult).substThis(clazz, MethodParam(mt, 0)))
+ mapClassParams(origResult).substThisUnlessStatic(clazz, MethodParam(mt, 0)))
}
/** Replace class type parameters by the added type parameters of the polytype `pt` */
@@ -203,7 +203,7 @@ trait FullParameterization {
typeMap = rewireType(_)
.subst(origTParams, trefs)
.subst(origVParams, argRefs.map(_.tpe))
- .substThis(origClass, thisRef.tpe),
+ .substThisUnlessStatic(origClass, thisRef.tpe),
ownerMap = (sym => if (sym eq origMeth) derived else sym),
treeMap = {
case tree: This if tree.symbol == origClass => thisRef