From: Jürg Billeter Date: Sat, 24 Jan 2009 16:24:46 +0000 (+0000) Subject: Fix type of implicit `this' parameter when using generics X-Git-Tag: 0.5.7~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2f295d73015b705fb48fb9236fda0b7aa3f7d4a7;p=thirdparty%2Fvala.git Fix type of implicit `this' parameter when using generics 2009-01-24 Jürg Billeter * vala/valaclass.vala: Fix type of implicit `this' parameter when using generics svn path=/trunk/; revision=2399 --- diff --git a/ChangeLog b/ChangeLog index 8a7ff1568..e352d4aac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-01-24 Jürg Billeter + + * vala/valaclass.vala: + + Fix type of implicit `this' parameter when using generics + 2009-01-23 Jürg Billeter * ccode/valaccodefunction.vala: diff --git a/vala/valaclass.vala b/vala/valaclass.vala index 6c06a4e1f..52690f95d 100644 --- a/vala/valaclass.vala +++ b/vala/valaclass.vala @@ -191,7 +191,7 @@ public class Vala.Class : ObjectTypeSymbol { if (_destructor.this_parameter != null) { _destructor.scope.remove (_destructor.this_parameter.name); } - _destructor.this_parameter = new FormalParameter ("this", new ObjectType (this)); + _destructor.this_parameter = new FormalParameter ("this", get_this_type ()); _destructor.scope.add (_destructor.this_parameter.name, _destructor.this_parameter); } } @@ -292,6 +292,16 @@ public class Vala.Class : ObjectTypeSymbol { return new ReadOnlyList (constants); } + ObjectType get_this_type () { + var result = new ObjectType (this); + foreach (var type_parameter in get_type_parameters ()) { + var type_arg = new GenericType (type_parameter); + type_arg.value_owned = true; + result.add_type_argument (type_arg); + } + return result; + } + /** * Adds the specified method as a member to this class. * @@ -302,7 +312,7 @@ public class Vala.Class : ObjectTypeSymbol { if (m.this_parameter != null) { m.scope.remove (m.this_parameter.name); } - m.this_parameter = new FormalParameter ("this", new ObjectType (this)); + m.this_parameter = new FormalParameter ("this", get_this_type ()); m.scope.add (m.this_parameter.name, m.this_parameter); } if (!(m.return_type is VoidType) && m.get_postconditions ().size > 0) { @@ -348,7 +358,7 @@ public class Vala.Class : ObjectTypeSymbol { properties.add (prop); scope.add (prop.name, prop); - prop.this_parameter = new FormalParameter ("this", new ObjectType (this)); + prop.this_parameter = new FormalParameter ("this", get_this_type ()); prop.scope.add (prop.this_parameter.name, prop.this_parameter); if (prop.field != null) {