Files
swift-mirror/test/SymbolGraph/ClangImporter/ErrorEnum.swift
Dylan Sturgeon 2c8e337f25 Merge pull request #80074 from dylansturg/objc_enum_refs
The Error enum synthesized declarations, e.g. the struct and its static accessors, should generally appear to be identical to the underlying Clang definitions. There are some specific use cases where the synthesized declarations are necessary though.

I've added an option for USR generation to override the Clang node and emit the USR of the synthesized Swift declaration. This is used by SwiftDocSupport so that the USRs of the synthesized declarations are emitted.

Fixes 79912
2025-03-25 11:21:21 +00:00

55 lines
1.7 KiB
Swift

// REQUIRES: OS=macosx
// RUN: %empty-directory(%t)
// RUN: split-file %s %t
// RUN: %target-swift-symbolgraph-extract -sdk %sdk -module-name MyError -I %t/MyError -output-dir %t -pretty-print -v -skip-protocol-implementations
// RUN: %FileCheck %s --input-file %t/MyError.symbols.json
// CHECK-NOT: "sourceOrigin"
// CHECK-NOT: "displayName": "_BridgedStoredNSError.Code"
// == is implemented as part of the hidden _BridgedStoredNSError protocol,
// but it should be hidden since it ultimately comes from Equatable
// CHECK-NOT: "precise": "s:10Foundation21_BridgedStoredNSErrorPAAE2eeoiySbx_xtFZ::SYNTHESIZED::s:SC11MyErrorCodeLeV"
// hash(into:) is implemented as part of an extension on that same protocol,
// but it should be hidden for a similar reason
// CHECK-NOT: "precise": "s:SYsSHRzSH8RawValueSYRpzrlE4hash4intoys6HasherVz_tF::SYNTHESIZED::c:@E@MyErrorCode"
// MyError
// CHECK-DAG: "precise": "s:SC11MyErrorCodeLeV"
// MyError.errFirst
// CHECK-DAG: "precise": "s:SC11MyErrorCodeLeV8errFirstSoAAVvpZ"
// MyErrorCode.Code
// CHECK-DAG: "precise": "c:@E@MyErrorCode"
// MyErrorCode.Code.init(rawValue:)
// CHECK-DAG: "precise": "s:So11MyErrorCodeV8rawValueABSgs5Int32V_tcfc"
// the following header and module map were copied from test/SourceKit/DocSupport/Inputs
//--- MyError/module.modulemap
module "MyError" {
header "MyError.h"
export *
}
//--- MyError/MyError.h
@import Foundation;
#define NS_ERROR_ENUM(_type, _name, _domain) \
enum _name : _type _name; enum __attribute__((ns_error_domain(_domain))) _name : _type
@class NSString;
extern const NSString *const MyErrorDomain;
/// This is my cool error code.
typedef NS_ERROR_ENUM(int, MyErrorCode, MyErrorDomain) {
/// This is first error.
MyErrFirst,
/// This is second error.
MyErrSecond,
};