[vala/0.54] vala: Don't unconditionally expect ObjectType of Class



commit 1e7c4d35869a695826f2491701e1bd0f55432417
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sat Jul 30 11:18:40 2022 +0200

    vala: Don't unconditionally expect ObjectType of Class
    
    Fixes https://gitlab.gnome.org/GNOME/vala/issues/1341

 tests/Makefile.am                                 |  1 +
 tests/semantic/methodcall-invocation-invalid.test | 13 +++++++++++++
 vala/valamethodcall.vala                          |  2 +-
 3 files changed, 15 insertions(+), 1 deletion(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 32d2c5641..3733c0706 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1161,6 +1161,7 @@ TESTS = \
        semantic/method-virtual-body.test \
        semantic/methodcall-field-initializer-throws.test \
        semantic/methodcall-invalid-argument-lambda.test \
+       semantic/methodcall-invocation-invalid.test \
        semantic/methodcall-void-expression.test \
        semantic/methodcall-yield-with-begin.test \
        semantic/objectcreation-abstract-class.test \
diff --git a/tests/semantic/methodcall-invocation-invalid.test 
b/tests/semantic/methodcall-invocation-invalid.test
new file mode 100644
index 000000000..a83ed4df9
--- /dev/null
+++ b/tests/semantic/methodcall-invocation-invalid.test
@@ -0,0 +1,13 @@
+Invalid Code
+
+interface Bar {
+}
+
+class Foo {
+       public Bar bar { get; set; }
+}
+
+void main() {
+       var foo = new Foo ();
+       print ("%d", foo.bar ());
+}
diff --git a/vala/valamethodcall.vala b/vala/valamethodcall.vala
index 36f82f93b..9f652b884 100644
--- a/vala/valamethodcall.vala
+++ b/vala/valamethodcall.vala
@@ -152,7 +152,7 @@ public class Vala.MethodCall : Expression, CallableExpression {
                        if (!(m.coroutine && !is_yield_expression && ((MemberAccess) call).member_name != 
"end")) {
                                m.get_error_types (collection, source_reference);
                        }
-               } else if (mtype is ObjectType) {
+               } else if (mtype is ObjectType && mtype.type_symbol is Class) {
                        // constructor
                        unowned Class cl = (Class) ((ObjectType) mtype).type_symbol;
                        unowned Method m = cl.default_construction_method;


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