Files
swift-mirror/test/Interpreter/foundation-bridge-error.swift
Ben Langmuir 8a824d70a0 [immediate] Load Foundation early enough for bridging
Foundation needs to be loaded early in the process for Swift's runtime
to properly initialize bridging support; otherwise it may cause issues
like unrecognized selectors. When scripting, load Foundation early in
performFrontend before any swift code runs.

rdar://129528115
2024-08-01 15:02:13 -07:00

25 lines
767 B
Swift

// Check that we can access localizedDescription, which crashes in the runtime
// if Foundation is loaded after the runtime is already initialized on Darwin.
// REQUIRES: executable_test
// REQUIRES: objc_interop
// REQUIRES: OS=macosx
// FIXME: There's a separate bridging error with the just-built stdlib on CI
// nodes.
// REQUIRES: use_os_stdlib
// RUN: %target-jit-run %s
// RUN: DYLD_INSERT_LIBRARIES=/System/Library/Frameworks/Foundation.framework/Foundation %target-jit-run %s
import Foundation
print("Insert Libraries: \(ProcessInfo.processInfo.environment["DYLD_INSERT_LIBRARIES"] ?? "<nil>")")
enum SomeError: LocalizedError {
case fail
}
let err = SomeError.fail
let path = (#file as NSString).lastPathComponent
let desc = err.localizedDescription