Skip to content

Commit 2f0ce4c

Browse files
committed
IRGen: GenericContextScope always resets CurGenericSignature to old value
Previously, we didn't reset it if the old value was null, however this enabled a very fragile anti-pattern: // ... CurGenericSignature is not set here ... { GenericContextScope scope(IGM, newSig); // signature is now newSig ... } // ... old signature is still newSig! foo(IGM.getCurGenericContext()); // works, most of the time
1 parent cda25b7 commit 2f0ce4c

File tree

2 files changed

+0
-5
lines changed

2 files changed

+0
-5
lines changed

lib/IRGen/GenType.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,9 +1441,6 @@ TypeConverter::~TypeConverter() {
14411441
}
14421442

14431443
void TypeConverter::setGenericContext(CanGenericSignature signature) {
1444-
if (!signature)
1445-
return;
1446-
14471444
CurGenericSignature = signature;
14481445

14491446
// Clear the dependent type info cache since we have a new active signature

lib/IRGen/GenType.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,6 @@ class GenericContextScope {
277277
{}
278278

279279
~GenericContextScope() {
280-
if (!newSig)
281-
return;
282280
assert(TC.CurGenericSignature == newSig);
283281
TC.setGenericContext(oldSig);
284282
}

0 commit comments

Comments
 (0)