mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
AST: Re-map macOS 16 aligned availability versions to 26.
- watchOS 12 -> 26 - visionOS 3 -> 26 - macos 16 -> 26 - iOS 19 -> 26 - tvOS 19 -> 26 The version numbers for `if #available(...)` queries are intentionally not re-mapped.
This commit is contained in:
@@ -263,16 +263,41 @@ bool swift::inheritsAvailabilityFromPlatform(PlatformKind Child,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::VersionTuple swift::canonicalizePlatformVersion(
|
static std::optional<llvm::Triple::OSType>
|
||||||
PlatformKind platform, const llvm::VersionTuple &version) {
|
tripleOSTypeForPlatform(PlatformKind platform) {
|
||||||
|
switch (platform) {
|
||||||
// Canonicalize macOS version for macOS Big Sur to treat
|
case PlatformKind::macOS:
|
||||||
// 10.16 as 11.0.
|
case PlatformKind::macOSApplicationExtension:
|
||||||
if (platform == PlatformKind::macOS ||
|
return llvm::Triple::MacOSX;
|
||||||
platform == PlatformKind::macOSApplicationExtension) {
|
case PlatformKind::iOS:
|
||||||
return llvm::Triple::getCanonicalVersionForOS(llvm::Triple::MacOSX,
|
case PlatformKind::iOSApplicationExtension:
|
||||||
version);
|
case PlatformKind::macCatalyst:
|
||||||
|
case PlatformKind::macCatalystApplicationExtension:
|
||||||
|
return llvm::Triple::IOS;
|
||||||
|
case PlatformKind::tvOS:
|
||||||
|
case PlatformKind::tvOSApplicationExtension:
|
||||||
|
return llvm::Triple::TvOS;
|
||||||
|
case PlatformKind::watchOS:
|
||||||
|
case PlatformKind::watchOSApplicationExtension:
|
||||||
|
return llvm::Triple::WatchOS;
|
||||||
|
case PlatformKind::visionOS:
|
||||||
|
case PlatformKind::visionOSApplicationExtension:
|
||||||
|
return llvm::Triple::XROS;
|
||||||
|
case PlatformKind::OpenBSD:
|
||||||
|
return llvm::Triple::OpenBSD;
|
||||||
|
case PlatformKind::Windows:
|
||||||
|
return llvm::Triple::Win32;
|
||||||
|
case PlatformKind::none:
|
||||||
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
llvm_unreachable("bad PlatformKind");
|
||||||
|
}
|
||||||
|
|
||||||
|
llvm::VersionTuple
|
||||||
|
swift::canonicalizePlatformVersion(PlatformKind platform,
|
||||||
|
const llvm::VersionTuple &version) {
|
||||||
|
if (auto osType = tripleOSTypeForPlatform(platform))
|
||||||
|
return llvm::Triple::getCanonicalVersionForOS(*osType, version);
|
||||||
|
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,20 @@ void FunctionIntroducedIn10_16();
|
|||||||
__attribute__((availability(macosx,introduced=11.0)))
|
__attribute__((availability(macosx,introduced=11.0)))
|
||||||
void FunctionIntroducedIn11_0();
|
void FunctionIntroducedIn11_0();
|
||||||
|
|
||||||
|
__attribute__((availability(macosx,introduced=16.0)))
|
||||||
|
void FunctionIntroducedIn16_0();
|
||||||
|
|
||||||
|
__attribute__((availability(macosx,introduced=26.0)))
|
||||||
|
void FunctionIntroducedIn26_0();
|
||||||
|
|
||||||
__attribute__((availability(macosx_app_extension,introduced=10.16)))
|
__attribute__((availability(macosx_app_extension,introduced=10.16)))
|
||||||
void FunctionIntroducedIn10_16AppExt();
|
void FunctionIntroducedIn10_16AppExt();
|
||||||
|
|
||||||
__attribute__((availability(macosx_app_extension,introduced=11.0)))
|
__attribute__((availability(macosx_app_extension,introduced=11.0)))
|
||||||
void FunctionIntroducedIn11_0AppExt();
|
void FunctionIntroducedIn11_0AppExt();
|
||||||
|
|
||||||
|
__attribute__((availability(macosx_app_extension,introduced=16.0)))
|
||||||
|
void FunctionIntroducedIn16_0AppExt();
|
||||||
|
|
||||||
|
__attribute__((availability(macosx_app_extension,introduced=26.0)))
|
||||||
|
void FunctionIntroducedIn26_0AppExt();
|
||||||
|
|||||||
@@ -11,3 +11,11 @@ FunctionIntroducedIn10_16()
|
|||||||
FunctionIntroducedIn11_0()
|
FunctionIntroducedIn11_0()
|
||||||
// expected-error@-1 {{'FunctionIntroducedIn11_0()' is only available in macOS 11.0 or newer}}
|
// expected-error@-1 {{'FunctionIntroducedIn11_0()' is only available in macOS 11.0 or newer}}
|
||||||
// expected-note@-2 {{add 'if #available' version check}}
|
// expected-note@-2 {{add 'if #available' version check}}
|
||||||
|
|
||||||
|
FunctionIntroducedIn16_0()
|
||||||
|
// expected-error@-1 {{'FunctionIntroducedIn16_0()' is only available in macOS 26.0 or newer}}
|
||||||
|
// expected-note@-2 {{add 'if #available' version check}}
|
||||||
|
|
||||||
|
FunctionIntroducedIn26_0()
|
||||||
|
// expected-error@-1 {{'FunctionIntroducedIn26_0()' is only available in macOS 26.0 or newer}}
|
||||||
|
// expected-note@-2 {{add 'if #available' version check}}
|
||||||
|
|||||||
@@ -11,3 +11,11 @@ FunctionIntroducedIn10_16AppExt()
|
|||||||
FunctionIntroducedIn11_0AppExt()
|
FunctionIntroducedIn11_0AppExt()
|
||||||
// expected-error@-1 {{'FunctionIntroducedIn11_0AppExt()' is only available in application extensions for macOS 11.0 or newer}}
|
// expected-error@-1 {{'FunctionIntroducedIn11_0AppExt()' is only available in application extensions for macOS 11.0 or newer}}
|
||||||
// expected-note@-2 {{add 'if #available' version check}}
|
// expected-note@-2 {{add 'if #available' version check}}
|
||||||
|
|
||||||
|
FunctionIntroducedIn16_0AppExt()
|
||||||
|
// expected-error@-1 {{'FunctionIntroducedIn16_0AppExt()' is only available in application extensions for macOS 26.0 or newer}}
|
||||||
|
// expected-note@-2 {{add 'if #available' version check}}
|
||||||
|
|
||||||
|
FunctionIntroducedIn26_0AppExt()
|
||||||
|
// expected-error@-1 {{'FunctionIntroducedIn26_0AppExt()' is only available in application extensions for macOS 26.0 or newer}}
|
||||||
|
// expected-note@-2 {{add 'if #available' version check}}
|
||||||
|
|||||||
21
test/IDE/print_ast_tc_decls_canonical_versions.swift
Normal file
21
test/IDE/print_ast_tc_decls_canonical_versions.swift
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
// RUN: %empty-directory(%t)
|
||||||
|
// RUN: %target-swift-frontend -typecheck -verify %s
|
||||||
|
// RUN: %target-swift-ide-test -skip-deinit=false -print-ast-typechecked -source-filename %s -function-definitions=false -prefer-type-repr=false -print-implicit-attrs=true > %t.printed.txt
|
||||||
|
// RUN: %FileCheck %s -check-prefix=PASS_COMMON -strict-whitespace < %t.printed.txt
|
||||||
|
|
||||||
|
@available(iOS 10.16, OSX 10.16, *)
|
||||||
|
func introduced10_16() {}
|
||||||
|
// PASS_COMMON: {{^}}@available(iOS 10.16, macOS 11.0, *){{$}}
|
||||||
|
// PASS_COMMON-NEXT: {{^}}func introduced10_16(){{$}}
|
||||||
|
|
||||||
|
@available(macOS 16.0, iOS 19.0, macCatalyst 19.0, watchOS 12.0, tvOS 19.0, visionOS 3.0, *)
|
||||||
|
func introducedInVersionsMappingTo26_0() {}
|
||||||
|
// FIXME: visionOS and macCatalyst are missing
|
||||||
|
// PASS_COMMON: {{^}}@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, *){{$}}
|
||||||
|
// PASS_COMMON-NEXT: {{^}}func introducedInVersionsMappingTo26_0(){{$}}
|
||||||
|
|
||||||
|
@available(macOS 18.0, iOS 21.0, macCatalyst 21.0, watchOS 14.0, tvOS 21.0, visionOS 5.0, *)
|
||||||
|
func introducedInVersionsMappingTo28_0() {}
|
||||||
|
// FIXME: visionOS and macCatalyst are missing
|
||||||
|
// PASS_COMMON: {{^}}@available(macOS 28.0, iOS 28.0, watchOS 28.0, tvOS 28.0, *){{$}}
|
||||||
|
// PASS_COMMON-NEXT: {{^}}func introducedInVersionsMappingTo28_0(){{$}}
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
// RUN: %empty-directory(%t)
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -swift-version 4 -typecheck -verify %s -F %S/Inputs/mock-sdk -enable-objc-interop -disable-objc-attr-requires-foundation-module
|
|
||||||
//
|
|
||||||
// RUN: %target-swift-ide-test(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -swift-version 4 -skip-deinit=false -print-ast-typechecked -source-filename %s -F %S/Inputs/mock-sdk -function-definitions=false -prefer-type-repr=false -print-implicit-attrs=true -enable-objc-interop -disable-objc-attr-requires-foundation-module > %t.printed.txt
|
|
||||||
// RUN: %FileCheck %s -check-prefix=PASS_COMMON -strict-whitespace < %t.printed.txt
|
|
||||||
|
|
||||||
|
|
||||||
// FIXME: rdar://problem/19648117 Needs splitting objc parts out
|
|
||||||
// REQUIRES: objc_interop
|
|
||||||
|
|
||||||
@available(iOS 10.16, OSX 10.16, *)
|
|
||||||
func introduced10_16() {}
|
|
||||||
// PASS_COMMON: {{^}}@available(iOS 10.16, macOS 11.0, *){{$}}
|
|
||||||
// PASS_COMMON-NEXT: {{^}}func introduced10_16(){{$}}
|
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
// CHECK: target triple = "{{.*}}-apple-macosx{{[0-9][0-9]}}.
|
// CHECK: target triple = "{{.*}}-apple-macosx{{[0-9][0-9]}}.
|
||||||
// CHECK-SPECIFIC-MAC-10-X: target triple = "{{.*}}-apple-macosx10.51.0"
|
// CHECK-SPECIFIC-MAC-10-X: target triple = "{{.*}}-apple-macosx10.51.0"
|
||||||
// CHECK-DARWIN-OVER-11: target triple = "{{.*}}-apple-macosx46.0.0"
|
// CHECK-DARWIN-OVER-11: target triple = "{{.*}}-apple-macosx56.0.0"
|
||||||
|
|
||||||
public func anchor() {}
|
public func anchor() {}
|
||||||
anchor()
|
anchor()
|
||||||
|
|||||||
34
test/ModuleInterface/availability-canonical-version.swift
Normal file
34
test/ModuleInterface/availability-canonical-version.swift
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
// RUN: %empty-directory(%t)
|
||||||
|
// RUN: %target-swift-emit-module-interface(%t/Module.swiftinterface) %s
|
||||||
|
// RUN: %target-swift-typecheck-module-from-interface(%t/Module.swiftinterface)
|
||||||
|
// RUN: %FileCheck %s < %t/Module.swiftinterface
|
||||||
|
|
||||||
|
@available(macOS 10.16, iOS 10.16, watchOS 10.16, tvOS 10.16, *)
|
||||||
|
public func introduced10_16() { }
|
||||||
|
// CHECK: @available(macOS 11.0, iOS 10.16, watchOS 10.16, tvOS 10.16, *)
|
||||||
|
// CHECK-NEXT: public func introduced10_16()
|
||||||
|
|
||||||
|
@available(OSX 11.0, iOS 11.0, watchOS 11.0, tvOS 11.0, *)
|
||||||
|
public func introduced11_0() { }
|
||||||
|
// CHECK-NEXT: @available(macOS 11.0, iOS 11.0, watchOS 11.0, tvOS 11.0, *)
|
||||||
|
// CHECK-NEXT: public func introduced11_0()
|
||||||
|
|
||||||
|
@available(macOS 16.0, iOS 19.0, macCatalyst 19.0, watchOS 12.0, tvOS 19.0, visionOS 3.0, *)
|
||||||
|
public func introducedInVersionsMappingTo26_0() { }
|
||||||
|
// CHECK-NEXT: @available(macOS 26.0, iOS 26.0, macCatalyst 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
|
||||||
|
// CHECK-NEXT: public func introducedInVersionsMappingTo26_0()
|
||||||
|
|
||||||
|
@available(macOS 17.0, iOS 20.0, macCatalyst 20.0, watchOS 13.0, tvOS 20.0, visionOS 4.0, *)
|
||||||
|
public func introducedInInvalidVersionsMappingTo27_0() { }
|
||||||
|
// CHECK-NEXT: @available(macOS 27.0, iOS 27.0, macCatalyst 27.0, watchOS 27.0, tvOS 27.0, visionOS 27.0, *)
|
||||||
|
// CHECK-NEXT: public func introducedInInvalidVersionsMappingTo27_0()
|
||||||
|
|
||||||
|
@available(macOS 19.1.1, iOS 21, macCatalyst 21.0, watchOS 14.5.1, tvOS 21.2.3, visionOS 4.0.1, *)
|
||||||
|
public func introducedInInvalidVersionsWithVaryingComponents() { }
|
||||||
|
// CHECK-NEXT: @available(macOS 29.1.1, iOS 28, macCatalyst 28.0, watchOS 28.5.1, tvOS 28.2.3, visionOS 27.0.1, *)
|
||||||
|
// CHECK-NEXT: public func introducedInInvalidVersionsWithVaryingComponents()
|
||||||
|
|
||||||
|
@available(macOS 26.0, iOS 26.0, macCatalyst 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
|
||||||
|
public func introduced26_0() { }
|
||||||
|
// CHECK-NEXT: @available(macOS 26.0, iOS 26.0, macCatalyst 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
|
||||||
|
// CHECK-NEXT: public func introduced26_0()
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
// RUN: %empty-directory(%t)
|
|
||||||
// RUN: %target-swift-emit-module-interface(%t/Module.swiftinterface) %s
|
|
||||||
// RUN: %target-swift-typecheck-module-from-interface(%t/Module.swiftinterface)
|
|
||||||
// RUN: %FileCheck %s < %t/Module.swiftinterface
|
|
||||||
|
|
||||||
// REQUIRES: OS=macosx
|
|
||||||
|
|
||||||
@available(macOS 10.16, *)
|
|
||||||
public func introduced10_16() { }
|
|
||||||
// CHECK: @available(macOS 11.0, *)
|
|
||||||
// CHECK-NEXT: public func introduced10_16()
|
|
||||||
|
|
||||||
|
|
||||||
@available(OSX 11.0, *)
|
|
||||||
public func introduced11_0() { }
|
|
||||||
// CHECK-NEXT: @available(macOS 11.0, *)
|
|
||||||
// CHECK-NEXT: public func introduced11_0()
|
|
||||||
|
|
||||||
|
|
||||||
47
test/PrintAsObjC/availability_canonical_versions.swift
Normal file
47
test/PrintAsObjC/availability_canonical_versions.swift
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
// RUN: %empty-directory(%t)
|
||||||
|
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-module -o %t %s -disable-objc-attr-requires-foundation-module
|
||||||
|
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -parse-as-library %t/availability_canonical_versions.swiftmodule -typecheck -verify -emit-objc-header-path %t/availability.h -import-objc-header %S/../Inputs/empty.h -disable-objc-attr-requires-foundation-module
|
||||||
|
// RUN: %FileCheck %s < %t/availability.h
|
||||||
|
// RUN: %check-in-clang %t/availability.h
|
||||||
|
|
||||||
|
// REQUIRES: objc_interop
|
||||||
|
|
||||||
|
// CHECK-LABEL: @interface Availability{{$}}
|
||||||
|
@objc class Availability {
|
||||||
|
// CHECK-NEXT: - (void)alwaysAvailable;
|
||||||
|
@objc func alwaysAvailable() {}
|
||||||
|
|
||||||
|
// CHECK-NEXT: - (void)introducedOn10_16
|
||||||
|
// CHECK-SAME: SWIFT_AVAILABILITY(ios,introduced=10.16)
|
||||||
|
// CHECK-SAME: SWIFT_AVAILABILITY(macos,introduced=11.0)
|
||||||
|
@available(macOS 10.16, *)
|
||||||
|
@available(iOS, introduced: 10.16)
|
||||||
|
@objc func introducedOn10_16() {}
|
||||||
|
|
||||||
|
// CHECK-NEXT: - (void)introducedOn11_0
|
||||||
|
// CHECK-SAME: SWIFT_AVAILABILITY(ios,introduced=11.0)
|
||||||
|
// CHECK-SAME: SWIFT_AVAILABILITY(macos,introduced=11.0)
|
||||||
|
@available(macOS 11.0, *)
|
||||||
|
@available(iOS, introduced: 11.0)
|
||||||
|
@objc func introducedOn11_0() {}
|
||||||
|
|
||||||
|
// CHECK-NEXT: - (void)introducedOnVersionsMappingTo26_0
|
||||||
|
// CHECK-SAME: SWIFT_AVAILABILITY(visionos,introduced=26.0)
|
||||||
|
// CHECK-SAME: SWIFT_AVAILABILITY(tvos,introduced=26.0)
|
||||||
|
// CHECK-SAME: SWIFT_AVAILABILITY(watchos,introduced=26.0)
|
||||||
|
// CHECK-SAME: SWIFT_AVAILABILITY(maccatalyst,introduced=26.0)
|
||||||
|
// CHECK-SAME: SWIFT_AVAILABILITY(ios,introduced=26.0)
|
||||||
|
// CHECK-SAME: SWIFT_AVAILABILITY(macos,introduced=26.0)
|
||||||
|
@available(macOS 16.0, iOS 19.0, macCatalyst 19.0, watchOS 12.0, tvOS 19.0, visionOS 3.0, *)
|
||||||
|
@objc func introducedOnVersionsMappingTo26_0() {}
|
||||||
|
|
||||||
|
// CHECK-NEXT: - (void)introducedOn26_0
|
||||||
|
// CHECK-SAME: SWIFT_AVAILABILITY(visionos,introduced=26.0)
|
||||||
|
// CHECK-SAME: SWIFT_AVAILABILITY(watchos,introduced=26.0)
|
||||||
|
// CHECK-SAME: SWIFT_AVAILABILITY(tvos,introduced=26.0)
|
||||||
|
// CHECK-SAME: SWIFT_AVAILABILITY(maccatalyst,introduced=26.0)
|
||||||
|
// CHECK-SAME: SWIFT_AVAILABILITY(ios,introduced=26.0)
|
||||||
|
// CHECK-SAME: SWIFT_AVAILABILITY(macos,introduced=26.0)
|
||||||
|
@available(macOS 26.0, iOS 26.0, macCatalyst 26.0, tvOS 26.0, watchOS 26.0, visionOS 26.0, *)
|
||||||
|
@objc func introducedOn26_0() {}
|
||||||
|
}
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
// RUN: %empty-directory(%t)
|
|
||||||
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-module -o %t %s -disable-objc-attr-requires-foundation-module
|
|
||||||
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -parse-as-library %t/availability_macosx_canonical_versions.swiftmodule -typecheck -verify -emit-objc-header-path %t/availability.h -import-objc-header %S/../Inputs/empty.h -disable-objc-attr-requires-foundation-module
|
|
||||||
// RUN: %FileCheck %s < %t/availability.h
|
|
||||||
// RUN: %check-in-clang %t/availability.h
|
|
||||||
|
|
||||||
// REQUIRES: objc_interop
|
|
||||||
|
|
||||||
// CHECK-LABEL: @interface Availability{{$}}
|
|
||||||
// CHECK-NEXT: - (void)alwaysAvailable;
|
|
||||||
// CHECK-NEXT: - (void)introducedOn10_16
|
|
||||||
// CHECK-DAG: SWIFT_AVAILABILITY(macos,introduced=11.0)
|
|
||||||
// CHECK-DAG: SWIFT_AVAILABILITY(ios,introduced=10.16)
|
|
||||||
|
|
||||||
@objc class Availability {
|
|
||||||
@objc func alwaysAvailable() {}
|
|
||||||
@available(macOS 10.16, *)
|
|
||||||
@available(iOS, introduced: 10.16)
|
|
||||||
@objc func introducedOn10_16() {}
|
|
||||||
}
|
|
||||||
@@ -1,15 +1,11 @@
|
|||||||
// RUN: %target-swift-emit-silgen %s -target x86_64-apple-macosx10.52 -target-variant x86_64-apple-ios50.0-macabi | %FileCheck %s
|
// RUN: %target-swift-emit-silgen %s -target %target-cpu-apple-macosx10.15 -target-variant %target-cpu-apple-ios13.0-macabi | %FileCheck %s
|
||||||
// RUN: %target-swift-emit-silgen %s -target x86_64-apple-ios50.0-macabi -target-variant x86_64-apple-macosx10.52 | %FileCheck %s
|
// RUN: %target-swift-emit-silgen %s -target %target-cpu-apple-ios13.0-macabi -target-variant %target-cpu-apple-macosx10.15 | %FileCheck %s
|
||||||
|
|
||||||
|
|
||||||
// REQUIRES: OS=macosx || OS=maccatalyst
|
// REQUIRES: OS=macosx || OS=maccatalyst
|
||||||
|
|
||||||
// CHECK-LABEL: sil{{.+}}@main{{.*}} {
|
// CHECK-LABEL: sil{{.+}}@main{{.*}} {
|
||||||
|
|
||||||
|
|
||||||
// Test for the runtime non-canonical version hack for canonical macOS versioning.
|
|
||||||
// This will eventually change to be the correctly canonicalized version.
|
|
||||||
|
|
||||||
// CHECK: [[MACOS_MAJOR:%.*]] = integer_literal $Builtin.Word, 10
|
// CHECK: [[MACOS_MAJOR:%.*]] = integer_literal $Builtin.Word, 10
|
||||||
// CHECK: [[MACOS_MINOR:%.*]] = integer_literal $Builtin.Word, 16
|
// CHECK: [[MACOS_MINOR:%.*]] = integer_literal $Builtin.Word, 16
|
||||||
// CHECK: [[MACOS_PATCH:%.*]] = integer_literal $Builtin.Word, 0
|
// CHECK: [[MACOS_PATCH:%.*]] = integer_literal $Builtin.Word, 0
|
||||||
@@ -20,3 +16,36 @@
|
|||||||
// CHECK: [[QUERY_RESULT:%.*]] = apply [[FUNC]]([[MACOS_MAJOR]], [[MACOS_MINOR]], [[MACOS_PATCH]], [[IOS_MAJOR]], [[IOS_MINOR]], [[IOS_PATCH]]) : $@convention(thin) (Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word) -> Builtin.Int1
|
// CHECK: [[QUERY_RESULT:%.*]] = apply [[FUNC]]([[MACOS_MAJOR]], [[MACOS_MINOR]], [[MACOS_PATCH]], [[IOS_MAJOR]], [[IOS_MINOR]], [[IOS_PATCH]]) : $@convention(thin) (Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word) -> Builtin.Int1
|
||||||
if #available(OSX 10.16, iOS 51.1.2, *) {
|
if #available(OSX 10.16, iOS 51.1.2, *) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CHECK: [[MACOS_MAJOR:%.*]] = integer_literal $Builtin.Word, 11
|
||||||
|
// CHECK: [[MACOS_MINOR:%.*]] = integer_literal $Builtin.Word, 0
|
||||||
|
// CHECK: [[MACOS_PATCH:%.*]] = integer_literal $Builtin.Word, 0
|
||||||
|
// CHECK: [[IOS_MAJOR:%.*]] = integer_literal $Builtin.Word, 51
|
||||||
|
// CHECK: [[IOS_MINOR:%.*]] = integer_literal $Builtin.Word, 1
|
||||||
|
// CHECK: [[IOS_PATCH:%.*]] = integer_literal $Builtin.Word, 2
|
||||||
|
// CHECK: [[FUNC:%.*]] = function_ref @$ss042_stdlib_isOSVersionAtLeastOrVariantVersiondE0yBi1_Bw_BwBwBwBwBwtF : $@convention(thin) (Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word) -> Builtin.Int1
|
||||||
|
// CHECK: [[QUERY_RESULT:%.*]] = apply [[FUNC]]([[MACOS_MAJOR]], [[MACOS_MINOR]], [[MACOS_PATCH]], [[IOS_MAJOR]], [[IOS_MINOR]], [[IOS_PATCH]]) : $@convention(thin) (Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word) -> Builtin.Int1
|
||||||
|
if #available(OSX 11.0, iOS 51.1.2, *) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// CHECK: [[MACOS_MAJOR:%.*]] = integer_literal $Builtin.Word, 16
|
||||||
|
// CHECK: [[MACOS_MINOR:%.*]] = integer_literal $Builtin.Word, 0
|
||||||
|
// CHECK: [[MACOS_PATCH:%.*]] = integer_literal $Builtin.Word, 0
|
||||||
|
// CHECK: [[IOS_MAJOR:%.*]] = integer_literal $Builtin.Word, 19
|
||||||
|
// CHECK: [[IOS_MINOR:%.*]] = integer_literal $Builtin.Word, 0
|
||||||
|
// CHECK: [[IOS_PATCH:%.*]] = integer_literal $Builtin.Word, 0
|
||||||
|
// CHECK: [[FUNC:%.*]] = function_ref @$ss042_stdlib_isOSVersionAtLeastOrVariantVersiondE0yBi1_Bw_BwBwBwBwBwtF : $@convention(thin) (Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word) -> Builtin.Int1
|
||||||
|
// CHECK: [[QUERY_RESULT:%.*]] = apply [[FUNC]]([[MACOS_MAJOR]], [[MACOS_MINOR]], [[MACOS_PATCH]], [[IOS_MAJOR]], [[IOS_MINOR]], [[IOS_PATCH]]) : $@convention(thin) (Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word) -> Builtin.Int1
|
||||||
|
if #available(macOS 16.0, iOS 19.0, *) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// CHECK: [[MACOS_MAJOR:%.*]] = integer_literal $Builtin.Word, 26
|
||||||
|
// CHECK: [[MACOS_MINOR:%.*]] = integer_literal $Builtin.Word, 0
|
||||||
|
// CHECK: [[MACOS_PATCH:%.*]] = integer_literal $Builtin.Word, 0
|
||||||
|
// CHECK: [[IOS_MAJOR:%.*]] = integer_literal $Builtin.Word, 26
|
||||||
|
// CHECK: [[IOS_MINOR:%.*]] = integer_literal $Builtin.Word, 0
|
||||||
|
// CHECK: [[IOS_PATCH:%.*]] = integer_literal $Builtin.Word, 0
|
||||||
|
// CHECK: [[FUNC:%.*]] = function_ref @$ss042_stdlib_isOSVersionAtLeastOrVariantVersiondE0yBi1_Bw_BwBwBwBwBwtF : $@convention(thin) (Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word) -> Builtin.Int1
|
||||||
|
// CHECK: [[QUERY_RESULT:%.*]] = apply [[FUNC]]([[MACOS_MAJOR]], [[MACOS_MINOR]], [[MACOS_PATCH]], [[IOS_MAJOR]], [[IOS_MINOR]], [[IOS_PATCH]]) : $@convention(thin) (Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word) -> Builtin.Int1
|
||||||
|
if #available(macOS 26.0, iOS 26.0, *) {
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
// RUN: %target-swift-emit-sil %s -target %target-cpu-apple-macosx10.50 -verify
|
// RUN: %target-swift-emit-sil %s -target %target-cpu-apple-macosx10.15 -verify
|
||||||
// RUN: %target-swift-emit-silgen %s -target %target-cpu-apple-macosx10.50 | %FileCheck %s
|
// RUN: %target-swift-emit-silgen %s -target %target-cpu-apple-macosx10.15 | %FileCheck %s
|
||||||
|
|
||||||
// REQUIRES: OS=macosx
|
// REQUIRES: OS=macosx
|
||||||
|
|
||||||
// CHECK-LABEL: sil{{.+}}@main{{.*}} {
|
// CHECK-LABEL: sil{{.+}}@main{{.*}} {
|
||||||
|
|
||||||
// Test for the runtime non-canonical version hack for canonical macOS versioning.
|
|
||||||
// This will eventually change to be the correctly canonicalized version.
|
|
||||||
|
|
||||||
// CHECK: [[MAJOR:%.*]] = integer_literal $Builtin.Word, 10
|
// CHECK: [[MAJOR:%.*]] = integer_literal $Builtin.Word, 10
|
||||||
// CHECK: [[MINOR:%.*]] = integer_literal $Builtin.Word, 16
|
// CHECK: [[MINOR:%.*]] = integer_literal $Builtin.Word, 16
|
||||||
// CHECK: [[PATCH:%.*]] = integer_literal $Builtin.Word, 0
|
// CHECK: [[PATCH:%.*]] = integer_literal $Builtin.Word, 0
|
||||||
@@ -15,3 +12,27 @@
|
|||||||
// CHECK: [[QUERY_RESULT:%.*]] = apply [[FUNC]]([[MAJOR]], [[MINOR]], [[PATCH]]) : $@convention(thin) (Builtin.Word, Builtin.Word, Builtin.Word) -> Builtin.Int1
|
// CHECK: [[QUERY_RESULT:%.*]] = apply [[FUNC]]([[MAJOR]], [[MINOR]], [[PATCH]]) : $@convention(thin) (Builtin.Word, Builtin.Word, Builtin.Word) -> Builtin.Int1
|
||||||
if #available(OSX 10.16, iOS 7.1, *) {
|
if #available(OSX 10.16, iOS 7.1, *) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CHECK: [[MAJOR:%.*]] = integer_literal $Builtin.Word, 11
|
||||||
|
// CHECK: [[MINOR:%.*]] = integer_literal $Builtin.Word, 0
|
||||||
|
// CHECK: [[PATCH:%.*]] = integer_literal $Builtin.Word, 0
|
||||||
|
// CHECK: [[FUNC:%.*]] = function_ref @$ss26_stdlib_isOSVersionAtLeastyBi1_Bw_BwBwtF : $@convention(thin) (Builtin.Word, Builtin.Word, Builtin.Word) -> Builtin.Int1
|
||||||
|
// CHECK: [[QUERY_RESULT:%.*]] = apply [[FUNC]]([[MAJOR]], [[MINOR]], [[PATCH]]) : $@convention(thin) (Builtin.Word, Builtin.Word, Builtin.Word) -> Builtin.Int1
|
||||||
|
if #available(OSX 11.0, *) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// CHECK: [[MAJOR:%.*]] = integer_literal $Builtin.Word, 16
|
||||||
|
// CHECK: [[MINOR:%.*]] = integer_literal $Builtin.Word, 0
|
||||||
|
// CHECK: [[PATCH:%.*]] = integer_literal $Builtin.Word, 0
|
||||||
|
// CHECK: [[FUNC:%.*]] = function_ref @$ss26_stdlib_isOSVersionAtLeastyBi1_Bw_BwBwtF : $@convention(thin) (Builtin.Word, Builtin.Word, Builtin.Word) -> Builtin.Int1
|
||||||
|
// CHECK: [[QUERY_RESULT:%.*]] = apply [[FUNC]]([[MAJOR]], [[MINOR]], [[PATCH]]) : $@convention(thin) (Builtin.Word, Builtin.Word, Builtin.Word) -> Builtin.Int1
|
||||||
|
if #available(macOS 16.0, *) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// CHECK: [[MAJOR:%.*]] = integer_literal $Builtin.Word, 26
|
||||||
|
// CHECK: [[MINOR:%.*]] = integer_literal $Builtin.Word, 0
|
||||||
|
// CHECK: [[PATCH:%.*]] = integer_literal $Builtin.Word, 0
|
||||||
|
// CHECK: [[FUNC:%.*]] = function_ref @$ss26_stdlib_isOSVersionAtLeastyBi1_Bw_BwBwtF : $@convention(thin) (Builtin.Word, Builtin.Word, Builtin.Word) -> Builtin.Int1
|
||||||
|
// CHECK: [[QUERY_RESULT:%.*]] = apply [[FUNC]]([[MAJOR]], [[MINOR]], [[PATCH]]) : $@convention(thin) (Builtin.Word, Builtin.Word, Builtin.Word) -> Builtin.Int1
|
||||||
|
if #available(macOS 26.0, *) {
|
||||||
|
}
|
||||||
|
|||||||
25
test/Sema/availability_versions_canonical.swift
Normal file
25
test/Sema/availability_versions_canonical.swift
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
// RUN: %target-typecheck-verify-swift -target %target-swift-5.1-abi-triple
|
||||||
|
|
||||||
|
@available(OSX 10.16, *)
|
||||||
|
func introducedOnMacOS10_16() { }
|
||||||
|
|
||||||
|
@available(OSX 11.0, *)
|
||||||
|
func introducedOnMacOS11_0() { }
|
||||||
|
|
||||||
|
@available(macOS 16.0, iOS 19.0, watchOS 12.0, tvOS 19.0, visionOS 3.0, *)
|
||||||
|
func introducedInVersionsMappingTo26_0() { }
|
||||||
|
|
||||||
|
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
|
||||||
|
func introducedIn26_0() { }
|
||||||
|
|
||||||
|
func useUnderPoundAvailable() {
|
||||||
|
if #available(OSX 10.16, *) {
|
||||||
|
introducedOnMacOS10_16()
|
||||||
|
introducedOnMacOS11_0()
|
||||||
|
}
|
||||||
|
|
||||||
|
if #available(macOS 16.0, iOS 19.0, watchOS 12.0, tvOS 19.0, visionOS 3.0, *) {
|
||||||
|
introducedInVersionsMappingTo26_0()
|
||||||
|
introducedIn26_0()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
// RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx10.15 -disable-objc-attr-requires-foundation-module
|
|
||||||
|
|
||||||
// REQUIRES: OS=macosx
|
|
||||||
|
|
||||||
func markUsed<T>(_ t: T) {}
|
|
||||||
|
|
||||||
@available(OSX 10.16, *)
|
|
||||||
func introducedOn10_16() { }
|
|
||||||
|
|
||||||
func useUnderPoundAvailable() {
|
|
||||||
if #available(OSX 10.16, *) {
|
|
||||||
introducedOn10_16() // no-error
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// RUN: %swift -typecheck -verify -parse-stdlib -module-name Swift -target x86_64-apple-macosx11.0 %s
|
// RUN: %swift -typecheck -verify -parse-stdlib -module-name Swift -target %target-cpu-apple-macosx26.0 %s
|
||||||
|
|
||||||
|
|
||||||
@available(OSX, introduced: 10.5, deprecated: 10.8, obsoleted: 11.0,
|
@available(OSX, introduced: 10.5, deprecated: 10.8, obsoleted: 11.0,
|
||||||
@@ -16,6 +16,19 @@ func obsoletedIn10_16() { }
|
|||||||
|
|
||||||
obsoletedIn10_16() // expected-error{{'obsoletedIn10_16()' is unavailable in macOS: you don't want to do that anyway}}
|
obsoletedIn10_16() // expected-error{{'obsoletedIn10_16()' is unavailable in macOS: you don't want to do that anyway}}
|
||||||
|
|
||||||
|
@available(OSX, introduced: 10.5, deprecated: 10.8, obsoleted: 16.0,
|
||||||
|
message: "you don't want to do that anyway")
|
||||||
|
func obsoletedIn16() { }
|
||||||
|
// expected-note @-1{{'obsoletedIn16()' was obsoleted in macOS 26.0}}
|
||||||
|
|
||||||
|
obsoletedIn16() // expected-error{{'obsoletedIn16()' is unavailable in macOS: you don't want to do that anyway}}
|
||||||
|
|
||||||
|
@available(OSX, introduced: 10.5, deprecated: 10.8, obsoleted: 26.0,
|
||||||
|
message: "you don't want to do that anyway")
|
||||||
|
func obsoletedIn26() { }
|
||||||
|
// expected-note @-1{{'obsoletedIn26()' was obsoleted in macOS 26.0}}
|
||||||
|
|
||||||
|
obsoletedIn26() // expected-error{{'obsoletedIn26()' is unavailable in macOS: you don't want to do that anyway}}
|
||||||
|
|
||||||
@available(OSX, deprecated: 10.16)
|
@available(OSX, deprecated: 10.16)
|
||||||
func deprecatedIn10_16() { }
|
func deprecatedIn10_16() { }
|
||||||
@@ -26,8 +39,14 @@ func deprecatedIn10_18() { }
|
|||||||
@available(OSX, deprecated: 11.0)
|
@available(OSX, deprecated: 11.0)
|
||||||
func deprecatedIn11_0() { }
|
func deprecatedIn11_0() { }
|
||||||
|
|
||||||
@available(OSX, deprecated: 13.0)
|
@available(OSX, deprecated: 16.0)
|
||||||
func deprecatedIn13_0() { }
|
func deprecatedIn16_0() { }
|
||||||
|
|
||||||
|
@available(OSX, deprecated: 26.0)
|
||||||
|
func deprecatedIn26_0() { }
|
||||||
|
|
||||||
|
@available(OSX, deprecated: 27.0)
|
||||||
|
func deprecatedIn27_0() { }
|
||||||
|
|
||||||
@available(OSXApplicationExtension, deprecated: 10.16)
|
@available(OSXApplicationExtension, deprecated: 10.16)
|
||||||
func deprecatedIn10_16AppExtension() { }
|
func deprecatedIn10_16AppExtension() { }
|
||||||
@@ -36,6 +55,9 @@ func useDeprecated() {
|
|||||||
deprecatedIn10_16() // expected-warning {{deprecatedIn10_16()' was deprecated in macOS 11.0}}
|
deprecatedIn10_16() // expected-warning {{deprecatedIn10_16()' was deprecated in macOS 11.0}}
|
||||||
deprecatedIn10_18() // expected-warning {{'deprecatedIn10_18()' was deprecated in macOS 10.18}}
|
deprecatedIn10_18() // expected-warning {{'deprecatedIn10_18()' was deprecated in macOS 10.18}}
|
||||||
deprecatedIn11_0() // expected-warning {{'deprecatedIn11_0()' was deprecated in macOS 11.0}}
|
deprecatedIn11_0() // expected-warning {{'deprecatedIn11_0()' was deprecated in macOS 11.0}}
|
||||||
|
deprecatedIn16_0() // expected-warning {{'deprecatedIn16_0()' was deprecated in macOS 26.0}}
|
||||||
|
deprecatedIn26_0() // expected-warning {{'deprecatedIn26_0()' was deprecated in macOS 26.0}}
|
||||||
|
|
||||||
deprecatedIn13_0() // no-warning
|
deprecatedIn27_0()
|
||||||
|
deprecatedIn10_16AppExtension()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// RUN: %swift -typecheck -verify -parse-stdlib -module-name Swift -target x86_64-apple-macosx10.15 %s
|
// RUN: %swift -typecheck -verify -parse-stdlib -module-name Swift -target %target-cpu-apple-macosx10.15 %s
|
||||||
|
|
||||||
@available(OSX, introduced: 10.16)
|
@available(OSX, introduced: 10.16)
|
||||||
func longFormIntroducedIn10_16() { }
|
func longFormIntroducedIn10_16() { }
|
||||||
@@ -12,6 +12,12 @@ func longFormIntroducedIn11_0() { }
|
|||||||
@available(OSX, introduced: 13.0)
|
@available(OSX, introduced: 13.0)
|
||||||
func longFormIntroducedIn13_0() { }
|
func longFormIntroducedIn13_0() { }
|
||||||
|
|
||||||
|
@available(OSX, introduced: 16.0)
|
||||||
|
func longFormIntroducedIn16_0() { }
|
||||||
|
|
||||||
|
@available(OSX, introduced: 26.0)
|
||||||
|
func longFormIntroducedIn26_0() { }
|
||||||
|
|
||||||
// expected-note@+1 *{{add '@available' attribute to enclosing global function}}
|
// expected-note@+1 *{{add '@available' attribute to enclosing global function}}
|
||||||
func useLongFromIntroduced() {
|
func useLongFromIntroduced() {
|
||||||
longFormIntroducedIn10_16()
|
longFormIntroducedIn10_16()
|
||||||
@@ -29,6 +35,14 @@ func useLongFromIntroduced() {
|
|||||||
longFormIntroducedIn13_0()
|
longFormIntroducedIn13_0()
|
||||||
// expected-error@-1{{'longFormIntroducedIn13_0()' is only available in macOS 13.0 or newer}}
|
// expected-error@-1{{'longFormIntroducedIn13_0()' is only available in macOS 13.0 or newer}}
|
||||||
// expected-note@-2{{add 'if #available' version check}}
|
// expected-note@-2{{add 'if #available' version check}}
|
||||||
|
|
||||||
|
longFormIntroducedIn16_0()
|
||||||
|
// expected-error@-1{{'longFormIntroducedIn16_0()' is only available in macOS 26.0 or newer}}
|
||||||
|
// expected-note@-2{{add 'if #available' version check}}
|
||||||
|
|
||||||
|
longFormIntroducedIn26_0()
|
||||||
|
// expected-error@-1{{'longFormIntroducedIn26_0()' is only available in macOS 26.0 or newer}}
|
||||||
|
// expected-note@-2{{add 'if #available' version check}}
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(OSX 10.16, *)
|
@available(OSX 10.16, *)
|
||||||
@@ -43,6 +57,12 @@ func shortFormIntroducedIn11_0() { }
|
|||||||
@available(OSX 13.0, *)
|
@available(OSX 13.0, *)
|
||||||
func shortFormIntroducedIn13_0() { }
|
func shortFormIntroducedIn13_0() { }
|
||||||
|
|
||||||
|
@available(OSX 16.0, *)
|
||||||
|
func shortFormIntroducedIn16_0() { }
|
||||||
|
|
||||||
|
@available(OSX 26.0, *)
|
||||||
|
func shortFormIntroducedIn26_0() { }
|
||||||
|
|
||||||
// expected-note@+1 *{{add '@available' attribute to enclosing global function}}
|
// expected-note@+1 *{{add '@available' attribute to enclosing global function}}
|
||||||
func useShortIntroduced() {
|
func useShortIntroduced() {
|
||||||
shortFormIntroducedIn10_16()
|
shortFormIntroducedIn10_16()
|
||||||
@@ -58,4 +78,12 @@ func useShortIntroduced() {
|
|||||||
shortFormIntroducedIn13_0()
|
shortFormIntroducedIn13_0()
|
||||||
// expected-error@-1{{'shortFormIntroducedIn13_0()' is only available in macOS 13.0 or newer}}
|
// expected-error@-1{{'shortFormIntroducedIn13_0()' is only available in macOS 13.0 or newer}}
|
||||||
// expected-note@-2{{add 'if #available' version check}}
|
// expected-note@-2{{add 'if #available' version check}}
|
||||||
|
|
||||||
|
shortFormIntroducedIn16_0()
|
||||||
|
// expected-error@-1{{'shortFormIntroducedIn16_0()' is only available in macOS 26.0 or newer}}
|
||||||
|
// expected-note@-2{{add 'if #available' version check}}
|
||||||
|
|
||||||
|
shortFormIntroducedIn26_0()
|
||||||
|
// expected-error@-1{{'shortFormIntroducedIn26_0()' is only available in macOS 26.0 or newer}}
|
||||||
|
// expected-note@-2{{add 'if #available' version check}}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,17 @@
|
|||||||
// RUN: %swift -typecheck -verify -parse-stdlib -module-name Swift -target x86_64-apple-macosx10.15 %s -application-extension
|
// RUN: %swift -typecheck -verify -parse-stdlib -module-name Swift -target %target-cpu-apple-macosx10.15 %s -application-extension
|
||||||
|
|
||||||
@available(OSXApplicationExtension 11, *)
|
@available(OSXApplicationExtension 11, *)
|
||||||
func introducedInAppExtension11_0() { }
|
func introducedInAppExtension11_0() { }
|
||||||
|
|
||||||
@available(OSXApplicationExtension 10.16, *)
|
@available(OSXApplicationExtension 10.16, *)
|
||||||
func useAppExtension() {
|
func useAppExtension10_16() {
|
||||||
introducedInAppExtension11_0() // no-warning
|
introducedInAppExtension11_0() // no-warning
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@available(OSXApplicationExtension 26, *)
|
||||||
|
func introducedInAppExtension26_0() { }
|
||||||
|
|
||||||
|
@available(OSXApplicationExtension 16, *)
|
||||||
|
func useAppExtension16_0() {
|
||||||
|
introducedInAppExtension26_0() // no-warning
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user