diff --git a/include/swift/SIL/SILType.h b/include/swift/SIL/SILType.h index 41fdfae5daba3..de96a05269914 100644 --- a/include/swift/SIL/SILType.h +++ b/include/swift/SIL/SILType.h @@ -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" @@ -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() && "constructing SILType with type that should have been " "eliminated by SIL lowering"); } diff --git a/lib/SIL/IR/SILTypeSubstitution.cpp b/lib/SIL/IR/SILTypeSubstitution.cpp index bd3e5718c6846..dab536f664c83 100644 --- a/lib/SIL/IR/SILTypeSubstitution.cpp +++ b/lib/SIL/IR/SILTypeSubstitution.cpp @@ -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) { diff --git a/test/SILOptimizer/specialize_move_only_wrapped_type.swift b/test/SILOptimizer/specialize_move_only_wrapped_type.swift new file mode 100644 index 0000000000000..d6c36f4fd47f0 --- /dev/null +++ b/test/SILOptimizer/specialize_move_only_wrapped_type.swift @@ -0,0 +1,15 @@ +// RUN: %target-swift-frontend -emit-sil -O %s + +public struct Mutex { + public init(_: T) {} +} + +public struct Locked { + public let mutex: Mutex + + public init(_ rawValue: consuming T) { + mutex = Mutex(rawValue) + } +} + +_ = Locked { }