diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-09-18 00:43:16 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-09-18 00:43:16 +0200 |
commit | 3881ab3831bfbd5b2588b0612402b797516a5715 (patch) | |
tree | 3b1f24bba7a1a81b2ac98ef9c6226d574fc4f55e | |
parent | 66603a2c003852d39faec20a9763fb0e25049cf4 (diff) | |
download | scala-3881ab3831bfbd5b2588b0612402b797516a5715.tar.gz scala-3881ab3831bfbd5b2588b0612402b797516a5715.tar.bz2 scala-3881ab3831bfbd5b2588b0612402b797516a5715.zip |
SI-5692 better error message
Doesn't fix the underlying issue with macros and type inference,
but at least now the error message says exactly what needs to be done
to make the error go away.
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala | 6 | ||||
-rw-r--r-- | test/files/neg/t5692a.check | 4 | ||||
-rw-r--r-- | test/files/neg/t5692a.flags | 1 | ||||
-rw-r--r-- | test/files/neg/t5692a/Macros_1.scala | 6 | ||||
-rw-r--r-- | test/files/neg/t5692a/Test_2.scala | 3 | ||||
-rw-r--r-- | test/files/neg/t5692b.check | 4 | ||||
-rw-r--r-- | test/files/neg/t5692b.flags | 1 | ||||
-rw-r--r-- | test/files/neg/t5692b/Macros_1.scala | 6 | ||||
-rw-r--r-- | test/files/neg/t5692b/Test_2.scala | 3 |
9 files changed, 33 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala index b30969d451..29b238c4cb 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala @@ -69,7 +69,11 @@ abstract class Pickler extends SubComponent { } if (!t.isDef && t.hasSymbol && t.symbol.isTermMacro) { - unit.error(t.pos, "macro has not been expanded") + unit.error(t.pos, t.symbol.typeParams.length match { + case 0 => "macro has not been expanded" + case 1 => "type parameter not specified" + case _ => "type parameters not specified" + }) return } } diff --git a/test/files/neg/t5692a.check b/test/files/neg/t5692a.check new file mode 100644 index 0000000000..527cb35fba --- /dev/null +++ b/test/files/neg/t5692a.check @@ -0,0 +1,4 @@ +Test_2.scala:2: error: type parameter not specified
+ def x = Macros.foo
+ ^
+one error found
diff --git a/test/files/neg/t5692a.flags b/test/files/neg/t5692a.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/files/neg/t5692a.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/t5692a/Macros_1.scala b/test/files/neg/t5692a/Macros_1.scala new file mode 100644 index 0000000000..06b5a3de36 --- /dev/null +++ b/test/files/neg/t5692a/Macros_1.scala @@ -0,0 +1,6 @@ +import scala.reflect.macros.Context + +object Macros { + def impl[T](c: Context) = c.literalUnit + def foo[T] = macro impl[T] +}
\ No newline at end of file diff --git a/test/files/neg/t5692a/Test_2.scala b/test/files/neg/t5692a/Test_2.scala new file mode 100644 index 0000000000..08d510cc6f --- /dev/null +++ b/test/files/neg/t5692a/Test_2.scala @@ -0,0 +1,3 @@ +class Test { + def x = Macros.foo +}
\ No newline at end of file diff --git a/test/files/neg/t5692b.check b/test/files/neg/t5692b.check new file mode 100644 index 0000000000..8f6b2624cf --- /dev/null +++ b/test/files/neg/t5692b.check @@ -0,0 +1,4 @@ +Test_2.scala:2: error: type parameters not specified
+ def x = Macros.foo
+ ^
+one error found
diff --git a/test/files/neg/t5692b.flags b/test/files/neg/t5692b.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/files/neg/t5692b.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/t5692b/Macros_1.scala b/test/files/neg/t5692b/Macros_1.scala new file mode 100644 index 0000000000..b28d19f903 --- /dev/null +++ b/test/files/neg/t5692b/Macros_1.scala @@ -0,0 +1,6 @@ +import scala.reflect.macros.Context + +object Macros { + def impl[T, U](c: Context) = c.literalUnit + def foo[T, U] = macro impl[T, U] +}
\ No newline at end of file diff --git a/test/files/neg/t5692b/Test_2.scala b/test/files/neg/t5692b/Test_2.scala new file mode 100644 index 0000000000..08d510cc6f --- /dev/null +++ b/test/files/neg/t5692b/Test_2.scala @@ -0,0 +1,3 @@ +class Test { + def x = Macros.foo +}
\ No newline at end of file |