Skip to content

4.0.0 - Fixed a breaking bug with @Lazy

Compare
Choose a tag to compare
@KyNorthstar KyNorthstar released this 02 Aug 05:57
· 5 commits to master since this release
6981fb1

Thanks to Gabe Shahbazian for reporting this bug. This seems to have been a symptom of a lower-level bug in Swift <5.3, where it would not properly wrap @autoclosure arguments for property wrappers. Sadly, the only "fix" I could find was to prevent the @Lazy property wrapper from being used in Swift <5.3. If you need to use Swift 5.2 or earlier, you can still use the old style:

// In Swift 5.2.x and earlier
let expensive = Lazy<Expensive> { ExpenseFactory.next() }

// In Swift 5.3 and newer
@Lazy
var expensive = ExpenseFactory.next()

Because this causes anyone using @Lazy property wrappers in Swift <5.3 to see compiler errors where there were none previously, this is a Major version increment.