Skip to content

Commit f3189fb

Browse files
Merge pull request #71299 from nate-chandler/bitwise-copyable/non-resilient-module-public-inference
[BitwiseCopyable] Fragile modules always infer.
2 parents 902a22d + fecaf28 commit f3189fb

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

lib/Sema/TypeCheckBitwise.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ getImplicitCheckForNominal(NominalTypeDecl *nominal) {
5757
if (!nominal
5858
->getFormalAccessScope(
5959
/*useDC=*/nullptr, /*treatUsableFromInlineAsPublic=*/true)
60-
.isPublic())
60+
.isPublic() ||
61+
!nominal->isResilient())
6162
return {BitwiseCopyableCheck::Implicit};
6263

6364
if (nominal->hasClangNode() ||

test/Sema/bitwise_copyable.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ struct S_Explicit_With_Function_C : _BitwiseCopyable {
6262
public struct S_Public {}
6363

6464
struct S_Explicit_With_S_Public : _BitwiseCopyable {
65-
var s: S_Public // expected-error {{non_bitwise_copyable_type_member}}
66-
// expected-note@-4 {{add_nominal_bitwise_copyable_conformance}}
65+
var s: S_Public
6766
}
6867

6968
struct S_Explicit_With_Generic<T> : _BitwiseCopyable {
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: split-file %s %t
3+
4+
// RUN: %target-swift-frontend \
5+
// RUN: %t/Library.swift \
6+
// RUN: -emit-module \
7+
// RUN: -enable-experimental-feature BitwiseCopyable \
8+
// RUN: -module-name Library \
9+
// RUN: -emit-module-path %t/Library.swiftmodule
10+
11+
// RUN: %target-swift-frontend \
12+
// RUN: %t/Downstream.swift \
13+
// RUN: -typecheck -verify \
14+
// RUN: -debug-diagnostic-names \
15+
// RUN: -enable-experimental-feature BitwiseCopyable \
16+
// RUN: -I %t
17+
18+
//--- Library.swift
19+
public enum Oopsional<T> {
20+
case someone(Int)
21+
case nobody
22+
}
23+
24+
@frozen public enum Woopsional<T> {
25+
case somebody(Int)
26+
case noone
27+
}
28+
29+
//--- Downstream.swift
30+
import Library
31+
32+
func take<T: _BitwiseCopyable>(_ t: T) {}
33+
34+
struct S_Explicit_With_Oopsional<T> : _BitwiseCopyable {
35+
var o: Oopsional<T>
36+
}
37+
38+
func passOopsional<T>(_ t: Oopsional<T>) { take(t) }
39+
40+
41+
struct S_Explicit_With_Woopsional<T> : _BitwiseCopyable {
42+
var o: Woopsional<T>
43+
}
44+
45+
func passWoopsional<T>(_ t: Woopsional<T>) { take(t) }
46+

0 commit comments

Comments
 (0)