Skip to content

Commit 33e9700

Browse files
Merge pull request #26935 from aschwaighofer/dyn_repl_generic_func-5.1_08-28
[5.1 08-28] Sema: Compare canonical bound signatures when comparing o…
2 parents 0304f41 + da40b2f commit 33e9700

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/AST/Type.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2363,7 +2363,8 @@ static bool matches(CanType t1, CanType t2, TypeMatchOptions matchMode,
23632363
if (matchMode.contains(TypeMatchFlags::AllowCompatibleOpaqueTypeArchetypes))
23642364
if (auto opaque1 = t1->getAs<OpaqueTypeArchetypeType>())
23652365
if (auto opaque2 = t2->getAs<OpaqueTypeArchetypeType>())
2366-
return opaque1->getBoundSignature() == opaque2->getBoundSignature() &&
2366+
return opaque1->getBoundSignature()->getCanonicalSignature() ==
2367+
opaque2->getBoundSignature()->getCanonicalSignature() &&
23672368
opaque1->getInterfaceType()->getCanonicalType()->matches(
23682369
opaque2->getInterfaceType()->getCanonicalType(), matchMode);
23692370

test/type/opaque.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -disable-availability-checking -typecheck -verify -enable-opaque-result-types %s
1+
// RUN: %target-swift-frontend -disable-availability-checking -typecheck -verify -enable-opaque-result-types %s -swift-version 5
22

33
protocol P {
44
func paul()
@@ -473,3 +473,16 @@ func invoke_52528543<T: P_52528543, U: P_52528543>(x: T, y: U) {
473473
var xab = f_52528543(x: x2)
474474
xab = f_52528543(x: y2) // expected-error{{cannot assign}}
475475
}
476+
477+
protocol Proto {}
478+
479+
struct I : Proto {}
480+
481+
dynamic func foo<S>(_ s: S) -> some Proto {
482+
return I()
483+
}
484+
485+
@_dynamicReplacement(for: foo)
486+
func foo_repl<S>(_ s: S) -> some Proto {
487+
return I()
488+
}

0 commit comments

Comments
 (0)