mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
NCGenerics: @_preInverseGenerics across modules
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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) {}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user