[vala/staging: 3/3] codegen: Implicitly cast instance arg to match used property get-accessor



commit e55f298cffe16092c85210bd0b577ea0dc85cb67
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Mon Feb 27 16:59:32 2017 +0100

    codegen: Implicitly cast instance arg to match used property get-accessor
    
    https://bugzilla.gnome.org/show_bug.cgi?id=779219

 codegen/valaccodememberaccessmodule.vala |    3 +++
 tests/Makefile.am                        |    1 +
 tests/objects/bug779219.vala             |   18 ++++++++++++++++++
 3 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index 2f9f50d..9e182a6 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -219,6 +219,9 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
                                                        instance = store_temp_value (instance, expr);
                                                }
                                                pub_inst = new CCodeUnaryExpression 
(CCodeUnaryOperator.ADDRESS_OF, get_cvalue_ (instance));
+                                       } else if (prop.parent_symbol is ObjectTypeSymbol) {
+                                               // FIXME this should be resolved correctly before it gets here
+                                               pub_inst = get_implicit_cast_expression (pub_inst, 
expr.inner.target_type, CCodeBaseModule.get_data_type_for_symbol ((TypeSymbol) prop.parent_symbol), prop);
                                        }
 
                                        ccall.add_argument (pub_inst);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 666f110..c790615 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -203,6 +203,7 @@ TESTS = \
        objects/bug615830-1.test \
        objects/bug615830-2.test \
        objects/bug766739.vala \
+       objects/bug779219.vala \
        errors/errors.vala \
        errors/bug567181.vala \
        errors/bug579101.vala \
diff --git a/tests/objects/bug779219.vala b/tests/objects/bug779219.vala
new file mode 100644
index 0000000..c0c4baa
--- /dev/null
+++ b/tests/objects/bug779219.vala
@@ -0,0 +1,18 @@
+interface IFoo : GLib.Object {
+       public abstract int foo { get; }
+}
+
+abstract class Foo : GLib.Object, IFoo {
+       public abstract int foo { get; }
+}
+
+class Bar : Foo {
+       public override int foo { get { return 42; } }
+       public Bar () {
+       }
+}
+
+void main () {
+       var bar = new Bar ();
+       assert (bar.foo == 42);
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]