[vala/staging] vala: Move dynamic property errors to semantic analyzer pass
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] vala: Move dynamic property errors to semantic analyzer pass
- Date: Sun, 6 Feb 2022 08:06:44 +0000 (UTC)
commit 400fd102d162d1474a7045438b39cddcde946874
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sun Feb 6 08:57:35 2022 +0100
vala: Move dynamic property errors to semantic analyzer pass
tests/Makefile.am | 1 +
tests/objects/property-dynamic-not-supported.test | 10 ++++++++++
vala/valamemberaccess.vala | 8 ++++++++
3 files changed, 19 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 72ff16da1..f1b5686f2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -533,6 +533,7 @@ TESTS = \
objects/property-array.vala \
objects/property-array-length.vala \
objects/property-base-access.vala \
+ objects/property-dynamic-not-supported.test \
objects/property-enum.vala \
objects/property-notify.vala \
objects/property-notify-owned-getter.vala \
diff --git a/tests/objects/property-dynamic-not-supported.test
b/tests/objects/property-dynamic-not-supported.test
new file mode 100644
index 000000000..15d659099
--- /dev/null
+++ b/tests/objects/property-dynamic-not-supported.test
@@ -0,0 +1,10 @@
+Invalid Code
+
+class Foo {
+}
+
+void main () {
+ dynamic Foo foo = new Foo ();
+ foo.bar = "foo";
+ int i = foo.bar;
+}
diff --git a/vala/valamemberaccess.vala b/vala/valamemberaccess.vala
index 7ee417a29..25d74fc88 100644
--- a/vala/valamemberaccess.vala
+++ b/vala/valamemberaccess.vala
@@ -493,6 +493,10 @@ public class Vala.MemberAccess : Expression {
prop.owner = inner.value_type.type_symbol.scope;
dynamic_object_type.type_symbol.scope.add (null, prop);
symbol_reference = prop;
+ if (!dynamic_object_type.type_symbol.is_subtype_of
(context.analyzer.object_type)) {
+ Report.error (source_reference, "dynamic properties
are not supported for `%s'", dynamic_object_type.type_symbol.get_full_name ());
+ error = true;
+ }
}
} else if (parent_node is MemberAccess && inner is MemberAccess &&
parent_node.parent_node is MethodCall) {
unowned MemberAccess ma = (MemberAccess) parent_node;
@@ -548,6 +552,10 @@ public class Vala.MemberAccess : Expression {
prop.owner = inner.value_type.type_symbol.scope;
dynamic_object_type.type_symbol.scope.add (null, prop);
symbol_reference = prop;
+ if (!dynamic_object_type.type_symbol.is_subtype_of
(context.analyzer.object_type)) {
+ Report.error (source_reference, "dynamic properties are not
supported for %s", dynamic_object_type.type_symbol.get_full_name ());
+ error = true;
+ }
}
if (symbol_reference != null) {
may_access_instance_members = true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]