Skip to content

Commit 9049eb1

Browse files
author
ematejska
authored
Merge pull request #11168 from DougGregor/nscolor-literal-extended-srgb-4.0
[4.0] [AppKit overlay] Use NSColor(red:green:blue:alpha:) for color literals.
2 parents 1293360 + 38a7815 commit 9049eb1

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

stdlib/public/SDK/AppKit/AppKit.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ extension NSColor : _ExpressibleByColorLiteral {
8181
@nonobjc
8282
public required convenience init(_colorLiteralRed red: Float, green: Float,
8383
blue: Float, alpha: Float) {
84-
self.init(srgbRed: CGFloat(red), green: CGFloat(green),
84+
self.init(red: CGFloat(red), green: CGFloat(green),
8585
blue: CGFloat(blue), alpha: CGFloat(alpha))
8686
}
8787
}

test/stdlib/AppKit_Swift4.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,15 @@ AppKitTests.test("NSRectFills") {
9494
expectEqual(bitmapImage.colorAt(x: 2, y: 2), blue)
9595
}
9696

97+
AppKitTests.test("NSColor.Literals") {
98+
if #available(macOS 10.12, *) {
99+
// Color literal in the extended sRGB color space.
100+
let c1 = #colorLiteral(red: 1.358, green: -0.074, blue: -0.012, alpha: 1.0)
101+
102+
var printedC1 = ""
103+
print(c1, to: &printedC1)
104+
expectTrue(printedC1.contains("extended"))
105+
}
106+
}
107+
97108
runAllTests()

0 commit comments

Comments
 (0)