From 9d66f8688291cb59ad78784d792dcf28a5527142 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sun, 17 Jul 2016 11:05:23 +0200 Subject: Adress reviewers comments --- src/dotty/tools/dotc/ast/TreeInfo.scala | 2 +- src/dotty/tools/dotc/typer/Applications.scala | 11 +++++------ src/dotty/tools/dotc/typer/Typer.scala | 5 ++++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/dotty/tools/dotc/ast/TreeInfo.scala b/src/dotty/tools/dotc/ast/TreeInfo.scala index 55eb21687..a48651ebf 100644 --- a/src/dotty/tools/dotc/ast/TreeInfo.scala +++ b/src/dotty/tools/dotc/ast/TreeInfo.scala @@ -280,7 +280,7 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] => trait UntypedTreeInfo extends TreeInfo[Untyped] { self: Trees.Instance[Untyped] => import TreeInfo._ - def isFunctionWithImplicitParamType(tree: Tree) = tree match { + def isFunctionWithUnknownParamType(tree: Tree) = tree match { case untpd.Function(args, _) => args.exists { case ValDef(_, tpt, _) => tpt.isEmpty diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala index 7a742112b..56183d2ff 100644 --- a/src/dotty/tools/dotc/typer/Applications.scala +++ b/src/dotty/tools/dotc/typer/Applications.scala @@ -554,12 +554,11 @@ trait Applications extends Compatibility { self: Typer with Dynamic => 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(_))) + // 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") diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 13b6167b1..d0d41a214 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -599,7 +599,10 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit val params = args.asInstanceOf[List[untpd.ValDef]] pt match { - case pt: TypeVar if untpd.isFunctionWithImplicitParamType(tree) => + case pt: TypeVar if untpd.isFunctionWithUnknownParamType(tree) => + // try to instantiate `pt` if this is possible. If it does not + // work the error will be reported later in `inferredParam`, + // when we try to infer the parameter type. isFullyDefined(pt, ForceDegree.noBottom) case _ => } -- cgit v1.2.3