[vala/0.48] vala: Don't unconditionally expect ObjectType of Class
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.48] vala: Don't unconditionally expect ObjectType of Class
- Date: Wed, 10 Aug 2022 17:22:07 +0000 (UTC)
commit b4ccd8678f3181064491a6458248e11e9b1a17bc
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 6ac21af77..ff3983f8c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1097,6 +1097,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 c7ace27bc..c53fafc69 100644
--- a/vala/valamethodcall.vala
+++ b/vala/valamethodcall.vala
@@ -152,7 +152,7 @@ public class Vala.MethodCall : Expression {
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]