You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SR-11647 Swift 5.1 on Linux: Regression in OperationQueue concurrency
Issue Description:
Example background:
CGColor.init(red:green:blue:alpha🙂 is not available on tvOS
CGColor.init(srgbRed:green:blue:alpha) is `@available(tvOS 13, *)`
Example:
importCoreGraphicspublicextensionColor {
@available(tvOS13, watchOS13, *)
varcgColor : CGColor {
if #available(OSX10.15, iOS13, *) {
returnCGColor(srgbRed: CGFloat(r),
green: CGFloat(g),
blue: CGFloat(b),
alpha: CGFloat(a))
} else {
// ERROR: CGColor.init(red:...) is not available on tvOS.returnCGColor(red: CGFloat(r),
green: CGFloat(g),
blue: CGFloat(b),
alpha: CGFloat(a))
}
}
}
}
Compiling for the tvOS simulator, Xcode 11.2.1 (11B500)
The compiler complains about the unavailable initialiser in the "else" branch of the OSX/iOS conditional and won't compile this code. Despite the fact that the #available condition will always be true for tvOS, so it will never hit that "else" branch.
There is a workaround, which is to wrap the initialiser (still in the "else" branch) with:
#if !os(tvOS)
returnCGColor(...)
#endif
Which is also strange, because now we're not returning anything on the "else" branch, but the compiler seems satisfied that it's dead and doesn't complain. If it knows that, it could also allow the use of the unavailable initialiser.
The text was updated successfully, but these errors were encountered:
The compiler complains about the unavailable initialiser in the "else" branch of the OSX/iOS conditional and won't compile this code. Despite the fact that the #available condition will always be true for tvOS, so it will never hit that "else" branch.
The program should type-check regardless of whether some conditions are statically known to be true or false. So this behavior is ok IMO.
There is a workaround, which is to wrap the initialiser (still in the "else" branch) with: [..]
which is also strange, because now we're not returning anything on the "else" branch, but the compiler seems satisfied that it's dead and doesn't complain.
Hmm, that shouldn't be happening if you compile for tvOS. To me, this seems like the buggy behavior.
Additional Detail from JIRA
md5: aa265d1621de94b205e34a88cfbf1b9e
relates to:
Issue Description:
Example background:
CGColor.init(red:green:blue:alpha🙂 is not available on tvOS
CGColor.init(srgbRed:green:blue:alpha) is `@available(tvOS 13, *)`
Example:
Compiling for the tvOS simulator, Xcode 11.2.1 (11B500)
The compiler complains about the unavailable initialiser in the "else" branch of the OSX/iOS conditional and won't compile this code. Despite the fact that the #available condition will always be true for tvOS, so it will never hit that "else" branch.
There is a workaround, which is to wrap the initialiser (still in the "else" branch) with:
Which is also strange, because now we're not returning anything on the "else" branch, but the compiler seems satisfied that it's dead and doesn't complain. If it knows that, it could also allow the use of the unavailable initialiser.
The text was updated successfully, but these errors were encountered: