Skip to content

Commit 2acacc9

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 f5f058f commit 2acacc9

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
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 =
@@ -145,9 +145,9 @@ Solution::computeSubstitutions(NullablePtr<ValueDecl> decl,
145145
return conformance;
146146
};
147147

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

153153
// 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+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// {"signature":"swift::ProtocolConformanceRef::forAbstract(swift::Type, swift::ProtocolDecl*)"}
2+
// RUN: not %target-swift-frontend -typecheck %s
3+
var sixDoubles
4+
: Double "six has the value [\( ( sixDoubles \[]) }0 \0\0 \0 \sixDoubles)"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// {"signature":"swift::FunctionType::get(llvm::ArrayRef<swift::AnyFunctionType::Param>, swift::Type, std::__1::optional<swift::ASTExtInfo>)"}
2+
// RUN: not %target-swift-frontend -typecheck %s
3+
struct a < b : FixedWidthInteger extension a : Sequence {
4+
c {
5+
{ for
6+
d self { b(truncatingIfNeeded : d

0 commit comments

Comments
 (0)