Skip to content

Commit 1eda5ab

Browse files
authored
Merge pull request #33949 from jckarter/serialized-capture-opaque-type-subst-assert-5.3
[5.3] SILGen: Relax assertion that incorrectly tripped on lowered opaque capture types.
2 parents 89edca6 + c3a1c7f commit 1eda5ab

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

lib/SILGen/SILGenThunk.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,14 @@ SILGenFunction::emitGlobalFunctionRef(SILLocation loc, SILDeclRef constant,
144144
}
145145

146146
auto f = SGM.getFunction(constant, NotForDefinition);
147-
assert(f->getLoweredFunctionTypeInContext(B.getTypeExpansionContext()) ==
148-
constantInfo.SILFnType);
147+
#ifndef NDEBUG
148+
auto constantFnTypeInContext =
149+
SGM.Types.getLoweredType(constantInfo.SILFnType,
150+
B.getTypeExpansionContext())
151+
.castTo<SILFunctionType>();
152+
assert(f->getLoweredFunctionTypeInContext(B.getTypeExpansionContext())
153+
== constantFnTypeInContext);
154+
#endif
149155
if (callPreviousDynamicReplaceableImpl)
150156
return B.createPreviousDynamicFunctionRef(loc, f);
151157
else
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %target-swift-frontend -disable-availability-checking -emit-silgen -verify %s
2+
3+
public func foo() -> some Any { return 1 }
4+
5+
public struct XY<X, Y> { public init(x: X, y: Y) { fatalError() } }
6+
7+
@inlinable
8+
public func bar() -> () -> Any {
9+
let xy = XY(x: 1, y: foo())
10+
11+
return { xy }
12+
}

0 commit comments

Comments
 (0)