[vala/staging] vala: NoWrapper methods must be declared abstract or virtual
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] vala: NoWrapper methods must be declared abstract or virtual
- Date: Sat, 30 Jan 2021 10:45:51 +0000 (UTC)
commit 249acf54ae964090e0ecc8411dc990b2e615f4a3
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sat Jan 30 11:44:17 2021 +0100
vala: NoWrapper methods must be declared abstract or virtual
tests/Makefile.am | 1 +
tests/methods/nowrapper-no-vfunc.test | 10 ++++++++++
vala/valamethod.vala | 6 ++++++
3 files changed, 17 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index cadc9cb98..e3a1efb0f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -219,6 +219,7 @@ TESTS = \
methods/argument-named.vala \
methods/delegate-target.vala \
methods/generics.vala \
+ methods/nowrapper-no-vfunc.test \
methods/params-array.vala \
methods/params-array-abstract.test \
methods/print-attribute.vala \
diff --git a/tests/methods/nowrapper-no-vfunc.test b/tests/methods/nowrapper-no-vfunc.test
new file mode 100644
index 000000000..563ae004d
--- /dev/null
+++ b/tests/methods/nowrapper-no-vfunc.test
@@ -0,0 +1,10 @@
+Invalid Code
+
+class Foo {
+ [NoWrapper]
+ public void bar () {
+ }
+}
+
+void main () {
+}
diff --git a/vala/valamethod.vala b/vala/valamethod.vala
index 4a76c5d39..99bacda44 100644
--- a/vala/valamethod.vala
+++ b/vala/valamethod.vala
@@ -748,6 +748,12 @@ public class Vala.Method : Subroutine, Callable {
return false;
}
+ if (get_attribute ("NoWrapper") != null && !(is_abstract || is_virtual)) {
+ error = true;
+ Report.error (source_reference, "[NoWrapper] methods must be declared abstract or
virtual");
+ return false;
+ }
+
if (is_abstract) {
if (parent_symbol is Class) {
unowned Class cl = (Class) parent_symbol;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]