Skip to content

Commit 3a3d2fd

Browse files
authored
Merge pull request swiftlang#33275 from jckarter/opaque-substitution-substitution
SILGen: Lower formal callee type pre-opaque-type-substitution.
2 parents 0684c62 + a07fce6 commit 3a3d2fd

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

lib/SILGen/SILGenApply.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,8 @@ class Callee {
318318
CanFunctionType SubstFormalInterfaceType;
319319

320320
/// The substitutions applied to OrigFormalInterfaceType to produce
321-
/// SubstFormalInterfaceType.
321+
/// SubstFormalInterfaceType, substituted into the current type expansion
322+
/// context.
322323
SubstitutionMap Substitutions;
323324

324325
/// The list of values captured by our callee.
@@ -354,14 +355,14 @@ class Callee {
354355
/// Constructor for Callee::forDirect.
355356
Callee(SILGenFunction &SGF, SILDeclRef standaloneFunction,
356357
AbstractionPattern origFormalType, CanAnyFunctionType substFormalType,
357-
SubstitutionMap subs, SILLocation l,
358+
SubstitutionMap subs, SubstitutionMap formalSubs, SILLocation l,
358359
bool callDynamicallyReplaceableImpl = false)
359360
: kind(callDynamicallyReplaceableImpl
360361
? Kind::StandaloneFunctionDynamicallyReplaceableImpl
361362
: Kind::StandaloneFunction),
362363
Constant(standaloneFunction), OrigFormalInterfaceType(origFormalType),
363364
SubstFormalInterfaceType(
364-
getSubstFormalInterfaceType(substFormalType, subs)),
365+
getSubstFormalInterfaceType(substFormalType, formalSubs)),
365366
Substitutions(subs), Loc(l) {}
366367

367368
/// Constructor called by all for* factory methods except forDirect and
@@ -390,7 +391,9 @@ class Callee {
390391
auto &ci = SGF.getConstantInfo(SGF.getTypeExpansionContext(), c);
391392
return Callee(
392393
SGF, c, ci.FormalPattern, ci.FormalType,
393-
subs.mapIntoTypeExpansionContext(SGF.getTypeExpansionContext()), l,
394+
subs.mapIntoTypeExpansionContext(SGF.getTypeExpansionContext()),
395+
subs,
396+
l,
394397
callPreviousDynamicReplaceableImpl);
395398
}
396399

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %target-swift-emit-silgen -disable-availability-checking -verify %s
2+
3+
// rdar://problem/65683913
4+
5+
@_silgen_name("foo") func foo() -> Int
6+
7+
func createSomeOpaqueObject() -> some CustomStringConvertible {
8+
foo()
9+
}
10+
11+
struct TypeWitness<R> {
12+
init(witness _: R) { }
13+
14+
var type: R.Type { R.self }
15+
func getType() -> R.Type { R.self }
16+
}
17+
18+
let w = TypeWitness(witness: createSomeOpaqueObject())
19+
print(w.getType())

0 commit comments

Comments
 (0)