[vala/0.48] vala: Accept NullType as generic type argument
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.48] vala: Accept NullType as generic type argument
- Date: Mon, 4 Oct 2021 12:47:24 +0000 (UTC)
commit 6405bab4e20c142d6c04d63ef7f69abf367712c3
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 1d823ca11..d8b353fed 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -680,6 +680,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 de9096775..abc0a4b56 100644
--- a/vala/valasemanticanalyzer.vala
+++ b/vala/valasemanticanalyzer.vala
@@ -1354,6 +1354,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]