Skip to content

Commit 2b05212

Browse files
committed
[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
1 parent 374658a commit 2b05212

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

lib/Sema/CSApply.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Solution::computeSubstitutions(NullablePtr<ValueDecl> decl,
116116
} else if (!type->is<PackType>())
117117
type = PackType::getSingletonPackExpansion(type);
118118
}
119-
replacementTypes.push_back(type);
119+
replacementTypes.push_back(simplifyType(type));
120120
}
121121

122122
auto lookupConformanceFn =
@@ -146,9 +146,9 @@ Solution::computeSubstitutions(NullablePtr<ValueDecl> decl,
146146
return conformance;
147147
};
148148

149-
return SubstitutionMap::get(sig,
150-
replacementTypes,
151-
lookupConformanceFn);
149+
auto subs = SubstitutionMap::get(sig, replacementTypes, lookupConformanceFn);
150+
ASSERT(!subs.getRecursiveProperties().isSolverAllocated());
151+
return subs;
152152
}
153153

154154
// Lazily instantiate function definitions for class template specializations.

test/Constraints/rdar154553285.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %target-typecheck-verify-swift -disable-experimental-parser-round-trip
2+
3+
// Make sure we don't crash
4+
func testInvalidInInterpolation(_ x: Int) {
5+
_ = "\((x, \[]))" // expected-error {{invalid component of Swift key path}}
6+
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
// {"signature":"swift::ProtocolConformanceRef::forAbstract(swift::Type, swift::ProtocolDecl*)"}
2-
// RUN: env DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib not --crash %target-swift-frontend -typecheck %s
3-
// REQUIRES: OS=macosx
4-
// REQUIRES: target-same-as-host
5-
// REQUIRES: no_asan
2+
// RUN: not %target-swift-frontend -typecheck %s
63
var sixDoubles
74
: Double "six has the value [\( ( sixDoubles \[]) }0 \0\0 \0 \sixDoubles)"

validation-test/compiler_crashers_2/89bcf379b8d4d092.swift renamed to validation-test/compiler_crashers_2_fixed/89bcf379b8d4d092.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// {"signature":"swift::FunctionType::get(llvm::ArrayRef<swift::AnyFunctionType::Param>, swift::Type, std::__1::optional<swift::ASTExtInfo>)"}
2-
// RUN: not --crash %target-swift-frontend -typecheck %s
2+
// RUN: not %target-swift-frontend -typecheck %s
33
struct a < b : FixedWidthInteger extension a : Sequence {
44
c {
55
{ for

0 commit comments

Comments
 (0)