Skip to content

Commit b02e16d

Browse files
authored
Merge pull request #60568 from xedin/rdar-98577451
[CSApply] Attempt value-to-opaque-result abstraction only after canon…
2 parents b51e9df + b4949a0 commit b02e16d

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

lib/Sema/CSApply.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6858,11 +6858,11 @@ Expr *ExprRewriter::coerceToType(Expr *expr, Type toType,
68586858
// below is just an approximate check since the above would be expensive to
68596859
// verify and still relies on the type checker ensuing `fromType` is
68606860
// compatible with any opaque archetypes.
6861-
if (toType->hasOpaqueArchetype() &&
6861+
if (toType->getCanonicalType()->hasOpaqueArchetype() &&
68626862
cs.getConstraintLocator(locator)->isForContextualType()) {
68636863
// Find the opaque type declaration. We need its generic signature.
68646864
OpaqueTypeDecl *opaqueDecl = nullptr;
6865-
bool found = toType.findIf([&](Type type) {
6865+
bool found = toType->getCanonicalType().findIf([&](Type type) {
68666866
if (auto opaqueType = type->getAs<OpaqueTypeArchetypeType>()) {
68676867
opaqueDecl = opaqueType->getDecl();
68686868
return true;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx10.15
2+
3+
// REQUIRES: objc_interop
4+
// REQUIRES: OS=macosx
5+
6+
protocol P {
7+
associatedtype T
8+
func f() -> T
9+
}
10+
11+
struct S: P {
12+
func f() -> some Any { return 3 }
13+
}
14+
15+
struct G<T> {
16+
typealias Foo = (T?, S.T)
17+
}
18+
19+
func f<T>(t: T) -> G<T>.Foo {
20+
return (t, S().f()) // Ok
21+
}

0 commit comments

Comments
 (0)