diff options
author | Martin Odersky <odersky@gmail.com> | 2013-10-29 16:04:27 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-10-29 16:04:27 +0100 |
commit | 4d230bb6613fc66b7b29339df637b8bf0e5f14b5 (patch) | |
tree | 899c20a52cd487994ce620d634113363ca1d2467 /src/dotty/tools/dotc/typer | |
parent | 52a8a0aec9da8a4eaa3faf95ec7acd3ecfbabf53 (diff) | |
download | dotty-4d230bb6613fc66b7b29339df637b8bf0e5f14b5.tar.gz dotty-4d230bb6613fc66b7b29339df637b8bf0e5f14b5.tar.bz2 dotty-4d230bb6613fc66b7b29339df637b8bf0e5f14b5.zip |
Fixes to type inference
1. Resolve overloading needs to be done with exploring typerstate
2. Need to handle case where A <: B for type variables in a more symmetric way.
(2) is not yet fully done.
Diffstat (limited to 'src/dotty/tools/dotc/typer')
-rw-r--r-- | src/dotty/tools/dotc/typer/Inferencing.scala | 5 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 8 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/typer/Inferencing.scala b/src/dotty/tools/dotc/typer/Inferencing.scala index 24fe80c58..8c7285883 100644 --- a/src/dotty/tools/dotc/typer/Inferencing.scala +++ b/src/dotty/tools/dotc/typer/Inferencing.scala @@ -212,8 +212,11 @@ object Inferencing { if (changed) interpolateUndetVars(tp, pos) else - for (tvar <- ctx.typerState.undetVars if (pos contains tvar.pos) && !(vs contains tvar)) + for (tvar <- ctx.typerState.undetVars + if (pos contains tvar.pos) && !(tvar.pos contains pos) && !(vs contains tvar)) { + // println(s"instantiating non-occurring $tvar in $tp") tvar.instantiate(fromBelow = true) + } } /** Instantiate undetermined type variables to that type `tp` is diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 47eee5d4d..244713496 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -981,7 +981,7 @@ class Typer extends Namer with Applications with Implicits { val alts = altDenots map (alt => TermRef.withSig(ref.prefix, ref.name, alt.info.signature).withDenot(alt)) def expectedStr = err.expectedTypeStr(pt) - resolveOverloaded(alts, pt) match { + resolveOverloaded(alts, pt)(ctx.fresh.withExploreTyperState) match { case alt :: Nil => adapt(tree.withType(alt), pt) case Nil => @@ -1053,7 +1053,11 @@ class Typer extends Namer with Applications with Implicits { case _ => if (tree.tpe <:< pt) tree else if (ctx.mode is Mode.Pattern) tree // no subtype check for pattern - else adaptToSubType(wtp) + else { + //println(s"adapt to subtype ${tree.tpe} !<:< $pt") // !!!DEBUG + //println(TypeComparer.explained(implicit ctx => tree.tpe <:< pt)) + adaptToSubType(wtp) + } } def adaptToSubType(wtp: Type): Tree = { |