diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2013-10-02 17:21:55 +0200 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-11-12 18:40:01 -0800 |
commit | 6038bac3513a834e67ab4074c2c7b03aac11b1b3 (patch) | |
tree | 61a5fb1019fd24e69c8fca420b710f1235b27b50 /test/files/run | |
parent | a2b523a39b4e56eb9ab5d9a5639f5b59d425e354 (diff) | |
download | scala-6038bac3513a834e67ab4074c2c7b03aac11b1b3.tar.gz scala-6038bac3513a834e67ab4074c2c7b03aac11b1b3.tar.bz2 scala-6038bac3513a834e67ab4074c2c7b03aac11b1b3.zip |
blackbox restriction #2: can't guide type inference
When an application of a blackbox macro still has undetermined type
parameters after Scala’s type inference algorithm has finished working,
these type parameters are inferred forcedly, in exactly the same manner
as type inference happens for normal methods.
This makes it impossible for blackbox macros to influence type inference,
prohibiting fundep materialization.
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/macro-blackbox-materialization.check | 3 | ||||
-rw-r--r-- | test/files/run/macro-blackbox-materialization/Macros_1.scala | 16 | ||||
-rw-r--r-- | test/files/run/macro-blackbox-materialization/Test_2.scala | 5 | ||||
-rw-r--r-- | test/files/run/macro-whitebox-fundep-materialization.check (renamed from test/files/run/t5923c.check) | 0 | ||||
-rw-r--r-- | test/files/run/macro-whitebox-fundep-materialization/Macros_1.scala (renamed from test/files/run/t5923c/Macros_1.scala) | 2 | ||||
-rw-r--r-- | test/files/run/macro-whitebox-fundep-materialization/Test_2.scala (renamed from test/files/run/t5923c/Test_2.scala) | 0 | ||||
-rw-r--r-- | test/files/run/t5923c.scala | 4 |
7 files changed, 29 insertions, 1 deletions
diff --git a/test/files/run/macro-blackbox-materialization.check b/test/files/run/macro-blackbox-materialization.check new file mode 100644 index 0000000000..7165b734ac --- /dev/null +++ b/test/files/run/macro-blackbox-materialization.check @@ -0,0 +1,3 @@ +C(Int) +C(String) +C(Nothing) diff --git a/test/files/run/macro-blackbox-materialization/Macros_1.scala b/test/files/run/macro-blackbox-materialization/Macros_1.scala new file mode 100644 index 0000000000..7c31dd7dc2 --- /dev/null +++ b/test/files/run/macro-blackbox-materialization/Macros_1.scala @@ -0,0 +1,16 @@ +// For the full version of the test, take a look at run/t5923a + +import scala.reflect.macros.BlackboxContext +import language.experimental.macros + +case class C[T](t: String) +object C { + implicit def foo[T]: C[T] = macro Macros.impl[T] +} + +object Macros { + def impl[T: c.WeakTypeTag](c: BlackboxContext) = { + import c.universe._ + reify(C[T](c.literal(weakTypeOf[T].toString).splice)) + } +}
\ No newline at end of file diff --git a/test/files/run/macro-blackbox-materialization/Test_2.scala b/test/files/run/macro-blackbox-materialization/Test_2.scala new file mode 100644 index 0000000000..001ff9aea8 --- /dev/null +++ b/test/files/run/macro-blackbox-materialization/Test_2.scala @@ -0,0 +1,5 @@ +object Test extends App { + println(implicitly[C[Int]]) + println(implicitly[C[String]]) + println(implicitly[C[Nothing]]) +}
\ No newline at end of file diff --git a/test/files/run/t5923c.check b/test/files/run/macro-whitebox-fundep-materialization.check index bed7429108..bed7429108 100644 --- a/test/files/run/t5923c.check +++ b/test/files/run/macro-whitebox-fundep-materialization.check diff --git a/test/files/run/t5923c/Macros_1.scala b/test/files/run/macro-whitebox-fundep-materialization/Macros_1.scala index c86e14966b..671a4fff4e 100644 --- a/test/files/run/t5923c/Macros_1.scala +++ b/test/files/run/macro-whitebox-fundep-materialization/Macros_1.scala @@ -1,4 +1,4 @@ -import language.experimental.macros +import scala.language.experimental.macros import scala.reflect.macros.WhiteboxContext trait Iso[T, U] { diff --git a/test/files/run/t5923c/Test_2.scala b/test/files/run/macro-whitebox-fundep-materialization/Test_2.scala index a00f4ed7db..a00f4ed7db 100644 --- a/test/files/run/t5923c/Test_2.scala +++ b/test/files/run/macro-whitebox-fundep-materialization/Test_2.scala diff --git a/test/files/run/t5923c.scala b/test/files/run/t5923c.scala new file mode 100644 index 0000000000..956b256785 --- /dev/null +++ b/test/files/run/t5923c.scala @@ -0,0 +1,4 @@ +// see neg/macro-blackbox-fundep-materialization and run/macro-whitebox-fundep-materialization +object Test extends App { + // do nothing +}
\ No newline at end of file |