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.57.0~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a2ab6a9c387cb181ca6d60ad6bb60ad42652e3a2;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 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;