diff options
author | Martin Odersky <odersky@gmail.com> | 2013-08-30 11:10:37 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-08-30 11:10:37 +0200 |
commit | 860fd2eb286c48d36655ad99a068a2e61bdb1381 (patch) | |
tree | 0c75f7aa2228adae973a16ec5b5afccaaa7c68be /src/dotty/tools/dotc/typer/Inferencing.scala | |
parent | 28f8102d1b4e8c8fd2d2f1838b49e70844245a5f (diff) | |
download | dotty-860fd2eb286c48d36655ad99a068a2e61bdb1381.tar.gz dotty-860fd2eb286c48d36655ad99a068a2e61bdb1381.tar.bz2 dotty-860fd2eb286c48d36655ad99a068a2e61bdb1381.zip |
More tests and fixes related to inference.
Main blooper: TypeVars got dereferenced in all Typemaps, so disappeared too quickly from types during inference.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Inferencing.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Inferencing.scala | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/typer/Inferencing.scala b/src/dotty/tools/dotc/typer/Inferencing.scala index 06b6e1487..1083b4f2e 100644 --- a/src/dotty/tools/dotc/typer/Inferencing.scala +++ b/src/dotty/tools/dotc/typer/Inferencing.scala @@ -124,6 +124,7 @@ object Inferencing { false case tvar: TypeVar if forceIt && !tvar.isInstantiated => val inst = tvar.instantiate(fromBelow = true) + println(i"forced instantiation of ${tvar.origin} = $inst") inst != defn.NothingType && inst != defn.NullType case _ => true @@ -193,10 +194,18 @@ object Inferencing { val vs = tp.variances(tvar => (ctx.typerState.undetVars contains tvar) && (pos contains tvar.pos)) for ((tvar, v) <- vs) - if (v == 1) tvar.instantiate(fromBelow = true) - else if (v == -1) tvar.instantiate(fromBelow = false) - for (tvar <- ctx.typerState.undetVars if !(vs contains tvar)) - tvar.instantiate(fromBelow = false) + if (v == 1) { + println(i"interpolate covariant $tvar in $tp") + tvar.instantiate(fromBelow = true) + } + else if (v == -1) { + println(i"interpolate contrvariant $tvar in $tp") + tvar.instantiate(fromBelow = false) + } + for (tvar <- ctx.typerState.undetVars if (pos contains tvar.pos) && !(vs contains tvar)) { + println(i"interpolate non-occurring $tvar in $tp") + tvar.instantiate(fromBelow = true) + } } /** Instantiate undetermined type variables to that type `tp` is |