From 4d230bb6613fc66b7b29339df637b8bf0e5f14b5 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 29 Oct 2013 16:04:27 +0100 Subject: 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. --- src/dotty/tools/dotc/typer/Typer.scala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/dotty/tools/dotc/typer/Typer.scala') 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 = { -- cgit v1.2.3