Skip to content

Commit 9943b92

Browse files
committed
[IRGen] Work around assertion in handling of keypaths into @objc protocols.
While we await for a proper fix for rdar://problem/36111009, disable the assertion triggered by that test case and make the result deterministically produce what a non-Asserts build will... usually... produce.
1 parent ebd67e7 commit 9943b92

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

lib/IRGen/ProtocolInfo.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,12 @@ class ProtocolInfo final :
227227
if (witness.matchesFunction(function))
228228
return getNonBaseWitnessIndex(&witness);
229229
}
230-
llvm_unreachable("didn't find entry for function");
230+
231+
// FIXME: This should be an "unreachable", but Swift < 4.1 had an
232+
// existing bug here that depends on (effectively) getting this
233+
// result in non-Asserts builds. Emulate that behavior for now,
234+
// but only on the Swift 4.1 branch.
235+
return WitnessIndex(0, false);
231236
}
232237

233238
/// Return the witness index for the type metadata access function
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: %target-swift-frontend -primary-file %s -emit-ir -o /dev/null
2+
3+
// REQUIRES: objc_interop
4+
5+
import Foundation
6+
7+
@objc protocol P {
8+
var property: Int64 { get }
9+
}
10+
11+
class PUser<T: P> where T: NSObject {
12+
init(t: T, updating progress: Progress) {
13+
_ = t.observe(\.property) { t, _ in
14+
let _ = t.property
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)