Skip to content

Commit a2184be

Browse files
authored
Merge pull request #74669 from slavapestov/fix-issue-74648-6.0
[6.0] SILGen: Fix emission of 'modify' witness when all generic params are concrete
2 parents b4a169e + 54d55b1 commit a2184be

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

lib/SILGen/SILGenApply.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6054,6 +6054,11 @@ SILGenFunction::emitBeginApplyWithRethrow(SILLocation loc, SILValue fn,
60546054
SubstitutionMap subs,
60556055
ArrayRef<SILValue> args,
60566056
SmallVectorImpl<SILValue> &yields) {
6057+
// We completely drop the generic signature if all generic parameters were
6058+
// concrete.
6059+
if (subs && subs.getGenericSignature()->areAllParamsConcrete())
6060+
subs = SubstitutionMap();
6061+
60576062
// TODO: adjust this to create try_begin_apply when appropriate.
60586063
assert(!substFnType.castTo<SILFunctionType>()->hasErrorResult());
60596064

test/SILGen/constrained_extensions.swift

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,4 +239,23 @@ extension S<Int> {
239239
fatalError()
240240
}
241241
}
242-
}
242+
}
243+
244+
// https://github.com/swiftlang/swift/issues/74648
245+
246+
protocol HasX {
247+
var x: Int { get set }
248+
}
249+
250+
extension S: HasX where T == Int {
251+
var x: Int {
252+
get { 3 }
253+
set { }
254+
}
255+
}
256+
257+
// CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s22constrained_extensions1SVyxGAA4HasXAASiRszlAaEP1xSivMTW : $@yield_once @convention(witness_method: HasX) @substituted <τ_0_0> (@inout τ_0_0) -> @yields @inout Int for <S<Int>> {
258+
// CHECK: [[WITNESS_FN:%.*]] = function_ref @$s22constrained_extensions1SVAASiRszlE1xSivM : $@yield_once @convention(method) (@inout S<Int>) -> @yields @inout Int
259+
// CHECK: begin_apply [[WITNESS_FN]](%0) : $@yield_once @convention(method) (@inout S<Int>) -> @yields @inout Int
260+
// CHECK: yield
261+
// CHECK: unwind

0 commit comments

Comments
 (0)