]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Don't unconditionally expect ObjectType of Class
authorRico Tzschichholz <ricotz@ubuntu.com>
Sat, 30 Jul 2022 09:18:40 +0000 (11:18 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 30 Jul 2022 09:18:40 +0000 (11:18 +0200)
Fixes https://gitlab.gnome.org/GNOME/vala/issues/1341

tests/Makefile.am
tests/semantic/methodcall-invocation-invalid.test [new file with mode: 0644]
vala/valamethodcall.vala

index c219e72f307de200029615bbc0bacdd5e2467fcc..48e9d37d7628bfb29a792be3d6edf7f578963603 100644 (file)
@@ -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 (file)
index 0000000..a83ed4d
--- /dev/null
@@ -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 ());
+}
index 162a9fad4ae2391f52d9cabbe1612096e331a034..75bf6b3a16261f408e67fa5e8c3d10b781893a1f 100644 (file)
@@ -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;