summaryrefslogtreecommitdiff
path: root/test/files/run/sammy_after_implicit_view.scala
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2016-03-23 17:53:19 -0700
committerAdriaan Moors <adriaan.moors@typesafe.com>2016-03-26 22:55:13 -0700
commitaa972dc100544179beecde48b52dfdb847162001 (patch)
treedc6c57fd7c1c97d6ce104797994dbf92637e86ae /test/files/run/sammy_after_implicit_view.scala
parent608ac2c2b9e3f6f46489e20830d8949ee7d506cf (diff)
downloadscala-aa972dc100544179beecde48b52dfdb847162001.tar.gz
scala-aa972dc100544179beecde48b52dfdb847162001.tar.bz2
scala-aa972dc100544179beecde48b52dfdb847162001.zip
SAM conversion precedes implicit view application (as in dotty).
This reflects the majority vote on the PR. DSLs that need their implicit conversions to kick in instead of SAM conversion, will have to make their target types not be SAM types (e.g., by adding a second abstract method to them).
Diffstat (limited to 'test/files/run/sammy_after_implicit_view.scala')
-rw-r--r--test/files/run/sammy_after_implicit_view.scala20
1 files changed, 10 insertions, 10 deletions
diff --git a/test/files/run/sammy_after_implicit_view.scala b/test/files/run/sammy_after_implicit_view.scala
index 30e3babc75..a13a71e562 100644
--- a/test/files/run/sammy_after_implicit_view.scala
+++ b/test/files/run/sammy_after_implicit_view.scala
@@ -5,24 +5,24 @@ object Test extends App {
final val AnonFunClass = "$anon$"
final val LMFClass = "$$Lambda$" // LambdaMetaFactory names classes like this
- // if there's an implicit conversion, it takes precedence
- def statusQuo() = {
+ // if there's an implicit conversion, it does not takes precedence (because that's what dotty does)
+ def implicitSam() = {
import language.implicitConversions
- var ok = false
- implicit def fun2sam(fun: Int => String): MySam = { ok = true; new MySam { def apply(x: Int) = fun(x) } }
+ var ok = true
+ implicit def fun2sam(fun: Int => String): MySam = { ok = false; new MySam { def apply(x: Int) = fun(x) } }
val className = (((x: Int) => x.toString): MySam).getClass.toString
assert(ok, "implicit conversion not called")
- assert(className contains AnonFunClass, className)
- assert(!(className contains LMFClass), className)
+ assert(!(className contains AnonFunClass), className)
+ assert(className contains LMFClass, className)
}
// indirectly check that this sam type instance was created from a class spun up by LambdaMetaFactory
- def statusIndy() = {
+ def justSammy() = {
val className = (((x: Int) => x.toString): MySam).getClass.toString
assert(!(className contains AnonFunClass), className)
assert(className contains LMFClass, className)
}
- statusQuo()
- statusIndy()
-} \ No newline at end of file
+ implicitSam()
+ justSammy()
+}