]> git.ipfire.org Git - thirdparty/vala.git/commit
Add support for "with" statement 35f72f3ecdf0d61d0e67cd4f72c29fee2c3c9a55
authorNick Schrader <nick.schrader@mailbox.org>
Fri, 27 Mar 2020 16:12:09 +0000 (13:12 -0300)
committerRico Tzschichholz <ricotz@ubuntu.com>
Tue, 2 Jun 2020 11:02:42 +0000 (13:02 +0200)
commit35f72f3ecdf0d61d0e67cd4f72c29fee2c3c9a55
tree07beb54a046a765a3e19ed2ad138dc166e74a5e9
parented320c6260bfa369f64f41450bc48fd5b664809a
Add support for "with" statement

Creates data type scoped blocks which allow implicit member access to
the given expression or declaration statement.

with (expr) {
    ...;
}

Within the with-block the expression's members can be directly accessed
without the member access operator.
Members may hide local, class and instance varibales with the same name.
Instance variables are still accessible through this.
A local variable can be directly declared in the with statement header.
Hidden local and class variables are currently not directly accessible
(using this for class members generates the expected warning).

Fixes https://gitlab.gnome.org/GNOME/vala/issues/327
41 files changed:
tests/Makefile.am
tests/nullability/with-non-null.test [new file with mode: 0644]
tests/objects/with-expression.vala [new file with mode: 0644]
tests/objects/with-instance.vala [new file with mode: 0644]
tests/objects/with-nested.vala [new file with mode: 0644]
tests/parser/with-embedded.vala [new file with mode: 0644]
tests/parser/with-empty.vala [new file with mode: 0644]
tests/parser/with-invalid-declaration.test [new file with mode: 0644]
tests/parser/with-invalid-expression.test [new file with mode: 0644]
tests/parser/with-no-block.test [new file with mode: 0644]
tests/parser/with-no-expression.test [new file with mode: 0644]
tests/semantic/with-array.test [new file with mode: 0644]
tests/semantic/with-buildin.vala [new file with mode: 0644]
tests/semantic/with-class.test [new file with mode: 0644]
tests/semantic/with-compact.vala [new file with mode: 0644]
tests/semantic/with-declaration-cast-type.vala [new file with mode: 0644]
tests/semantic/with-declaration-wrong-type.test [new file with mode: 0644]
tests/semantic/with-declaration.vala [new file with mode: 0644]
tests/semantic/with-dereferenced-pointer.vala [new file with mode: 0644]
tests/semantic/with-enum-member.vala [new file with mode: 0644]
tests/semantic/with-enum.test [new file with mode: 0644]
tests/semantic/with-error-member.test [new file with mode: 0644]
tests/semantic/with-error.test [new file with mode: 0644]
tests/semantic/with-namespace.test [new file with mode: 0644]
tests/semantic/with-no-declaration.test [new file with mode: 0644]
tests/semantic/with-no-such-member.test [new file with mode: 0644]
tests/semantic/with-null.vala [new file with mode: 0644]
tests/semantic/with-outside-declaration.test [new file with mode: 0644]
tests/semantic/with-pointer.test [new file with mode: 0644]
tests/semantic/with-string.vala [new file with mode: 0644]
tests/semantic/with-value.vala [new file with mode: 0644]
vala/Makefile.am
vala/valacodevisitor.vala
vala/valacodewriter.vala
vala/valaflowanalyzer.vala
vala/valamemberaccess.vala
vala/valaparser.vala
vala/valascanner.vala
vala/valasymbolresolver.vala
vala/valatokentype.vala
vala/valawithstatement.vala [new file with mode: 0644]