Skip to content

Commit 7a38c03

Browse files
authored
Merge pull request #72134 from kavon/fix-preinverse-generics-crossmodule
Fix preinverse generics crossmodule
2 parents 567c6ad + 777e3d9 commit 7a38c03

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

lib/AST/ASTMangler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static bool inversesAllowed(const Decl *decl) {
7070
if (auto *storage = accessor->getStorage())
7171
decl = storage;
7272

73-
return !decl->getParsedAttrs().hasAttribute<PreInverseGenericsAttr>();
73+
return !decl->getAttrs().hasAttribute<PreInverseGenericsAttr>();
7474
}
7575

7676
static bool inversesAllowedIn(const DeclContext *ctx) {

test/ModuleInterface/Inputs/NoncopyableGenerics_Misc.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,6 @@ extension Outer.InnerStruct {
9696
}
9797

9898
public struct Freestanding<T: ~Copyable> where T: ~Escapable {}
99+
100+
@_preInverseGenerics
101+
public func old_swap<T: ~Copyable>(_ a: inout T, _ b: inout T) {}

test/ModuleInterface/noncopyable_generics.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,12 @@
3232
// RUN: -enable-experimental-feature NonescapableTypes \
3333
// RUN: %t/Swiftskell.swiftinterface -o %t/Swiftskell.swiftmodule
3434

35-
// RUN: %target-swift-frontend -typecheck -I %t %s \
35+
// RUN: %target-swift-frontend -emit-silgen -I %t %s \
3636
// RUN: -enable-experimental-feature NoncopyableGenerics \
37-
// RUN: -enable-experimental-feature NonescapableTypes
37+
// RUN: -enable-experimental-feature NonescapableTypes \
38+
// RUN: -o %t/final.silgen
39+
40+
// RUN: %FileCheck %s --check-prefix=CHECK-SILGEN < %t/final.silgen
3841

3942

4043

@@ -120,6 +123,8 @@ import NoncopyableGenerics_Misc
120123
// CHECK-MISC: #if compiler(>=5.3) && $NoncopyableGenerics
121124
// CHECK-MISC-NEXT: public struct Freestanding<T> where T : ~Copyable, T : ~Escapable {
122125

126+
// CHECK-MISC-DAG: @_preInverseGenerics public func old_swap<T>(_ a: inout T, _ b: inout T) where T : ~Copyable
127+
123128
///////////////////////////////////////////////////////////////////////
124129
// Synthesized conditional conformances are next
125130

@@ -186,4 +191,9 @@ struct FileDescriptor: ~Copyable, Eq, Show {
186191
static func ==(_ a: borrowing Self, _ b: borrowing Self) -> Bool {
187192
return a.id == b.id
188193
}
194+
195+
mutating func exchangeWith(_ other: inout Self) {
196+
// CHECK-SILGEN: function_ref @$s24NoncopyableGenerics_Misc8old_swapyyxz_xztlF
197+
old_swap(&self, &other)
198+
}
189199
}

0 commit comments

Comments
 (0)