Files
swift-mirror/test/Inputs/clang-importer-sdk/usr/include/OtherSubscripts.h
John McCall 80b180a9a1 Implement a syntactic peephole to recognize explicit bridging
conversions that reverse an implicit conversion done to align
foreign declarations with their imported types.

For example, consider an Objective-C method that returns an NSString*:
  - (nonnull NSString*) foo;
This will be imported into Swift as a method returning a String:
  func foo() -> String
A call to this method will implicitly convert the result to String
behind the scenes.  If the user then casts the result back to NSString*,
that would normally be compiled as an additional conversion.  The
compiler cannot simply eliminate the conversion because that is not
necessarily semantically equivalent.

This peephole recognizes as-casts that immediately reverse a bridging
conversion as a special case and gives them special power to eliminate
both conversions.  For example, 'foo() as NSString' will simply return
the original return value.  In addition to call results, this also
applies to call arguments, property accesses, and subscript accesses.
2017-07-15 01:13:41 -04:00

18 lines
621 B
Objective-C

#include "Foundation.h"
@interface NullableSubscript : NSObject
- (nullable NSString*) objectForKeyedSubscript: (nonnull id) key;
- (void) setObject: (nullable NSString*) obj forKeyedSubscript: (nonnull id) key;
@end
@interface NullproneSubscript : NSObject
- (null_unspecified NSString*) objectForKeyedSubscript: (nonnull id) key;
- (void) setObject: (null_unspecified NSString*) obj forKeyedSubscript: (nonnull id) key;
@end
@interface NonnullSubscript : NSObject
- (nonnull NSString*) objectForKeyedSubscript: (nonnull id) key;
- (void) setObject: (nonnull NSString*) obj forKeyedSubscript: (nonnull id) key;
@end