Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/swift/SIL/SILType.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "swift/AST/SILLayout.h"
#include "swift/AST/Types.h"
#include "swift/Basic/Assertions.h"
#include "swift/SIL/AbstractionPattern.h"
#include "swift/SIL/Lifetime.h"
#include "llvm/ADT/Hashing.h"
Expand Down Expand Up @@ -109,7 +110,7 @@ class SILType {
SILType(CanType ty, SILValueCategory category)
: value(ty.getPointer(), unsigned(category)) {
if (!ty) return;
assert(ty->isLegalSILType() &&
ASSERT(ty->isLegalSILType() &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

"constructing SILType with type that should have been "
"eliminated by SIL lowering");
}
Expand Down
8 changes: 8 additions & 0 deletions lib/SIL/IR/SILTypeSubstitution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,14 @@ class SILTypeSubstituter :
substObjectType));
}

/// MoveOnlyWrappedTypes need to have their inner types substituted
/// by these rules.
CanType visitSILMoveOnlyWrappedType(CanSILMoveOnlyWrappedType origType) {
CanType origInnerType = origType->getInnerType();
CanType substInnerType = visit(origInnerType);
return CanType(SILMoveOnlyWrappedType::get(substInnerType));
}

/// Any other type would be a valid type in the AST. Just apply the
/// substitution on the AST level and then lower that.
CanType visitType(CanType origType) {
Expand Down
15 changes: 15 additions & 0 deletions test/SILOptimizer/specialize_move_only_wrapped_type.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// RUN: %target-swift-frontend -emit-sil -O %s

public struct Mutex<T> {
public init(_: T) {}
}

public struct Locked<T> {
public let mutex: Mutex<T>

public init(_ rawValue: consuming T) {
mutex = Mutex(rawValue)
}
}

_ = Locked { }