diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2016-03-23 17:53:19 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2016-03-26 22:55:13 -0700 |
commit | aa972dc100544179beecde48b52dfdb847162001 (patch) | |
tree | dc6c57fd7c1c97d6ce104797994dbf92637e86ae /test/files/run/sammy_after_implicit_view.scala | |
parent | 608ac2c2b9e3f6f46489e20830d8949ee7d506cf (diff) | |
download | scala-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.scala | 20 |
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() +} |