aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Typer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-05-18 16:36:20 +0200
committerMartin Odersky <odersky@gmail.com>2014-05-30 14:43:39 +0200
commit70e785f5d8a583dae127dadf4d9add70bdea71f7 (patch)
tree62067ce7094f2aead1e7977f7be118ac157c04fe /src/dotty/tools/dotc/typer/Typer.scala
parentc70366db8469e81e315fe89672e8321607a7310a (diff)
downloaddotty-70e785f5d8a583dae127dadf4d9add70bdea71f7.tar.gz
dotty-70e785f5d8a583dae127dadf4d9add70bdea71f7.tar.bz2
dotty-70e785f5d8a583dae127dadf4d9add70bdea71f7.zip
Simplify result handling in FunProto.
Following the example of SelectionProto, we now always hide the result in a FunProto behind an IgnoreProto. This avoids a special case retry with a weaker FunProto in tryInsertApplyOrImplicit.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala30
1 files changed, 5 insertions, 25 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 0293d1803..d6b724270 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -1014,20 +1014,12 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
}
}
- private def noResultProto(pt: Type) = pt match {
- case pt: FunProto => pt.derivedFunProto(pt.args, WildcardType, pt.typer) // drop result type, because views are disabled
- case _ => pt
- }
-
- /** Add apply node or implicit conversions. Three strategies are tried, and the first
- * that is succesful is picked. If none of the strategies are succesful, continues with
+ /** Add apply node or implicit conversions. Two strategies are tried, and the first
+ * that is succesful is picked. If neither of the strategies are succesful, continues with
* `fallBack`.
*
* 1st strategy: Try to insert `.apply` so that the result conforms to prototype `pt`.
- * 2nd strategy: If the expected type is a FunProto with a non-wildcard resulttype,
- * try to match against the FunProto with wildcard resulttype (this allows for an additional
- * implicit conversion on the result).
- * 3rd stratgey: If tree is a select `qual.name`, try to insert an implicit conversion
+ * 2nd stratgey: If tree is a select `qual.name`, try to insert an implicit conversion
* around the qualifier part `qual` so that the result conforms to the expected type
* with wildcard result type.
*/
@@ -1036,23 +1028,11 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
val sel = typedSelect(untpd.Select(untpd.TypedSplice(tree), nme.apply), pt)
if (sel.tpe.isError) sel else adapt(sel, pt)
} { (failedTree, failedState) =>
- val tree1 = tryInsertImplicits(tree, pt)
+ val tree1 = tryInsertImplicitOnQualifier(tree, pt)
if (tree1 eq tree) fallBack(failedTree, failedState)
- else adapt(tree1, noResultProto(pt))
+ else adapt(tree1, pt)
}
- def tryInsertImplicits(tree: Tree, pt: ProtoType)(implicit ctx: Context): Tree = {
- val normalizedProto = noResultProto(pt)
- if (normalizedProto eq pt) tryInsertImplicitOnQualifier(tree, pt)
- else tryEither { implicit ctx =>
- val tree1 = adaptInterpolated(tree, normalizedProto, EmptyTree)
- if (tree1 eq tree) ctx.error("no progress")
- tree1
- } { (_, _) =>
- tryInsertImplicitOnQualifier(tree, normalizedProto)
- }
- }
-
/** If this tree is a select node `qual.name`, try to insert an implicit conversion
* `c` around `qual` so that `c(qual).name` conforms to `pt`. If that fails
* return `tree` itself.