[vala/0.48] vala: Apply stricter condition for lambda to delegate assignment
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.48] vala: Apply stricter condition for lambda to delegate assignment
- Date: Sun, 28 Feb 2021 17:26:25 +0000 (UTC)
commit 5640be5fbd669f89e5ee64805590d039e5ca8344
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sat Jan 23 17:29:44 2021 +0100
vala: Apply stricter condition for lambda to delegate assignment
This moves an internal codegen error to the semantic-analyzer.
tests/Makefile.am | 1 +
tests/delegates/lambda-incompatible.test | 11 +++++++++++
vala/valadelegate.vala | 2 +-
3 files changed, 13 insertions(+), 1 deletion(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ef1044232..b944c75d9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -379,6 +379,7 @@ TESTS = \
delegates/incompatible-target.test \
delegates/instance-method-to-no-target.test \
delegates/instance-method-to-no-target-2.test \
+ delegates/lambda-incompatible.test \
delegates/lambda-mixed-instance-static.vala \
delegates/lambda-shared-closure.vala \
delegates/member-target-destroy.vala \
diff --git a/tests/delegates/lambda-incompatible.test b/tests/delegates/lambda-incompatible.test
new file mode 100644
index 000000000..450fe456e
--- /dev/null
+++ b/tests/delegates/lambda-incompatible.test
@@ -0,0 +1,11 @@
+Invalid Code
+
+[CCode (has_target = false)]
+delegate void FooFunc ();
+
+void main () {
+ int i = 0;
+ FooFunc f = () => {
+ i++;
+ };
+}
diff --git a/vala/valadelegate.vala b/vala/valadelegate.vala
index b498133c6..601145ade 100644
--- a/vala/valadelegate.vala
+++ b/vala/valadelegate.vala
@@ -188,7 +188,7 @@ public class Vala.Delegate : TypeSymbol, Callable {
}
// delegate without target for instance method or closure
- if (first && m.binding == MemberBinding.INSTANCE && !has_target) {
+ if (first && !has_target && (m.binding == MemberBinding.INSTANCE || m.closure) &&
(parameters.size == 0 || m.closure)) {
return false;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]