[vala] Fix target_type of inner expression for generic field access
- From: JÃrg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] Fix target_type of inner expression for generic field access
- Date: Thu, 16 Jun 2011 20:25:02 +0000 (UTC)
commit 0bef85f44d9f1d0c06b3779a7bfddc4f673312f5
Author: Luca Bruno <lucabru src gnome org>
Date: Mon May 9 16:12:30 2011 +0200
Fix target_type of inner expression for generic field access
The target_type of inner expression must have the actual type arguments.
Fixes a regression introduced by 4935646d325911198e1fbf1c4f0734be03341c.
tests/objects/fields.vala | 7 ++++++-
vala/valamemberaccess.vala | 3 ++-
vala/valasemanticanalyzer.vala | 11 +++++++++++
3 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/tests/objects/fields.vala b/tests/objects/fields.vala
index 5d490c0..96b6678 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 a40cf7d..5a46de0 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 21f67e4..a2a3a10 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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]