[vala/staging: 3/6] vala: NoWrapper methods must be declared abstract or virtual




commit 021c4425972b5827b1ac323d4da93d515df07596
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]