[vala] Add PointerType.get_actual_type



commit 3c6311065082de28b83c9f2ba1c616ccb3dd1407
Author: Luca Bruno <lucabru src gnome org>
Date:   Tue Aug 16 10:47:24 2011 +0200

    Add PointerType.get_actual_type
    
    Fixes bug 646792.

 tests/Makefile.am            |    1 +
 tests/objects/bug646792.vala |   10 ++++++++++
 vala/valapointertype.vala    |   15 +++++++++++++++
 3 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9f3e89b..b218306 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -104,6 +104,7 @@ TESTS = \
 	objects/bug634782.vala \
 	objects/bug642809.vala \
 	objects/bug643711.vala \
+	objects/bug646792.vala \
 	objects/bug653138.vala \
 	objects/bug654702.vala \
 	errors/errors.vala \
diff --git a/tests/objects/bug646792.vala b/tests/objects/bug646792.vala
new file mode 100644
index 0000000..e881a52
--- /dev/null
+++ b/tests/objects/bug646792.vala
@@ -0,0 +1,10 @@
+public class Wrapper<G> {
+	public G item;
+	public G *ptr;
+}
+
+void main () {
+	var item = new Wrapper<Wrapper<string>> ();
+	Wrapper<string> inner_item = item.item;
+	Wrapper<string> *inner_ptr = item.ptr;
+}
diff --git a/vala/valapointertype.vala b/vala/valapointertype.vala
index 40016c3..fce8e9b 100644
--- a/vala/valapointertype.vala
+++ b/vala/valapointertype.vala
@@ -133,6 +133,21 @@ public class Vala.PointerType : DataType {
 		return false;
 	}
 
+	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;
+		}
+
+		PointerType result = this;
+
+		if (base_type is GenericType || base_type.has_type_arguments ()) {
+			result = (PointerType) result.copy ();
+			result.base_type = result.base_type.get_actual_type (derived_instance_type, method_access, node_reference);
+		}
+
+		return result;
+	}
+
 	public override bool check (CodeContext context) {
 		error = !base_type.check (context);
 		return !error;



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