Skip to content

Commit e8335bd

Browse files
slavapestovDeniz Dizman
authored andcommitted
SIL: The inner type of a SILMoveOnlyWrappedType is a lowered position
Fixes rdar://161968922.
1 parent f3f13a3 commit e8335bd

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

lib/SIL/IR/SILTypeSubstitution.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,14 @@ class SILTypeSubstituter :
420420
substObjectType));
421421
}
422422

423+
/// MoveOnlyWrappedTypes need to have their inner types substituted
424+
/// by these rules.
425+
CanType visitSILMoveOnlyWrappedType(CanSILMoveOnlyWrappedType origType) {
426+
CanType origInnerType = origType->getInnerType();
427+
CanType substInnerType = visit(origInnerType);
428+
return CanType(SILMoveOnlyWrappedType::get(substInnerType));
429+
}
430+
423431
/// Any other type would be a valid type in the AST. Just apply the
424432
/// substitution on the AST level and then lower that.
425433
CanType visitType(CanType origType) {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %target-swift-frontend -emit-sil -O %s
2+
3+
public struct Mutex<T> {
4+
public init(_: T) {}
5+
}
6+
7+
public struct Locked<T> {
8+
public let mutex: Mutex<T>
9+
10+
public init(_ rawValue: consuming T) {
11+
mutex = Mutex(rawValue)
12+
}
13+
}
14+
15+
_ = Locked { }

0 commit comments

Comments
 (0)