diff options
-rw-r--r-- | tests/objects/fields.vala | 7 | ||||
-rw-r--r-- | vala/valamemberaccess.vala | 3 | ||||
-rw-r--r-- | vala/valasemanticanalyzer.vala | 11 |
3 files changed, 19 insertions, 2 deletions
diff --git a/tests/objects/fields.vala b/tests/objects/fields.vala index 5d490c090..96b66783e 100644 --- a/tests/objects/fields.vala +++ b/tests/objects/fields.vala @@ -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; } - diff --git a/vala/valamemberaccess.vala b/vala/valamemberaccess.vala index a40cf7de2..5a46de05c 100644 --- a/vala/valamemberaccess.vala +++ b/vala/valamemberaccess.vala @@ -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); } } diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala index 21f67e4ed..a2a3a1059 100644 --- a/vala/valasemanticanalyzer.vala +++ b/vala/valasemanticanalyzer.vala @@ -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; } |