[vala/0.44] vala: Improve error message for arrays as type arguments



commit fe7c88fe4360084ad0f239413057f6671c9b422f
Author: Florian Brosch <flo brosch gmail com>
Date:   Wed Sep 3 01:37:31 2014 +0200

    vala: Improve error message for arrays as type arguments

 codegen/valaccodebasemodule.vala         | 2 ++
 tests/Makefile.am                        | 1 +
 tests/generics/arrays-not-supported.test | 8 ++++++++
 3 files changed, 11 insertions(+)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 776562087..54bf70bc5 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -4688,6 +4688,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                        if (delegate_type.delegate_symbol.has_target) {
                                Report.error (type_arg.source_reference, "Delegates with target are not 
supported as generic type arguments");
                        }
+               } else if (type_arg is ArrayType) {
+                       Report.error (type_arg.source_reference, "Arrays are not supported as generic type 
arguments");
                } else {
                        Report.error (type_arg.source_reference, "`%s' is not a supported generic type 
argument, use `?' to box value types".printf (type_arg.to_string ()));
                }
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6cc135dac..d802cbc7a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -484,6 +484,7 @@ TESTS = \
        asynchronous/variadic-invalid.test \
        asynchronous/variadic-invalid-2.test \
        asynchronous/yield.vala \
+       generics/arrays-not-supported.test \
        generics/constructor-chain-up.vala \
        generics/inference-static-function.vala \
        generics/parameter-sizeof-initializer.vala \
diff --git a/tests/generics/arrays-not-supported.test b/tests/generics/arrays-not-supported.test
new file mode 100644
index 000000000..39bce9001
--- /dev/null
+++ b/tests/generics/arrays-not-supported.test
@@ -0,0 +1,8 @@
+Invalid Code
+
+void foo<G>(G g = null) {
+}
+
+void main () {
+       foo<int[]>();
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]