Skip to content

Commit 592d427

Browse files
authored
Merge pull request #33668 from CodaFi/field-day
[SR-13461] Relax An Assert
2 parents 7c8041a + 84c5065 commit 592d427

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

lib/SILGen/SILGenConstructor.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,9 @@ static void emitImplicitValueConstructor(SILGenFunction &SGF,
216216
.forwardInto(SGF, Loc, init.get());
217217
++elti;
218218
} else {
219-
#ifndef NDEBUG
220-
assert(
221-
field->getType()->isEqual(field->getParentInitializer()->getType())
222-
&& "Checked by sema");
223-
#endif
219+
assert(field->getType()->getReferenceStorageReferent()->isEqual(
220+
field->getParentInitializer()->getType()) &&
221+
"Initialization of field with mismatched type!");
224222

225223
// Cleanup after this initialization.
226224
FullExpr scope(SGF.Cleanups, field->getParentPatternBinding());
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: %target-swift-frontend -disable-availability-checking -emit-ir -o /dev/null %s
2+
// REQUIRES: asserts
3+
4+
final class Klass {
5+
static var current: Klass {
6+
fatalError()
7+
}
8+
}
9+
private struct Build<T> {
10+
let val: T
11+
unowned let unownedBinding = Klass.current
12+
unowned(unsafe) let unownedUnsafeBinding = Klass.current
13+
weak var weakBinding = Klass.current
14+
}
15+
private func phase<T>(_ val: T) -> Build<T> {
16+
return Build<T>(val: val)
17+
}

0 commit comments

Comments
 (0)