Skip to content

Commit 2c8b845

Browse files
committed
IRGen: Ignore the metadata of fixed sized types with opaque result type parameters
The removed check by this patch seems somewhat arbitrary and the test case that was added for it no longer fails. rdar://67841860
1 parent 8bbffac commit 2c8b845

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed

lib/IRGen/Outlining.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ void OutliningMetadataCollector::collectTypeMetadataForLayout(SILType type) {
3939
}
4040

4141
// Substitute opaque types if allowed.
42-
auto origType = type;
4342
type =
4443
IGF.IGM.substOpaqueTypesWithUnderlyingTypes(type, CanGenericSignature());
4544

@@ -49,9 +48,7 @@ void OutliningMetadataCollector::collectTypeMetadataForLayout(SILType type) {
4948
// We don't need the metadata for fixed size types or types that are not ABI
5049
// accessible. Outlining will call the value witness of the enclosing type of
5150
// non ABI accessible field/element types.
52-
if ((!origType.getASTType()->hasOpaqueArchetype() &&
53-
isa<FixedTypeInfo>(ti)) ||
54-
!ti.isABIAccessible()) {
51+
if (isa<FixedTypeInfo>(ti) || !ti.isABIAccessible()) {
5552
return;
5653
}
5754

test/IRGen/Inputs/opaque_result_type_private_underlying_2.swift

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,39 @@ public struct PublicUnderlyingInlinable : A {
4545
return PublicS()
4646
}
4747
}
48+
49+
50+
public protocol P {}
51+
52+
private struct PrivateSome : P {}
53+
public func getSome() -> some P {
54+
return PrivateSome()
55+
}
56+
57+
@propertyWrapper
58+
public struct Wrapper<T> {
59+
public var wrappedValue: T
60+
61+
public init(wrappedValue v: T) {
62+
wrappedValue = v
63+
}
64+
}
65+
66+
public struct R<V, T: P>: P {
67+
@Wrapper private var privateState = PrivateState()
68+
var x: T? = nil
69+
70+
public init(_ v: V.Type, _ t: T) {
71+
x = t
72+
}
73+
74+
public mutating func modify() {
75+
x = nil
76+
}
77+
}
78+
79+
private extension R {
80+
struct PrivateState {
81+
var x = 0
82+
}
83+
}

test/IRGen/opaque_result_type_private_underlying.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,11 @@ public struct MyThing {
6868
}
6969
}
7070
#endif
71+
72+
public struct E<V> {
73+
var body : some P {
74+
var r = R(V.self, getSome())
75+
r.modify()
76+
return r
77+
}
78+
}

0 commit comments

Comments
 (0)