From a1c5a0b52836337d31bc3d2220daf7fedc64c769 Mon Sep 17 00:00:00 2001 From: Max Moiseev Date: Fri, 13 Jan 2017 10:40:28 -0800 Subject: [PATCH] Deprecating M_SQRT2 and M_SQRT1_2 Now that square root is being propoerly inlined and optimized away, it is safe to deprecate these two constants in favor of a Swiftier API. Fixes: --- stdlib/public/Platform/Darwin.swift | 6 ++++++ stdlib/public/Platform/Glibc.swift | 6 ++++++ test/MathConstants.swift | 3 +++ 3 files changed, 15 insertions(+) diff --git a/stdlib/public/Platform/Darwin.swift b/stdlib/public/Platform/Darwin.swift index f23a6c5c6084a..070f65170f557 100644 --- a/stdlib/public/Platform/Darwin.swift +++ b/stdlib/public/Platform/Darwin.swift @@ -23,3 +23,9 @@ public let M_PI_2 = Double.pi / 2 @available(swift, deprecated: 3.0, message: "Please use 'Double.pi / 4' or '.pi / 4' to get the value of correct type and avoid casting.") public let M_PI_4 = Double.pi / 4 + +@available(swift, deprecated: 3.0, message: "Please use '2.squareRoot()'.") +public let M_SQRT2 = 2.squareRoot() + +@available(swift, deprecated: 3.0, message: "Please use '0.5.squareRoot()'.") +public let M_SQRT1_2 = 0.5.squareRoot() diff --git a/stdlib/public/Platform/Glibc.swift b/stdlib/public/Platform/Glibc.swift index 8f34fe8d9f323..e25556bd7ccde 100644 --- a/stdlib/public/Platform/Glibc.swift +++ b/stdlib/public/Platform/Glibc.swift @@ -23,3 +23,9 @@ public let M_PI_2 = Double.pi / 2 @available(swift, deprecated: 3.0, message: "Please use '.pi / 4' to get the value of correct type and avoid casting.") public let M_PI_4 = Double.pi / 4 + +@available(swift, deprecated: 3.0, message: "Please use '2.squareRoot()'.") +public let M_SQRT2 = 2.squareRoot() + +@available(swift, deprecated: 3.0, message: "Please use '0.5.squareRoot()'.") +public let M_SQRT1_2 = 0.5.squareRoot() diff --git a/test/MathConstants.swift b/test/MathConstants.swift index cc7abb1fba3bc..fd3c3a0a6c533 100644 --- a/test/MathConstants.swift +++ b/test/MathConstants.swift @@ -9,3 +9,6 @@ import Glibc _ = M_PI // expected-warning {{is deprecated}} _ = M_PI_2 // expected-warning {{is deprecated}} _ = M_PI_4 // expected-warning {{is deprecated}} + +_ = M_SQRT2 // expected-warning {{is deprecated}} +_ = M_SQRT1_2 // expected-warning {{is deprecated}}