Skip to content

Commit 94f49d4

Browse files
committed
CGFloat: add CGFloat.init(CGFloat), which makes CGFloat similar to Float and Double
This is an API bugfix, this API was accidentally omitted when we added CGFloat to the overlay, so no evolution proposal is necessary.
1 parent 60ba432 commit 94f49d4

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

stdlib/public/SDK/CoreGraphics/CGFloat.swift.gyb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ public struct CGFloat {
4646
self.native = NativeType(value)
4747
}
4848

49+
@_transparent
50+
public init(_ value: CGFloat) {
51+
self = value
52+
}
53+
4954
/// The native value.
5055
public var native: NativeType
5156
}

test/Interpreter/SDK/CoreGraphics_CGFloat.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ CGFloatTestSuite.test("init") {
2121
expectEqual(0.0, CGFloat())
2222
expectEqual(4.125, CGFloat(Float(4.125)))
2323
expectEqual(4.125, CGFloat(Double(4.125)))
24+
expectEqual(4.125, CGFloat(CGFloat(Double(4.125))))
2425

2526
expectEqual(42, CGFloat(Int(42)))
2627
expectEqual(42, CGFloat(Int8(42)))

0 commit comments

Comments
 (0)