diff options
author | odersky <odersky@gmail.com> | 2016-07-21 15:57:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-21 15:57:02 +0200 |
commit | 80a65f4b2512bdf1dc46144bea1c000d39319872 (patch) | |
tree | 3153a177e298d5416a0a187163a48d4ba6503154 /src/dotty/tools/dotc/typer/Applications.scala | |
parent | 990663624bdaa93bd7db5f64be78f3ca26d59633 (diff) | |
parent | 9ccb47ae2e9ae34a0ebd6bafbf6f327b39fc8d4a (diff) | |
download | dotty-80a65f4b2512bdf1dc46144bea1c000d39319872.tar.gz dotty-80a65f4b2512bdf1dc46144bea1c000d39319872.tar.bz2 dotty-80a65f4b2512bdf1dc46144bea1c000d39319872.zip |
Merge pull request #1395 from dotty-staging/fix-#1378
Fix #1378: Propagate more knowledge of result type into applications
Diffstat (limited to 'src/dotty/tools/dotc/typer/Applications.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Applications.scala | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala index 69ad4f107..f0a514e8c 100644 --- a/src/dotty/tools/dotc/typer/Applications.scala +++ b/src/dotty/tools/dotc/typer/Applications.scala @@ -553,6 +553,15 @@ 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, relate the normalized result type of the application with the + // expected type through `constrainResult`. This can add more constraints which + // help sharpen the inferred parameter types for the argument function literal(s). + // This tweak is needed to make i1378 compile. + if (tree.args.exists(untpd.isFunctionWithUnknownParamType(_))) + 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 => |