[vala/0.52] vala: Accept NullType as generic type argument



commit 2639b81a9feacf475aede3aab2f7764200047ce4
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sun Sep 26 13:49:51 2021 +0200

    vala: Accept NullType as generic type argument

 tests/Makefile.am              |  1 +
 tests/generics/null-type.vala  | 10 ++++++++++
 vala/valasemanticanalyzer.vala |  1 +
 3 files changed, 12 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 24f060f2a..07b617fe3 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -698,6 +698,7 @@ TESTS = \
        generics/parameter-invalid-initializer.test \
        generics/parameter-sizeof-initializer.vala \
        generics/member-dup-destroy.vala \
+       generics/null-type.vala \
        generics/property-int-cast.vala \
        generics/reference-transfer.vala \
        generics/string-literal-comparison.vala \
diff --git a/tests/generics/null-type.vala b/tests/generics/null-type.vala
new file mode 100644
index 000000000..a427ee8c1
--- /dev/null
+++ b/tests/generics/null-type.vala
@@ -0,0 +1,10 @@
+void foo<T> (T t) {
+       assert (t == null);
+       assert (typeof (T) == Type.INVALID);
+       assert (T.dup == null);
+       assert (T.destroy == null);
+}
+
+void main () {
+       foo (null);
+}
diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala
index 141d19cdd..550942269 100644
--- a/vala/valasemanticanalyzer.vala
+++ b/vala/valasemanticanalyzer.vala
@@ -1314,6 +1314,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
 
        void check_type_argument (DataType type_arg) {
                if (type_arg is GenericType
+                   || type_arg is NullType
                    || type_arg is PointerType
                    || type_arg is VoidType
                    || is_reference_type_argument (type_arg)


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