mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Implicit initializers are given a source location within the type they belong to. This works poorly for @objc @implementation classes, because the class they belong to is imported and so those SourceLocs are in a different source buffer from the extension they’re inside, breaking an invariant enforced by index-while-building features. Fix these SourceLocs to come from the implementation context, so they’ll come from the extension for an objcImpl class and the type itself otherwise.
31 lines
1.3 KiB
Swift
31 lines
1.3 KiB
Swift
// REQUIRES: objc_interop
|
|
|
|
// RUN: %empty-directory(%t)
|
|
// RUN: %empty-directory(%t/mods)
|
|
// RUN: split-file %s %t
|
|
|
|
// We use `-index-store-path` to exercise a code path that used to crash; we
|
|
// aren't checking its output.
|
|
// RUN: %target-swift-frontend -emit-module -o %t/mods %t/ObjcImpl.swift -import-objc-header %t/objc_impl.h -target %target-stable-abi-triple -disable-objc-attr-requires-foundation-module -index-store-path %t/index-store
|
|
// RUN: %target-swift-ide-test -print-indexed-symbols -module-to-print ObjcImpl -source-filename none -I %t/mods -target %target-stable-abi-triple | %FileCheck %s
|
|
|
|
//--- objc_impl.h
|
|
@interface NSObject
|
|
- (instancetype)init;
|
|
@end
|
|
|
|
@interface ObjCClass : NSObject
|
|
@property int someObjCDeclaredVar;
|
|
@end
|
|
|
|
//--- ObjcImpl.swift
|
|
// CHECK: extension/ext-class/Swift | ObjCClass | s:e:c:@CM@ObjcImpl@@objc(cs)ObjCClass(py)someObjCDeclaredVar | Def
|
|
// CHECK: class/Swift | ObjCClass | c:objc(cs)ObjCClass | Ref
|
|
@_objcImplementation public extension ObjCClass {
|
|
// CHECK: instance-property/Swift | someObjCDeclaredVar | c:@CM@ObjcImpl@@objc(cs)ObjCClass(py)someObjCDeclaredVar | Def
|
|
@objc var someObjCDeclaredVar: CInt = 1
|
|
|
|
// Implicitly synthesized `override init()`:
|
|
// CHECK: constructor/Swift | init() | c:@CM@ObjcImpl@@objc(cs)ObjCClass(im)init | Def
|
|
}
|