[vala] Set target_type of switch statement expression to be non-nullable
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] Set target_type of switch statement expression to be non-nullable
- Date: Wed, 3 Aug 2011 19:04:48 +0000 (UTC)
commit a2056afe1922280401a5a991428c9c4ba6edaf9a
Author: Luca Bruno <lucabru src gnome org>
Date: Wed Aug 3 17:07:58 2011 +0200
Set target_type of switch statement expression to be non-nullable
Fixes bug 655908.
tests/Makefile.am | 1 +
tests/basic-types/bug655908.vala | 4 ++++
vala/valaswitchstatement.vala | 1 +
3 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 09ca1a5..9f3e89b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -28,6 +28,7 @@ TESTS = \
basic-types/bug648364.vala \
basic-types/bug650993.vala \
basic-types/bug652380.vala \
+ basic-types/bug655908.vala \
namespaces.vala \
methods/lambda.vala \
methods/closures.vala \
diff --git a/tests/basic-types/bug655908.vala b/tests/basic-types/bug655908.vala
new file mode 100644
index 0000000..2c97ff9
--- /dev/null
+++ b/tests/basic-types/bug655908.vala
@@ -0,0 +1,4 @@
+void main () {
+ int? a = 2;
+ switch (a) { }
+}
diff --git a/vala/valaswitchstatement.vala b/vala/valaswitchstatement.vala
index 6509d49..12ad04b 100644
--- a/vala/valaswitchstatement.vala
+++ b/vala/valaswitchstatement.vala
@@ -116,6 +116,7 @@ public class Vala.SwitchStatement : CodeNode, Statement {
// ensure that possibly owned (string) expression stays alive
expression.target_type = expression.value_type.copy ();
+ expression.target_type.nullable = false;
var labelset = new HashSet<string> (str_hash, str_equal);
foreach (SwitchSection section in sections) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]