mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Recent Swift uses 2 as the is-Swift bit when running on newer versions, and 1 on older versions. Since it's difficult or impossible to know what we'll be running on at build time, make the selection at runtime.
30 lines
970 B
Swift
30 lines
970 B
Swift
// RUN: %empty-directory(%t)
|
|
// -- Deployment target is set to pre-10.14.4 so that we use the "old"
|
|
// Swift runtime bit in compiler-emitted classes
|
|
// RUN: %target-build-swift -target x86_64-apple-macosx10.9 %s -module-name main -o %t/a.out
|
|
// RUN: %target-run %t/a.out | %FileCheck %s
|
|
|
|
// REQUIRES: executable_test
|
|
// REQUIRES: OS=macosx
|
|
|
|
import Foundation
|
|
|
|
// A fixed-layout class should be considered Swift metadata by the OS runtime.
|
|
class FixedLayout { }
|
|
|
|
debugPrint(FixedLayout.self) // CHECK: main.FixedLayout
|
|
|
|
// A generic class
|
|
class GenericBase<T> { }
|
|
debugPrint(GenericBase<Int>.self) // CHECK-NEXT: main.GenericBase<Swift.Int>
|
|
|
|
// A singleton-initialized class
|
|
class SingletonInit: GenericBase<Int> { }
|
|
debugPrint(SingletonInit.self) // CHECK-NEXT: main.SingletonInit
|
|
|
|
// A resilient-heritage class
|
|
class ResilientSubInit: JSONEncoder {}
|
|
debugPrint(ResilientSubInit.self) // CHECK-NEXT: main.ResilientSubInit
|
|
|
|
print("nailed it") // CHECK-NEXT: nailed it
|