[vala/0.50] vala: NoWrapper methods must be declared abstract or virtual
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.50] vala: NoWrapper methods must be declared abstract or virtual
- Date: Sun, 28 Feb 2021 08:58:21 +0000 (UTC)
commit d9c05345fd79831c2e679044fbd7c63b12c6f791
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 2600447b0..35c3fd7ff 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -218,6 +218,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 b7c44c092..0bed502b9 100644
--- a/vala/valamethod.vala
+++ b/vala/valamethod.vala
@@ -741,6 +741,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]