]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Fix target_type of inner expression for generic field access
authorLuca Bruno <lucabru@src.gnome.org>
Mon, 9 May 2011 14:12:30 +0000 (16:12 +0200)
committerJürg Billeter <j@bitron.ch>
Thu, 16 Jun 2011 20:22:09 +0000 (22:22 +0200)
The target_type of inner expression must have the actual type arguments.
Fixes a regression introduced by 4935646d325911198e1fbf1c4f0734be03341c.

tests/objects/fields.vala
vala/valamemberaccess.vala
vala/valasemanticanalyzer.vala

index 5d490c0909bb699890d205cbe0133d731810ea45..96b66783e129d2aec509f037e39bf00750fcb320 100644 (file)
@@ -98,7 +98,12 @@ class Maman.Bar : Foo {
        }
 }
 
+class Maman.Baz<T> {
+       public T foo;
+}
+
 void main () {
        Maman.Bar.main ();
+       Maman.Baz<Maman.Bar> baz = new Maman.Baz<Maman.Bar> ();
+       baz.foo = null;
 }
-
index a40cf7de2468e1095aee1b3aa8464617c63bb31b..5a46de05c195de2acf451b5004dc7e6ef07ecf48 100644 (file)
@@ -804,7 +804,8 @@ public class Vala.MemberAccess : Expression {
                        } else if ((symbol_reference is Field
                                    || symbol_reference is Signal)
                                   && instance && symbol_reference.parent_symbol != null) {
-                               inner.target_type = context.analyzer.get_data_type_for_symbol ((TypeSymbol) symbol_reference.parent_symbol);
+                               var parent_type = context.analyzer.get_data_type_for_symbol ((TypeSymbol) symbol_reference.parent_symbol);
+                               inner.target_type = parent_type.get_actual_type (inner.value_type, null, this);
                        }
                }
 
index 21f67e4ed8368f2ed60fb0355fcaecc8a8ef4d30..a2a3a1059afcfae27d3ea50b232b9d25c9bef635 100644 (file)
@@ -351,8 +351,10 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
        public static DataType get_data_type_for_symbol (TypeSymbol sym) {
                DataType type = null;
 
+               List<TypeParameter> type_parameters = null;
                if (sym is ObjectTypeSymbol) {
                        type = new ObjectType ((ObjectTypeSymbol) sym);
+                       type_parameters = ((ObjectTypeSymbol) sym).get_type_parameters ();
                } else if (sym is Struct) {
                        var st = (Struct) sym;
                        if (st.is_boolean_type ()) {
@@ -364,6 +366,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                        } else {
                                type = new StructValueType (st);
                        }
+                       type_parameters = st.get_type_parameters ();
                } else if (sym is Enum) {
                        type = new EnumValueType ((Enum) sym);
                } else if (sym is ErrorDomain) {
@@ -375,6 +378,14 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                        return new InvalidType ();
                }
 
+               if (type_parameters != null) {
+                       foreach (var type_param in type_parameters) {
+                               var type_arg = new GenericType (type_param);
+                               type_arg.value_owned = true;
+                               type.add_type_argument (type_arg);
+                       }
+               }
+
                return type;
        }