[vala/staging] Fix crash due to not copying a type



commit eaf1a1feafc621d3dad1106c0a4c389ceefd22b2
Author: Luca Bruno <lucabru src gnome org>
Date:   Wed Oct 9 20:57:08 2013 +0200

    Fix crash due to not copying a type

 vala/valaarraytype.vala   |    7 +++----
 vala/valadatatype.vala    |    7 +++----
 vala/valamethodcall.vala  |    2 +-
 vala/valapointertype.vala |    7 +++----
 4 files changed, 10 insertions(+), 13 deletions(-)
---
diff --git a/vala/valaarraytype.vala b/vala/valaarraytype.vala
index b376723..852342c 100644
--- a/vala/valaarraytype.vala
+++ b/vala/valaarraytype.vala
@@ -235,14 +235,13 @@ public class Vala.ArrayType : ReferenceType {
        }
 
        public override DataType get_actual_type (DataType? derived_instance_type, MemberAccess? 
method_access, CodeNode node_reference) {
+               ArrayType result = (ArrayType) this.copy ();
+
                if (derived_instance_type == null && method_access == null) {
-                       return this;
+                       return result;
                }
 
-               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);
                }
 
diff --git a/vala/valadatatype.vala b/vala/valadatatype.vala
index 085d321..352885b 100644
--- a/vala/valadatatype.vala
+++ b/vala/valadatatype.vala
@@ -442,19 +442,18 @@ public abstract class Vala.DataType : CodeNode {
        }
 
        public virtual DataType get_actual_type (DataType? derived_instance_type, MemberAccess? 
method_access, CodeNode node_reference) {
+               DataType result = this.copy ();
+
                if (derived_instance_type == null && method_access == null) {
-                       return this;
+                       return result;
                }
 
-               DataType result = this;
-
                if (result is GenericType) {
                        result = SemanticAnalyzer.get_actual_type (derived_instance_type, method_access, 
(GenericType) result, node_reference);
                        // don't try to resolve type arguments of returned actual type
                        // they can never be resolved and are not related to the instance type
                } else if (result.type_argument_list != null) {
                        // recursely get actual types for type arguments
-                       result = result.copy ();
                        for (int i = 0; i < result.type_argument_list.size; i++) {
                                result.type_argument_list[i] = result.type_argument_list[i].get_actual_type 
(derived_instance_type, method_access, node_reference);
                        }
diff --git a/vala/valamethodcall.vala b/vala/valamethodcall.vala
index 89d2ba5..f30f59c 100644
--- a/vala/valamethodcall.vala
+++ b/vala/valamethodcall.vala
@@ -579,7 +579,7 @@ public class Vala.MethodCall : Expression {
                        }
                }
 
-               formal_value_type = ret_type;
+               formal_value_type = ret_type.copy ();
                value_type = formal_value_type.get_actual_type (target_object_type, call as MemberAccess, 
this);
 
                bool may_throw = false;
diff --git a/vala/valapointertype.vala b/vala/valapointertype.vala
index 4bfaf34..822123e 100644
--- a/vala/valapointertype.vala
+++ b/vala/valapointertype.vala
@@ -124,14 +124,13 @@ public class Vala.PointerType : DataType {
        }
 
        public override DataType get_actual_type (DataType? derived_instance_type, MemberAccess? 
method_access, CodeNode node_reference) {
+               PointerType result = (PointerType) this.copy ();
+
                if (derived_instance_type == null && method_access == null) {
-                       return this;
+                       return result;
                }
 
-               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);
                }
 


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