aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-09-05 18:01:12 +0200
committerMartin Odersky <odersky@gmail.com>2016-10-02 16:11:21 +0200
commit04de4b58b75cb526506317db02d8b6b2a8aefd99 (patch)
tree69a6fdecb59af37341ae2cc32d2c237f8050dbf0 /src/dotty/tools/dotc
parent61e8ea4824e14c9884d69eec502ea73c9ebd0838 (diff)
downloaddotty-04de4b58b75cb526506317db02d8b6b2a8aefd99.tar.gz
dotty-04de4b58b75cb526506317db02d8b6b2a8aefd99.tar.bz2
dotty-04de4b58b75cb526506317db02d8b6b2a8aefd99.zip
Fix problems handling types in Inliner
1. Don't generate local aliases - we can potentially run into avoidance problems later for such aliases 2. Scan all parts of leaf types for things that need to be registered cor remappings.
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r--src/dotty/tools/dotc/core/Types.scala7
-rw-r--r--src/dotty/tools/dotc/typer/Inliner.scala16
2 files changed, 8 insertions, 15 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 30d1c0136..7a64e19c8 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -228,8 +228,8 @@ object Types {
!existsPart(!p(_))
/** Performs operation on all parts of this type */
- final def foreachPart(p: Type => Unit)(implicit ctx: Context): Unit =
- new ForeachAccumulator(p).apply((), this)
+ final def foreachPart(p: Type => Unit, stopAtStatic: Boolean = false)(implicit ctx: Context): Unit =
+ new ForeachAccumulator(p, stopAtStatic).apply((), this)
/** The parts of this type which are type or term refs */
final def namedParts(implicit ctx: Context): collection.Set[NamedType] =
@@ -3704,8 +3704,7 @@ object Types {
x || p(tp) || (forceLazy || !tp.isInstanceOf[LazyRef]) && foldOver(x, tp)
}
- class ForeachAccumulator(p: Type => Unit)(implicit ctx: Context) extends TypeAccumulator[Unit] {
- override def stopAtStatic = false
+ class ForeachAccumulator(p: Type => Unit, override val stopAtStatic: Boolean)(implicit ctx: Context) extends TypeAccumulator[Unit] {
def apply(x: Unit, tp: Type): Unit = foldOver(p(tp), tp)
}
diff --git a/src/dotty/tools/dotc/typer/Inliner.scala b/src/dotty/tools/dotc/typer/Inliner.scala
index 631c98734..4af9ecaec 100644
--- a/src/dotty/tools/dotc/typer/Inliner.scala
+++ b/src/dotty/tools/dotc/typer/Inliner.scala
@@ -104,13 +104,7 @@ class Inliner(call: tpd.Tree, rhs: tpd.Tree)(implicit ctx: Context) {
private def computeParamBindings(tp: Type, targs: List[Tree], argss: List[List[Tree]]): Unit = tp match {
case tp: PolyType =>
(tp.paramNames, targs).zipped.foreach { (name, arg) =>
- paramBinding(name) = arg.tpe.stripTypeVar match {
- case argtpe: TypeRef => argtpe
- case argtpe =>
- val binding = newSym(name, EmptyFlags, TypeAlias(argtpe)).asType
- bindingsBuf += TypeDef(binding)
- binding.typeRef
- }
+ paramBinding(name) = arg.tpe.stripTypeVar
}
computeParamBindings(tp.resultType, Nil, argss)
case tp: MethodType =>
@@ -155,7 +149,8 @@ class Inliner(call: tpd.Tree, rhs: tpd.Tree)(implicit ctx: Context) {
}
private def registerLeaf(tree: Tree): Unit = tree match {
- case _: This | _: Ident | _: TypeTree => registerType(tree.tpe)
+ case _: This | _: Ident | _: TypeTree =>
+ tree.tpe.foreachPart(registerType, stopAtStatic = true)
case _ =>
}
@@ -166,7 +161,6 @@ class Inliner(call: tpd.Tree, rhs: tpd.Tree)(implicit ctx: Context) {
case res @ Select(qual, name) =>
if (name.endsWith(nme.OUTER)) {
val outerAcc = tree.symbol
- println(i"selecting $tree / ${acc} / ${qual.tpe.normalizedPrefix}")
res.withType(qual.tpe.widen.normalizedPrefix)
}
else {
@@ -227,8 +221,8 @@ class Inliner(call: tpd.Tree, rhs: tpd.Tree)(implicit ctx: Context) {
}
case _: Ident =>
paramProxy.get(tree.tpe) match {
- case Some(t: TypeRef) => ref(t)
- case Some(t: SingletonType) => singleton(t)
+ case Some(t: SingletonType) if tree.isTerm => singleton(t)
+ case Some(t) if tree.isType => TypeTree(t)
case None => tree
}
case _ => tree