3 * Copyright (C) 2007-2010 Jürg Billeter
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 * Jürg Billeter <j@bitron.ch>
26 * The type of the null literal.
28 public class Vala
.NullType
: ReferenceType
{
29 public NullType (SourceReference? source_reference
) {
31 this
.source_reference
= source_reference
;
34 public override bool compatible (DataType target_type
) {
35 if (CodeContext
.get ().experimental_non_null
) {
36 return target_type
.nullable
;
39 if (!(target_type is PointerType
) && (target_type is NullType
|| (target_type
.data_type
== null && !(target_type is GenericType
)))) {
43 /* null can be cast to any reference or array type or pointer type */
44 if (target_type is GenericType
||
45 target_type is PointerType
||
46 target_type
.nullable
||
47 target_type
.data_type
.get_attribute ("PointerType") != null) {
51 if (target_type
.data_type
.is_reference_type () ||
52 target_type is ArrayType
||
53 target_type is DelegateType
) {
57 /* null is not compatible with any other type (i.e. value types) */
61 public override DataType
copy () {
62 return new
NullType (source_reference
);
65 public override bool is_disposable () {
69 public override string to_qualified_string (Scope? scope
= null) {