aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Applications.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-05-30 14:37:40 +0200
committerMartin Odersky <odersky@gmail.com>2014-05-30 14:37:40 +0200
commit05668169eca68bbdc777fbf698f92e256f8e50a9 (patch)
treeda628f1f17fbc30e0183c95546caad4cef2f4039 /src/dotty/tools/dotc/typer/Applications.scala
parent3b247c34a4c8959b638c61b116635d6c7e80403a (diff)
downloaddotty-05668169eca68bbdc777fbf698f92e256f8e50a9.tar.gz
dotty-05668169eca68bbdc777fbf698f92e256f8e50a9.tar.bz2
dotty-05668169eca68bbdc777fbf698f92e256f8e50a9.zip
Fix of t2504
Another problem where we need to insert an implicit on the result type of complex operation. Two additions: (1) If adapt fails, we now try with a weaker FunProto without result type, thus allowing for an additional implicit cpmversion on the result. (2) An Application in a committable context will not fail if the result type does not match the expected one. The problem will be simply deferred in that case.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Applications.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index a4c26080d..023063585 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -125,9 +125,16 @@ trait Applications extends Compatibility { self: Typer =>
protected def init() = methType match {
case methType: MethodType =>
// apply the result type constraint, unless method type is dependent
- if (!methType.isDependent)
+ if (!methType.isDependent) {
+ val savedConstraint = ctx.typerState.constraint
if (!constrainResult(methType.resultType, resultType))
- fail(err.typeMismatchStr(methType.resultType, resultType))
+ if (ctx.typerState.isCommittable)
+ // defer the problem until after the application;
+ // it might be healed by an implicit conversion
+ assert(ctx.typerState.constraint eq savedConstraint)
+ else
+ fail(err.typeMismatchStr(methType.resultType, resultType))
+ }
// match all arguments with corresponding formal parameters
matchArgs(orderedArgs, methType.paramTypes, 0)
case _ =>
@@ -454,7 +461,7 @@ trait Applications extends Compatibility { self: Typer =>
val result = app.result
ConstFold(result)
} { (failedVal, failedState) =>
- val fun2 = tryInsertImplicit(fun1, proto)
+ val fun2 = tryInsertImplicits(fun1, proto)
if (fun1 eq fun2) {
failedState.commit()
failedVal