From: Rico Tzschichholz Date: Sat, 30 Jul 2022 09:18:40 +0000 (+0200) Subject: vala: Don't unconditionally expect ObjectType of Class X-Git-Tag: 0.54.9~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1e7c4d35869a695826f2491701e1bd0f55432417;p=thirdparty%2Fvala.git vala: Don't unconditionally expect ObjectType of Class Fixes https://gitlab.gnome.org/GNOME/vala/issues/1341 --- 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;