mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Swift 4.x (x < 2) names are obsoleted in 4.2, not 5.
In APINotes, when an unversioned name overrides a previously declared name with a Swift version, if the previously declared name is guarded under version 4 the obsoleted version should be 4.2, not 5. In all other cases, the obsoleted version is the next major Swift version. Fixes rdar://problem/39950937
This commit is contained in:
@@ -2359,12 +2359,20 @@ namespace {
|
||||
PlatformAgnosticAvailabilityKind::UnavailableInSwift);
|
||||
} else {
|
||||
unsigned majorVersion = getVersion().majorVersionNumber();
|
||||
unsigned minorVersion = getVersion().minorVersionNumber();
|
||||
if (getVersion() < getActiveSwiftVersion()) {
|
||||
// A Swift 2 name, for example, was obsoleted in Swift 3.
|
||||
// However, a Swift 4 name is obsoleted in Swift 4.2.
|
||||
// FIXME: it would be better to have a unified place
|
||||
// to represent Swift versions for API versioning.
|
||||
clang::VersionTuple obsoletedVersion =
|
||||
(majorVersion == 4 && minorVersion < 2)
|
||||
? clang::VersionTuple(4, 2)
|
||||
: clang::VersionTuple(majorVersion + 1);
|
||||
attr = AvailableAttr::createPlatformAgnostic(
|
||||
ctx, /*Message*/StringRef(), ctx.AllocateCopy(renamed.str()),
|
||||
PlatformAgnosticAvailabilityKind::SwiftVersionSpecific,
|
||||
clang::VersionTuple(majorVersion + 1));
|
||||
obsoletedVersion);
|
||||
} else {
|
||||
// Future names are introduced in their future version.
|
||||
assert(getVersion() > getActiveSwiftVersion());
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
Name: M
|
||||
Classes:
|
||||
- Name: FooID
|
||||
SwiftName: Foo_ID
|
||||
|
||||
SwiftVersions:
|
||||
- Version: 4
|
||||
Classes:
|
||||
- Name: FooID
|
||||
SwiftName: FooID
|
||||
@@ -0,0 +1,3 @@
|
||||
@import Foundation;
|
||||
@interface FooID: NSObject
|
||||
@end
|
||||
@@ -1,3 +1,6 @@
|
||||
module APINotesTest {
|
||||
header "APINotesTest.h"
|
||||
}
|
||||
module ObsoletedAPINotesTest {
|
||||
header "ObsoletedAPINotesTest.h"
|
||||
}
|
||||
|
||||
7
test/APINotes/obsoleted.swift
Normal file
7
test/APINotes/obsoleted.swift
Normal file
@@ -0,0 +1,7 @@
|
||||
// RUN: not %target-swift-frontend -typecheck -verify -I %S/Inputs/custom-modules -F %S/Inputs/custom-frameworks -swift-version 3 %s
|
||||
// RUN: %target-swift-frontend -typecheck -verify -I %S/Inputs/custom-modules -F %S/Inputs/custom-frameworks -swift-version 4.2 %s
|
||||
// RUN: %target-swift-frontend -typecheck -verify -I %S/Inputs/custom-modules -F %S/Inputs/custom-frameworks -swift-version 5 %s
|
||||
import ObsoletedAPINotesTest
|
||||
|
||||
let _: FooID // expected-error{{'FooID' has been renamed to 'Foo_ID'}}
|
||||
let _: Foo_ID
|
||||
Reference in New Issue
Block a user