From: Luca Bruno Date: Wed, 9 Oct 2013 18:57:08 +0000 (+0200) Subject: Fix crash due to not copying a type X-Git-Tag: 0.22.1~8^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eaf1a1feafc621d3dad1106c0a4c389ceefd22b2;p=thirdparty%2Fvala.git Fix crash due to not copying a type --- diff --git a/vala/valaarraytype.vala b/vala/valaarraytype.vala index b37672335..852342c20 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 085d321e0..352885bfd 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 89d2ba5cc..f30f59c40 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 4bfaf34ee..822123e91 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); }