NCGenerics: @_preInverseGenerics across modules

This commit is contained in:
Kavon Farvardin
2024-03-06 14:54:52 -08:00
parent 4d484c9f12
commit 777e3d945f
3 changed files with 16 additions and 3 deletions

View File

@@ -70,7 +70,7 @@ static bool inversesAllowed(const Decl *decl) {
if (auto *storage = accessor->getStorage())
decl = storage;
return !decl->getParsedAttrs().hasAttribute<PreInverseGenericsAttr>();
return !decl->getAttrs().hasAttribute<PreInverseGenericsAttr>();
}
static bool inversesAllowedIn(const DeclContext *ctx) {

View File

@@ -96,3 +96,6 @@ extension Outer.InnerStruct {
}
public struct Freestanding<T: ~Copyable> where T: ~Escapable {}
@_preInverseGenerics
public func old_swap<T: ~Copyable>(_ a: inout T, _ b: inout T) {}

View File

@@ -32,9 +32,12 @@
// RUN: -enable-experimental-feature NonescapableTypes \
// RUN: %t/Swiftskell.swiftinterface -o %t/Swiftskell.swiftmodule
// RUN: %target-swift-frontend -typecheck -I %t %s \
// RUN: %target-swift-frontend -emit-silgen -I %t %s \
// RUN: -enable-experimental-feature NoncopyableGenerics \
// RUN: -enable-experimental-feature NonescapableTypes
// RUN: -enable-experimental-feature NonescapableTypes \
// RUN: -o %t/final.silgen
// RUN: %FileCheck %s --check-prefix=CHECK-SILGEN < %t/final.silgen
@@ -120,6 +123,8 @@ import NoncopyableGenerics_Misc
// CHECK-MISC: #if compiler(>=5.3) && $NoncopyableGenerics
// CHECK-MISC-NEXT: public struct Freestanding<T> where T : ~Copyable, T : ~Escapable {
// CHECK-MISC-DAG: @_preInverseGenerics public func old_swap<T>(_ a: inout T, _ b: inout T) where T : ~Copyable
///////////////////////////////////////////////////////////////////////
// Synthesized conditional conformances are next
@@ -186,4 +191,9 @@ struct FileDescriptor: ~Copyable, Eq, Show {
static func ==(_ a: borrowing Self, _ b: borrowing Self) -> Bool {
return a.id == b.id
}
mutating func exchangeWith(_ other: inout Self) {
// CHECK-SILGEN: function_ref @$s24NoncopyableGenerics_Misc8old_swapyyxz_xztlF
old_swap(&self, &other)
}
}