Commit Graph

155 Commits

Author SHA1 Message Date
Doug Gregor
fc00bf6076 Parsing and semantic analysis for delegating initializers.
Swift SVN r11921
2014-01-06 16:33:08 +00:00
Doug Gregor
f51542a40e Implement basic support for downcasting from DynamicLookup via postfix '!'.
An expression of DynamicLookup type can be unconditionally downcast to
any class type via the postfix '!'. This will allow one to replace

  var w : NSWindow = (nsarray[0] as NSWindow)!

with

  var w : NSWindow = nsarray[0]!

The current implementation is fairly limited: it only works when the
operand of '!' is an rvalue of type DynamicLookup, and we don't ensure
that the result is a class type. Nonetheless, it cleans up some of
ListMaker nicely.

This is the first client of disjunction constraints, which were added
in r9142.



Swift SVN r9151
2013-10-10 18:16:55 +00:00
Doug Gregor
c10b1cef65 Allow trailing closures without pipes wherever we don't expect curly braces.
This moves trailing closures from expr-postfix up to the level of
expr, and introduces an intermediate level (expr-basic) for places
that need to parse expressions followed by curly braces, such as
if/while/switch/for. Trailing closures are still restricted to occur
after expr-postfix, although the parser itself parses a slightly more
general and then complains if it got more than an expr-postfix.


Swift SVN r5256
2013-05-21 22:30:25 +00:00
Doug Gregor
ca27f8e2ea ... and the compiler accepted it ;)
Swift SVN r5211
2013-05-17 21:00:24 +00:00
Doug Gregor
4d60bb7173 Implement trailing closure syntax.
Trailing closure syntax allows one to write a closure following any
other postfix expression, which passes the closure to that postfix
expression as an arguments. For example:

        sort(fruits) { |lhs, rhs|
          print("Comparing \(lhs) to \(rhs)\n")
          return lhs > rhs
        }

As a temporary limitation to work around the ambiguity with

  if foo { ... } { ... }

we require trailing closures to have an explicit parameter list, e.g.,

  if foo { || ... } { ... }



Swift SVN r5210
2013-05-17 19:16:18 +00:00