]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Add PointerType.get_actual_type
authorLuca Bruno <lucabru@src.gnome.org>
Tue, 16 Aug 2011 08:47:24 +0000 (10:47 +0200)
committerLuca Bruno <lucabru@src.gnome.org>
Tue, 16 Aug 2011 15:19:00 +0000 (17:19 +0200)
Fixes bug 646792.

tests/Makefile.am
tests/objects/bug646792.vala [new file with mode: 0644]
vala/valapointertype.vala

index 9f3e89b99e36aa3dbaa06f5acee6b61e9eb83103..b218306c96ce3f91aca0927265f23bfb609515f2 100644 (file)
@@ -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 (file)
index 0000000..e881a52
--- /dev/null
@@ -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;
+}
index 40016c3426d878d3df8e2137c795b2182fdf5480..fce8e9b6b09d72187602e5b25b6bc0e184e29597 100644 (file)
@@ -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;