[vala/staging: 3/3] codegen: Properly handle GenericType in get_ccode_lower_case_name()
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging: 3/3] codegen: Properly handle GenericType in get_ccode_lower_case_name()
- Date: Fri, 5 Feb 2016 14:40:58 +0000 (UTC)
commit 8983406e5dfa37df9a5371830168b3bf70f095ad
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Fri Feb 5 15:14:19 2016 +0100
codegen: Properly handle GenericType in get_ccode_lower_case_name()
codegen/valaccodebasemodule.vala | 2 +
tests/basic-types/arrays.vala | 48 ++++++++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+), 0 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index bd4ecbf..ae18ce5 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -6069,6 +6069,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
} else if (node is DelegateType) {
var type = (DelegateType) node;
return get_ccode_lower_case_name (type.delegate_symbol, infix);
+ } else if (node is GenericType) {
+ return "valageneric";
} else {
var type = (DataType) node;
return get_ccode_lower_case_name (type.data_type, infix);
diff --git a/tests/basic-types/arrays.vala b/tests/basic-types/arrays.vala
index e9143b4..b3a7baf 100644
--- a/tests/basic-types/arrays.vala
+++ b/tests/basic-types/arrays.vala
@@ -136,6 +136,53 @@ void test_delegate_array () {
assert (simple_func in a);
}
+class Baz : Object {
+ public Baz () {
+ }
+
+ Baz get_object ()
+ {
+ return new Baz ();
+ }
+
+ public Baz[] create_array () {
+ var a = get_array<Baz> ();
+ a += (Baz) get_object ();
+ assert (a.length == 2);
+ assert (!(get_object () in a));
+ return a;
+ }
+
+ public V[] create_array2<V> () {
+ var a = get_array2<V> ();
+ a += (V) get_object ();
+ assert (a.length == 3);
+ assert (!(get_object () in a));
+ return a;
+ }
+
+ T[] get_array<T> () {
+ T[] a = {};
+ a += (T) get_object ();
+ return a;
+ }
+
+ G[] get_array2<G> () {
+ G[] a = {};
+ a += (G) get_object ();
+ a += (G) get_object ();
+ return a;
+ }
+}
+
+void test_generics_array () {
+ var g = new Baz ();
+ var a = g.create_array ();
+ assert (a.length == 2);
+ var b = g.create_array2<Baz> ();
+ assert (b.length == 3);
+}
+
void main () {
test_integer_array ();
test_string_array ();
@@ -145,4 +192,5 @@ void main () {
test_length_assignment ();
test_inline_array ();
test_delegate_array ();
+ test_generics_array ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]