Skip to content

Commit 377a3bd

Browse files
authored
Merge pull request #33880 from jckarter/replace-opaque-types-terminate-on-fix-point-5.3
[5.3] Stop ReplaceOpaqueTypesWithUnderlyingTypes recursion if it hits a fixpoint
2 parents 6446e64 + ba8362e commit 377a3bd

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
@@ -3059,8 +3059,8 @@ operator()(SubstitutableType *maybeOpaqueType) const {
30593059
}))
30603060
return maybeOpaqueType;
30613061

3062-
// If the type still contains opaque types, recur.
3063-
if (substTy->hasOpaqueArchetype()) {
3062+
// If the type changed, but still contains opaque types, recur.
3063+
if (!substTy->isEqual(maybeOpaqueType) && substTy->hasOpaqueArchetype()) {
30643064
return ::substOpaqueTypesWithUnderlyingTypes(
30653065
substTy, inContext, contextExpansion, isContextWholeModule);
30663066
}
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)