Skip to content

Commit c368e58

Browse files
committed
Add Escapable conformance to some builtin functions
1 parent 56e4dfc commit c368e58

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lib/AST/Builtins.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2102,12 +2102,17 @@ static ValueDecl *getOnceOperation(ASTContext &Context,
21022102
return getBuiltinFunction(Id, ArgTypes, Context.TheSILTokenType);
21032103
}
21042104

2105+
21052106
static ValueDecl *getPolymorphicBinaryOperation(ASTContext &ctx,
21062107
Identifier id) {
21072108
BuiltinFunctionBuilder builder(ctx);
2108-
builder.addParameter(makeGenericParam());
2109-
builder.addParameter(makeGenericParam());
2110-
builder.setResult(makeGenericParam());
2109+
2110+
// Builtins of the form: func binOp<T>(_ t: T, _ t: T) -> T
2111+
auto genericParam = makeGenericParam();
2112+
builder.addConformanceRequirement(genericParam, KnownProtocolKind::Escapable);
2113+
builder.addParameter(genericParam);
2114+
builder.addParameter(genericParam);
2115+
builder.setResult(genericParam);
21112116
return builder.build(id);
21122117
}
21132118

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)