Skip to content

Commit d23685f

Browse files
committed
[BitwiseCopyable] Fix resilient enum type info.
Like other `EnumTypeInfo`s, the `TypeInfo` subclasses `EnumTypeInfoBase` and store the `EnumImplStrategy`.
1 parent 17ec817 commit d23685f

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

lib/IRGen/GenEnum.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6838,6 +6838,14 @@ namespace {
68386838
IsABIAccessible_t abiAccessible)
68396839
: EnumTypeInfoBase(strategy, irTy, copyable, abiAccessible) {}
68406840
};
6841+
6842+
class BitwiseCopyableEnumTypeInfo
6843+
: public EnumTypeInfoBase<BitwiseCopyableTypeInfo> {
6844+
public:
6845+
BitwiseCopyableEnumTypeInfo(EnumImplStrategy &strategy, llvm::Type *irTy,
6846+
IsABIAccessible_t abiAccessible)
6847+
: EnumTypeInfoBase(strategy, irTy, abiAccessible) {}
6848+
};
68416849
} // end anonymous namespace
68426850

68436851
const EnumImplStrategy &
@@ -7383,7 +7391,8 @@ ResilientEnumImplStrategy::completeEnumTypeLayout(TypeConverter &TC,
73837391
KnownProtocolKind::BitwiseCopyable);
73847392
if (bitwiseCopyableProtocol &&
73857393
checkConformance(Type.getASTType(), bitwiseCopyableProtocol)) {
7386-
return BitwiseCopyableTypeInfo::create(enumTy, abiAccessible);
7394+
return registerEnumTypeInfo(
7395+
new BitwiseCopyableEnumTypeInfo(*this, enumTy, abiAccessible));
73877396
}
73887397
return registerEnumTypeInfo(
73897398
new ResilientEnumTypeInfo(*this, enumTy, cp,

lib/IRGen/NonFixedTypeInfo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ class BitwiseCopyableTypeInfo
136136
: public WitnessSizedTypeInfo<BitwiseCopyableTypeInfo> {
137137
using Self = BitwiseCopyableTypeInfo;
138138
using Super = WitnessSizedTypeInfo<Self>;
139+
140+
protected:
139141
BitwiseCopyableTypeInfo(llvm::Type *type, IsABIAccessible_t abiAccessible)
140142
: Super(type, Alignment(1), IsNotTriviallyDestroyable,
141143
IsNotBitwiseTakable, IsCopyable, abiAccessible) {}

test/IRGen/bitwise_copyable_resilient.swift

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@
99
// RUN: -emit-module-path %t/Library.swiftmodule
1010

1111
// RUN: %target-swift-frontend \
12-
// RUN: %t/Downstream.swift \
12+
// RUN: %t/DownstreamDiagnostics.swift \
1313
// RUN: -typecheck -verify \
1414
// RUN: -debug-diagnostic-names \
1515
// RUN: -I %t
1616

17+
// RUN: %target-swift-frontend \
18+
// RUN: %t/Downstream.swift \
19+
// RUN: -emit-irgen \
20+
// RUN: -debug-diagnostic-names \
21+
// RUN: -I %t
22+
1723
//--- Library.swift
1824
public enum Oopsional<T> {
1925
case someone(T)
@@ -29,7 +35,14 @@ public struct Integer {
2935
var value: Int
3036
}
3137

32-
//--- Downstream.swift
38+
public enum Int2: BitwiseCopyable {
39+
case zero
40+
case one
41+
case two
42+
case three
43+
}
44+
45+
//--- DownstreamDiagnostics.swift
3346
import Library
3447

3548
func take<T: BitwiseCopyable>(_ t: T) {}
@@ -51,3 +64,13 @@ func passWoopsional<T>(_ t: Woopsional<T>) { take(t) } // expected-error {{ty
5164

5265
extension Integer : @retroactive BitwiseCopyable {} // expected-error {{bitwise_copyable_outside_module}}
5366

67+
struct S_Explicit_With_Int2 {
68+
var i: Int2
69+
}
70+
71+
//--- Downstream.swift
72+
import Library
73+
74+
class C_With_Int2 {
75+
let i = Int2.one
76+
}

0 commit comments

Comments
 (0)