aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Applications.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-07-16 15:21:12 +0200
committerMartin Odersky <odersky@gmail.com>2016-07-16 15:21:21 +0200
commit0eb2d76c467a53786ae6147c9c983c23ab0894c8 (patch)
tree44db7e49882c87f2906d6d21dca564c0d5407d38 /src/dotty/tools/dotc/typer/Applications.scala
parentbd45ecc06b04c3788d1ce706508eed5e0c50b50b (diff)
downloaddotty-0eb2d76c467a53786ae6147c9c983c23ab0894c8.tar.gz
dotty-0eb2d76c467a53786ae6147c9c983c23ab0894c8.tar.bz2
dotty-0eb2d76c467a53786ae6147c9c983c23ab0894c8.zip
Proparage function result constrains when inferring parameter types
If an application has functions with implicit parameter types we need to be more aggressive about propagating knowledge of the expected result type into the constraint. Fixes #1378.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Applications.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index 6e78a570d..7a742112b 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -553,6 +553,16 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
// a modified tree but this would be more convoluted and less efficient.
if (proto.isTupled) proto = proto.tupled
+ // If some of the application's arguments are function literals without explicitly declared
+ // parameter types, and the expected type is a value type, relate the
+ // normalized result type of the application with the expected type through `<:<`.
+ // This can add more constraints which help sharpen the inferred parameter
+ // types for the argument function literal(s).
+ // This tweak is needed to make i1348 compile.
+ if (tree.args.exists(untpd.isFunctionWithImplicitParamType(_)))
+ if (!constrainResult(fun1.tpe.widen, proto.derivedFunProto(resultType = pt)))
+ typr.println(i"result failure for $tree with type ${fun1.tpe.widen}, expected = $pt")
+
fun1.tpe match {
case ErrorType => tree.withType(ErrorType)
case TryDynamicCallType =>