mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Lifetimes: add a diagnostic note for implicit accessors
Lifetime diagnostics may report an error within an implicit initializer or accessor. The source location is misleading in these cases and causes much consternation.
This commit is contained in:
@@ -1240,6 +1240,8 @@ NOTE(lifetime_outside_scope_use, none,
|
||||
NOTE(lifetime_outside_scope_escape, none,
|
||||
"this use causes the lifetime-dependent value to escape", ())
|
||||
|
||||
NOTE(implicit_function_note, none, "error in compiler-generated '%0'", (StringRef))
|
||||
|
||||
ERROR(noncopyable_shared_case_block_unimplemented, none,
|
||||
"matching a non-'Copyable' value using a case label that has multiple patterns is not implemented", ())
|
||||
|
||||
|
||||
@@ -509,6 +509,9 @@ struct BridgedFunction {
|
||||
BridgedOwnedString getDebugDescription() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedLocation getLocation() const;
|
||||
BRIDGED_INLINE bool isAccessor() const;
|
||||
BRIDGED_INLINE bool isInitializer() const;
|
||||
BRIDGED_INLINE bool isDeinitializer() const;
|
||||
BRIDGED_INLINE bool isImplicit() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedStringRef getAccessorName() const;
|
||||
BRIDGED_INLINE bool hasOwnership() const;
|
||||
BRIDGED_INLINE bool hasLoweredAddresses() const;
|
||||
|
||||
@@ -701,6 +701,21 @@ BridgedStringRef BridgedFunction::getAccessorName() const {
|
||||
return accessorKindName(accessorDecl->getAccessorKind());
|
||||
}
|
||||
|
||||
bool BridgedFunction::isInitializer() const {
|
||||
return getFunction()->getDeclRef().isConstructor();
|
||||
}
|
||||
|
||||
bool BridgedFunction::isDeinitializer() const {
|
||||
return getFunction()->getDeclRef().isDestructor();
|
||||
}
|
||||
|
||||
bool BridgedFunction::isImplicit() const {
|
||||
if (auto *funcDecl = getFunction()->getDeclRef().getAbstractFunctionDecl()) {
|
||||
return funcDecl->isImplicit();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool BridgedFunction::hasOwnership() const { return getFunction()->hasOwnership(); }
|
||||
|
||||
bool BridgedFunction::hasLoweredAddresses() const { return getFunction()->getModule().useLoweredAddresses(); }
|
||||
|
||||
Reference in New Issue
Block a user