]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Micro optimizations 9811ebe2f9b984bca96248183fc412fa8d049c60
authorRico Tzschichholz <ricotz@ubuntu.com>
Sun, 29 Sep 2019 16:15:54 +0000 (18:15 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 30 Sep 2019 14:03:29 +0000 (16:03 +0200)
40 files changed:
vala/valaaddressofexpression.vala
vala/valaarraytype.vala
vala/valabinaryexpression.vala
vala/valablock.vala
vala/valacallabletype.vala
vala/valaclass.vala
vala/valacodewriter.vala
vala/valaconstant.vala
vala/valacreationmethod.vala
vala/valadatatype.vala
vala/valadeclarationstatement.vala
vala/valadelegatetype.vala
vala/valadostatement.vala
vala/valaelementaccess.vala
vala/valaerrortype.vala
vala/valaexpression.vala
vala/valaflowanalyzer.vala
vala/valaforstatement.vala
vala/valagenieparser.vala
vala/valainitializerlist.vala
vala/valalocalvariable.vala
vala/valamethod.vala
vala/valamethodtype.vala
vala/valaobjectcreationexpression.vala
vala/valaobjecttype.vala
vala/valaparameter.vala
vala/valaparser.vala
vala/valapointertype.vala
vala/valapostfixexpression.vala
vala/valareferencetransferexpression.vala
vala/valareturnstatement.vala
vala/valasignal.vala
vala/valasliceexpression.vala
vala/valastringliteral.vala
vala/valastruct.vala
vala/valastructvaluetype.vala
vala/valasymbolresolver.vala
vala/valaunaryexpression.vala
vala/valaunresolvedsymbol.vala
vala/valawhilestatement.vala

index 4948a46c2a4ea6f03ab804a540ffb8b9ad4db3aa..991596b2285176f5fdbd4f340b2b98cfb349f844 100644 (file)
@@ -93,7 +93,8 @@ public class Vala.AddressofExpression : Expression {
                        error = true;
                        return false;
                }
-               var ea = inner as ElementAccess;
+
+               unowned ElementAccess? ea = inner as ElementAccess;
                if (inner is MemberAccess && inner.symbol_reference is Variable) {
                        // address of variable is always possible
                } else if (ea != null &&
index 76216893382d29ad7bd77f365203cbd44beb849e..e9b7192d7e7e95ce03266fe50eff8033e80d98ba 100644 (file)
@@ -223,7 +223,7 @@ public class Vala.ArrayType : ReferenceType {
                        return true;
                }
 
-               var target_array_type = target_type as ArrayType;
+               unowned ArrayType? target_array_type = target_type as ArrayType;
                if (target_array_type == null) {
                        return false;
                }
@@ -332,7 +332,7 @@ public class Vala.ArrayType : ReferenceType {
        }
 
        public override DataType? infer_type_argument (TypeParameter type_param, DataType value_type) {
-               var array_type = value_type as ArrayType;
+               unowned ArrayType? array_type = value_type as ArrayType;
                if (array_type != null) {
                        return element_type.infer_type_argument (type_param, array_type.element_type);
                }
index 893670232d8b063e1c64d3b3bfc4f2893eb0b66f..f3127dcc0409160c65400e49e5b760c0fd364fb7 100644 (file)
@@ -341,7 +341,7 @@ public class Vala.BinaryExpression : Expression {
                } else if (left.value_type is ArrayType && operator == BinaryOperator.PLUS) {
                        // array concatenation
 
-                       var array_type = (ArrayType) left.value_type;
+                       unowned ArrayType array_type = (ArrayType) left.value_type;
 
                        if (right.value_type == null || !right.value_type.compatible (array_type.element_type)) {
                                error = true;
@@ -359,14 +359,14 @@ public class Vala.BinaryExpression : Expression {
                           || operator == BinaryOperator.DIV) {
                        // check for pointer arithmetic
                        if (left.value_type is PointerType) {
-                               var pointer_type = (PointerType) left.value_type;
+                               unowned PointerType pointer_type = (PointerType) left.value_type;
                                if (pointer_type.base_type is VoidType) {
                                        error = true;
                                        Report.error (source_reference, "Pointer arithmetic not supported for `void*'");
                                        return false;
                                }
 
-                               var offset_type = right.value_type.type_symbol as Struct;
+                               unowned Struct? offset_type = right.value_type.type_symbol as Struct;
                                if (offset_type != null && offset_type.is_integer_type ()) {
                                        if (operator == BinaryOperator.PLUS
                                            || operator == BinaryOperator.MINUS) {
index ae30c8b1546c003b34f7d173c093290ac158f5f4..c4e8ab74e299db2f3c3c8fddded0e7cb3a70e078 100644 (file)
@@ -70,7 +70,7 @@ public class Vala.Block : Symbol, Statement {
        public List<Statement> get_statements () {
                var list = new ArrayList<Statement> ();
                foreach (Statement stmt in statement_list) {
-                       var stmt_list = stmt as StatementList;
+                       unowned StatementList? stmt_list = stmt as StatementList;
                        if (stmt_list != null) {
                                for (int i = 0; i < stmt_list.length; i++) {
                                        list.add (stmt_list.get (i));
@@ -88,7 +88,7 @@ public class Vala.Block : Symbol, Statement {
         * @param local a variable declarator
         */
        public void add_local_variable (LocalVariable local) {
-               var parent_block = parent_symbol;
+               unowned Symbol? parent_block = parent_symbol;
                while (parent_block is Block || parent_block is Method || parent_block is PropertyAccessor) {
                        if (parent_block.scope.lookup (local.name) != null) {
                                Report.error (local.source_reference, "Local variable `%s' conflicts with a local variable or constant declared in a parent scope".printf (local.name));
@@ -113,7 +113,7 @@ public class Vala.Block : Symbol, Statement {
        }
 
        public void add_local_constant (Constant constant) {
-               var parent_block = parent_symbol;
+               unowned Symbol? parent_block = parent_symbol;
                while (parent_block is Block || parent_block is Method || parent_block is PropertyAccessor) {
                        if (parent_block.scope.lookup (constant.name) != null) {
                                Report.error (constant.source_reference, "Local constant `%s' conflicts with a local variable or constant declared in a parent scope".printf (constant.name));
index d0db023bd0d23e10d100e6ae7efb18f0c1f530b7..14813ec5bb7778abe393660e8978b36cf61b1017 100644 (file)
@@ -52,7 +52,7 @@ public abstract class Vala.CallableType : DataType {
                StringBuilder builder = new StringBuilder ();
 
                // Append return-type
-               var return_type = get_return_type ();
+               unowned DataType return_type = get_return_type ();
                if (return_type.is_weak ()) {
                        builder.append ("unowned ");
                }
@@ -67,9 +67,9 @@ public abstract class Vala.CallableType : DataType {
                builder.append_c ('(');
                int i = 1;
                // add sender parameter for internal signal-delegates
-               var delegate_type = this as DelegateType;
+               unowned DelegateType? delegate_type = this as DelegateType;
                if (delegate_type != null) {
-                       var delegate_symbol = delegate_type.delegate_symbol;
+                       unowned Delegate delegate_symbol = delegate_type.delegate_symbol;
                        if (delegate_symbol.parent_symbol is Signal && delegate_symbol.sender_type != null) {
                                builder.append (delegate_symbol.sender_type.to_qualified_string ());
                                i++;
index 6fb3ff6607465f873e1b662dd89c8cb0aeca2a74..fcf239b33e45c6f08b93f1498b80ec5bf30acdb8 100644 (file)
@@ -289,7 +289,7 @@ public class Vala.Class : ObjectTypeSymbol {
                                m.name = ".new";
                        }
 
-                       var cm = (CreationMethod) m;
+                       unowned CreationMethod cm = (CreationMethod) m;
                        if (cm.class_name != null && cm.class_name != name) {
                                // class_name is null for constructors generated by GIdlParser
                                Report.error (m.source_reference, "missing return type in method `%s.%s´".printf (get_full_name (), cm.class_name));
@@ -732,7 +732,7 @@ public class Vala.Class : ObjectTypeSymbol {
                        /* all abstract symbols defined in base types have to be at least defined (or implemented) also in this type */
                        foreach (DataType base_type in get_base_types ()) {
                                if (base_type.type_symbol is Interface) {
-                                       Interface iface = (Interface) base_type.type_symbol;
+                                       unowned Interface iface = (Interface) base_type.type_symbol;
 
                                        if (base_class != null && base_class.is_subtype_of (iface)) {
                                                // reimplementation of interface, class is not required to reimplement all methods
@@ -747,7 +747,7 @@ public class Vala.Class : ObjectTypeSymbol {
                                        foreach (Method m in iface.get_methods ()) {
                                                if (m.is_abstract) {
                                                        var implemented = false;
-                                                       var base_class = this;
+                                                       unowned Class? base_class = this;
                                                        while (base_class != null && !implemented) {
                                                                foreach (var impl in base_class.get_methods ()) {
                                                                        if (impl.base_interface_method == m || (base_class != this
@@ -777,7 +777,7 @@ public class Vala.Class : ObjectTypeSymbol {
                                        foreach (Property prop in iface.get_properties ()) {
                                                if (prop.is_abstract) {
                                                        Symbol sym = null;
-                                                       var base_class = this;
+                                                       unowned Class? base_class = this;
                                                        while (base_class != null && !(sym is Property)) {
                                                                sym = base_class.scope.lookup (prop.name);
                                                                base_class = base_class.base_class;
@@ -804,7 +804,7 @@ public class Vala.Class : ObjectTypeSymbol {
 
                        /* all abstract symbols defined in base classes have to be implemented in non-abstract classes */
                        if (!is_abstract) {
-                               var base_class = base_class;
+                               unowned Class? base_class = base_class;
                                while (base_class != null && base_class.is_abstract) {
                                        foreach (Method base_method in base_class.get_methods ()) {
                                                if (base_method.is_abstract) {
index 97aa48136cde471dab84ed9015c3d18b8ba908f6..930fbdf2e385a0589de47be869e8214005c31327 100644 (file)
@@ -1476,7 +1476,7 @@ public class Vala.CodeWriter : CodeVisitor {
        }
 
        private void write_type_suffix (DataType type) {
-               var array_type = type as ArrayType;
+               unowned ArrayType? array_type = type as ArrayType;
                if (array_type != null && array_type.fixed_length) {
                        write_string ("[");
                        array_type.length.accept (this);
@@ -1555,7 +1555,7 @@ public class Vala.CodeWriter : CodeVisitor {
        }
 
        private void write_attributes (CodeNode node) {
-               var sym = node as Symbol;
+               unowned Symbol? sym = node as Symbol;
 
                var need_cheaders = type != CodeWriterType.FAST && sym != null && !(sym is Namespace) && sym.parent_symbol is Namespace;
 
index 2fc75afabd457fb1ec39e5a546f954beaa56231e..519d43b1bc5be2f1c9cea5359bdbafad97d43009 100644 (file)
@@ -141,9 +141,9 @@ public class Vala.Constant : Symbol {
 
                                // support translated string constants for efficiency / convenience
                                // even though the expression is not a compile-time constant
-                               var call = value as MethodCall;
+                               unowned MethodCall? call = value as MethodCall;
                                if (call != null) {
-                                       var method_type = call.call.value_type as MethodType;
+                                       unowned MethodType? method_type = call.call.value_type as MethodType;
                                        if (method_type != null && method_type.method_symbol.get_full_name () == "GLib._") {
                                                // first argument is string
                                                var literal = call.get_argument_list ().get (0) as StringLiteral;
@@ -183,7 +183,7 @@ public class Vala.Constant : Symbol {
                if (type is ValueType) {
                        return true;
                } else if (type is ArrayType) {
-                       var array_type = type as ArrayType;
+                       unowned ArrayType array_type = (ArrayType) type;
                        return check_const_type (array_type.element_type, context);
                } else if (type.type_symbol.is_subtype_of (context.analyzer.string_type.type_symbol)) {
                        return true;
index ae8daab3853a5e046daa2528187e82d237baa616..48f301ddf6f4ddb66bea10d67f0142b9cde8f4b7 100644 (file)
@@ -128,7 +128,7 @@ public class Vala.CreationMethod : Method {
                if (body != null) {
                        body.check (context);
 
-                       var cl = parent_symbol as Class;
+                       unowned Class? cl = parent_symbol as Class;
 
                        // ensure we chain up to base constructor
                        if (!chain_up && cl != null && cl.base_class != null) {
index 2a9b33b1fb44defd1c1c50e282575f419bdaaa6c..6dc7cd07fc8b901893898ba0227239ca38e279da 100644 (file)
@@ -351,8 +351,8 @@ public abstract class Vala.DataType : CodeNode {
                }
 
                if (type_symbol is Struct && target_type.type_symbol is Struct) {
-                       var expr_struct = (Struct) type_symbol;
-                       var expect_struct = (Struct) target_type.type_symbol;
+                       unowned Struct expr_struct = (Struct) type_symbol;
+                       unowned Struct expect_struct = (Struct) target_type.type_symbol;
 
                        /* integer types may be implicitly cast to floating point types */
                        if (expr_struct.is_integer_type () && expect_struct.is_floating_type ()) {
@@ -549,7 +549,7 @@ public abstract class Vala.DataType : CodeNode {
                        }
 
                        return string.nfill (array_type.rank, 'a') + element_type_signature;
-               } else if (type_symbol != null && type_symbol is Enum && type_symbol.get_attribute_bool ("DBus", "use_string_marshalling")) {
+               } else if (type_symbol is Enum && type_symbol.get_attribute_bool ("DBus", "use_string_marshalling")) {
                        return "s";
                } else if (type_symbol != null) {
                        string sig = type_symbol.get_attribute_string ("CCode", "type_signature");
index ab652e90673b5488227f4355195069fa60cda3ac..e103024138d00f15d38e51e0fd2b435a3bf3d075 100644 (file)
@@ -66,7 +66,7 @@ public class Vala.DeclarationStatement : CodeNode, Statement {
                if (source_reference == null) {
                        source_reference = this.source_reference;
                }
-               var local = declaration as LocalVariable;
+               unowned LocalVariable? local = declaration as LocalVariable;
                if (local != null && local.initializer != null) {
                        local.initializer.get_error_types (collection, source_reference);
                }
@@ -89,9 +89,9 @@ public class Vala.DeclarationStatement : CodeNode, Statement {
        }
 
        public override void get_defined_variables (Collection<Variable> collection) {
-               var local = declaration as LocalVariable;
+               unowned LocalVariable? local = declaration as LocalVariable;
                if (local != null) {
-                       var array_type = local.variable_type as ArrayType;
+                       unowned ArrayType? array_type = local.variable_type as ArrayType;
                        if (local.initializer != null) {
                                local.initializer.get_defined_variables (collection);
                                collection.add (local);
@@ -102,7 +102,7 @@ public class Vala.DeclarationStatement : CodeNode, Statement {
        }
 
        public override void get_used_variables (Collection<Variable> collection) {
-               var local = declaration as LocalVariable;
+               unowned LocalVariable? local = declaration as LocalVariable;
                if (local != null && local.initializer != null) {
                        local.initializer.get_used_variables (collection);
                }
index 91b349081b55fbe9450347badbd3f6c479b7d62e..539b53050ea1e1a90cd6c175bbd07f13030124ac 100644 (file)
@@ -91,7 +91,7 @@ public class Vala.DelegateType : CallableType {
        }
 
        public override bool compatible (DataType target_type) {
-               var dt_target = target_type as DelegateType;
+               unowned DelegateType? dt_target = target_type as DelegateType;
                if (dt_target == null) {
                        return false;
                }
index f34e223584655ff6b196f4ebe8578314680719cd..fb9095858529c4e49d0244b62f9b61ff9d772a6c 100644 (file)
@@ -82,7 +82,7 @@ public class Vala.DoStatement : CodeNode, Statement {
        }
 
        bool always_true (Expression condition) {
-               var literal = condition as BooleanLiteral;
+               unowned BooleanLiteral? literal = condition as BooleanLiteral;
                return (literal != null && literal.value);
        }
 
@@ -105,7 +105,7 @@ public class Vala.DoStatement : CodeNode, Statement {
                if (always_true (condition)) {
                        var loop = new Loop (body, source_reference);
 
-                       var parent_block = (Block) parent_node;
+                       unowned Block parent_block = (Block) parent_node;
                        parent_block.replace_statement (this, loop);
 
                        if (!loop.check (context)) {
@@ -134,7 +134,7 @@ public class Vala.DoStatement : CodeNode, Statement {
 
                block.add_statement (new Loop (body, source_reference));
 
-               var parent_block = (Block) parent_node;
+               unowned Block parent_block = (Block) parent_node;
                parent_block.replace_statement (this, block);
 
                if (!block.check (context)) {
index 90c718ff80fbd26f8fe40d01a6794f546d66f9f0..9ecc6c67e8d96ae2704c85345f6bcbe58961e84d 100644 (file)
@@ -171,16 +171,16 @@ public class Vala.ElementAccess : Expression {
 
                bool index_int_type_check = true;
 
-               var pointer_type = container.value_type as PointerType;
+               unowned PointerType? pointer_type = container.value_type as PointerType;
 
                /* assign a value_type when possible */
                if (container.value_type is ArrayType) {
-                       var array_type = (ArrayType) container.value_type;
+                       unowned ArrayType array_type = (ArrayType) container.value_type;
                        value_type = array_type.element_type.copy ();
                        if (!lvalue) {
                                value_type.value_owned = false;
                        } else {
-                               var ma = container as MemberAccess;
+                               unowned MemberAccess? ma = container as MemberAccess;
                                if (context.profile == Profile.GOBJECT && ma != null && ma.symbol_reference is ArrayLengthField) {
                                        // propagate lvalue for gobject length access
                                        ma.inner.lvalue = true;
@@ -209,7 +209,7 @@ public class Vala.ElementAccess : Expression {
                } else {
                        if (lvalue) {
                                var set_method = container.value_type.get_member ("set") as Method;
-                               var assignment = parent_node as Assignment;
+                               unowned Assignment? assignment = parent_node as Assignment;
                                if (set_method != null && set_method.return_type is VoidType && assignment != null) {
                                        return !error;
                                }
index 868a41b28d02375c072f84c2b063e738c31315d3..26edcaddd608b316464c79d52233ab16e0b215d3 100644 (file)
@@ -55,7 +55,7 @@ public class Vala.ErrorType : ReferenceType {
                        return true;
                }
 
-               var et = target_type as ErrorType;
+               unowned ErrorType? et = target_type as ErrorType;
 
                /* error types are only compatible to error types */
                if (et == null) {
@@ -105,7 +105,7 @@ public class Vala.ErrorType : ReferenceType {
        }
 
        public override bool equals (DataType type2) {
-               var et = type2 as ErrorType;
+               unowned ErrorType? et = type2 as ErrorType;
 
                if (et == null) {
                        return false;
index 885d82b9d2a1f8d53dac7cec4a0aa8532019bbcd..2b9170e427562ad8725bdeb6603ae696eeb73ead 100644 (file)
@@ -88,10 +88,10 @@ public abstract class Vala.Expression : CodeNode {
 
        public Statement? parent_statement {
                get {
-                       var expr = parent_node as Expression;
-                       var stmt = parent_node as Statement;
-                       var local = parent_node as LocalVariable;
-                       var initializer = parent_node as MemberInitializer;
+                       unowned Expression? expr = parent_node as Expression;
+                       unowned Statement? stmt = parent_node as Statement;
+                       unowned LocalVariable? local = parent_node as LocalVariable;
+                       unowned MemberInitializer? initializer = parent_node as MemberInitializer;
                        if (stmt != null) {
                                return (Statement) parent_node;
                        } else if (expr != null) {
index 4e81db9e26f3eb0cb512c269950ab4788570d978..978ab94f8f8f46dbde7c6d998cb14e022f1e6b5f 100644 (file)
@@ -566,7 +566,7 @@ public class Vala.FlowAnalyzer : CodeVisitor {
 
                current_block.add_node (stmt);
 
-               var local = stmt.declaration as LocalVariable;
+               unowned LocalVariable? local = stmt.declaration as LocalVariable;
                if (local != null && local.initializer != null) {
                        handle_errors (local.initializer);
                }
@@ -590,8 +590,8 @@ public class Vala.FlowAnalyzer : CodeVisitor {
                handle_errors (stmt);
 
                if (stmt.expression is MethodCall) {
-                       var expr = (MethodCall) stmt.expression;
-                       var ma = expr.call as MemberAccess;
+                       unowned MethodCall expr = (MethodCall) stmt.expression;
+                       unowned MemberAccess? ma = expr.call as MemberAccess;
                        if (ma != null && ma.symbol_reference != null && ma.symbol_reference.get_attribute ("NoReturn") != null) {
                                mark_unreachable ();
                                return;
@@ -600,12 +600,12 @@ public class Vala.FlowAnalyzer : CodeVisitor {
        }
 
        bool always_true (Expression condition) {
-               var literal = condition as BooleanLiteral;
+               unowned BooleanLiteral? literal = condition as BooleanLiteral;
                return (literal != null && literal.value);
        }
 
        bool always_false (Expression condition) {
-               var literal = condition as BooleanLiteral;
+               unowned BooleanLiteral? literal = condition as BooleanLiteral;
                return (literal != null && !literal.value);
        }
 
@@ -870,8 +870,8 @@ public class Vala.FlowAnalyzer : CodeVisitor {
                        var error_types = new ArrayList<DataType> ();
                        node.get_error_types (error_types);
                        foreach (DataType error_data_type in error_types) {
-                               var error_type = error_data_type as ErrorType;
-                               var error_class = error_data_type.type_symbol as Class;
+                               unowned ErrorType? error_type = error_data_type as ErrorType;
+                               unowned Class? error_class = error_data_type.type_symbol as Class;
                                current_block = last_block;
                                unreachable_reported = true;
 
@@ -989,10 +989,10 @@ public class Vala.FlowAnalyzer : CodeVisitor {
 
                        if (catch_clause.error_type != null) {
                                if (context.profile == Profile.GOBJECT) {
-                                       var error_type = (ErrorType) catch_clause.error_type;
+                                       unowned ErrorType error_type = (ErrorType) catch_clause.error_type;
                                        jump_stack.add (new JumpTarget.error_target (error_block, catch_clause, catch_clause.error_type.type_symbol as ErrorDomain, error_type.error_code, null));
                                } else {
-                                       var error_class = catch_clause.error_type.type_symbol as Class;
+                                       unowned Class? error_class = catch_clause.error_type.type_symbol as Class;
                                        jump_stack.add (new JumpTarget.error_target (error_block, catch_clause, null, null, error_class));
                                }
                        } else {
index 19501c614885574b0ec5bcbffc686cad08419f4c..0bef2cc3e1a5300ccbbb730ab20aecc7e8c7aefb 100644 (file)
@@ -155,12 +155,12 @@ public class Vala.ForStatement : CodeNode, Statement {
        }
 
        bool always_true (Expression condition) {
-               var literal = condition as BooleanLiteral;
+               unowned BooleanLiteral? literal = condition as BooleanLiteral;
                return (literal != null && literal.value);
        }
 
        bool always_false (Expression condition) {
-               var literal = condition as BooleanLiteral;
+               unowned BooleanLiteral? literal = condition as BooleanLiteral;
                return (literal != null && !literal.value);
        }
 
@@ -209,7 +209,7 @@ public class Vala.ForStatement : CodeNode, Statement {
 
                block.add_statement (new Loop (body, source_reference));
 
-               var parent_block = (Block) parent_node;
+               unowned Block parent_block = (Block) parent_node;
                parent_block.replace_statement (this, block);
 
                if (!block.check (context)) {
index 9c7d72dd6e1c713125351503128f9ccec40f2120..05c300723e89694757fcf70c30be5480687281e1 100644 (file)
@@ -1176,8 +1176,8 @@ public class Vala.Genie.Parser : CodeVisitor {
 
                var expr = parse_expression ();
 
-               var call = expr as MethodCall;
-               var object_creation = expr as ObjectCreationExpression;
+               unowned MethodCall? call = expr as MethodCall;
+               unowned ObjectCreationExpression? object_creation = expr as ObjectCreationExpression;
                if (call == null && object_creation == null) {
                        Report.error (expr.source_reference, "syntax error, expected method call");
                        throw new ParseError.SYNTAX ("expected method call");
@@ -2757,7 +2757,7 @@ public class Vala.Genie.Parser : CodeVisitor {
                expect_terminator ();
 
                // constant arrays don't own their element
-               var array_type = type as ArrayType;
+               unowned ArrayType? array_type = type as ArrayType;
                if (array_type != null) {
                        array_type.element_type.value_owned = false;
                }
index 5183640f8feeb9f5bd38133df9a490adaaa082ba..50d1ed487e001f5ef7d5c5186e0bfe31fabe203b 100644 (file)
@@ -143,7 +143,7 @@ public class Vala.InitializerList : Expression {
                        return false;
                } else if (target_type is ArrayType) {
                        /* initializer is used as array initializer */
-                       var array_type = (ArrayType) target_type;
+                       unowned ArrayType array_type = (ArrayType) target_type;
 
                        bool requires_constants_only = false;
                        unowned CodeNode? node = parent_node;
@@ -189,7 +189,7 @@ public class Vala.InitializerList : Expression {
                        }
                } else if (target_type.type_symbol is Struct) {
                        /* initializer is used as struct initializer */
-                       var st = (Struct) target_type.type_symbol;
+                       unowned Struct st = (Struct) target_type.type_symbol;
                        while (st.base_struct != null) {
                                st = st.base_struct;
                        }
@@ -233,7 +233,7 @@ public class Vala.InitializerList : Expression {
                                continue;
                        }
 
-                       var unary = e as UnaryExpression;
+                       unowned UnaryExpression? unary = e as UnaryExpression;
                        if (unary != null && (unary.operator == UnaryOperator.REF || unary.operator == UnaryOperator.OUT)) {
                                // TODO check type for ref and out expressions
                        } else if (!e.value_type.compatible (e.target_type)) {
index 24c2f2b198a0340cf5d471e37290099110d9f23e..f6a39ba8e96ac0453ec5681ed6f13252e65e6c42 100644 (file)
@@ -83,7 +83,7 @@ public class Vala.LocalVariable : Variable {
                        // local reference variables are considered nullable
                        // except when using experimental non-null enhancements
                        if (variable_type is ReferenceType) {
-                               var array_type = variable_type as ArrayType;
+                               unowned ArrayType? array_type = variable_type as ArrayType;
                                if (array_type != null && array_type.fixed_length) {
                                        // local fixed length arrays are not nullable
                                } else {
@@ -218,7 +218,7 @@ public class Vala.LocalVariable : Variable {
 
                // current_symbol is a Method if this is the `result'
                // variable used for postconditions
-               var block = context.analyzer.current_symbol as Block;
+               unowned Block? block = context.analyzer.current_symbol as Block;
                if (block != null) {
                        block.add_local_variable (this);
                }
index d118fb50e7e40083aa8bdb639c7e5b0774b8ef54..4e288a210b8ea77a9d2b7c203f1be3b5a7f71cbb 100644 (file)
@@ -609,11 +609,11 @@ public class Vala.Method : Subroutine, Callable {
        private void find_base_class_method (Class cl) {
                var sym = cl.scope.lookup (name);
                if (sym is Signal) {
-                       var sig = (Signal) sym;
+                       unowned Signal sig = (Signal) sym;
                        sym = sig.default_handler;
                }
                if (sym is Method) {
-                       var base_method = (Method) sym;
+                       unowned Method base_method = (Method) sym;
                        if (base_method.is_abstract || base_method.is_virtual) {
                                string invalid_match;
                                if (!compatible (base_method, out invalid_match)) {
@@ -648,11 +648,11 @@ public class Vala.Method : Subroutine, Callable {
 
                                var sym = type.type_symbol.scope.lookup (name);
                                if (sym is Signal) {
-                                       var sig = (Signal) sym;
+                                       unowned Signal sig = (Signal) sym;
                                        sym = sig.default_handler;
                                }
                                if (sym is Method) {
-                                       var base_method = (Method) sym;
+                                       unowned Method base_method = (Method) sym;
                                        if (base_method.is_abstract || base_method.is_virtual) {
                                                if (base_interface_type == null) {
                                                        // check for existing explicit implementation
@@ -712,7 +712,7 @@ public class Vala.Method : Subroutine, Callable {
                }
 
                if (parent_symbol is Class && (is_abstract || is_virtual)) {
-                       var cl = (Class) parent_symbol;
+                       unowned Class cl = (Class) parent_symbol;
                        if (cl.is_compact && cl.base_class != null) {
                                error = true;
                                Report.error (source_reference, "Abstract and virtual methods may not be declared in derived compact classes");
@@ -728,7 +728,7 @@ public class Vala.Method : Subroutine, Callable {
 
                if (is_abstract) {
                        if (parent_symbol is Class) {
-                               var cl = (Class) parent_symbol;
+                               unowned Class cl = (Class) parent_symbol;
                                if (!cl.is_abstract) {
                                        error = true;
                                        Report.error (source_reference, "Abstract methods may not be declared in non-abstract classes");
@@ -843,16 +843,16 @@ public class Vala.Method : Subroutine, Callable {
 
                if (error_types != null) {
                        foreach (DataType error_type in error_types) {
-                       error_type.check (context);
+                               error_type.check (context);
 
-                       // check whether error type is at least as accessible as the method
-                       if (!context.analyzer.is_type_accessible (this, error_type)) {
-                               error = true;
-                               Report.error (source_reference, "error type `%s' is less accessible than method `%s'".printf (error_type.to_string (), get_full_name ()));
-                               return false;
+                               // check whether error type is at least as accessible as the method
+                               if (!context.analyzer.is_type_accessible (this, error_type)) {
+                                       error = true;
+                                       Report.error (source_reference, "error type `%s' is less accessible than method `%s'".printf (error_type.to_string (), get_full_name ()));
+                                       return false;
+                               }
                        }
                }
-               }
 
                if (result_var != null) {
                        result_var.check (context);
@@ -889,7 +889,7 @@ public class Vala.Method : Subroutine, Callable {
                }
 
                if (base_interface_type != null && base_interface_method != null && parent_symbol is Class) {
-                       var cl = (Class) parent_symbol;
+                       unowned Class cl = (Class) parent_symbol;
                        foreach (var m in cl.get_methods ()) {
                                if (m != this && m.base_interface_method == base_interface_method) {
                                        m.checked = true;
@@ -1080,7 +1080,7 @@ public class Vala.Method : Subroutine, Callable {
                        return false;
                }
 
-               var array_type = (ArrayType) param.variable_type;
+               unowned ArrayType array_type = (ArrayType) param.variable_type;
                if (array_type.element_type.type_symbol != context.analyzer.string_type.type_symbol) {
                        // parameter must be an array of strings
                        return false;
index 2ebef745171c6f77b356e427cf2ad24b74abc1c4..2fc5318709d3a39871f26773747e268a35f76235 100644 (file)
@@ -41,7 +41,7 @@ public class Vala.MethodType : CallableType {
        }
 
        public override bool compatible (DataType target_type) {
-               var dt = target_type as DelegateType;
+               unowned DelegateType? dt = target_type as DelegateType;
                if (dt == null) {
                        // method types incompatible to anything but delegates
                        return false;
index 9e688cf709f8f206c73c6494a4be1d059799186e..410f43afdb8df1cf59c64ebedc34c4a87cddca01 100644 (file)
@@ -220,7 +220,7 @@ public class Vala.ObjectCreationExpression : Expression {
                                symbol_reference = constructor;
 
                                // inner expression can also be base access when chaining constructors
-                               var ma = member_name.inner as MemberAccess;
+                               unowned MemberAccess? ma = member_name.inner as MemberAccess;
                                if (ma != null) {
                                        type_args = ma.get_type_arguments ();
                                }
index 97b56e16968b2c5d46645eb74ffdc148de94fa63..154fa3872adf4a64463e01049dac495e062f59d6 100644 (file)
@@ -55,7 +55,7 @@ public class Vala.ObjectType : ReferenceType {
        }
 
        public override bool stricter (DataType target_type) {
-               var obj_target_type = target_type as ObjectType;
+               unowned ObjectType? obj_target_type = target_type as ObjectType;
                if (obj_target_type == null) {
                        return false;
                }
@@ -72,7 +72,7 @@ public class Vala.ObjectType : ReferenceType {
        }
 
        public override bool is_invokable () {
-               var cl = type_symbol as Class;
+               unowned Class? cl = type_symbol as Class;
                if (cl != null && cl.default_construction_method != null) {
                        return true;
                } else {
@@ -81,7 +81,7 @@ public class Vala.ObjectType : ReferenceType {
        }
 
        public override unowned DataType? get_return_type () {
-               var cl = type_symbol as Class;
+               unowned Class? cl = type_symbol as Class;
                if (cl != null && cl.default_construction_method != null) {
                        return cl.default_construction_method.return_type;
                } else {
@@ -90,7 +90,7 @@ public class Vala.ObjectType : ReferenceType {
        }
 
        public override unowned List<Parameter>? get_parameters () {
-               var cl = type_symbol as Class;
+               unowned Class? cl = type_symbol as Class;
                if (cl != null && cl.default_construction_method != null) {
                        return cl.default_construction_method.get_parameters ();
                } else {
index 19e78a9940458fd88ddca36a0d556f5d56a3176e..978fec737ea40f6117c8f1a0cc693e75abec8cef 100644 (file)
@@ -197,9 +197,9 @@ public class Vala.Parameter : Variable {
                        }
                }
 
-               var m = parent_symbol as Method;
+               unowned Method? m = parent_symbol as Method;
                if (m != null) {
-                       Method base_method = m.base_method != null ? m.base_method : m.base_interface_method;
+                       unowned Method? base_method = m.base_method != null ? m.base_method : m.base_interface_method;
                        if (base_method != null && base_method != m) {
                                int index = m.get_parameters ().index_of (this);
                                if (index >= 0) {
index 754d50cb5e5e71cb037a2c592830d521aa292ed5..37d34ec81d56942567a5537241bfdaa6441c9c31 100644 (file)
@@ -779,7 +779,7 @@ public class Vala.Parser : CodeVisitor {
 
                if (init_list.size > 0 && inner is MemberAccess) {
                        // struct creation expression
-                       var member = (MemberAccess) inner;
+                       unowned MemberAccess member = (MemberAccess) inner;
                        member.creation_member = true;
 
                        var expr = new ObjectCreationExpression (member, src);
@@ -1000,8 +1000,8 @@ public class Vala.Parser : CodeVisitor {
 
                var expr = parse_expression ();
 
-               var call = expr as MethodCall;
-               var object_creation = expr as ObjectCreationExpression;
+               unowned MethodCall? call = expr as MethodCall;
+               unowned ObjectCreationExpression? object_creation = expr as ObjectCreationExpression;
                if (call == null && object_creation == null) {
                        Report.error (expr.source_reference, "syntax error, expected method call");
                        throw new ParseError.SYNTAX ("expected method call");
@@ -1054,7 +1054,7 @@ public class Vala.Parser : CodeVisitor {
                if (operator != UnaryOperator.NONE) {
                        next ();
                        var op = parse_unary_expression ();
-                       var lit = op as IntegerLiteral;
+                       unowned IntegerLiteral? lit = op as IntegerLiteral;
                        if (lit != null) {
                                if (operator == UnaryOperator.PLUS) {
                                        return lit;
@@ -1852,7 +1852,7 @@ public class Vala.Parser : CodeVisitor {
                var constant_type = parse_type (false, false);
 
                // constant arrays don't own their element
-               var array_type = constant_type as ArrayType;
+               unowned ArrayType? array_type = constant_type as ArrayType;
                if (array_type != null) {
                        array_type.element_type.value_owned = false;
                }
@@ -2623,7 +2623,7 @@ public class Vala.Parser : CodeVisitor {
                type = parse_inline_array_type (type);
 
                // constant arrays don't own their element
-               var array_type = type as ArrayType;
+               unowned ArrayType? array_type = type as ArrayType;
                if (array_type != null) {
                        array_type.element_type.value_owned = false;
                }
index ee2864fbd29000aca883184bfc13ed58af9ae5ff..2a26f92cbd128fef9970982b988727409dea677b 100644 (file)
@@ -55,7 +55,7 @@ public class Vala.PointerType : DataType {
 
        public override bool compatible (DataType target_type) {
                if (target_type is PointerType) {
-                       var tt = target_type as PointerType;
+                       unowned PointerType? tt = target_type as PointerType;
 
                        if (tt.base_type is VoidType || base_type is VoidType) {
                                return true;
@@ -96,7 +96,7 @@ public class Vala.PointerType : DataType {
        }
 
        public override Symbol? get_pointer_member (string member_name) {
-               Symbol base_symbol = base_type.type_symbol;
+               unowned Symbol? base_symbol = base_type.type_symbol;
 
                if (base_symbol == null) {
                        return null;
@@ -138,7 +138,7 @@ public class Vala.PointerType : DataType {
        }
 
        public override DataType? infer_type_argument (TypeParameter type_param, DataType value_type) {
-               var pointer_type = value_type as PointerType;
+               unowned PointerType? pointer_type = value_type as PointerType;
                if (pointer_type != null) {
                        return base_type.infer_type_argument (type_param, pointer_type.base_type);
                }
index 1dd6466255f6fe247db1b6a904b33956cc4b94a1..a7849235e8d3ba04b8d72c1429040ea0598058c8 100644 (file)
@@ -78,8 +78,8 @@ public class Vala.PostfixExpression : Expression {
 
        public override void get_defined_variables (Collection<Variable> collection) {
                inner.get_defined_variables (collection);
-               var local = inner.symbol_reference as LocalVariable;
-               var param = inner.symbol_reference as Parameter;
+               unowned LocalVariable? local = inner.symbol_reference as LocalVariable;
+               unowned Parameter? param = inner.symbol_reference as Parameter;
                if (local != null) {
                        collection.add (local);
                } else if (param != null && param.direction == ParameterDirection.OUT) {
@@ -117,7 +117,7 @@ public class Vala.PostfixExpression : Expression {
                }
 
                if (inner is MemberAccess) {
-                       var ma = (MemberAccess) inner;
+                       unowned MemberAccess ma = (MemberAccess) inner;
 
                        if (ma.prototype_access) {
                                error = true;
@@ -131,7 +131,7 @@ public class Vala.PostfixExpression : Expression {
                                return false;
                        }
                } else if (inner is ElementAccess) {
-                       var ea = (ElementAccess) inner;
+                       unowned ElementAccess ea = (ElementAccess) inner;
                        if (!(ea.container.value_type is ArrayType)) {
                                error = true;
                                Report.error (source_reference, "unsupported lvalue in postfix expression");
@@ -144,10 +144,10 @@ public class Vala.PostfixExpression : Expression {
                }
 
                if (inner is MemberAccess) {
-                       var ma = (MemberAccess) inner;
+                       unowned MemberAccess ma = (MemberAccess) inner;
 
                        if (ma.symbol_reference is Property) {
-                               var prop = (Property) ma.symbol_reference;
+                               unowned Property prop = (Property) ma.symbol_reference;
 
                                if (prop.set_accessor == null || !prop.set_accessor.writable) {
                                        ma.error = true;
index f9b4289979db1fcadb8ca15f54fc622729248522..3363c30f5667b54db53557c3baed59cef6014a6e 100644 (file)
@@ -124,8 +124,8 @@ public class Vala.ReferenceTransferExpression : Expression {
 
        public override void get_defined_variables (Collection<Variable> collection) {
                inner.get_defined_variables (collection);
-               var local = inner.symbol_reference as LocalVariable;
-               var param = inner.symbol_reference as Parameter;
+               unowned LocalVariable? local = inner.symbol_reference as LocalVariable;
+               unowned Parameter? param = inner.symbol_reference as Parameter;
                if (local != null) {
                        collection.add (local);
                } else if (param != null && param.direction == ParameterDirection.OUT) {
@@ -135,8 +135,8 @@ public class Vala.ReferenceTransferExpression : Expression {
 
        public override void get_used_variables (Collection<Variable> collection) {
                inner.get_used_variables (collection);
-               var local = inner.symbol_reference as LocalVariable;
-               var param = inner.symbol_reference as Parameter;
+               unowned LocalVariable? local = inner.symbol_reference as LocalVariable;
+               unowned Parameter? param = inner.symbol_reference as Parameter;
                if (local != null) {
                        collection.add (local);
                } else if (param != null && param.direction == ParameterDirection.OUT) {
index f51164968d69d81c99a22598674ab83afc49dfc6..026dd1f2884ecc6700c83b0758fb6574e1a592ec 100644 (file)
@@ -131,7 +131,7 @@ public class Vala.ReturnStatement : CodeNode, Statement {
                        return false;
                }
 
-               var local = return_expression.symbol_reference as LocalVariable;
+               unowned LocalVariable? local = return_expression.symbol_reference as LocalVariable;
                if (local != null && local.variable_type.is_disposable () &&
                    !context.analyzer.current_return_type.value_owned) {
                        error = true;
index 607b75ba76558d24ef94f91ed1ed013a2da5898f..66c7a89c2a63ef6f2ee7f8682e8acb10b30abb94 100644 (file)
@@ -128,7 +128,7 @@ public class Vala.Signal : Symbol, Callable {
                }
 
                if (is_generic) {
-                       var cl = (ObjectTypeSymbol) parent_symbol;
+                       unowned ObjectTypeSymbol cl = (ObjectTypeSymbol) parent_symbol;
                        foreach (var type_param in cl.get_type_parameters ()) {
                                generated_delegate.add_type_parameter (new TypeParameter (type_param.name, type_param.source_reference));
                        }
@@ -136,7 +136,7 @@ public class Vala.Signal : Symbol, Callable {
                        // parameter types must refer to the delegate type parameters
                        // instead of to the class type parameters
                        foreach (var param in generated_delegate.get_parameters ()) {
-                               var generic_type = param.variable_type as GenericType;
+                               unowned GenericType? generic_type = param.variable_type as GenericType;
                                if (generic_type != null) {
                                        generic_type.type_parameter = generated_delegate.get_type_parameters ().get (generated_delegate.get_type_parameter_index (generic_type.type_parameter.name));
                                }
@@ -182,7 +182,7 @@ public class Vala.Signal : Symbol, Callable {
                checked = true;
 
                // parent_symbol may be null for dynamic signals
-               var parent_cl = parent_symbol as Class;
+               unowned Class? parent_cl = parent_symbol as Class;
                if (parent_cl != null && parent_cl.is_compact) {
                        error = true;
                        Report.error (source_reference, "Signals are not supported in compact classes");
@@ -235,7 +235,7 @@ public class Vala.Signal : Symbol, Callable {
                                default_handler.add_parameter (param);
                        }
 
-                       var cl = parent_symbol as ObjectTypeSymbol;
+                       unowned ObjectTypeSymbol? cl = parent_symbol as ObjectTypeSymbol;
 
                        cl.add_hidden_method (default_handler);
                        default_handler.check (context);
@@ -262,7 +262,7 @@ public class Vala.Signal : Symbol, Callable {
                        }
                        emitter.body = body;
 
-                       var cl = parent_symbol as ObjectTypeSymbol;
+                       unowned ObjectTypeSymbol? cl = parent_symbol as ObjectTypeSymbol;
 
                        cl.add_hidden_method (emitter);
                        emitter.check (context);
index 5637330315f0c63a096b42ec6511c25b8f449c58..bb280c339ec6dfc951d8804fa02e6da2bc17e8d5 100644 (file)
@@ -115,7 +115,7 @@ public class Vala.SliceExpression : Expression {
                }
 
                if (container.value_type is ArrayType) {
-                       var array_type = (ArrayType) container.value_type;
+                       unowned ArrayType array_type = (ArrayType) container.value_type;
                        start.target_type = array_type.length_type.copy ();
                        stop.target_type = array_type.length_type.copy ();
                }
index d1995576c5d578c053810444af1d1edaa9fe7350..4aa931aebbcb372f56e6c16b27bbdf0f47612f7c 100644 (file)
@@ -98,12 +98,12 @@ public class Vala.StringLiteral : Literal {
        }
 
        public static StringLiteral? get_format_literal (Expression expr) {
-               var format_literal = expr as StringLiteral;
+               unowned StringLiteral? format_literal = expr as StringLiteral;
                if (format_literal != null) {
                        return format_literal;
                }
 
-               var call = expr as MethodCall;
+               unowned MethodCall? call = expr as MethodCall;
                if (call != null) {
                        return call.get_format_literal ();
                }
index b777c4c12fbf2bccb14a63009b3769ecaf90eb5c..f8b725fd86a51376416bc9f3528997af2dafed14 100644 (file)
@@ -332,7 +332,7 @@ public class Vala.Struct : TypeSymbol {
         * @return true if this is a boolean type, false otherwise
         */
        public bool is_boolean_type () {
-               var st = base_struct;
+               unowned Struct? st = base_struct;
                if (st != null && st.is_boolean_type ()) {
                        return true;
                }
@@ -348,7 +348,7 @@ public class Vala.Struct : TypeSymbol {
         * @return true if this is an integer type, false otherwise
         */
        public bool is_integer_type () {
-               var st = base_struct;
+               unowned Struct? st = base_struct;
                if (st != null && st.is_integer_type ()) {
                        return true;
                }
@@ -364,7 +364,7 @@ public class Vala.Struct : TypeSymbol {
         * @return true if this is a floating point type, false otherwise
         */
        public bool is_floating_type () {
-               var st = base_struct;
+               unowned Struct? st = base_struct;
                if (st != null && st.is_floating_type ()) {
                        return true;
                }
@@ -375,7 +375,7 @@ public class Vala.Struct : TypeSymbol {
        }
 
        public bool is_decimal_floating_type () {
-               var st = base_struct;
+               unowned Struct? st = base_struct;
                if (st != null && st.is_decimal_floating_type ()) {
                        return true;
                }
@@ -403,7 +403,7 @@ public class Vala.Struct : TypeSymbol {
         * instances are passed by value.
         */
        public bool is_simple_type () {
-               var st = base_struct;
+               unowned Struct? st = base_struct;
                if (st != null && st.is_simple_type ()) {
                        return true;
                }
@@ -459,9 +459,9 @@ public class Vala.Struct : TypeSymbol {
        }
 
        bool is_recursive_value_type (DataType type) {
-               var struct_type = type as StructValueType;
+               unowned StructValueType? struct_type = type as StructValueType;
                if (struct_type != null && !struct_type.nullable) {
-                       var st = (Struct) struct_type.type_symbol;
+                       unowned Struct st = (Struct) struct_type.type_symbol;
                        if (st == this) {
                                return true;
                        }
index 1413b5d3289e681314f08c1bb0ca60ac0f275590..bdd20f3cd9ff52c3fdebfaefee0536879efaf4e4 100644 (file)
@@ -31,7 +31,7 @@ public class Vala.StructValueType : ValueType {
        }
 
        public override bool is_invokable () {
-               var st = type_symbol as Struct;
+               unowned Struct? st = type_symbol as Struct;
                if (st != null && st.default_construction_method != null) {
                        return true;
                } else {
@@ -40,7 +40,7 @@ public class Vala.StructValueType : ValueType {
        }
 
        public override unowned DataType? get_return_type () {
-               var st = type_symbol as Struct;
+               unowned Struct? st = type_symbol as Struct;
                if (st != null && st.default_construction_method != null) {
                        return st.default_construction_method.return_type;
                } else {
@@ -49,7 +49,7 @@ public class Vala.StructValueType : ValueType {
        }
 
        public override unowned List<Parameter>? get_parameters () {
-               var st = type_symbol as Struct;
+               unowned Struct? st = type_symbol as Struct;
                if (st != null && st.default_construction_method != null) {
                        return st.default_construction_method.get_parameters ();
                } else {
index bb36b54bee2f8b5b5ee2131c131994e16bdd1996..dbe9b1f218dd7c1c9e50c0c02dda10ad0ee22907 100644 (file)
@@ -402,7 +402,7 @@ public class Vala.SymbolResolver : CodeVisitor {
                        if (sym is Delegate) {
                                type = new DelegateType ((Delegate) sym);
                        } else if (sym is Class) {
-                               var cl = (Class) sym;
+                               unowned Class cl = (Class) sym;
                                if (cl.is_error_base) {
                                        type = new ErrorType (null, null, unresolved_type.source_reference);
                                } else {
index af4ede95d5acc94502c2a710d926a49fef6c8c08..4e2b50b906faac641c13dd54bd5e6738cc5d79ef 100644 (file)
@@ -87,7 +87,7 @@ public class Vala.UnaryExpression : Expression {
                }
 
                if (operator == UnaryOperator.REF || operator == UnaryOperator.OUT) {
-                       var field = inner.symbol_reference as Field;
+                       unowned Field? field = inner.symbol_reference as Field;
                        if (field != null && field.binding == MemberBinding.STATIC) {
                                return true;
                        } else {
@@ -111,20 +111,20 @@ public class Vala.UnaryExpression : Expression {
        }
 
        bool is_numeric_type (DataType type) {
-               if (type.nullable || !(type.type_symbol is Struct)) {
+               unowned Struct? st = type.type_symbol as Struct;
+               if (type.nullable || st == null) {
                        return false;
                }
 
-               var st = (Struct) type.type_symbol;
                return st.is_integer_type () || st.is_floating_type ();
        }
 
        bool is_integer_type (DataType type) {
-               if (type.nullable || !(type.type_symbol is Struct)) {
+               unowned Struct? st = type.type_symbol as Struct;
+               if (type.nullable || st == null) {
                        return false;
                }
 
-               var st = (Struct) type.type_symbol;
                return st.is_integer_type ();
        }
 
@@ -219,7 +219,7 @@ public class Vala.UnaryExpression : Expression {
                        assignment.check (context);
                        return true;
                } else if (operator == UnaryOperator.REF || operator == UnaryOperator.OUT) {
-                       var ea = inner as ElementAccess;
+                       unowned ElementAccess? ea = inner as ElementAccess;
                        if (inner.symbol_reference is Field || inner.symbol_reference is Parameter || inner.symbol_reference is LocalVariable ||
                            (ea != null && ea.container.value_type is ArrayType)) {
                                // ref and out can only be used with fields, parameters, local variables, and array element access
@@ -252,8 +252,8 @@ public class Vala.UnaryExpression : Expression {
        public override void get_defined_variables (Collection<Variable> collection) {
                inner.get_defined_variables (collection);
                if (operator == UnaryOperator.OUT || operator == UnaryOperator.REF) {
-                       var local = inner.symbol_reference as LocalVariable;
-                       var param = inner.symbol_reference as Parameter;
+                       unowned LocalVariable? local = inner.symbol_reference as LocalVariable;
+                       unowned Parameter? param = inner.symbol_reference as Parameter;
                        if (local != null) {
                                collection.add (local);
                        }
index 40b4371591dcebc6ffdbf7d5f1309fc196fe38c7..5e4791d44bc51bb5665f056579ed5272db24d120 100644 (file)
@@ -40,7 +40,7 @@ public class Vala.UnresolvedSymbol : Symbol {
        }
 
        public static UnresolvedSymbol? new_from_expression (Expression expr) {
-               var ma = expr as MemberAccess;
+               unowned MemberAccess? ma = expr as MemberAccess;
                if (ma != null) {
                        if (ma.inner != null) {
                                return new UnresolvedSymbol (new_from_expression (ma.inner), ma.member_name, ma.source_reference);
index a15b1abe8947991e260fdd494a576ce6a0dcd8b6..b91867817fc999afc2cddf839a1038812c5671c1 100644 (file)
@@ -82,12 +82,12 @@ public class Vala.WhileStatement : CodeNode, Statement {
        }
 
        bool always_true (Expression condition) {
-               var literal = condition as BooleanLiteral;
+               unowned BooleanLiteral? literal = condition as BooleanLiteral;
                return (literal != null && literal.value);
        }
 
        bool always_false (Expression condition) {
-               var literal = condition as BooleanLiteral;
+               unowned BooleanLiteral? literal = condition as BooleanLiteral;
                return (literal != null && !literal.value);
        }
 
@@ -121,7 +121,7 @@ public class Vala.WhileStatement : CodeNode, Statement {
 
                var loop = new Loop (body, source_reference);
 
-               var parent_block = (Block) parent_node;
+               unowned Block parent_block = (Block) parent_node;
                parent_block.replace_statement (this, loop);
 
                if (!loop.check (context)) {