Skip to content

Commit 8565544

Browse files
authored
Merge pull request #33276 from jckarter/opaque-substitution-substitution-5.3
SILGen: Lower formal callee type pre-opaque-type-substitution.
2 parents 7cced30 + 3e5ecba commit 8565544

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
@@ -315,7 +315,8 @@ class Callee {
315315
CanFunctionType SubstFormalInterfaceType;
316316

317317
/// The substitutions applied to OrigFormalInterfaceType to produce
318-
/// SubstFormalInterfaceType.
318+
/// SubstFormalInterfaceType, substituted into the current type expansion
319+
/// context.
319320
SubstitutionMap Substitutions;
320321

321322
/// The list of values captured by our callee.
@@ -351,14 +352,14 @@ class Callee {
351352
/// Constructor for Callee::forDirect.
352353
Callee(SILGenFunction &SGF, SILDeclRef standaloneFunction,
353354
AbstractionPattern origFormalType, CanAnyFunctionType substFormalType,
354-
SubstitutionMap subs, SILLocation l,
355+
SubstitutionMap subs, SubstitutionMap formalSubs, SILLocation l,
355356
bool callDynamicallyReplaceableImpl = false)
356357
: kind(callDynamicallyReplaceableImpl
357358
? Kind::StandaloneFunctionDynamicallyReplaceableImpl
358359
: Kind::StandaloneFunction),
359360
Constant(standaloneFunction), OrigFormalInterfaceType(origFormalType),
360361
SubstFormalInterfaceType(
361-
getSubstFormalInterfaceType(substFormalType, subs)),
362+
getSubstFormalInterfaceType(substFormalType, formalSubs)),
362363
Substitutions(subs), Loc(l) {}
363364

364365
/// Constructor called by all for* factory methods except forDirect and
@@ -387,7 +388,9 @@ class Callee {
387388
auto &ci = SGF.getConstantInfo(SGF.getTypeExpansionContext(), c);
388389
return Callee(
389390
SGF, c, ci.FormalPattern, ci.FormalType,
390-
subs.mapIntoTypeExpansionContext(SGF.getTypeExpansionContext()), l,
391+
subs.mapIntoTypeExpansionContext(SGF.getTypeExpansionContext()),
392+
subs,
393+
l,
391394
callPreviousDynamicReplaceableImpl);
392395
}
393396

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)