diff options
author | Martin Odersky <odersky@gmail.com> | 2016-08-18 17:24:11 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-08-18 17:49:06 +0200 |
commit | d5ef867b1f89c79f8620129693e4f1e9bc6f617c (patch) | |
tree | 90b573d0452c362d6dbe6be0731f22d211d35200 /src/dotty/tools/dotc/typer/Typer.scala | |
parent | 5a5f9d7ed37ca6449ef61ee5e0f6fbf9731df795 (diff) | |
download | dotty-d5ef867b1f89c79f8620129693e4f1e9bc6f617c.tar.gz dotty-d5ef867b1f89c79f8620129693e4f1e9bc6f617c.tar.bz2 dotty-d5ef867b1f89c79f8620129693e4f1e9bc6f617c.zip |
Refinements to auto tupling
There's a nasty interaction with auto-tupling and trying to insert an implicit
on the qualifier of a call. If the original call fails, we need to "undo" any
auto-tupling decisions in calls where an implicit is inserted on the qualifier.
Also: Needed to fix canAutoTuple test so that Scala2 feature is checked instead of dotty's.
Also: Drop features in dotty.language that duplicate those in scala.language.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 2b690ef51..34cd5448b 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -1445,26 +1445,27 @@ 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 = tryInsertImplicitOnQualifier(tree, pt) - if (tree1 eq tree) fallBack(failedTree, failedState) - else adapt(tree1, pt) - } + tryInsertImplicitOnQualifier(tree, pt) match { + case Some(tree1) => adapt(tree1, pt) + case none => fallBack(failedTree, failedState) + } + } /** 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. */ - def tryInsertImplicitOnQualifier(tree: Tree, pt: Type)(implicit ctx: Context): Tree = ctx.traceIndented(i"try insert impl on qualifier $tree $pt") { + def tryInsertImplicitOnQualifier(tree: Tree, pt: Type)(implicit ctx: Context): Option[Tree] = ctx.traceIndented(i"try insert impl on qualifier $tree $pt") { tree match { case Select(qual, name) => val qualProto = SelectionProto(name, pt, NoViewsAllowed) tryEither { implicit ctx => val qual1 = adaptInterpolated(qual, qualProto, EmptyTree) - if ((qual eq qual1) || ctx.reporter.hasErrors) tree - else typedSelect(cpy.Select(tree)(untpd.TypedSplice(qual1), name), pt) - } { (_, _) => tree + if ((qual eq qual1) || ctx.reporter.hasErrors) None + else Some(typedSelect(cpy.Select(tree)(untpd.TypedSplice(qual1), name), pt)) + } { (_, _) => None } - case _ => tree + case _ => None } } |