File tree 2 files changed +47
-9
lines changed 2 files changed +47
-9
lines changed Original file line number Diff line number Diff line change @@ -1443,18 +1443,22 @@ static InferenceCandidateKind checkInferenceCandidate(
1443
1443
}
1444
1444
1445
1445
if (auto otherAssoc = other->getAs <DependentMemberType>()) {
1446
- if (otherAssoc->getBase ()->isEqual (selfTy)) {
1447
- DependentMemberType *otherDMT;
1448
- if (ctx.LangOpts .EnableExperimentalAssociatedTypeInference ) {
1446
+ if (ctx.LangOpts .EnableExperimentalAssociatedTypeInference ) {
1449
1447
1450
- otherDMT = otherAssoc;
1451
-
1452
- } else {
1448
+ result->second = result->second .transform ([&](Type t) -> Type{
1449
+ if (t->isEqual (dmt))
1450
+ return otherAssoc;
1451
+ return t;
1452
+ });
1453
+ LLVM_DEBUG (llvm::dbgs () << " ++ we can same-type to:\n " ;
1454
+ result->second ->dump (llvm::dbgs ()));
1455
+ return InferenceCandidateKind::Good;
1453
1456
1454
- otherDMT = DependentMemberType::get (dmt->getBase (),
1455
- otherAssoc->getAssocType ());
1457
+ } else {
1456
1458
1457
- }
1459
+ if (otherAssoc->getBase ()->isEqual (selfTy)) {
1460
+ auto *otherDMT = DependentMemberType::get (dmt->getBase (),
1461
+ otherAssoc->getAssocType ());
1458
1462
1459
1463
result->second = result->second .transform ([&](Type t) -> Type{
1460
1464
if (t->isEqual (dmt))
@@ -1465,6 +1469,8 @@ static InferenceCandidateKind checkInferenceCandidate(
1465
1469
result->second ->dump (llvm::dbgs ()));
1466
1470
return InferenceCandidateKind::Good;
1467
1471
}
1472
+
1473
+ }
1468
1474
}
1469
1475
break ;
1470
1476
}
Original file line number Diff line number Diff line change
1
+ // RUN: %target-typecheck-verify-swift -disable-experimental-associated-type-inference
2
+ // RUN: %target-typecheck-verify-swift -enable-experimental-associated-type-inference
3
+
4
+ public protocol P < A> {
5
+ associatedtype A
6
+ associatedtype B : P
7
+
8
+ func makeA( ) -> A
9
+ var b : B { get }
10
+ }
11
+
12
+ extension P where A == B . A {
13
+ public func makeA( ) -> B . A {
14
+ fatalError ( )
15
+ }
16
+ }
17
+
18
+ public struct S : P {
19
+ public var b : some P < Int > {
20
+ return G < Int > ( )
21
+ }
22
+ }
23
+
24
+ public struct G < A> : P {
25
+ public func makeA( ) -> A { fatalError ( ) }
26
+ public var b : Never { fatalError ( ) }
27
+ }
28
+
29
+ extension Never : P {
30
+ public func makeA( ) -> Never { fatalError ( ) }
31
+ public var b : Never { fatalError ( ) }
32
+ }
You can’t perform that action at this time.
0 commit comments