Skip to content

Commit 804c1f9

Browse files
authored
Merge pull request #84771 from slavapestov/fix-rdar131832797
SIL: The inner type of a SILMoveOnlyWrappedType is a lowered position
2 parents fd29fca + b55a141 commit 804c1f9

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

include/swift/SIL/SILType.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include "swift/AST/SILLayout.h"
2222
#include "swift/AST/Types.h"
23+
#include "swift/Basic/Assertions.h"
2324
#include "swift/SIL/AbstractionPattern.h"
2425
#include "swift/SIL/Lifetime.h"
2526
#include "llvm/ADT/Hashing.h"
@@ -109,7 +110,7 @@ class SILType {
109110
SILType(CanType ty, SILValueCategory category)
110111
: value(ty.getPointer(), unsigned(category)) {
111112
if (!ty) return;
112-
assert(ty->isLegalSILType() &&
113+
ASSERT(ty->isLegalSILType() &&
113114
"constructing SILType with type that should have been "
114115
"eliminated by SIL lowering");
115116
}

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)