Merge pull request #18468 from lorentey/deprecated_simulator_macro-4.2

[4.2][stdlib]Remove deprecated TARGET_IPHONE_SIMULATOR reference
diff --git a/stdlib/public/SDK/Foundation/Data.swift b/stdlib/public/SDK/Foundation/Data.swift
index 1aa7a8f..ce63ade 100644
--- a/stdlib/public/SDK/Foundation/Data.swift
+++ b/stdlib/public/SDK/Foundation/Data.swift
@@ -1249,11 +1249,22 @@
         self.init(backing: backing, range: 0..<backing._length)
     }
     
+    @available(swift, introduced: 4.2)
     @inlinable
     public init<S: Sequence>(bytes elements: S) where S.Iterator.Element == UInt8 {
         self.init(elements)
     }
 
+    @available(swift, obsoleted: 4.2)
+    public init(bytes: Array<UInt8>) {
+       self.init(bytes)
+    }
+    
+    @available(swift, obsoleted: 4.2)
+    public init(bytes: ArraySlice<UInt8>) {
+       self.init(bytes)
+    }
+
     @usableFromInline
     internal init(backing: _DataStorage, range: Range<Index>) {
         _backing = backing
diff --git a/test/stdlib/TestData_Swift4.swift b/test/stdlib/TestData_Swift4.swift
new file mode 100644
index 0000000..e2cbf8e
--- /dev/null
+++ b/test/stdlib/TestData_Swift4.swift
@@ -0,0 +1,36 @@
+
+// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
+// Licensed under Apache License v2.0 with Runtime Library Exception
+//
+// See https://swift.org/LICENSE.txt for license information
+// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
+//
+//===----------------------------------------------------------------------===//
+//
+// RUN: %empty-directory(%t)
+// RUN: %target-build-swift -swift-version 4 %s -o %t/TestData_Swift4
+// RUN: %target-run %t/TestData_Swift4
+// REQUIRES: executable_test
+// REQUIRES: objc_interop
+
+import Foundation
+import StdlibUnittest
+
+var DataTests = TestSuite("TestDataSwift4")
+
+DataTests.test("functional map init usage") {
+	let res1 = [[UInt8(0), UInt8(1), UInt8(2)]].map(Data.init) // previously this could be done without being ambiguous (however in swift 4.2 an overload was added that makes it ambiguous as a function ref)
+	// the following two strategies are preferred to the previous version
+	let res2 = [[UInt8(0), UInt8(1), UInt8(2)]].map(Data.init(_:))
+	let res3 = [[UInt8(0), UInt8(1), UInt8(2)]].map { Data($0) }
+
+	expectEqual(res1.count, 1)
+	expectEqual(res2.count, 1)
+	expectEqual(res3.count, 1)
+
+	expectEqual(res1[0], res2[0])
+	expectEqual(res2[0], res3[0])
+}
+
+
+runAllTests()
\ No newline at end of file