]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: NoWrapper methods must be declared abstract or virtual
authorRico Tzschichholz <ricotz@ubuntu.com>
Sat, 30 Jan 2021 10:44:17 +0000 (11:44 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 30 Jan 2021 12:18:58 +0000 (13:18 +0100)
tests/Makefile.am
tests/methods/nowrapper-no-vfunc.test [new file with mode: 0644]
vala/valamethod.vala

index cadc9cb98a6febbef996f18f7acd609394577ec6..e3a1efb0f34180a917c13af6851cca5753881a28 100644 (file)
@@ -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 (file)
index 0000000..563ae00
--- /dev/null
@@ -0,0 +1,10 @@
+Invalid Code
+
+class Foo {
+       [NoWrapper]
+       public void bar () {
+       }
+}
+
+void main () {
+}
index 4a76c5d39c9e65f608326fe5e0dfa838acf5d48d..99bacda44e90dabcf9b5cc66746f1a6cc747c3fe 100644 (file)
@@ -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;