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



commit a2ab6a9c387cb181ca6d60ad6bb60ad42652e3a2
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 c219e72f3..48e9d37d7 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1195,6 +1195,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 162a9fad4..75bf6b3a1 100644
--- a/vala/valamethodcall.vala
+++ b/vala/valamethodcall.vala
@@ -149,7 +149,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]