[vala] Fix generic type resolution for arrays of generic types



commit 1788fa5854ac3e393978039851b3a173adc642ec
Author: Luca Bruno <lethalman88 gmail com>
Date:   Sun Jan 24 01:27:42 2010 +0100

    Fix generic type resolution for arrays of generic types
    
    Arrays of generic types are still only supported for pointer-based
    element types.
    
    Fixes bug 568972.

 vala/valaarraytype.vala |   16 ++++++++++++++++
 vala/valadatatype.vala  |   10 +++++++++-
 2 files changed, 25 insertions(+), 1 deletions(-)
---
diff --git a/vala/valaarraytype.vala b/vala/valaarraytype.vala
index 63028cb..da81400 100644
--- a/vala/valaarraytype.vala
+++ b/vala/valaarraytype.vala
@@ -247,4 +247,20 @@ public class Vala.ArrayType : ReferenceType {
 			return null;
 		}
 	}
+
+	public override DataType get_actual_type (DataType? derived_instance_type, MemberAccess? method_access, CodeNode node_reference) {
+		if (derived_instance_type == null && method_access == null) {
+			return this;
+		}
+
+		ArrayType result = this;
+
+		if (element_type is GenericType || element_type.has_type_arguments ()) {
+			result = (ArrayType) result.copy ();
+			result.element_type = result.element_type.get_actual_type (derived_instance_type, method_access, node_reference);
+		}
+
+		return result;
+	}
+
 }
diff --git a/vala/valadatatype.vala b/vala/valadatatype.vala
index b8b6ceb..7e6cb64 100644
--- a/vala/valadatatype.vala
+++ b/vala/valadatatype.vala
@@ -90,6 +90,14 @@ public abstract class Vala.DataType : CodeNode {
 		return _empty_type_list;
 	}
 
+	public bool has_type_arguments () {
+		if (type_argument_list == null) {
+			return false;
+		}
+
+		return type_argument_list.size > 0;
+	}
+
 	/**
 	 * Removes all generic type arguments.
 	 */
@@ -507,7 +515,7 @@ public abstract class Vala.DataType : CodeNode {
 		return false;
 	}
 
-	public DataType get_actual_type (DataType? derived_instance_type, MemberAccess? method_access, CodeNode node_reference) {
+	public virtual DataType get_actual_type (DataType? derived_instance_type, MemberAccess? method_access, CodeNode node_reference) {
 		if (derived_instance_type == null && method_access == null) {
 			return this;
 		}



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