Skip to content

Commit 2ed50ec

Browse files
committed
Sema: If the structural occurs check skips a witness, treat it as tautological
Fixes rdar://problem/122584912.
1 parent f92a67d commit 2ed50ec

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

lib/Sema/AssociatedTypeInference.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,6 +1493,10 @@ AssociatedTypeInference::getPotentialTypeWitnessesFromRequirement(
14931493

14941494
if (cycleCheck.checkForPotentialCycle(witness)) {
14951495
LLVM_DEBUG(llvm::dbgs() << "Skipping witness to avoid request cycle\n");
1496+
1497+
// We must consider the possibility that none of the witnesses for this
1498+
// requirement can be chosen.
1499+
hadTautologicalWitness = true;
14961500
continue;
14971501
}
14981502

test/Distributed/actor_protocols.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ actor A2: DistributedActor {
6767
final class DA2: DistributedActor {
6868
// expected-error@-1{{non-actor type 'DA2' cannot conform to the 'AnyActor' protocol}}
6969
// expected-error@-2{{non-distributed actor type 'DA2' cannot conform to the 'DistributedActor' protocol}}
70-
// expected-error@-3{{'DistributedActor' requires the types 'ObjectIdentifier' and 'FakeActorSystem.ActorID' (aka 'ActorAddress') be equivalent}}
71-
// expected-note@-4{{requirement specified as 'Self.ID' == 'Self.ActorSystem.ActorID' [with Self = DA2]}}
7270
nonisolated var id: ID {
7371
fatalError()
7472
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// RUN: %target-typecheck-verify-swift -enable-experimental-associated-type-inference
2+
// RUN: %target-typecheck-verify-swift -disable-experimental-associated-type-inference
3+
4+
public struct DefaultA {}
5+
6+
public protocol P {
7+
associatedtype A = DefaultA
8+
associatedtype B
9+
10+
static func foo(_: A, _: B)
11+
static func bar(_: B)
12+
}
13+
14+
extension P {
15+
public static func foo(_: A, _: B) where B == Void {}
16+
}
17+
18+
// The only way C can conform to P is with 'A := DefaultA' and 'B := String'.
19+
// We skip C.foo() because it contains 'A', so we must not infer 'B := Void'
20+
// from P.foo() above.
21+
class C: P {
22+
public static func foo(_: A, _: String) {}
23+
public static func bar(_: String) {}
24+
}
25+
26+
let x: DefaultA.Type = C.A.self
27+
let y: String.Type = C.B.self

0 commit comments

Comments
 (0)