aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/typer/Typer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-12-03 13:52:48 +0100
committerMartin Odersky <odersky@gmail.com>2016-12-17 18:34:27 +0100
commitad7edc7bd8af963b768afdc50b7038a8daa47ccb (patch)
treec4f437115a3e898f854a9977a7c4b1cf1c1bf19b /compiler/src/dotty/tools/dotc/typer/Typer.scala
parentfd2c24c3159cefa583889a176f31d1e2325fe7e6 (diff)
downloaddotty-ad7edc7bd8af963b768afdc50b7038a8daa47ccb.tar.gz
dotty-ad7edc7bd8af963b768afdc50b7038a8daa47ccb.tar.bz2
dotty-ad7edc7bd8af963b768afdc50b7038a8daa47ccb.zip
Always insert apply for expressions of implicit function type
Diffstat (limited to 'compiler/src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/typer/Typer.scala21
1 files changed, 13 insertions, 8 deletions
diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala
index c8deda4bc..018a6064b 100644
--- a/compiler/src/dotty/tools/dotc/typer/Typer.scala
+++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala
@@ -1616,6 +1616,14 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
}
}
+ /** Is `pt` a prototype of an `apply` selection, or a parameterless function yielding one? */
+ def isApplyProto(pt: Type)(implicit ctx: Context): Boolean = pt match {
+ case pt: SelectionProto => pt.name == nme.apply
+ case pt: FunProto => pt.args.isEmpty && isApplyProto(pt.resultType)
+ case pt: IgnoredProto => isApplyProto(pt.ignored)
+ case _ => false
+ }
+
/** Add apply node or implicit conversions. Two strategies are tried, and the first
* that is successful is picked. If neither of the strategies are successful, continues with
* `fallBack`.
@@ -1629,14 +1637,6 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
*/
def tryInsertApplyOrImplicit(tree: Tree, pt: ProtoType)(fallBack: => Tree)(implicit ctx: Context): Tree = {
- /** Is `pt` a prototype of an `apply` selection, or a parameterless function yielding one? */
- def isApplyProto(pt: Type): Boolean = pt match {
- case pt: SelectionProto => pt.name == nme.apply
- case pt: FunProto => pt.args.isEmpty && isApplyProto(pt.resultType)
- case pt: IgnoredProto => isApplyProto(pt.ignored)
- case _ => false
- }
-
def tryApply(implicit ctx: Context) = {
val sel = typedSelect(untpd.Select(untpd.TypedSplice(tree), nme.apply), pt)
if (sel.tpe.isError) sel else adapt(sel, pt)
@@ -1878,6 +1878,11 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
err.typeMismatch(tree, pt)
else
missingArgs
+ case wtp: RefinedType
+ if defn.isImplicitFunctionClass(wtp.underlyingClassRef(refinementOK = false).classSymbol) &&
+ !isApplyProto(pt) =>
+ typr.println(i"insert apply on implicit $tree")
+ typed(untpd.Select(untpd.TypedSplice(tree), nme.apply), pt)
case _ =>
ctx.typeComparer.GADTused = false
if (ctx.mode is Mode.Pattern) {