Skip to content

Commit 133602d

Browse files
committed
Add Escapable conformance to some builtin functions
1 parent 9e4469e commit 133602d

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
@@ -2114,9 +2114,13 @@ static ValueDecl *getOnceOperation(ASTContext &Context,
21142114
static ValueDecl *getPolymorphicBinaryOperation(ASTContext &ctx,
21152115
Identifier id) {
21162116
BuiltinFunctionBuilder builder(ctx);
2117-
builder.addParameter(makeGenericParam());
2118-
builder.addParameter(makeGenericParam());
2119-
builder.setResult(makeGenericParam());
2117+
2118+
// Builtins of the form: func binOp<T>(_ t: T, _ t: T) -> T
2119+
auto genericParam = makeGenericParam();
2120+
builder.addConformanceRequirement(genericParam, KnownProtocolKind::Escapable);
2121+
builder.addParameter(genericParam);
2122+
builder.addParameter(genericParam);
2123+
builder.setResult(genericParam);
21202124
return builder.build(id);
21212125
}
21222126

@@ -2230,6 +2234,7 @@ static ValueDecl *getEmplace(ASTContext &ctx, Identifier id) {
22302234
BuiltinFunctionBuilder builder(ctx, /* genericParamCount */ 1);
22312235

22322236
auto T = makeGenericParam();
2237+
builder.addConformanceRequirement(T, KnownProtocolKind::Escapable);
22332238

22342239
auto fnParamTy = FunctionType::get(FunctionType::Param(ctx.TheRawPointerType),
22352240
ctx.TheEmptyTupleType,

lib/AST/ConformanceLookup.cpp

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

853+
if (type->is<SILTokenType>()) {
854+
return true;
855+
}
856+
853857
// The SIL types in the AST do not have real conformances, and should have
854858
// been handled in SILType instead.
855859
assert(!(type->is<SILBoxType,

0 commit comments

Comments
 (0)