aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Applications.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-08-23 16:21:27 +0200
committerMartin Odersky <odersky@gmail.com>2013-08-23 16:21:27 +0200
commit873a3bc1a273974d7d47de054e68a92c29a359e8 (patch)
tree7e6b0fd2c308a855a05350bb4d12d9d2119f382a /src/dotty/tools/dotc/typer/Applications.scala
parenta8467b0a7cddeef7110155f9853ff84feb2281fa (diff)
downloaddotty-873a3bc1a273974d7d47de054e68a92c29a359e8.tar.gz
dotty-873a3bc1a273974d7d47de054e68a92c29a359e8.tar.bz2
dotty-873a3bc1a273974d7d47de054e68a92c29a359e8.zip
Fixes in implicit handling
Plus a new test file: implicits1
Diffstat (limited to 'src/dotty/tools/dotc/typer/Applications.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index 8af9e0b57..e5e8be05b 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -6,7 +6,7 @@ import core._
import ast.{Trees, untpd, tpd, TreeInfo}
import util.Positions._
import Trees.Untyped
-import Mode.ImplicitsDisabled
+import Mode.ImplicitsEnabled
import Contexts._
import Flags._
import Denotations._
@@ -629,6 +629,14 @@ trait Applications extends Compatibility { self: Typer =>
def isApplicableToTypes(methRef: TermRef, args: List[Type], resultType: Type = WildcardType)(implicit ctx: Context) =
new ApplicableToTypes(methRef, args, resultType)(ctx.fresh.withNewTyperState).success
+ def isApplicableToTypes(tp: Type, args: List[Type], resultType: Type)(implicit ctx: Context): Boolean = tp match {
+ case methRef: TermRef => isApplicableToTypes(methRef, args, resultType)
+ case _ =>
+ val app = tp.member(nme.apply)
+ app.exists && app.hasAltWith(d =>
+ isApplicableToTypes(TermRef(tp, nme.apply).withDenot(d), args, resultType))
+ }
+
/** Is `tp` a subtype of `pt`? */
def testCompatible(tp: Type, pt: Type)(implicit ctx: Context) =
isCompatible(tp, pt)(ctx.fresh.withNewTyperState)
@@ -788,6 +796,6 @@ trait Applications extends Compatibility { self: Typer =>
}
if (isDetermined(candidates)) candidates
- else narrowMostSpecific(candidates)(ctx.addMode(ImplicitsDisabled))
+ else narrowMostSpecific(candidates)(ctx.retractMode(ImplicitsEnabled))
}
} \ No newline at end of file