From 292c9469e88b9a8401d68348103267dea4773ddd Mon Sep 17 00:00:00 2001 From: Drew Maxwell Date: Fri, 16 Sep 2022 15:11:10 -0700 Subject: [PATCH 1/2] Updating Swift tests to remove outdated tests and use more current calls. (cherry picked from commit 7825221cd4ced1af71453fdbb64142a8321750a5) --- test/Interpreter/SDK/FoundationDiagnostics.swift | 10 ---------- test/Interpreter/SDK/Foundation_NSRect.swift | 4 +++- test/Interpreter/SDK/Quartz_without_Foundation.swift | 10 ---------- test/Interpreter/SDK/objc_implicit_inner_pointer.swift | 4 ++++ test/Interpreter/SDK/objc_inner_pointer.swift | 2 ++ test/Interpreter/SDK/objc_unowned.swift | 2 ++ test/stdlib/NSStringAPI.swift | 7 ++++--- .../compiler_crashers_2_fixed/rdar81590807.swift | 1 + 8 files changed, 16 insertions(+), 24 deletions(-) delete mode 100644 test/Interpreter/SDK/FoundationDiagnostics.swift delete mode 100644 test/Interpreter/SDK/Quartz_without_Foundation.swift diff --git a/test/Interpreter/SDK/FoundationDiagnostics.swift b/test/Interpreter/SDK/FoundationDiagnostics.swift deleted file mode 100644 index fbfc17f862cc8..0000000000000 --- a/test/Interpreter/SDK/FoundationDiagnostics.swift +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: %target-swift-frontend %s -typecheck -verify - -// REQUIRES: objc_interop - -import Foundation - -func encode(_ string: String) { - _ = string.cString(using: NSUTF8StringEncoding) // expected-error {{'NSUTF8StringEncoding' has been renamed to 'String.Encoding.utf8'}} {{29-49=String.Encoding.utf8}} - let _: NSStringEncoding? = nil // expected-error {{'NSStringEncoding' has been renamed to 'String.Encoding'}} {{10-26=String.Encoding}} -} diff --git a/test/Interpreter/SDK/Foundation_NSRect.swift b/test/Interpreter/SDK/Foundation_NSRect.swift index fbea20b257399..09be484477c02 100644 --- a/test/Interpreter/SDK/Foundation_NSRect.swift +++ b/test/Interpreter/SDK/Foundation_NSRect.swift @@ -4,7 +4,9 @@ // iOS doesn't have NSRect. iOS and OS X CGRect is tested elsewhere. // REQUIRES: OS=macosx -import Foundation +import Coreimage + +_ = JSONDecoder() func printRect(_ r: NSRect) { // FIXME: Constraint checker takes too long to typecheck this as an diff --git a/test/Interpreter/SDK/Quartz_without_Foundation.swift b/test/Interpreter/SDK/Quartz_without_Foundation.swift deleted file mode 100644 index 446ae40163355..0000000000000 --- a/test/Interpreter/SDK/Quartz_without_Foundation.swift +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: %target-run-simple-swift | %FileCheck %s -// REQUIRES: executable_test -// REQUIRES: OS=macosx - -import QuartzCore -// Do NOT add anything that publicly imports Foundation here! - -var v = CIVector(x:7); -// CHECK: x = 7 -print("x = \(v.x)") diff --git a/test/Interpreter/SDK/objc_implicit_inner_pointer.swift b/test/Interpreter/SDK/objc_implicit_inner_pointer.swift index 77d2c7de236ff..a2227a213537c 100644 --- a/test/Interpreter/SDK/objc_implicit_inner_pointer.swift +++ b/test/Interpreter/SDK/objc_implicit_inner_pointer.swift @@ -7,6 +7,10 @@ // REQUIRES: executable_test // REQUIRES: objc_interop +import Foundation + +_ = JSONDecoder() + do { // The lifetime of Foo() currently gets extended using autorelease. autoreleasepool { diff --git a/test/Interpreter/SDK/objc_inner_pointer.swift b/test/Interpreter/SDK/objc_inner_pointer.swift index 44f893b3fecf6..710404075ac0d 100644 --- a/test/Interpreter/SDK/objc_inner_pointer.swift +++ b/test/Interpreter/SDK/objc_inner_pointer.swift @@ -4,6 +4,8 @@ // REQUIRES: objc_interop import Foundation + +_ = JSONDecoder() class Canary: NSObject { deinit { diff --git a/test/Interpreter/SDK/objc_unowned.swift b/test/Interpreter/SDK/objc_unowned.swift index fc75dc0ca0b3b..cd862541d9500 100644 --- a/test/Interpreter/SDK/objc_unowned.swift +++ b/test/Interpreter/SDK/objc_unowned.swift @@ -5,6 +5,8 @@ import Foundation +_ = JSONDecoder() + let x = NSObject() unowned let y = x diff --git a/test/stdlib/NSStringAPI.swift b/test/stdlib/NSStringAPI.swift index a1cdc280f6592..c29ca48ce2269 100644 --- a/test/stdlib/NSStringAPI.swift +++ b/test/stdlib/NSStringAPI.swift @@ -210,9 +210,10 @@ NSStringAPIs.test("init(contentsOf:usedEncoding:error:)") { } NSStringAPIs.test("init(cString_:encoding:)") { - expectEqual("foo, a basmati bar!", - String(cString: - "foo, a basmati bar!", encoding: String.defaultCStringEncoding)) + "foo, a basmati bar!".withCString { + expectEqual("foo, a basmati bar!", + String(cString: $0, encoding: String.defaultCStringEncoding)) + } } NSStringAPIs.test("init(utf8String:)") { diff --git a/validation-test/compiler_crashers_2_fixed/rdar81590807.swift b/validation-test/compiler_crashers_2_fixed/rdar81590807.swift index 2d82ccc13825c..46170c5e94aae 100644 --- a/validation-test/compiler_crashers_2_fixed/rdar81590807.swift +++ b/validation-test/compiler_crashers_2_fixed/rdar81590807.swift @@ -48,6 +48,7 @@ func run(on object: PFXObject) async throws { @main struct Main { static func main() async throws { + _ = JSONDecoder() let object = PFXObject() try await run(on: object) } From 32ae37201592fe5c5912361c80dca767fb8671f8 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Sat, 17 Sep 2022 00:15:13 -0700 Subject: [PATCH 2/2] Update test/Interpreter/SDK/Foundation_NSRect.swift (cherry picked from commit e072c8e3a5a7c32829bf5f41b6bc9f2f29ffbde3) --- test/Interpreter/SDK/Foundation_NSRect.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Interpreter/SDK/Foundation_NSRect.swift b/test/Interpreter/SDK/Foundation_NSRect.swift index 09be484477c02..cdf57f73fab15 100644 --- a/test/Interpreter/SDK/Foundation_NSRect.swift +++ b/test/Interpreter/SDK/Foundation_NSRect.swift @@ -4,7 +4,7 @@ // iOS doesn't have NSRect. iOS and OS X CGRect is tested elsewhere. // REQUIRES: OS=macosx -import Coreimage +import CoreImage _ = JSONDecoder()