[CS] Avoid escaping solver-allocated types in computeSubstitutions

Make sure we call `simplifyType` for the opened type bindings to
ensure holes get converted to UnresolvedType.

rdar://154553285
This commit is contained in:
Hamish Knight
2025-06-28 09:33:11 +01:00
parent 374658aae0
commit 2b05212ff5
4 changed files with 12 additions and 9 deletions

View File

@@ -116,7 +116,7 @@ Solution::computeSubstitutions(NullablePtr<ValueDecl> decl,
} else if (!type->is<PackType>()) } else if (!type->is<PackType>())
type = PackType::getSingletonPackExpansion(type); type = PackType::getSingletonPackExpansion(type);
} }
replacementTypes.push_back(type); replacementTypes.push_back(simplifyType(type));
} }
auto lookupConformanceFn = auto lookupConformanceFn =
@@ -146,9 +146,9 @@ Solution::computeSubstitutions(NullablePtr<ValueDecl> decl,
return conformance; return conformance;
}; };
return SubstitutionMap::get(sig, auto subs = SubstitutionMap::get(sig, replacementTypes, lookupConformanceFn);
replacementTypes, ASSERT(!subs.getRecursiveProperties().isSolverAllocated());
lookupConformanceFn); return subs;
} }
// Lazily instantiate function definitions for class template specializations. // Lazily instantiate function definitions for class template specializations.

View File

@@ -0,0 +1,6 @@
// RUN: %target-typecheck-verify-swift -disable-experimental-parser-round-trip
// Make sure we don't crash
func testInvalidInInterpolation(_ x: Int) {
_ = "\((x, \[]))" // expected-error {{invalid component of Swift key path}}
}

View File

@@ -1,7 +1,4 @@
// {"signature":"swift::ProtocolConformanceRef::forAbstract(swift::Type, swift::ProtocolDecl*)"} // {"signature":"swift::ProtocolConformanceRef::forAbstract(swift::Type, swift::ProtocolDecl*)"}
// RUN: env DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib not --crash %target-swift-frontend -typecheck %s // RUN: not %target-swift-frontend -typecheck %s
// REQUIRES: OS=macosx
// REQUIRES: target-same-as-host
// REQUIRES: no_asan
var sixDoubles var sixDoubles
: Double "six has the value [\( ( sixDoubles \[]) }0 \0\0 \0 \sixDoubles)" : Double "six has the value [\( ( sixDoubles \[]) }0 \0\0 \0 \sixDoubles)"

View File

@@ -1,5 +1,5 @@
// {"signature":"swift::FunctionType::get(llvm::ArrayRef<swift::AnyFunctionType::Param>, swift::Type, std::__1::optional<swift::ASTExtInfo>)"} // {"signature":"swift::FunctionType::get(llvm::ArrayRef<swift::AnyFunctionType::Param>, swift::Type, std::__1::optional<swift::ASTExtInfo>)"}
// RUN: not --crash %target-swift-frontend -typecheck %s // RUN: not %target-swift-frontend -typecheck %s
struct a < b : FixedWidthInteger extension a : Sequence { struct a < b : FixedWidthInteger extension a : Sequence {
c { c {
{ for { for