mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[ClangImporter] Remove importer-based NS stripping. (#3880)
* [ClangImporter] Remove importer-based NS stripping. As Tony puts it, in the end we wound up with more Foundation declarations imported as members or keeping "NS" than those that dropped it, and any further decisions will be made on a case-by-case basis. Move all of the existing cases of prefix-stripping into Foundation's API notes and drop the logic from the compiler. Tested by dumping the generated interface for Foundation and its submodules for both macOS and the iOS simulator, and comparing the results. A few cases did slip through here because of the interaction between "SwiftName" and "Availability: nonswift". The next commit will re-add "NS" to some stragglers that we missed. rdar://problem/26880017 * APINotes: Add "NS" back to a few types. NSKeyedUnarchiverDelegate NSKeyedArchiverDelegate NSTextCheckingTypes NSBinarySearchingOptions NSEnumerationOptions NSSortOptions More rdar://problem/26880017 * Remove now-redundant SwiftNames from API notes. No change observed in the generated interface of Foundation and its submodules. Finishes rdar://problem/26880017.
This commit is contained in:
committed by
Ted Kremenek
parent
654c5235fe
commit
b5aca663bc
File diff suppressed because it is too large
Load Diff
@@ -120,10 +120,6 @@ enum class KnownFoundationEntity {
|
||||
/// entity name.
|
||||
Optional<KnownFoundationEntity> getKnownFoundationEntity(StringRef name);
|
||||
|
||||
/// Determine with the non-prefixed name of the given known Foundation
|
||||
/// entity conflicts with the Swift standard library.
|
||||
bool nameConflictsWithStandardLibrary(KnownFoundationEntity entity);
|
||||
|
||||
/// Callback function used when referring to a type member of a given
|
||||
/// type variable.
|
||||
typedef std::function<Type(TypeVariableType *, AssociatedTypeDecl *)>
|
||||
|
||||
@@ -30,7 +30,6 @@ FOUNDATION_ENTITY(NSObject)
|
||||
FOUNDATION_ENTITY(NSRange)
|
||||
FOUNDATION_ENTITY(NSSet)
|
||||
FOUNDATION_ENTITY(NSString)
|
||||
FOUNDATION_ENTITY(NSStringEncoding)
|
||||
FOUNDATION_ENTITY(NSUInteger)
|
||||
FOUNDATION_ENTITY(NSURL)
|
||||
FOUNDATION_ENTITY(NSZone)
|
||||
|
||||
@@ -161,9 +161,6 @@ namespace swift {
|
||||
/// and methods.
|
||||
bool InferImportAsMember = false;
|
||||
|
||||
/// Whether we are stripping the "NS" prefix from Foundation et al.
|
||||
bool StripNSPrefix = true;
|
||||
|
||||
/// Should 'id' in Objective-C be imported as 'Any' in Swift?
|
||||
bool EnableIdAsAny = true;
|
||||
|
||||
|
||||
@@ -247,10 +247,6 @@ def enable_swift_newtype :
|
||||
Flag<["-"], "enable-swift-newtype">,
|
||||
HelpText<"Enable the swift_newtype attribute">;
|
||||
|
||||
def enable_strip_ns_prefix :
|
||||
Flag<["-"], "enable-strip-ns-prefix">,
|
||||
HelpText<"Strip 'NS' prefix from Foundation entities">;
|
||||
|
||||
def swift3_migration :
|
||||
Flag<["-"], "swift3-migration">,
|
||||
HelpText<"Enable Fix-It based migration aids for Swift 3">;
|
||||
|
||||
@@ -2578,29 +2578,6 @@ Optional<KnownFoundationEntity> swift::getKnownFoundationEntity(StringRef name){
|
||||
.Default(None);
|
||||
}
|
||||
|
||||
bool swift::nameConflictsWithStandardLibrary(KnownFoundationEntity entity) {
|
||||
switch (entity) {
|
||||
case KnownFoundationEntity::NSArray:
|
||||
case KnownFoundationEntity::NSDictionary:
|
||||
case KnownFoundationEntity::NSInteger:
|
||||
case KnownFoundationEntity::NSRange:
|
||||
case KnownFoundationEntity::NSSet:
|
||||
case KnownFoundationEntity::NSString:
|
||||
case KnownFoundationEntity::NSCopying:
|
||||
case KnownFoundationEntity::NSError:
|
||||
case KnownFoundationEntity::NSErrorPointer:
|
||||
case KnownFoundationEntity::NSNumber:
|
||||
case KnownFoundationEntity::NSObject:
|
||||
case KnownFoundationEntity::NSUInteger:
|
||||
case KnownFoundationEntity::NSURL:
|
||||
case KnownFoundationEntity::NSZone:
|
||||
return true;
|
||||
|
||||
case KnownFoundationEntity::NSStringEncoding:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
StringRef ASTContext::getSwiftName(KnownFoundationEntity kind) {
|
||||
StringRef objcName;
|
||||
switch (kind) {
|
||||
@@ -2610,13 +2587,6 @@ StringRef ASTContext::getSwiftName(KnownFoundationEntity kind) {
|
||||
#include "swift/AST/KnownFoundationEntities.def"
|
||||
}
|
||||
|
||||
// If we're omitting needless words and the name won't conflict with
|
||||
// something in the standard library, strip the prefix off the Swift
|
||||
// name.
|
||||
if (LangOpts.StripNSPrefix &&
|
||||
!nameConflictsWithStandardLibrary(kind))
|
||||
return objcName.substr(2);
|
||||
|
||||
return objcName;
|
||||
}
|
||||
|
||||
|
||||
@@ -1309,13 +1309,6 @@ ClangImporter::Implementation::Implementation(ASTContext &ctx,
|
||||
DeprecatedAsUnavailableMessage =
|
||||
"APIs deprecated as of OS X 10.9 and earlier are unavailable in Swift";
|
||||
}
|
||||
|
||||
// Prepopulate the set of module prefixes.
|
||||
// FIXME: Hard-coded list should move into the module map language.
|
||||
if (ctx.LangOpts.StripNSPrefix) {
|
||||
ModulePrefixes["Foundation"] = "NS";
|
||||
ModulePrefixes["ObjectiveC"] = "NS";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1817,7 +1810,6 @@ static unsigned stripModulePrefixLength(
|
||||
// Check whether this is a known Foundation entity that conflicts with the
|
||||
// standard library.
|
||||
if (auto known = getKnownFoundationEntity(baseName))
|
||||
if (nameConflictsWithStandardLibrary(*known))
|
||||
return 0;
|
||||
|
||||
// If the character following the prefix is a '_', eat that, too.
|
||||
@@ -4436,7 +4428,6 @@ ClangImporter::Implementation::SwiftNameLookupExtension::hashExtension(
|
||||
SWIFT_LOOKUP_TABLE_VERSION_MAJOR,
|
||||
SWIFT_LOOKUP_TABLE_VERSION_MINOR,
|
||||
Impl.InferImportAsMember,
|
||||
Impl.SwiftContext.LangOpts.StripNSPrefix,
|
||||
Impl.HonorSwiftNewtypeAttr);
|
||||
}
|
||||
|
||||
|
||||
@@ -165,9 +165,7 @@ MAP_STDLIB_TYPE("CFIndex", SignedWord, 0, "Int", false, DefineAndUse)
|
||||
|
||||
// Foundation types.
|
||||
// FIXME: <rdar://problem/16074941> NSStringEncoding doesn't work on 32-bit
|
||||
MAP_STDLIB_TYPE(
|
||||
Impl.SwiftContext.getSwiftName(KnownFoundationEntity::NSStringEncoding),
|
||||
UnsignedWord, 0, "UInt", false, DoNothing)
|
||||
MAP_STDLIB_TYPE("NSStringEncoding", UnsignedWord, 0, "UInt", false, DoNothing)
|
||||
|
||||
#undef MAP_STDLIB_TYPE
|
||||
#undef MAP_TYPE
|
||||
|
||||
@@ -771,7 +771,6 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
|
||||
Opts.Playground |= Args.hasArg(OPT_playground);
|
||||
Opts.Swift3Migration |= Args.hasArg(OPT_swift3_migration);
|
||||
Opts.WarnOmitNeedlessWords = Args.hasArg(OPT_warn_omit_needless_words);
|
||||
Opts.StripNSPrefix |= Args.hasArg(OPT_enable_strip_ns_prefix);
|
||||
Opts.InferImportAsMember |= Args.hasArg(OPT_enable_infer_import_as_member);
|
||||
|
||||
Opts.EnableThrowWithoutTry |= Args.hasArg(OPT_enable_throw_without_try);
|
||||
|
||||
@@ -1100,13 +1100,12 @@ Decl *ModuleFile::resolveCrossReference(Module *M, uint32_t pathLen) {
|
||||
// has to go through this path, but it's an option we toggle for
|
||||
// testing.
|
||||
if (values.empty() && !retrying &&
|
||||
getContext().LangOpts.StripNSPrefix &&
|
||||
(M->getName().str() == "ObjectiveC" ||
|
||||
M->getName().str() == "Foundation")) {
|
||||
if (name.str().startswith("NS")) {
|
||||
if (name.str().size() > 2 && name.str() != "NSCocoaError") {
|
||||
auto known = getKnownFoundationEntity(name.str());
|
||||
if (!known || !nameConflictsWithStandardLibrary(*known)) {
|
||||
if (!known) {
|
||||
name = getContext().getIdentifier(name.str().substr(2));
|
||||
retrying = true;
|
||||
goto retry;
|
||||
|
||||
@@ -112,6 +112,6 @@ func testImportAsMember() {
|
||||
}
|
||||
|
||||
func testUnavailableRenamedEnum() {
|
||||
_ = ClothingStyle.hipster
|
||||
_ = NSClothingStyleOfficeCasual // expected-error{{'NSClothingStyleOfficeCasual' has been renamed to 'ClothingStyle.semiFormal'}} {{7-34=ClothingStyle.semiFormal}}
|
||||
_ = NSClothingStyle.hipster
|
||||
_ = NSClothingStyleOfficeCasual // expected-error{{'NSClothingStyleOfficeCasual' has been renamed to 'NSClothingStyle.semiFormal'}} {{7-34=NSClothingStyle.semiFormal}}
|
||||
}
|
||||
|
||||
@@ -17,23 +17,23 @@ func useClassThatTriggersImportOfDeprecatedEnum() {
|
||||
// when importing deprecated enums do not themselves trigger deprecation
|
||||
// warnings in the synthesized code.
|
||||
|
||||
_ = ClassWithDeprecatedOptionsInMethodSignature.sharedInstance()
|
||||
_ = NSClassWithDeprecatedOptionsInMethodSignature.sharedInstance()
|
||||
}
|
||||
|
||||
func useClassThatTriggersImportOExplicitlyUnavailableOptions() {
|
||||
_ = ClassWithPotentiallyUnavailableOptionsInMethodSignature.sharedInstance()
|
||||
_ = NSClassWithPotentiallyUnavailableOptionsInMethodSignature.sharedInstance()
|
||||
}
|
||||
|
||||
func useClassThatTriggersImportOfPotentiallyUnavailableOptions() {
|
||||
_ = ClassWithExplicitlyUnavailableOptionsInMethodSignature.sharedInstance()
|
||||
_ = NSClassWithExplicitlyUnavailableOptionsInMethodSignature.sharedInstance()
|
||||
}
|
||||
|
||||
func directUseShouldStillTriggerDeprecationWarning() {
|
||||
_ = DeprecatedOptions.first // expected-warning {{'DeprecatedOptions' was deprecated in OS X 10.51: Use a different API}}
|
||||
_ = DeprecatedEnum.first // expected-warning {{'DeprecatedEnum' was deprecated in OS X 10.51: Use a different API}}
|
||||
_ = NSDeprecatedOptions.first // expected-warning {{'NSDeprecatedOptions' was deprecated in OS X 10.51: Use a different API}}
|
||||
_ = NSDeprecatedEnum.first // expected-warning {{'NSDeprecatedEnum' was deprecated in OS X 10.51: Use a different API}}
|
||||
}
|
||||
|
||||
func useInSignature(_ options: DeprecatedOptions) { // expected-warning {{'DeprecatedOptions' was deprecated in OS X 10.51: Use a different API}}
|
||||
func useInSignature(_ options: NSDeprecatedOptions) { // expected-warning {{'NSDeprecatedOptions' was deprecated in OS X 10.51: Use a different API}}
|
||||
}
|
||||
|
||||
class SuperClassWithDeprecatedInitializer {
|
||||
@@ -53,11 +53,11 @@ func callImplicitInitializerOnSubClassWithSynthesizedDesignedInitializerOverride
|
||||
}
|
||||
|
||||
@available(OSX, introduced: 10.9, deprecated: 10.51)
|
||||
class DeprecatedSuperClass {
|
||||
class NSDeprecatedSuperClass {
|
||||
var i : Int = 7 // Causes initializer to be synthesized
|
||||
}
|
||||
|
||||
class NotDeprecatedSubClassOfDeprecatedSuperClass : DeprecatedSuperClass { // expected-warning {{'DeprecatedSuperClass' was deprecated in OS X 10.51}}
|
||||
class NotDeprecatedSubClassOfDeprecatedSuperClass : NSDeprecatedSuperClass { // expected-warning {{'NSDeprecatedSuperClass' was deprecated in OS X 10.51}}
|
||||
}
|
||||
|
||||
func callImplicitInitializerOnNotDeprecatedSubClassOfDeprecatedSuperClass() {
|
||||
@@ -68,7 +68,7 @@ func callImplicitInitializerOnNotDeprecatedSubClassOfDeprecatedSuperClass() {
|
||||
}
|
||||
|
||||
@available(OSX, introduced: 10.9, deprecated: 10.51)
|
||||
class DeprecatedSubClassOfDeprecatedSuperClass : DeprecatedSuperClass {
|
||||
class NSDeprecatedSubClassOfDeprecatedSuperClass : NSDeprecatedSuperClass {
|
||||
}
|
||||
|
||||
// Tests synthesis of materializeForSet
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import Foundation
|
||||
import user_objc
|
||||
|
||||
let aliasOriginal = AliasesEnum.byName
|
||||
let aliasOriginal = NSAliasesEnum.byName
|
||||
|
||||
switch aliasOriginal {
|
||||
case .original:
|
||||
|
||||
@@ -9,7 +9,7 @@ import user_objc
|
||||
let calendarUnits: NSCalendar.Unit = [.era, .year, .calendar]
|
||||
let calendarUnits2: NSCalendar.Unit = [.NSMonthCalendarUnit, .NSYearCalendarUnit] // expected-error 2 {{unavailable}}
|
||||
// ...unless they're all deprecated.
|
||||
let calendarUnitsDep: CalendarUnitDeprecated = [.eraCalendarUnitDeprecated, .yearCalendarUnitDeprecated] // expected-error 2 {{unavailable}}
|
||||
let calendarUnitsDep: NSCalendarUnitDeprecated = [.eraCalendarUnitDeprecated, .yearCalendarUnitDeprecated] // expected-error 2 {{unavailable}}
|
||||
|
||||
// rdar://problem/21081557
|
||||
func pokeRawValue(_ random: SomeRandomEnum) {
|
||||
|
||||
@@ -8,29 +8,29 @@ import Foundation
|
||||
import user_objc
|
||||
|
||||
// NS_ENUM
|
||||
var mince = RuncingMode.mince
|
||||
var quince = RuncingMode.quince
|
||||
var mince = NSRuncingMode.mince
|
||||
var quince = NSRuncingMode.quince
|
||||
|
||||
var rawMince: UInt = RuncingMode.mince.rawValue
|
||||
var rawFoo: CInt = UnderlyingType.foo.rawValue
|
||||
var rawMince: UInt = NSRuncingMode.mince.rawValue
|
||||
var rawFoo: CInt = NSUnderlyingType.foo.rawValue
|
||||
var rawNegativeOne: CUnsignedInt
|
||||
= UnsignedUnderlyingTypeNegativeValue.negativeOne.rawValue
|
||||
= NSUnsignedUnderlyingTypeNegativeValue.negativeOne.rawValue
|
||||
|
||||
var rawWordBreakA: Int = PrefixWordBreak.banjo.rawValue
|
||||
var rawWordBreakB: Int = PrefixWordBreak.bandana.rawValue
|
||||
var rawWordBreakA: Int = NSPrefixWordBreak.banjo.rawValue
|
||||
var rawWordBreakB: Int = NSPrefixWordBreak.bandana.rawValue
|
||||
|
||||
var rawWordBreak2A: Int = PrefixWordBreak2.breakBarBas.rawValue
|
||||
var rawWordBreak2B: Int = PrefixWordBreak2.breakBareBass.rawValue
|
||||
var rawWordBreak2A: Int = NSPrefixWordBreak2.breakBarBas.rawValue
|
||||
var rawWordBreak2B: Int = NSPrefixWordBreak2.breakBareBass.rawValue
|
||||
|
||||
var rawWordBreak3A: Int = PrefixWordBreak3.break1Bob.rawValue
|
||||
var rawWordBreak3B: Int = PrefixWordBreak3.break1Ben.rawValue
|
||||
var rawWordBreak3A: Int = NSPrefixWordBreak3.break1Bob.rawValue
|
||||
var rawWordBreak3B: Int = NSPrefixWordBreak3.break1Ben.rawValue
|
||||
|
||||
var singleConstant = SingleConstantEnum.value
|
||||
var singleConstant = NSSingleConstantEnum.value
|
||||
|
||||
var myCoolWaterMelon = MyCoolEnum.waterMelon
|
||||
|
||||
var hashMince: Int = RuncingMode.mince.hashValue
|
||||
if RuncingMode.mince != .quince { }
|
||||
var hashMince: Int = NSRuncingMode.mince.hashValue
|
||||
if NSRuncingMode.mince != .quince { }
|
||||
|
||||
var numberBehavior: NumberFormatter.Behavior = .default
|
||||
numberBehavior = .behavior10_4
|
||||
@@ -57,10 +57,10 @@ let objcABI: objc_abi = .v2
|
||||
let underscoreSuffix: ALL_CAPS_ENUM = .ENUM_CASE_ONE
|
||||
let underscoreSuffix2: ALL_CAPS_ENUM2 = .CASE_TWO
|
||||
|
||||
var alias1 = AliasesEnum.bySameValue
|
||||
var alias2 = AliasesEnum.byEquivalentValue
|
||||
var alias3 = AliasesEnum.byName
|
||||
var aliasOriginal = AliasesEnum.original
|
||||
var alias1 = NSAliasesEnum.bySameValue
|
||||
var alias2 = NSAliasesEnum.byEquivalentValue
|
||||
var alias3 = NSAliasesEnum.byName
|
||||
var aliasOriginal = NSAliasesEnum.original
|
||||
|
||||
switch aliasOriginal {
|
||||
case .original:
|
||||
@@ -89,13 +89,13 @@ default:
|
||||
}
|
||||
|
||||
switch aliasOriginal {
|
||||
case AliasesEnum.bySameValue:
|
||||
case NSAliasesEnum.bySameValue:
|
||||
break
|
||||
case AliasesEnum.differentValue:
|
||||
case NSAliasesEnum.differentValue:
|
||||
break
|
||||
}
|
||||
|
||||
extension AliasesEnum {
|
||||
extension NSAliasesEnum {
|
||||
func test() {
|
||||
switch aliasOriginal {
|
||||
case .bySameValue:
|
||||
@@ -109,47 +109,47 @@ extension AliasesEnum {
|
||||
// Test NS_SWIFT_NAME:
|
||||
_ = XMLNode.Kind.DTDKind == .invalid
|
||||
|
||||
_ = PrefixWordBreakCustom.problemCase == .deprecatedGoodCase // expected-warning {{deprecated}}
|
||||
_ = NSPrefixWordBreakCustom.problemCase == .deprecatedGoodCase // expected-warning {{deprecated}}
|
||||
|
||||
_ = PrefixWordBreak2Custom.problemCase == .goodCase
|
||||
_ = PrefixWordBreak2Custom.problemCase == .PrefixWordBreak2DeprecatedBadCase // expected-warning {{deprecated}}
|
||||
_ = PrefixWordBreak2Custom.problemCase == .deprecatedGoodCase // expected-warning {{deprecated}}
|
||||
_ = NSPrefixWordBreak2Custom.problemCase == .goodCase
|
||||
_ = NSPrefixWordBreak2Custom.problemCase == .PrefixWordBreak2DeprecatedBadCase // expected-warning {{deprecated}}
|
||||
_ = NSPrefixWordBreak2Custom.problemCase == .deprecatedGoodCase // expected-warning {{deprecated}}
|
||||
|
||||
_ = PrefixWordBreakReversedCustom.problemCase == .deprecatedGoodCase // expected-warning {{deprecated}}
|
||||
_ = NSPrefixWordBreakReversedCustom.problemCase == .deprecatedGoodCase // expected-warning {{deprecated}}
|
||||
|
||||
_ = PrefixWordBreakReorderedCustom.problemCase == .goodCase
|
||||
_ = PrefixWordBreakReorderedCustom.problemCase == .PrefixWordBreakReorderedDeprecatedBadCase // expected-warning {{deprecated}}
|
||||
_ = PrefixWordBreakReorderedCustom.problemCase == .deprecatedGoodCase // expected-warning {{deprecated}}
|
||||
_ = NSPrefixWordBreakReorderedCustom.problemCase == .goodCase
|
||||
_ = NSPrefixWordBreakReorderedCustom.problemCase == .PrefixWordBreakReorderedDeprecatedBadCase // expected-warning {{deprecated}}
|
||||
_ = NSPrefixWordBreakReorderedCustom.problemCase == .deprecatedGoodCase // expected-warning {{deprecated}}
|
||||
|
||||
_ = PrefixWordBreakReordered2Custom.problemCase == .goodCase
|
||||
_ = PrefixWordBreakReordered2Custom.problemCase == .PrefixWordBreakReordered2DeprecatedBadCase // expected-warning {{deprecated}}
|
||||
_ = PrefixWordBreakReordered2Custom.problemCase == .deprecatedGoodCase // expected-warning {{deprecated}}
|
||||
_ = NSPrefixWordBreakReordered2Custom.problemCase == .goodCase
|
||||
_ = NSPrefixWordBreakReordered2Custom.problemCase == .PrefixWordBreakReordered2DeprecatedBadCase // expected-warning {{deprecated}}
|
||||
_ = NSPrefixWordBreakReordered2Custom.problemCase == .deprecatedGoodCase // expected-warning {{deprecated}}
|
||||
|
||||
_ = SwiftNameAllTheThings.Foo == .Bar
|
||||
_ = SwiftNameBad.`class`
|
||||
_ = NSSwiftNameAllTheThings.Foo == .Bar
|
||||
_ = NSSwiftNameBad.`class`
|
||||
|
||||
|
||||
#if !IRGEN
|
||||
var qualifiedName = RuncingMode.mince
|
||||
var qualifiedName = NSRuncingMode.mince
|
||||
var topLevelCaseName = RuncingMince // expected-error{{}}
|
||||
#endif
|
||||
|
||||
// NS_OPTIONS
|
||||
var withMince: RuncingOptions = .enableMince
|
||||
var withQuince: RuncingOptions = .enableQuince
|
||||
var withMince: NSRuncingOptions = .enableMince
|
||||
var withQuince: NSRuncingOptions = .enableQuince
|
||||
|
||||
// When there is a single enum constant, compare it against the type name to
|
||||
// derive the namespaced name.
|
||||
var singleValue: SingleOptions = .value
|
||||
var singleValue: NSSingleOptions = .value
|
||||
|
||||
// Check OptionSet conformance.
|
||||
var minceAndQuince: RuncingOptions = RuncingOptions.enableMince.intersection(RuncingOptions.enableQuince)
|
||||
var minceOrQuince: RuncingOptions = [.enableMince, .enableQuince]
|
||||
var minceAndQuince: NSRuncingOptions = NSRuncingOptions.enableMince.intersection(NSRuncingOptions.enableQuince)
|
||||
var minceOrQuince: NSRuncingOptions = [.enableMince, .enableQuince]
|
||||
minceOrQuince.formIntersection(minceAndQuince)
|
||||
minceOrQuince.formUnion(minceAndQuince)
|
||||
|
||||
var minceValue: UInt = minceAndQuince.rawValue
|
||||
var minceFromMask: RuncingOptions = []
|
||||
var minceFromMask: NSRuncingOptions = []
|
||||
|
||||
// Strip leading 'k' in "kConstant".
|
||||
let calendarUnit: CFCalendarUnit = [.year, .weekday]
|
||||
@@ -162,12 +162,12 @@ let bluetoothProps: CBCharacteristicProperties = [.write, .writeWithoutResponse]
|
||||
let buzzFilter: AlertBuzzes = [.funk, .sosumi]
|
||||
|
||||
// Match multi-capital acronym.
|
||||
let bitmapFormat: BitmapFormat = [.NSAlphaFirstBitmapFormat, .NS32BitBigEndianBitmapFormat];
|
||||
let bitmapFormatR: BitmapFormatReversed = [.NSAlphaFirstBitmapFormatR, .NS32BitBigEndianBitmapFormatR];
|
||||
let bitmapFormat2: BitmapFormat2 = [.NSU16a , .NSU32a]
|
||||
let bitmapFormat3: BitmapFormat3 = [.NSU16b , .NSS32b]
|
||||
let bitmapFormat4: UBitmapFormat4 = [.NSU16c , .NSU32c]
|
||||
let bitmapFormat5: ABitmapFormat5 = [.NSAA16d , .NSAB32d]
|
||||
let bitmapFormat: NSBitmapFormat = [.NSAlphaFirstBitmapFormat, .NS32BitBigEndianBitmapFormat];
|
||||
let bitmapFormatR: NSBitmapFormatReversed = [.NSAlphaFirstBitmapFormatR, .NS32BitBigEndianBitmapFormatR];
|
||||
let bitmapFormat2: NSBitmapFormat2 = [.NSU16a , .NSU32a]
|
||||
let bitmapFormat3: NSBitmapFormat3 = [.NSU16b , .NSS32b]
|
||||
let bitmapFormat4: NSUBitmapFormat4 = [.NSU16c , .NSU32c]
|
||||
let bitmapFormat5: NSABitmapFormat5 = [.NSAA16d , .NSAB32d]
|
||||
|
||||
// Drop trailing underscores when possible.
|
||||
let timeFlags: CMTimeFlags = [.valid , .hasBeenRounded]
|
||||
@@ -178,11 +178,11 @@ let audioComponentFlags2: FakeAudioComponentFlags = [.loadOutOfProcess]
|
||||
|
||||
let objcFlags: objc_flags = [.taggedPointer, .swiftRefcount]
|
||||
|
||||
let optionsWithSwiftName: OptionsAlsoGetSwiftName = .Case
|
||||
let optionsWithSwiftName: NSOptionsAlsoGetSwiftName = .Case
|
||||
|
||||
// <rdar://problem/25168818> Don't import None members in NS_OPTIONS types
|
||||
#if !IRGEN
|
||||
let _ = RuncingOptions.none // expected-error {{'none' is unavailable: use [] to construct an empty option set}}
|
||||
let _ = NSRuncingOptions.none // expected-error {{'none' is unavailable: use [] to construct an empty option set}}
|
||||
#endif
|
||||
// ...but do if they have a custom name
|
||||
_ = EmptySet1.default
|
||||
|
||||
@@ -21,8 +21,8 @@ class Base : NSObject {
|
||||
return nil
|
||||
}
|
||||
class func testInout(_: inout Refrigerator) {} // expected-note {{potential overridden class method 'testInout' here}}
|
||||
func testUnmigrated(a: RuncingMode, b: Refrigerator, c: NSCoding) {} // expected-note {{potential overridden instance method 'testUnmigrated(a:b:c:)' here}}
|
||||
func testPartialMigrated(a: RuncingMode, b: Refrigerator) {} // expected-note {{potential overridden instance method 'testPartialMigrated(a:b:)' here}}
|
||||
func testUnmigrated(a: NSRuncingMode, b: Refrigerator, c: NSCoding) {} // expected-note {{potential overridden instance method 'testUnmigrated(a:b:c:)' here}}
|
||||
func testPartialMigrated(a: NSRuncingMode, b: Refrigerator) {} // expected-note {{potential overridden instance method 'testPartialMigrated(a:b:)' here}}
|
||||
|
||||
subscript(a a: Refrigerator, b b: Refrigerator) -> Refrigerator? { // expected-note {{potential overridden subscript 'subscript(a:b:)' here}} {{none}}
|
||||
return nil
|
||||
@@ -55,7 +55,7 @@ class Sub : Base {
|
||||
|
||||
override func testUnmigrated(a: NSObject, b: NSObject, c: NSObject) {} // expected-error {{method does not override any method from its superclass}} {{none}}
|
||||
|
||||
// expected-note@+1 {{type does not match superclass instance method with type '(RuncingMode, Refrigerator) -> ()'}} {{53-68=Refrigerator}}
|
||||
// expected-note@+1 {{type does not match superclass instance method with type '(NSRuncingMode, Refrigerator) -> ()'}} {{53-68=Refrigerator}}
|
||||
override func testPartialMigrated(a: NSObject, b: APPRefrigerator) {} // expected-error {{method does not override any method from its superclass}} {{none}}
|
||||
|
||||
// expected-note@+1 {{type does not match superclass subscript with type '(Refrigerator, Refrigerator) -> Refrigerator?'}} {{27-42=Refrigerator}} {{49-65=Refrigerator?}} {{70-85=Refrigerator}}
|
||||
@@ -90,8 +90,8 @@ protocol TestProto {
|
||||
func test(a: Refrigerator, b: Refrigerator) -> Refrigerator? // expected-note {{protocol requires}}
|
||||
func testGeneric(a: ManufacturerInfo<NSString>, b: ManufacturerInfo<NSString>) -> ManufacturerInfo<NSString>? // expected-note {{protocol requires}}
|
||||
static func testInout(_: inout Refrigerator) // expected-note {{protocol requires}}
|
||||
func testUnmigrated(a: RuncingMode, b: Refrigerator, c: NSCoding) // expected-note {{protocol requires}}
|
||||
func testPartialMigrated(a: RuncingMode, b: Refrigerator) // expected-note {{protocol requires}}
|
||||
func testUnmigrated(a: NSRuncingMode, b: Refrigerator, c: NSCoding) // expected-note {{protocol requires}}
|
||||
func testPartialMigrated(a: NSRuncingMode, b: Refrigerator) // expected-note {{protocol requires}}
|
||||
|
||||
subscript(a a: Refrigerator, b b: Refrigerator) -> Refrigerator? { get } // expected-note {{protocol requires}}
|
||||
subscript(generic a: ManufacturerInfo<NSString>, b b: ManufacturerInfo<NSString>) -> ManufacturerInfo<NSString>? { get } // expected-note {{protocol requires}}
|
||||
@@ -152,8 +152,8 @@ class TestProtoImpl : NSObject, TestProto { // expected-error {{type 'TestProtoI
|
||||
@objc protocol TestObjCProto {
|
||||
@objc optional func test(a: Refrigerator, b: Refrigerator) -> Refrigerator? // expected-note {{here}} {{none}}
|
||||
@objc optional func testGeneric(a: ManufacturerInfo<NSString>, b: ManufacturerInfo<NSString>) -> ManufacturerInfo<NSString>? // expected-note {{here}} {{none}}
|
||||
@objc optional func testUnmigrated(a: RuncingMode, b: Refrigerator, c: NSCoding) // expected-note {{here}} {{none}}
|
||||
@objc optional func testPartialMigrated(a: RuncingMode, b: Refrigerator) // expected-note {{here}} {{none}}
|
||||
@objc optional func testUnmigrated(a: NSRuncingMode, b: Refrigerator, c: NSCoding) // expected-note {{here}} {{none}}
|
||||
@objc optional func testPartialMigrated(a: NSRuncingMode, b: Refrigerator) // expected-note {{here}} {{none}}
|
||||
|
||||
@objc optional subscript(a a: Refrigerator) -> Refrigerator? { get } // expected-note {{here}} {{none}}
|
||||
@objc optional subscript(generic a: ManufacturerInfo<NSString>) -> ManufacturerInfo<NSString>? { get } // expected-note {{here}} {{none}}
|
||||
|
||||
@@ -6,7 +6,7 @@ import Foundation
|
||||
func assertTypeIsAny(_: Any.Protocol) {}
|
||||
func staticType<T>(_: T) -> T.Type { return T.self }
|
||||
|
||||
let idLover = IdLover()
|
||||
let idLover = NSIdLover()
|
||||
|
||||
let t1 = staticType(idLover.makesId())
|
||||
assertTypeIsAny(t1)
|
||||
|
||||
@@ -262,25 +262,25 @@ func classAnyObject(_ obj: NSObject) {
|
||||
}
|
||||
|
||||
// Protocol conformances
|
||||
class Wobbler : Wobbling { // expected-note{{candidate has non-matching type '()'}}
|
||||
class Wobbler : NSWobbling { // expected-note{{candidate has non-matching type '()'}}
|
||||
@objc func wobble() { }
|
||||
|
||||
func returnMyself() -> Self { return self } // expected-error{{non-'@objc' method 'returnMyself()' does not satisfy requirement of '@objc' protocol 'Wobbling'}}{{none}}
|
||||
func returnMyself() -> Self { return self } // expected-error{{non-'@objc' method 'returnMyself()' does not satisfy requirement of '@objc' protocol 'NSWobbling'}}{{none}}
|
||||
// expected-error@-1{{method cannot be an implementation of an @objc requirement because its result type cannot be represented in Objective-C}}
|
||||
}
|
||||
|
||||
extension Wobbler : MaybeInitWobble { // expected-error{{type 'Wobbler' does not conform to protocol 'MaybeInitWobble'}}
|
||||
extension Wobbler : NSMaybeInitWobble { // expected-error{{type 'Wobbler' does not conform to protocol 'NSMaybeInitWobble'}}
|
||||
}
|
||||
|
||||
@objc class Wobbler2 : NSObject, Wobbling { // expected-note{{candidate has non-matching type '()'}}
|
||||
@objc class Wobbler2 : NSObject, NSWobbling { // expected-note{{candidate has non-matching type '()'}}
|
||||
func wobble() { }
|
||||
func returnMyself() -> Self { return self }
|
||||
}
|
||||
|
||||
extension Wobbler2 : MaybeInitWobble { // expected-error{{type 'Wobbler2' does not conform to protocol 'MaybeInitWobble'}}
|
||||
extension Wobbler2 : NSMaybeInitWobble { // expected-error{{type 'Wobbler2' does not conform to protocol 'NSMaybeInitWobble'}}
|
||||
}
|
||||
|
||||
func optionalMemberAccess(_ w: Wobbling) {
|
||||
func optionalMemberAccess(_ w: NSWobbling) {
|
||||
w.wobble()
|
||||
w.wibble() // expected-error{{value of optional type '(() -> Void)?' not unwrapped; did you mean to use '!' or '?'?}} {{11-11=!}}
|
||||
let x = w[5]!!
|
||||
@@ -315,7 +315,7 @@ func customAccessors(_ hive: Hive, bee: Bee) {
|
||||
}
|
||||
|
||||
// instancetype/Dynamic Self invocation.
|
||||
func testDynamicSelf(_ queen: Bee, wobbler: Wobbling) {
|
||||
func testDynamicSelf(_ queen: Bee, wobbler: NSWobbling) {
|
||||
var hive = Hive()
|
||||
|
||||
// Factory method with instancetype result.
|
||||
@@ -330,7 +330,7 @@ func testDynamicSelf(_ queen: Bee, wobbler: Wobbling) {
|
||||
|
||||
// Instance method on a protocol with instancetype result.
|
||||
var wobbler2 = wobbler.returnMyself()!
|
||||
var wobbler: Wobbling = wobbler2
|
||||
var wobbler: NSWobbling = wobbler2
|
||||
wobbler2 = wobbler
|
||||
|
||||
// Instance method on a base class with instancetype result, called on the
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk -I %S/../IDE/Inputs/custom-modules) -emit-sil -I %S/Inputs/custom-modules -enable-strip-ns-prefix %s -verify
|
||||
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk -I %S/../IDE/Inputs/custom-modules) -emit-sil -I %S/Inputs/custom-modules %s -verify
|
||||
|
||||
// REQUIRES: objc_interop
|
||||
|
||||
@@ -13,7 +13,7 @@ func testOldTypeNames() {
|
||||
|
||||
_ = NSPostingStyle(rawValue: 1) // expected-error{{'NSPostingStyle' has been renamed to 'NotificationQueue.PostingStyle'}}{{7-21=NotificationQueue.PostingStyle}}
|
||||
|
||||
_ = NSSoapDispenser<AnyObject>() // expected-error{{'NSSoapDispenser' has been renamed to 'SoapDispenser'}}{{7-22=SoapDispenser}}
|
||||
_ = NSOperation() // expected-error{{'NSOperation' has been renamed to 'Operation'}}{{7-18=Operation}}
|
||||
}
|
||||
|
||||
func testOldMethodNames(array: NSArray) {
|
||||
@@ -42,13 +42,13 @@ func testOldEnumCaseNames(i: Int) -> XMLNode.Kind {
|
||||
}
|
||||
}
|
||||
|
||||
func testOldOptionCaseNames(i: Int) -> RuncingOptions {
|
||||
func testOldOptionCaseNames(i: Int) -> NSRuncingOptions {
|
||||
switch i {
|
||||
case 0:
|
||||
return .EnableQuince // expected-error{{'EnableQuince' has been renamed to 'enableQuince'}}{{13-25=enableQuince}}
|
||||
|
||||
case 1:
|
||||
return RuncingOptions.EnableMince // expected-error{{'EnableMince' has been renamed to 'enableMince'}}{{27-38=enableMince}}
|
||||
return NSRuncingOptions.EnableMince // expected-error{{'EnableMince' has been renamed to 'enableMince'}}{{29-40=enableMince}}
|
||||
|
||||
default:
|
||||
return .enableQuince
|
||||
@@ -96,9 +96,9 @@ class X : NSDocument {
|
||||
}
|
||||
}
|
||||
|
||||
func makeCopy<T: NSWobbling>(thing: T) {} // expected-error {{'NSWobbling' has been renamed to 'Wobbling'}} {{18-28=Wobbling}}
|
||||
func makeProgress<T: NSProgressReporting>(thing: T) {} // expected-error {{'NSProgressReporting' has been renamed to 'ProgressReporting'}} {{22-41=ProgressReporting}}
|
||||
|
||||
func useLowercasedEnumCase(x: RuncingMode) {
|
||||
func useLowercasedEnumCase(x: NSRuncingMode) {
|
||||
switch x {
|
||||
case .Mince: return // expected-error {{'Mince' has been renamed to 'mince'}} {{11-16=mince}}
|
||||
case .Quince: return // expected-error {{'Quince' has been renamed to 'quince'}} {{11-17=quince}}
|
||||
|
||||
@@ -5,6 +5,6 @@ import Foundation
|
||||
|
||||
class RV {
|
||||
init() {
|
||||
PrefixWordBreak2.breakBarBas.rawValue = 0 // expected-error{{cannot assign to property: 'rawValue' is immutable}}
|
||||
NSPrefixWordBreak2.breakBarBas.rawValue = 0 // expected-error{{cannot assign to property: 'rawValue' is immutable}}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
// RUN: %target-swift-ide-test -dump-importer-lookup-table -source-filename %s -import-objc-header %S/Inputs/swift_name_objc.h > %t.log 2>&1
|
||||
// RUN: FileCheck %s < %t.log
|
||||
|
||||
// RUN: %target-swift-ide-test -dump-importer-lookup-table -source-filename %s -import-objc-header %S/Inputs/swift_name_objc.h -enable-strip-ns-prefix > %t-omit-needless-words.log 2>&1
|
||||
// RUN: FileCheck -check-prefix=CHECK-OMIT-NEEDLESS-WORDS %s < %t-omit-needless-words.log
|
||||
|
||||
// REQUIRES: objc_interop
|
||||
// REQUIRES: OS=macosx
|
||||
|
||||
// CHECK-LABEL: <<Foundation lookup table>>
|
||||
// CHECK: NSTimeIntervalSince1970:
|
||||
// CHECK: TU: Macro
|
||||
// CHECK-NEXT: TU: Macro
|
||||
// CHECK: Categories:{{.*}}NSValue(NSValueCreation){{.*}}
|
||||
|
||||
// CHECK-LABEL: <<ObjectiveC lookup table>>
|
||||
@@ -19,6 +16,8 @@
|
||||
// CHECK-NEXT: TU: NSObject
|
||||
// CHECK-NEXT: NSObjectProtocol:
|
||||
// CHECK-NEXT: TU: NSObject
|
||||
// CHECK: responds:
|
||||
// CHECK-NEXT: -[NSObject respondsToSelector:]
|
||||
|
||||
// CHECK-LABEL: <<Bridging header lookup table>>
|
||||
// CHECK-NEXT: Base name -> entry mappings:
|
||||
@@ -88,16 +87,3 @@
|
||||
// CHECK-NEXT: SNSomeClass: -[SNSomeClass objectAtIndexedSubscript:]
|
||||
|
||||
// CHECK: Categories: SNSomeClass(), SNSomeClass(Category1)
|
||||
|
||||
// CHECK-OMIT-NEEDLESS-WORDS-LABEL: <<Foundation lookup table>>
|
||||
// CHECK-OMIT-NEEDLESS-WORDS: timeIntervalSince1970:
|
||||
// CHECK-OMIT-NEEDLESS-WORDS: TU: Macro
|
||||
|
||||
// CHECK-OMIT-NEEDLESS-WORDS: <<ObjectiveC lookup table>>
|
||||
// CHECK-OMIT-NEEDLESS-WORDS-NOT: lookup table
|
||||
// CHECK-OMIT-NEEDLESS-WORDS: responds:
|
||||
// CHECK-OMIT-NEEDLESS-WORDS-NEXT: -[NSObject respondsToSelector:]
|
||||
|
||||
// CHECK-OMIT-NEEDLESS-WORDS: Base name -> entry mappings:
|
||||
// CHECK-OMIT-NEEDLESS-WORDS: method:
|
||||
// CHECK-OMIT-NEEDLESS-WORDS: NSErrorImports: {{.*}}-[NSErrorImports methodWithFloat:error:]
|
||||
|
||||
@@ -23,5 +23,5 @@
|
||||
// CHECK-DAG: func copy() -> Any
|
||||
// CHECK-DAG: class func hash() -> Int
|
||||
// CHECK-WITH-FORWARD-DECLS-DAG: class func description() -> String
|
||||
// CHECK-WITH-FORWARD-DECLS-DAG: func forwardInvocation(_ anInvocation: Invocation!)
|
||||
// CHECK-WITH-FORWARD-DECLS-DAG: func forwardInvocation(_ anInvocation: NSInvocation!)
|
||||
// CHECK: {{^[}]$}}
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
// FOUNDATION-NEXT: subscript(idx: Int) -> Any { get }
|
||||
|
||||
// FOUNDATION-LABEL: {{^}}/// Aaa. NSRuncingMode. Bbb.{{$}}
|
||||
// FOUNDATION-NEXT: {{^}}enum RuncingMode : UInt {{{$}}
|
||||
// FOUNDATION-NEXT: {{^}}enum NSRuncingMode : UInt {{{$}}
|
||||
// FOUNDATION-NEXT: {{^}} init?(rawValue: UInt){{$}}
|
||||
// FOUNDATION-NEXT: {{^}} var rawValue: UInt { get }{{$}}
|
||||
// FOUNDATION-NEXT: {{^}} case mince{{$}}
|
||||
@@ -97,13 +97,13 @@
|
||||
// FOUNDATION-NEXT: {{^}}}{{$}}
|
||||
|
||||
// FOUNDATION-LABEL: {{^}}/// Aaa. NSRuncingOptions. Bbb.{{$}}
|
||||
// FOUNDATION-NEXT: {{^}}struct RuncingOptions : OptionSet {{{$}}
|
||||
// FOUNDATION-NEXT: {{^}}struct NSRuncingOptions : OptionSet {{{$}}
|
||||
// FOUNDATION-NEXT: {{^}} init(rawValue: UInt){{$}}
|
||||
// FOUNDATION-NEXT: {{^}} let rawValue: UInt{{$}}
|
||||
// FOUNDATION-NEXT: {{^}} @available(*, unavailable, message: "use [] to construct an empty option set"){{$}}
|
||||
// FOUNDATION-NEXT: {{^}} static var none: RuncingOptions { get }{{$}}
|
||||
// FOUNDATION-NEXT: {{^}} static var enableMince: RuncingOptions { get }{{$}}
|
||||
// FOUNDATION-NEXT: {{^}} static var enableQuince: RuncingOptions { get }{{$}}
|
||||
// FOUNDATION-NEXT: {{^}} static var none: NSRuncingOptions { get }{{$}}
|
||||
// FOUNDATION-NEXT: {{^}} static var enableMince: NSRuncingOptions { get }{{$}}
|
||||
// FOUNDATION-NEXT: {{^}} static var enableQuince: NSRuncingOptions { get }{{$}}
|
||||
// FOUNDATION-NEXT: {{^}}}{{$}}
|
||||
|
||||
// FOUNDATION-LABEL: {{^}}/// Unavailable Global Functions{{$}}
|
||||
|
||||
@@ -5,30 +5,30 @@
|
||||
// FIXME: this is failing on simulators
|
||||
// REQUIRES: OS=macosx
|
||||
|
||||
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-module -o %t -enable-strip-ns-prefix %S/../Inputs/clang-importer-sdk/swift-modules-without-ns/ObjectiveC.swift
|
||||
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-module -o %t -enable-strip-ns-prefix %S/../Inputs/clang-importer-sdk/swift-modules-without-ns/CoreGraphics.swift
|
||||
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-module -o %t -enable-strip-ns-prefix %S/../Inputs/clang-importer-sdk/swift-modules-without-ns/Foundation.swift
|
||||
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-module -o %t %S/../Inputs/clang-importer-sdk/swift-modules-without-ns/ObjectiveC.swift
|
||||
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-module -o %t %S/../Inputs/clang-importer-sdk/swift-modules-without-ns/CoreGraphics.swift
|
||||
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-module -o %t %S/../Inputs/clang-importer-sdk/swift-modules-without-ns/Foundation.swift
|
||||
|
||||
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-module -o %t -enable-strip-ns-prefix %S/../Inputs/clang-importer-sdk/swift-modules-without-ns/AppKit.swift
|
||||
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-module -o %t %S/../Inputs/clang-importer-sdk/swift-modules-without-ns/AppKit.swift
|
||||
|
||||
// RUN: %target-swift-ide-test(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -print-module -source-filename %s -module-to-print=ObjectiveC -function-definitions=false -prefer-type-repr=true -enable-strip-ns-prefix > %t.ObjectiveC.txt
|
||||
// RUN: %target-swift-ide-test(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -print-module -source-filename %s -module-to-print=ObjectiveC -function-definitions=false -prefer-type-repr=true > %t.ObjectiveC.txt
|
||||
// RUN: FileCheck %s -check-prefix=CHECK-OBJECTIVEC -strict-whitespace < %t.ObjectiveC.txt
|
||||
|
||||
// RUN: %target-swift-ide-test(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -print-module -source-filename %s -module-to-print=Foundation -function-definitions=false -prefer-type-repr=true -enable-strip-ns-prefix -skip-parameter-names > %t.Foundation.txt
|
||||
// RUN: %target-swift-ide-test(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -print-module -source-filename %s -module-to-print=Foundation -function-definitions=false -prefer-type-repr=true -skip-parameter-names > %t.Foundation.txt
|
||||
// RUN: FileCheck %s -check-prefix=CHECK-FOUNDATION -strict-whitespace < %t.Foundation.txt
|
||||
|
||||
// RUN: %target-swift-ide-test(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -print-module -source-filename %s -module-to-print=AppKit -function-definitions=false -prefer-type-repr=true -enable-strip-ns-prefix -skip-parameter-names > %t.AppKit.txt
|
||||
// RUN: %target-swift-ide-test(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -print-module -source-filename %s -module-to-print=AppKit -function-definitions=false -prefer-type-repr=true -skip-parameter-names > %t.AppKit.txt
|
||||
// RUN: FileCheck %s -check-prefix=CHECK-APPKIT -strict-whitespace < %t.AppKit.txt
|
||||
|
||||
// RUN: %target-swift-ide-test(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t -I %S/../ClangModules/Inputs/custom-modules) -print-module -source-filename %s -module-to-print=CoreCooling -function-definitions=false -prefer-type-repr=true -enable-strip-ns-prefix -skip-parameter-names > %t.CoreCooling.txt
|
||||
// RUN: %target-swift-ide-test(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t -I %S/../ClangModules/Inputs/custom-modules) -print-module -source-filename %s -module-to-print=CoreCooling -function-definitions=false -prefer-type-repr=true -skip-parameter-names > %t.CoreCooling.txt
|
||||
// RUN: FileCheck %s -check-prefix=CHECK-CORECOOLING -strict-whitespace < %t.CoreCooling.txt
|
||||
|
||||
// RUN: %target-swift-ide-test(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t -I %S/Inputs/custom-modules) -print-module -source-filename %s -module-to-print=OmitNeedlessWords -function-definitions=false -prefer-type-repr=true -enable-strip-ns-prefix -skip-parameter-names > %t.OmitNeedlessWords.txt 2> %t.OmitNeedlessWords.diagnostics.txt
|
||||
// RUN: %target-swift-ide-test(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t -I %S/Inputs/custom-modules) -print-module -source-filename %s -module-to-print=OmitNeedlessWords -function-definitions=false -prefer-type-repr=true -skip-parameter-names > %t.OmitNeedlessWords.txt 2> %t.OmitNeedlessWords.diagnostics.txt
|
||||
// RUN: FileCheck %s -check-prefix=CHECK-OMIT-NEEDLESS-WORDS -strict-whitespace < %t.OmitNeedlessWords.txt
|
||||
// RUN: FileCheck %s -check-prefix=CHECK-OMIT-NEEDLESS-WORDS-DIAGS -strict-whitespace < %t.OmitNeedlessWords.diagnostics.txt
|
||||
|
||||
|
||||
// RUN: %target-swift-ide-test(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -print-module -source-filename %s -module-to-print=errors -function-definitions=false -prefer-type-repr=true -enable-strip-ns-prefix -skip-parameter-names > %t.errors.txt
|
||||
// RUN: %target-swift-ide-test(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -print-module -source-filename %s -module-to-print=errors -function-definitions=false -prefer-type-repr=true -skip-parameter-names > %t.errors.txt
|
||||
// RUN: FileCheck %s -check-prefix=CHECK-ERRORS -strict-whitespace < %t.errors.txt
|
||||
|
||||
// Note: SEL -> "Selector"
|
||||
@@ -80,7 +80,7 @@
|
||||
// CHECK-FOUNDATION: var isMakingHoney: Bool
|
||||
|
||||
// Note: multi-word enum name matching; "with" splits the first piece.
|
||||
// CHECK-FOUNDATION: func someMethod(deprecatedOptions: DeprecatedOptions = [])
|
||||
// CHECK-FOUNDATION: func someMethod(deprecatedOptions: NSDeprecatedOptions = [])
|
||||
|
||||
// Note: class name matching; don't drop "With".
|
||||
// CHECK-FOUNDATION: class func withString(_: String!) -> Self!
|
||||
@@ -131,13 +131,13 @@
|
||||
// CHECK-FOUNDATION: var withHTTPS: NSURL { get }
|
||||
|
||||
// Note: lowercasing option set values
|
||||
// CHECK-FOUNDATION: struct EnumerationOptions
|
||||
// CHECK-FOUNDATION: static var concurrent: EnumerationOptions
|
||||
// CHECK-FOUNDATION: static var reverse: EnumerationOptions
|
||||
// CHECK-FOUNDATION: struct NSEnumerationOptions
|
||||
// CHECK-FOUNDATION: static var concurrent: NSEnumerationOptions
|
||||
// CHECK-FOUNDATION: static var reverse: NSEnumerationOptions
|
||||
|
||||
// Note: usingBlock -> body
|
||||
// CHECK-FOUNDATION: func enumerateObjects(_: (@escaping (Any?, Int, UnsafeMutablePointer<ObjCBool>?) -> Void)!)
|
||||
// CHECK-FOUNDATION: func enumerateObjects(options: EnumerationOptions = [], using: (@escaping (Any?, Int, UnsafeMutablePointer<ObjCBool>?) -> Void)!)
|
||||
// CHECK-FOUNDATION: func enumerateObjects(options: NSEnumerationOptions = [], using: (@escaping (Any?, Int, UnsafeMutablePointer<ObjCBool>?) -> Void)!)
|
||||
|
||||
// Note: WithBlock -> body, nullable closures default to nil.
|
||||
// CHECK-FOUNDATION: func enumerateObjectsRandomly(block: (@escaping (Any?, Int, UnsafeMutablePointer<ObjCBool>?) -> Void)? = nil)
|
||||
@@ -155,10 +155,10 @@
|
||||
// CHECK-FOUNDATION: func remove(_: [Any])
|
||||
|
||||
// Note: Skipping "Type" suffix.
|
||||
// CHECK-FOUNDATION: func doSomething(with: UnderlyingType)
|
||||
// CHECK-FOUNDATION: func doSomething(with: NSUnderlyingType)
|
||||
|
||||
// Don't introduce default arguments for lone parameters to setters.
|
||||
// CHECK-FOUNDATION: func setDefaultEnumerationOptions(_: EnumerationOptions)
|
||||
// CHECK-FOUNDATION: func setDefaultEnumerationOptions(_: NSEnumerationOptions)
|
||||
|
||||
// CHECK-FOUNDATION: func normalizingXMLPreservingComments(_: Bool)
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import Foundation
|
||||
@objc protocol P { }
|
||||
@objc protocol Q { }
|
||||
|
||||
class Foo: ManagedObject {
|
||||
class Foo: NSManagedObject {
|
||||
// -- POD types:
|
||||
|
||||
// nonatomic, readonly, ivar b
|
||||
|
||||
@@ -1030,8 +1030,14 @@ extern NSString *NSHTTPRequestKey;
|
||||
-(void)messageSomeObject:(nonnull id)object selector:(SEL)selector;
|
||||
@end
|
||||
|
||||
@interface NSSoapDispenser<Fragrance> : NSObject
|
||||
@interface NSOperation : NSObject
|
||||
@end
|
||||
|
||||
@interface NSProgress : NSObject
|
||||
@end
|
||||
|
||||
@protocol NSProgressReporting <NSObject>
|
||||
@property (readonly) NSProgress *progress;
|
||||
@end
|
||||
|
||||
@interface NSIdLover: NSObject
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
let opts: BinarySearchingOptions = [.firstEqual, .insertionIndex]
|
||||
let opts: NSBinarySearchingOptions = [.firstEqual, .insertionIndex]
|
||||
|
||||
// CHECK: true
|
||||
print(opts.intersection([.lastEqual, .insertionIndex]) == .insertionIndex)
|
||||
@@ -13,4 +13,4 @@ print(opts.intersection([.lastEqual, .insertionIndex]) == .insertionIndex)
|
||||
print(!opts.intersection(.lastEqual).isEmpty)
|
||||
|
||||
// CHECK: {{^}}0 0{{$}}
|
||||
print("\(([] as BinarySearchingOptions).rawValue) \(BinarySearchingOptions(rawValue: 0).rawValue)")
|
||||
print("\(([] as NSBinarySearchingOptions).rawValue) \(NSBinarySearchingOptions(rawValue: 0).rawValue)")
|
||||
|
||||
@@ -283,7 +283,7 @@ typealias AliasForNSRect = NSRect
|
||||
func emptyArray() -> NSArray { return NSArray() }
|
||||
func maybeArray() -> NSArray? { return nil }
|
||||
|
||||
func someEnum() -> RuncingMode { return .mince }
|
||||
func someEnum() -> NSRuncingMode { return .mince }
|
||||
func protocolClass() -> NSCoding.Type? { return nil }
|
||||
|
||||
func zone() -> NSZone? { return nil }
|
||||
|
||||
@@ -26,7 +26,7 @@ import Foundation
|
||||
@objc func takeAndReturnEnum(_ foo: FooComments) -> NegativeValues {
|
||||
return .Zung
|
||||
}
|
||||
@objc func acceptPlainEnum(_: MalformedEnumMissingTypedef) {}
|
||||
@objc func acceptPlainEnum(_: NSMalformedEnumMissingTypedef) {}
|
||||
@objc func takeAndReturnRenamedEnum(_ foo: EnumNamed) -> EnumNamed {
|
||||
return .A
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ class Test: NSObject {
|
||||
// CHECK: [[RESULT:%.*]] = apply {{%.*}}([[CLOSURE]])
|
||||
// CHECK: return [[RESULT]]
|
||||
|
||||
func clearDraggingItemImageComponentsProvider(_ x: DraggingItem) {
|
||||
func clearDraggingItemImageComponentsProvider(_ x: NSDraggingItem) {
|
||||
x.imageComponentsProvider = {}
|
||||
}
|
||||
// CHECK-LABEL: sil shared [transparent] [reabstraction_thunk] @_TTRXFo__oGSaP___XFdCb__aGSqCSo7NSArray__
|
||||
|
||||
@@ -9,7 +9,7 @@ protocol CP: class {}
|
||||
struct KnownUnbridged {}
|
||||
|
||||
// CHECK-LABEL: sil hidden @_TF17objc_bridging_any11passingToId
|
||||
func passingToId<T: CP, U>(receiver: IdLover,
|
||||
func passingToId<T: CP, U>(receiver: NSIdLover,
|
||||
string: String,
|
||||
nsString: NSString,
|
||||
object: AnyObject,
|
||||
@@ -22,7 +22,7 @@ func passingToId<T: CP, U>(receiver: IdLover,
|
||||
optionalA: String?,
|
||||
optionalB: NSString?,
|
||||
optionalC: Any?) {
|
||||
// CHECK: bb0([[SELF:%.*]] : $IdLover,
|
||||
// CHECK: bb0([[SELF:%.*]] : $NSIdLover,
|
||||
// CHECK: [[STRING:%.*]] : $String
|
||||
// CHECK: [[NSSTRING:%.*]] : $NSString
|
||||
// CHECK: [[OBJECT:%.*]] : $AnyObject
|
||||
@@ -43,21 +43,21 @@ func passingToId<T: CP, U>(receiver: IdLover,
|
||||
// CHECK: apply [[METHOD]]([[ANYOBJECT]], [[SELF]])
|
||||
receiver.takesId(string)
|
||||
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $IdLover,
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $NSIdLover,
|
||||
// CHECK: [[ANYOBJECT:%.*]] = init_existential_ref [[NSSTRING]] : $NSString : $NSString, $AnyObject
|
||||
// CHECK: apply [[METHOD]]([[ANYOBJECT]], [[SELF]])
|
||||
receiver.takesId(nsString)
|
||||
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $IdLover,
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $NSIdLover,
|
||||
// CHECK: [[ANYOBJECT:%.*]] = init_existential_ref [[CLASS_GENERIC]] : $T : $T, $AnyObject
|
||||
// CHECK: apply [[METHOD]]([[ANYOBJECT]], [[SELF]])
|
||||
receiver.takesId(classGeneric)
|
||||
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $IdLover,
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $NSIdLover,
|
||||
// CHECK: apply [[METHOD]]([[OBJECT]], [[SELF]])
|
||||
receiver.takesId(object)
|
||||
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $IdLover,
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $NSIdLover,
|
||||
// CHECK: [[OPENED:%.*]] = open_existential_ref [[CLASS_EXISTENTIAL]] : $CP
|
||||
// CHECK: [[ANYOBJECT:%.*]] = init_existential_ref [[OPENED]]
|
||||
// CHECK: apply [[METHOD]]([[ANYOBJECT]], [[SELF]])
|
||||
@@ -65,7 +65,7 @@ func passingToId<T: CP, U>(receiver: IdLover,
|
||||
|
||||
// These cases perform a universal bridging conversion.
|
||||
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $IdLover,
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $NSIdLover,
|
||||
// CHECK-NEXT: [[COPY:%.*]] = alloc_stack $U
|
||||
// CHECK-NEXT: copy_addr [[GENERIC]] to [initialization] [[COPY]]
|
||||
// CHECK-NEXT: // function_ref _bridgeAnythingToObjectiveC
|
||||
@@ -76,7 +76,7 @@ func passingToId<T: CP, U>(receiver: IdLover,
|
||||
// CHECK-NEXT: dealloc_stack [[COPY]]
|
||||
receiver.takesId(generic)
|
||||
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $IdLover,
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $NSIdLover,
|
||||
// CHECK-NEXT: [[COPY:%.*]] = alloc_stack $P
|
||||
// CHECK-NEXT: copy_addr [[EXISTENTIAL]] to [initialization] [[COPY]]
|
||||
// CHECK-NEXT: [[OPENED_COPY:%.*]] = open_existential_addr [[COPY]] : $*P to $*[[OPENED_TYPE:@opened.*P]],
|
||||
@@ -89,7 +89,7 @@ func passingToId<T: CP, U>(receiver: IdLover,
|
||||
// CHECK-NEXT: dealloc_stack [[COPY]]
|
||||
receiver.takesId(existential)
|
||||
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $IdLover,
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $NSIdLover,
|
||||
// CHECK-NEXT: [[COPY:%.*]] = alloc_stack $Any
|
||||
// CHECK-NEXT: copy_addr [[ANY]] to [initialization] [[COPY]]
|
||||
// CHECK-NEXT: [[OPENED_COPY:%.*]] = open_existential_addr [[COPY]] : $*Any to $*[[OPENED_TYPE:@opened.*Any]],
|
||||
@@ -102,7 +102,7 @@ func passingToId<T: CP, U>(receiver: IdLover,
|
||||
// CHECK-NEXT: dealloc_stack [[COPY]]
|
||||
receiver.takesId(any)
|
||||
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $IdLover,
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $NSIdLover,
|
||||
// CHECK: [[TMP:%.*]] = alloc_stack $KnownUnbridged
|
||||
// CHECK: store [[KNOWN_UNBRIDGED]] to [[TMP]]
|
||||
// CHECK: [[BRIDGE_ANYTHING:%.*]] = function_ref @_TFs27_bridgeAnythingToObjectiveC
|
||||
@@ -110,7 +110,7 @@ func passingToId<T: CP, U>(receiver: IdLover,
|
||||
// CHECK: apply [[METHOD]]([[ANYOBJECT]], [[SELF]])
|
||||
receiver.takesId(knownUnbridged)
|
||||
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $IdLover,
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $NSIdLover,
|
||||
// CHECK: [[TMP:%.*]] = alloc_stack $Optional<String>
|
||||
// CHECK: store [[OPT_STRING]] to [[TMP]]
|
||||
// CHECK: [[BRIDGE_ANYTHING:%.*]] = function_ref @_TFs27_bridgeAnythingToObjectiveC
|
||||
@@ -118,7 +118,7 @@ func passingToId<T: CP, U>(receiver: IdLover,
|
||||
// CHECK: apply [[METHOD]]([[ANYOBJECT]], [[SELF]])
|
||||
receiver.takesId(optionalA)
|
||||
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $IdLover,
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $NSIdLover,
|
||||
// CHECK: [[TMP:%.*]] = alloc_stack $Optional<NSString>
|
||||
// CHECK: store [[OPT_NSSTRING]] to [[TMP]]
|
||||
// CHECK: [[BRIDGE_ANYTHING:%.*]] = function_ref @_TFs27_bridgeAnythingToObjectiveC
|
||||
@@ -126,7 +126,7 @@ func passingToId<T: CP, U>(receiver: IdLover,
|
||||
// CHECK: apply [[METHOD]]([[ANYOBJECT]], [[SELF]])
|
||||
receiver.takesId(optionalB)
|
||||
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $IdLover,
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $NSIdLover,
|
||||
// CHECK: [[TMP:%.*]] = alloc_stack $Optional<Any>
|
||||
// CHECK: copy_addr [[OPT_ANY]] to [initialization] [[TMP]]
|
||||
// CHECK: [[BRIDGE_ANYTHING:%.*]] = function_ref @_TFs27_bridgeAnythingToObjectiveC
|
||||
@@ -138,7 +138,7 @@ func passingToId<T: CP, U>(receiver: IdLover,
|
||||
}
|
||||
|
||||
// CHECK-LABEL: sil hidden @_TF17objc_bridging_any19passingToNullableId
|
||||
func passingToNullableId<T: CP, U>(receiver: IdLover,
|
||||
func passingToNullableId<T: CP, U>(receiver: NSIdLover,
|
||||
string: String,
|
||||
nsString: NSString,
|
||||
object: AnyObject,
|
||||
@@ -161,7 +161,7 @@ func passingToNullableId<T: CP, U>(receiver: IdLover,
|
||||
optOptB: NSString??,
|
||||
optOptC: Any??)
|
||||
{
|
||||
// CHECK: bb0([[SELF:%.*]] : $IdLover,
|
||||
// CHECK: bb0([[SELF:%.*]] : $NSIdLover,
|
||||
// CHECK: [[STRING:%.*]] : $String,
|
||||
// CHECK: [[NSSTRING:%.*]] : $NSString
|
||||
// CHECK: [[OBJECT:%.*]] : $AnyObject
|
||||
@@ -192,31 +192,31 @@ func passingToNullableId<T: CP, U>(receiver: IdLover,
|
||||
// CHECK: apply [[METHOD]]([[OPT_ANYOBJECT]], [[SELF]])
|
||||
receiver.takesNullableId(string)
|
||||
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $IdLover,
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $NSIdLover,
|
||||
// CHECK: [[ANYOBJECT:%.*]] = init_existential_ref [[NSSTRING]] : $NSString : $NSString, $AnyObject
|
||||
// CHECK: [[OPT_ANYOBJECT:%.*]] = enum {{.*}} [[ANYOBJECT]]
|
||||
// CHECK: apply [[METHOD]]([[OPT_ANYOBJECT]], [[SELF]])
|
||||
receiver.takesNullableId(nsString)
|
||||
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $IdLover,
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $NSIdLover,
|
||||
// CHECK: [[OPT_ANYOBJECT:%.*]] = enum {{.*}} [[OBJECT]]
|
||||
// CHECK: apply [[METHOD]]([[OPT_ANYOBJECT]], [[SELF]])
|
||||
receiver.takesNullableId(object)
|
||||
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $IdLover,
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $NSIdLover,
|
||||
// CHECK: [[ANYOBJECT:%.*]] = init_existential_ref [[CLASS_GENERIC]] : $T : $T, $AnyObject
|
||||
// CHECK: [[OPT_ANYOBJECT:%.*]] = enum {{.*}} [[ANYOBJECT]]
|
||||
// CHECK: apply [[METHOD]]([[OPT_ANYOBJECT]], [[SELF]])
|
||||
receiver.takesNullableId(classGeneric)
|
||||
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $IdLover,
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $NSIdLover,
|
||||
// CHECK: [[OPENED:%.*]] = open_existential_ref [[CLASS_EXISTENTIAL]] : $CP
|
||||
// CHECK: [[ANYOBJECT:%.*]] = init_existential_ref [[OPENED]]
|
||||
// CHECK: [[OPT_ANYOBJECT:%.*]] = enum {{.*}} [[ANYOBJECT]]
|
||||
// CHECK: apply [[METHOD]]([[OPT_ANYOBJECT]], [[SELF]])
|
||||
receiver.takesNullableId(classExistential)
|
||||
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $IdLover,
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $NSIdLover,
|
||||
// CHECK-NEXT: [[COPY:%.*]] = alloc_stack $U
|
||||
// CHECK-NEXT: copy_addr [[GENERIC]] to [initialization] [[COPY]]
|
||||
// CHECK-NEXT: // function_ref _bridgeAnythingToObjectiveC
|
||||
@@ -228,7 +228,7 @@ func passingToNullableId<T: CP, U>(receiver: IdLover,
|
||||
// CHECK-NEXT: dealloc_stack [[COPY]]
|
||||
receiver.takesNullableId(generic)
|
||||
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $IdLover,
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $NSIdLover,
|
||||
// CHECK-NEXT: [[COPY:%.*]] = alloc_stack $P
|
||||
// CHECK-NEXT: copy_addr [[EXISTENTIAL]] to [initialization] [[COPY]]
|
||||
// CHECK-NEXT: [[OPENED_COPY:%.*]] = open_existential_addr [[COPY]] : $*P to $*[[OPENED_TYPE:@opened.*P]],
|
||||
@@ -242,7 +242,7 @@ func passingToNullableId<T: CP, U>(receiver: IdLover,
|
||||
// CHECK-NEXT: dealloc_stack [[COPY]]
|
||||
receiver.takesNullableId(existential)
|
||||
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $IdLover,
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $NSIdLover,
|
||||
// CHECK-NEXT: [[COPY:%.*]] = alloc_stack $Any
|
||||
// CHECK-NEXT: copy_addr [[ANY]] to [initialization] [[COPY]]
|
||||
// CHECK-NEXT: [[OPENED_COPY:%.*]] = open_existential_addr [[COPY]] : $*Any to $*[[OPENED_TYPE:@opened.*Any]],
|
||||
@@ -256,7 +256,7 @@ func passingToNullableId<T: CP, U>(receiver: IdLover,
|
||||
// CHECK-NEXT: dealloc_stack [[COPY]]
|
||||
receiver.takesNullableId(any)
|
||||
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $IdLover,
|
||||
// CHECK: [[METHOD:%.*]] = class_method [volatile] [[SELF]] : $NSIdLover,
|
||||
// CHECK: [[TMP:%.*]] = alloc_stack $KnownUnbridged
|
||||
// CHECK: store [[KNOWN_UNBRIDGED]] to [[TMP]]
|
||||
// CHECK: [[BRIDGE_ANYTHING:%.*]] = function_ref @_TFs27_bridgeAnythingToObjectiveC
|
||||
|
||||
@@ -8,13 +8,13 @@ import Foundation
|
||||
|
||||
// Tests for uses of version-based potential unavailability imported from ObjC APIs.
|
||||
func callUnavailableObjC() {
|
||||
_ = AvailableOn10_51() // expected-error {{'AvailableOn10_51' is only available on OS X 10.51 or newer}}
|
||||
_ = NSAvailableOn10_51() // expected-error {{'NSAvailableOn10_51' is only available on OS X 10.51 or newer}}
|
||||
// expected-note@-1 {{add @available attribute to enclosing global function}}
|
||||
// expected-note@-2 {{add 'if #available' version check}}
|
||||
|
||||
|
||||
if #available(OSX 10.51, *) {
|
||||
let o = AvailableOn10_51()!
|
||||
let o = NSAvailableOn10_51()!
|
||||
|
||||
// Properties
|
||||
_ = o.propertyOn10_52 // expected-error {{'propertyOn10_52' is only available on OS X 10.52 or newer}}
|
||||
@@ -32,7 +32,7 @@ func callUnavailableObjC() {
|
||||
|
||||
// Initializers
|
||||
|
||||
_ = AvailableOn10_51(stringOn10_52:"Hi") // expected-error {{'init(stringOn10_52:)' is only available on OS X 10.52 or newer}}
|
||||
_ = NSAvailableOn10_51(stringOn10_52:"Hi") // expected-error {{'init(stringOn10_52:)' is only available on OS X 10.52 or newer}}
|
||||
// expected-note@-1 {{add @available attribute to enclosing global function}}
|
||||
// expected-note@-2 {{add 'if #available' version check}}
|
||||
}
|
||||
@@ -40,40 +40,40 @@ func callUnavailableObjC() {
|
||||
|
||||
// Declarations with Objective-C-originated potentially unavailable APIs
|
||||
|
||||
func functionWithObjCParam(o: AvailableOn10_51) { // expected-error {{'AvailableOn10_51' is only available on OS X 10.51 or newer}}
|
||||
func functionWithObjCParam(o: NSAvailableOn10_51) { // expected-error {{'NSAvailableOn10_51' is only available on OS X 10.51 or newer}}
|
||||
// expected-note@-1 {{add @available attribute to enclosing global function}}
|
||||
}
|
||||
|
||||
class ClassExtendingUnvailableClass : AvailableOn10_51 { // expected-error {{'AvailableOn10_51' is only available on OS X 10.51 or newer}}
|
||||
class ClassExtendingUnvailableClass : NSAvailableOn10_51 { // expected-error {{'NSAvailableOn10_51' is only available on OS X 10.51 or newer}}
|
||||
// expected-note@-1 {{add @available attribute to enclosing class}}
|
||||
}
|
||||
|
||||
// We allow classes to conform to potentially unavailable protocols
|
||||
class ClassAdoptingUnavailableProtocol : ProtocolAvailableOn10_51 {
|
||||
class ClassAdoptingUnavailableProtocol : NSProtocolAvailableOn10_51 {
|
||||
}
|
||||
|
||||
class SomeSoonToBeConformingClass { }
|
||||
|
||||
extension SomeSoonToBeConformingClass : ProtocolAvailableOn10_51 {
|
||||
extension SomeSoonToBeConformingClass : NSProtocolAvailableOn10_51 {
|
||||
}
|
||||
|
||||
// Enums from Objective-C
|
||||
|
||||
let _: PotentiallyUnavailableOptions = .first // expected-error {{'PotentiallyUnavailableOptions' is only available on OS X 10.51 or newer}}
|
||||
let _: NSPotentiallyUnavailableOptions = .first // expected-error {{'NSPotentiallyUnavailableOptions' is only available on OS X 10.51 or newer}}
|
||||
// expected-note@-1 {{add 'if #available' version check}}
|
||||
|
||||
let _: OptionsWithUnavailableElement = .third // expected-error {{'third' is only available on OS X 10.51 or newer}}
|
||||
let _: NSOptionsWithUnavailableElement = .third // expected-error {{'third' is only available on OS X 10.51 or newer}}
|
||||
// expected-note@-1 {{add 'if #available' version check}}
|
||||
|
||||
let _: UnavailableEnum = .first // expected-error {{'UnavailableEnum' is only available on OS X 10.51 or newer}}
|
||||
let _: NSUnavailableEnum = .first // expected-error {{'NSUnavailableEnum' is only available on OS X 10.51 or newer}}
|
||||
// expected-note@-1 {{add 'if #available' version check}}
|
||||
|
||||
let _: EnumWithUnavailableElement = .third // expected-error {{'third' is only available on OS X 10.51 or newer}}
|
||||
let _: NSEnumWithUnavailableElement = .third // expected-error {{'third' is only available on OS X 10.51 or newer}}
|
||||
// expected-note@-1 {{add 'if #available' version check}}
|
||||
|
||||
// Differing availability on getters and setters imported from ObjC.
|
||||
|
||||
func gettersAndSettersFromObjC(o: AvailableOn10_9) {
|
||||
func gettersAndSettersFromObjC(o: NSAvailableOn10_9) {
|
||||
let _: Int = o.propertyOn10_51WithSetterOn10_52After // expected-error {{'propertyOn10_51WithSetterOn10_52After' is only available on OS X 10.51 or newer}}
|
||||
// expected-note@-1 {{add @available attribute to enclosing global function}}
|
||||
// expected-note@-2 {{add 'if #available' version check}}
|
||||
@@ -121,7 +121,7 @@ func useGlobalsFromObjectiveC() {
|
||||
|
||||
if #available(OSX 10.51, *) {
|
||||
_ = globalStringAvailableOn10_51
|
||||
let _: AvailableOn10_51 = globalClassInstanceAvailableOn10_51
|
||||
let _: NSAvailableOn10_51 = globalClassInstanceAvailableOn10_51
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,11 +129,11 @@ func useGlobalsFromObjectiveC() {
|
||||
|
||||
// Make sure we're not emitting errors in the Foundation module, where the witness is.
|
||||
// CHECK-NOT: Foundation.ClassWithMethodFromNSProtocolWithOptionalRequirement:
|
||||
class SubclassOfNSClassWithMethodFromNSProtocolWithOptionalRequirement : ClassWithMethodFromNSProtocolWithOptionalRequirement {
|
||||
class SubclassOfNSClassWithMethodFromNSProtocolWithOptionalRequirement : NSClassWithMethodFromNSProtocolWithOptionalRequirement {
|
||||
|
||||
}
|
||||
|
||||
class SubclassWithItsOwnAvailableWitnessOfNSClassWithMethodFromNSProtocolWithOptionalRequirement : ClassWithMethodFromNSProtocolWithOptionalRequirement {
|
||||
class SubclassWithItsOwnAvailableWitnessOfNSClassWithMethodFromNSProtocolWithOptionalRequirement : NSClassWithMethodFromNSProtocolWithOptionalRequirement {
|
||||
override func optionalRequirement() { }
|
||||
}
|
||||
|
||||
|
||||
@@ -21,16 +21,16 @@ func useClassThatTriggersImportOfDeprecatedEnum() {
|
||||
// when importing deprecated enums do not themselves trigger deprecation
|
||||
// warnings in the synthesized code.
|
||||
|
||||
_ = ClassWithDeprecatedOptionsInMethodSignature.sharedInstance()
|
||||
_ = ClassWithExplicitlyUnavailableOptionsInMethodSignature.sharedInstance()
|
||||
_ = NSClassWithDeprecatedOptionsInMethodSignature.sharedInstance()
|
||||
_ = NSClassWithExplicitlyUnavailableOptionsInMethodSignature.sharedInstance()
|
||||
}
|
||||
|
||||
func directUseShouldStillTriggerDeprecationWarning() {
|
||||
_ = DeprecatedOptions.first // expected-warning {{'DeprecatedOptions' was deprecated in OS X 10.51: Use a different API}}
|
||||
_ = DeprecatedEnum.first // expected-warning {{'DeprecatedEnum' was deprecated in OS X 10.51: Use a different API}}
|
||||
_ = NSDeprecatedOptions.first // expected-warning {{'NSDeprecatedOptions' was deprecated in OS X 10.51: Use a different API}}
|
||||
_ = NSDeprecatedEnum.first // expected-warning {{'NSDeprecatedEnum' was deprecated in OS X 10.51: Use a different API}}
|
||||
}
|
||||
|
||||
func useInSignature(options: DeprecatedOptions) { // expected-warning {{'DeprecatedOptions' was deprecated in OS X 10.51: Use a different API}}
|
||||
func useInSignature(options: NSDeprecatedOptions) { // expected-warning {{'NSDeprecatedOptions' was deprecated in OS X 10.51: Use a different API}}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -308,11 +308,6 @@ HonorSwiftNewtypeAttr("enable-swift-newtype",
|
||||
llvm::cl::desc("Enable swift_newtype import"),
|
||||
llvm::cl::init(false));
|
||||
|
||||
static llvm::cl::opt<bool>
|
||||
StripNSPrefix("enable-strip-ns-prefix",
|
||||
llvm::cl::desc("Strip the NS prefix from Foundation et al"),
|
||||
llvm::cl::init(false));
|
||||
|
||||
static llvm::cl::opt<bool>
|
||||
DisableObjCAttrRequiresFoundationModule(
|
||||
"disable-objc-attr-requires-foundation-module",
|
||||
@@ -2797,7 +2792,6 @@ int main(int argc, char *argv[]) {
|
||||
InitInvok.getLangOptions().Swift3Migration |= options::Swift3Migration;
|
||||
InitInvok.getLangOptions().InferImportAsMember |=
|
||||
options::InferImportAsMember;
|
||||
InitInvok.getLangOptions().StripNSPrefix |= options::StripNSPrefix;
|
||||
InitInvok.getClangImporterOptions().ImportForwardDeclarations |=
|
||||
options::ObjCForwardDeclarations;
|
||||
InitInvok.getClangImporterOptions().InferImportAsMember |=
|
||||
|
||||
Reference in New Issue
Block a user