summaryrefslogtreecommitdiff
path: root/vala/valanulltype.vala
diff options
context:
space:
mode:
authorJuerg Billeter <j@bitron.ch>2008-02-01 13:56:01 +0000
committerJürg Billeter <juergbi@src.gnome.org>2008-02-01 13:56:01 +0000
commit97a9f3bc32e0abb73e1aa8fe3cbbc7708a5faa61 (patch)
tree3c102575cd6f8349b316c0f7b2e1cb07fa86b2b1 /vala/valanulltype.vala
parentc878f08e4fe5accecffaebf9416973f6a1622771 (diff)
downloadvala-97a9f3bc32e0abb73e1aa8fe3cbbc7708a5faa61.tar.gz
add more non-null warnings
2008-02-01 Juerg Billeter <j@bitron.ch> * vala/parser.y, vala/valaarraytype.vala, vala/valadatatype.vala, vala/valaintegertype.vala, vala/valanulltype.vala, vala/valapointertype.vala, vala/valasemanticanalyzer.vala, vala/valasymbolresolver.vala, vala/valaunresolvedtype.vala, ccode/valaccodeassignment.vala, ccode/valaccodebinaryexpression.vala, gobject/valaccodegenerator.vala: add more non-null warnings svn path=/trunk/; revision=940
Diffstat (limited to 'vala/valanulltype.vala')
-rw-r--r--vala/valanulltype.vala10
1 files changed, 6 insertions, 4 deletions
diff --git a/vala/valanulltype.vala b/vala/valanulltype.vala
index d77be59fc..a2d2977c3 100644
--- a/vala/valanulltype.vala
+++ b/vala/valanulltype.vala
@@ -26,10 +26,11 @@ using GLib;
* The type of the null literal.
*/
public class Vala.NullType : ReferenceType {
- public NullType () {
+ public NullType (SourceReference source_reference) {
+ this.source_reference = source_reference;
}
- public override bool compatible (DataType! target_type) {
+ public override bool compatible (DataType! target_type, bool enable_non_null = true) {
if (!(target_type is PointerType) && (target_type is NullType || (target_type.data_type == null && target_type.type_parameter == null))) {
return true;
}
@@ -46,7 +47,8 @@ public class Vala.NullType : ReferenceType {
if (target_type.data_type.is_reference_type () ||
target_type is ArrayType ||
target_type.data_type is Delegate) {
- return !(CodeContext.is_non_null_enabled ());
+ // incompatibility between null and non-null types
+ return !enable_non_null;
}
/* null is not compatible with any other type (i.e. value types) */
@@ -54,6 +56,6 @@ public class Vala.NullType : ReferenceType {
}
public override DataType! copy () {
- return new NullType ();
+ return new NullType (source_reference);
}
}