Skip to content

Commit 99b445a

Browse files
committed
RequirementMachine: Narrow fix for concrete type requirements with opaque archetype
Fixes rdar://problem/90665615.
1 parent ce25df6 commit 99b445a

File tree

3 files changed

+73
-3
lines changed

3 files changed

+73
-3
lines changed

lib/AST/RequirementMachine/PropertyUnification.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -491,9 +491,9 @@ void PropertyMap::concretizeNestedTypesFromConcreteParent(
491491
continue;
492492
}
493493

494-
// FIXME: Maybe this can happen if the concrete type is an
495-
// opaque result type?
496-
assert(!conformance.isAbstract());
494+
// This can happen if the concrete type is an opaque result type.
495+
if (conformance.isAbstract())
496+
continue;
497497

498498
auto *concrete = conformance.getConcrete();
499499

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// RUN: %target-swift-frontend -emit-silgen %s -disable-availability-checking
2+
3+
protocol P {
4+
associatedtype T
5+
6+
var t: T { get }
7+
}
8+
9+
protocol RecursiveP {
10+
associatedtype T : RecursiveP
11+
}
12+
13+
struct S_RecursiveP : RecursiveP {
14+
typealias T = S_RecursiveP
15+
}
16+
17+
struct DefinesRecursiveP : P {
18+
var t: some RecursiveP {
19+
return S_RecursiveP()
20+
}
21+
}
22+
23+
protocol HasRecursiveP {
24+
associatedtype T : RecursiveP
25+
}
26+
27+
extension HasRecursiveP where T == DefinesRecursiveP.T {
28+
func checkSameType(_ t: T) -> DefinesRecursiveP.T { return t }
29+
}
30+

test/Generics/sr16040.swift

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// RUN: %target-swift-frontend -typecheck -verify %s -disable-availability-checking
2+
3+
public protocol View {
4+
associatedtype Body : View
5+
var body: Body { get }
6+
}
7+
8+
public struct Text : View {
9+
public init(_: String) {}
10+
public var body: Self { return self }
11+
}
12+
13+
public protocol DisplayableValue {}
14+
15+
public protocol SingleValueDisplay: View {
16+
associatedtype DisplayedValue
17+
init (_ singleValue: DisplayedValue)
18+
var displayedValue: DisplayedValue { get }
19+
}
20+
21+
public protocol RawDisplayableValue: DisplayableValue {
22+
associatedtype RawDisplay: SingleValueDisplay
23+
where RawDisplay.DisplayedValue == Self
24+
}
25+
26+
public protocol RawTextDisplayableValue: RawDisplayableValue
27+
where Self: CustomStringConvertible,
28+
RawDisplay == RawTextDisplay<Self> { }
29+
30+
public struct RawTextDisplay <Value: CustomStringConvertible>: SingleValueDisplay {
31+
public var displayedValue: Value
32+
33+
public init (_ singleValue: Value) {
34+
self.displayedValue = singleValue
35+
}
36+
37+
public var body: some View {
38+
Text(displayedValue.description)
39+
}
40+
}

0 commit comments

Comments
 (0)