Skip to content

Commit f095eee

Browse files
committed
Stop ReplaceOpaqueTypesWithUnderlyingTypes recursion if it hits a fixpoint.
This can happen when a non-substitutable opaque type appears in structural position, such as the root of an associated type archetype. Fixes rdar://problem/67040429.
1 parent 2e03264 commit f095eee

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

lib/AST/Type.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3063,8 +3063,8 @@ operator()(SubstitutableType *maybeOpaqueType) const {
30633063
}))
30643064
return maybeOpaqueType;
30653065

3066-
// If the type still contains opaque types, recur.
3067-
if (substTy->hasOpaqueArchetype()) {
3066+
// If the type changed, but still contains opaque types, recur.
3067+
if (!substTy->isEqual(maybeOpaqueType) && substTy->hasOpaqueArchetype()) {
30683068
return ::substOpaqueTypesWithUnderlyingTypes(
30693069
substTy, inContext, contextExpansion, isContextWholeModule);
30703070
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
public protocol Gesture {
2+
associatedtype Body: Gesture
3+
var body: Body { get }
4+
5+
associatedtype Value
6+
var value: Value { get }
7+
}
8+
9+
extension Gesture {
10+
public var value: Body.Value { return body.value }
11+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -disable-availability-checking -emit-module-path %t/replace_opaque_type_public_assoc_type_m.swiftmodule %S/Inputs/replace_opaque_type_public_assoc_type_m.swift
3+
// RUN: %target-swift-emit-silgen -disable-availability-checking -I %t %s -verify
4+
5+
import replace_opaque_type_public_assoc_type_m
6+
7+
struct PiggyBack: Gesture {
8+
var action: () -> Void
9+
10+
var body: some Gesture {
11+
action()
12+
return self
13+
}
14+
}

0 commit comments

Comments
 (0)