Commit Graph

8 Commits

Author SHA1 Message Date
Joe Groff
a4fa786a6f Handle a parameter to property behaviors.
For prototyping purposes, we only support a single trailing closure parameter to begin with.
2016-03-01 11:51:25 -08:00
Michael Gottesman
8eed9f15b8 Disable two interpreter tests that fail when run with optimizations until they are looked at.
rdar://24874073
2016-02-27 02:35:17 -08:00
Joe Groff
48b643c6af Property behaviors: Iterate prototype syntax to try a postfix form.
If behaviors are specified after the declaration, something like this:

  ```swift
  var x: Int __behavior foo // __behavior is a stand-in keyword
  ```

we're thinking this encourages a simpler design for smaller, more composable behaviors. If we think of behavior application as function-like, then parameters to the behavior could be passed with function-like syntax:

  ```swift
  __behavior lazy(@autoclosure initialValue: () -> Value) { ... }

  var x: Int __behavior lazy(1738)

  __behavior didSet(body: (oldValue: Value) -> Void) { ... }

  var x: Int __behavior didSet {
    trailingClosure()
  }
  ```

Since behaviors are implementation details, they arguably belong to the right of the declaration as well.
2016-02-25 15:49:27 -08:00
Joe Groff
e99961eb8f AST: Fix Substitution::subst to substitute associated types from conformance witnesses instead of by name.
Fixes a crash when property behavior uses are run through the specializer, since they set up associated type conformances that are not recoverable by name lookup.
2016-02-22 15:31:14 -08:00
Joe Groff
f21a1093f9 Disable test/Interpreter/property_behavior.swift optimized execution tests.
The specializer needs to be updated to resolve associated types by protocol conformance witness rather than name lookup.
2016-02-22 13:21:37 -08:00
Joe Groff
c6bfac7281 Handle initial value requirements in property behaviors.
If a behavior protocol requires an `initialValue` static property, satisfy the requirement using the initial value expression from the property declaration. This lets us implement `lazy` as a property behavior.
2016-02-22 08:43:17 -08:00
Joe Groff
d4fdc1e7a8 Conditionally enable behaviors by a frontend flag.
Since the feature is incomplete and yet to be accepted or implemented as proposed, hide it behind an -enable-experimental-property-behaviors frontend flag.
2016-02-20 15:01:06 -08:00
Joe Groff
89a0578eae Add an interpreter test for "delayed" property behavior.
We have enough implementation to do "delayed" now.
2016-02-20 15:01:06 -08:00