Skip to content

Commit c6131d8

Browse files
author
ematejska
authored
Merge pull request #5564 from jckarter/silgen-transform-null-context-3.0
[3.0] SILGen: Check for a null emission context before dereferencing.
2 parents 8784fb1 + 775753a commit c6131d8

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/SILGen/SILGenPoly.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,8 @@ RValue Transform::transform(RValue &&input,
275275
SmallVector<InitializationPtr, 4> eltInitsBuffer;
276276
MutableArrayRef<InitializationPtr> eltInits;
277277
auto tupleInit = ctxt.getEmitInto();
278-
if (!ctxt.getEmitInto()->canSplitIntoTupleElements()) {
278+
if (!ctxt.getEmitInto()
279+
|| !ctxt.getEmitInto()->canSplitIntoTupleElements()) {
279280
tupleInit = nullptr;
280281
} else {
281282
eltInits = tupleInit->splitIntoTupleElements(SGF, Loc, outputTupleType,

test/SILGen/reabstract-tuple.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %target-swift-frontend -emit-silgen -verify %s
2+
3+
// SR-3090:
4+
5+
class Box<T> {
6+
public let value: T
7+
8+
public init(_ value: T) {
9+
self.value = value
10+
}
11+
}
12+
13+
let box = Box((22, { () in }))
14+
let foo = box.value.0
15+
print(foo)

0 commit comments

Comments
 (0)