Skip to content

Commit b8c6442

Browse files
authored
Merge pull request #72990 from rjmccall/vargentupwmofix
Fix a crash when serializing variadic generic tuple code under -wmo
2 parents 9c8e923 + 82d9e4c commit b8c6442

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

include/swift/SIL/SILCloner.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,14 +293,18 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
293293
continue;
294294
}
295295

296-
// Substitute the shape class of the expansion.
296+
// Substitute the shape class of the expansion. If this doesn't
297+
// give us a pack (e.g. if this isn't a substituting clone),
298+
// we're never erasing tuple structure.
297299
auto newShapeClass = getOpASTType(expansion.getCountType());
298300
auto newShapePack = dyn_cast<PackType>(newShapeClass);
301+
if (!newShapePack)
302+
return false;
299303

300304
// If the element has a name, then the tuple sticks around unless
301305
// the expansion disappears completely.
302306
if (type->getElement(index).hasName()) {
303-
if (newShapePack && newShapePack->getNumElements() == 0)
307+
if (newShapePack->getNumElements() == 0)
304308
continue;
305309
return false;
306310
}

test/SILOptimizer/Inputs/cross-module/cross-module.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,3 +295,13 @@ public func getEmptySet() -> Set<Int> {
295295
return Set()
296296
}
297297

298+
public protocol Visitable {
299+
func visit()
300+
}
301+
@available(SwiftStdlib 6.0, *)
302+
public struct S<each T : Visitable> {
303+
var storage: (repeat each T)
304+
public func visit() {
305+
_ = (repeat (each storage).visit())
306+
}
307+
}

0 commit comments

Comments
 (0)