aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-05-26 12:03:02 +0200
committerMartin Odersky <odersky@gmail.com>2015-06-06 11:04:54 +0200
commitbf203a52ef0933498a88c2c60e4dad6005bf51cb (patch)
tree55bcd15bc1dbe3d5dffc91bdeeda98e238f8d273 /src/dotty/tools
parent3352ffc97f3577fd6de5c22a22c7c7c887e9b1f9 (diff)
downloaddotty-bf203a52ef0933498a88c2c60e4dad6005bf51cb.tar.gz
dotty-bf203a52ef0933498a88c2c60e4dad6005bf51cb.tar.bz2
dotty-bf203a52ef0933498a88c2c60e4dad6005bf51cb.zip
Follow aliases when deskolemizing
Be more aggressive doing this than with lookupRefined in that we compute the member of a projected name, instead of just analyzing the type structurally. Reason: (1) If we do not follow aliases, skolemization will lose information (2) Skolemization is applied rather late, less risk of cyclic references by computing members.
Diffstat (limited to 'src/dotty/tools')
-rw-r--r--src/dotty/tools/dotc/core/Skolemization.scala22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/dotty/tools/dotc/core/Skolemization.scala b/src/dotty/tools/dotc/core/Skolemization.scala
index af7530458..eef5f0e5d 100644
--- a/src/dotty/tools/dotc/core/Skolemization.scala
+++ b/src/dotty/tools/dotc/core/Skolemization.scala
@@ -1,7 +1,7 @@
package dotty.tools.dotc
package core
-import Symbols._, Types._, Contexts._
+import Symbols._, Types._, Contexts._, Decorators._
import collection.mutable
/** Methods to add and remove skolemtypes.
@@ -46,7 +46,7 @@ trait Skolemization {
final def deSkolemize(tp: Type): Type = deSkolemize(tp, 1, Set())
private def deSkolemize(tp: Type, variance: Int, seen: Set[SkolemType]): Type =
- ctx.traceIndented(s"deskolemize $tp, variance = $variance, seen = $seen = ") {
+ ctx.traceIndented(i"deskolemize $tp, variance = $variance, seen = $seen = ", show = true) {
def approx(lo: Type = defn.NothingType, hi: Type = defn.AnyType, newSeen: Set[SkolemType] = seen) =
if (variance == 0) NoType
else deSkolemize(if (variance < 0) lo else hi, variance, newSeen)
@@ -59,12 +59,20 @@ trait Skolemization {
if (sym.isStatic) tp
else {
val pre1 = deSkolemize(tp.prefix, variance, seen)
- if (pre1.exists && !pre1.isRef(defn.NothingClass)) tp.derivedSelect(pre1)
+ if (pre1 eq tp.prefix) tp
else {
- ctx.log(s"deskolem: $tp: ${tp.info}")
- tp.info match {
- case TypeBounds(lo, hi) => approx(lo, hi)
- case info => approx(defn.NothingType, info)
+ val d = tp.prefix.member(tp.name)
+ d.info match {
+ case TypeAlias(alias) => deSkolemize(alias, variance, seen)
+ case _ =>
+ if (pre1.exists && !pre1.isRef(defn.NothingClass)) tp.derivedSelect(pre1)
+ else {
+ ctx.log(s"deskolem: $tp: ${tp.info}")
+ tp.info match {
+ case TypeBounds(lo, hi) => approx(lo, hi)
+ case info => approx(defn.NothingType, info)
+ }
+ }
}
}
}