Skip to content

Commit dad45d3

Browse files
committed
Add Escapable conformance to some builtin functions
1 parent 212fb85 commit dad45d3

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

lib/AST/Builtins.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,9 +2105,13 @@ static ValueDecl *getOnceOperation(ASTContext &Context,
21052105
static ValueDecl *getPolymorphicBinaryOperation(ASTContext &ctx,
21062106
Identifier id) {
21072107
BuiltinFunctionBuilder builder(ctx);
2108-
builder.addParameter(makeGenericParam());
2109-
builder.addParameter(makeGenericParam());
2110-
builder.setResult(makeGenericParam());
2108+
2109+
// Builtins of the form: func binOp<T>(_ t: T, _ t: T) -> T
2110+
auto genericParam = makeGenericParam();
2111+
builder.addConformanceRequirement(genericParam, KnownProtocolKind::Escapable);
2112+
builder.addParameter(genericParam);
2113+
builder.addParameter(genericParam);
2114+
builder.setResult(genericParam);
21112115
return builder.build(id);
21122116
}
21132117

lib/AST/ConformanceLookup.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,10 @@ static bool conformsToInvertible(CanType type, InvertibleProtocolKind ip) {
839839
if (type->is<SILPackType>())
840840
return true;
841841

842+
if (type->is<SILTokenType>()) {
843+
return true;
844+
}
845+
842846
// The SIL types in the AST do not have real conformances, and should have
843847
// been handled in SILType instead.
844848
assert(!(type->is<SILBoxType,

0 commit comments

Comments
 (0)