You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sema: New opaque return type circularity check that doesn't trigger lazy type checking of bodies
Commit b70f8a8 introduced a usage of
ReplaceOpaqueTypesWithUnderlyingTypes in Sema. Previously this was only
called from SILGen.
The problem was that ReplaceOpaqueTypesWithUnderlyingTypes would call
getUniqueUnderlyingTypeSubstitutions(), which triggers a request to
type check the body of the referenced function.
While this didn't result in unnecessary type checking work, because
UniqueUnderlyingTypeSubstitutionsRequest::evaluate() would skip bodies
in secondary files, it did change declaration checking order.
The specific issue we saw was a bad interaction with associated type
inference and unqualified lookup in a WMO build, and a complete test
case is hard to reduce here.
However, no behavior change is intended with this change, modulo bugs
elsewhere related to declaration checking order, so I feel OK not adding
a test case.
I'll hopefully address the unqualified lookup issue exposed in the
radar soon; it has a reproducer independent of opaque return types.
Fixes rdar://157329046.
Copy file name to clipboardExpand all lines: test/Generics/infinite_opaque_result_type.swift
+22-22Lines changed: 22 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -5,25 +5,25 @@ func concrete1() -> some Any {
5
5
returnconcrete1()
6
6
}
7
7
8
-
func concrete2()->someAny{
9
-
return[concrete2()] // expected-error {{function opaque return type was inferred as '[some Any]', which defines the opaque type in terms of itself}}
8
+
func concrete2()->someAny{ // expected-error {{function opaque return type was inferred as '[some Any]', which defines the opaque type in terms of itself}}
9
+
return[concrete2()]
10
10
}
11
11
12
12
13
-
func concrete1a()->someAny{
14
-
returnconcrete1b() // expected-error {{function opaque return type was inferred as 'some Any', which defines the opaque type in terms of itself}}
13
+
func concrete1a()->someAny{ // expected-error {{function opaque return type was inferred as 'some Any', which defines the opaque type in terms of itself}}
14
+
returnconcrete1b()
15
15
}
16
16
17
-
func concrete1b()->someAny{
17
+
func concrete1b()->someAny{ // expected-error {{function opaque return type was inferred as 'some Any', which defines the opaque type in terms of itself}}
18
18
returnconcrete1a()
19
19
}
20
20
21
21
22
-
func concrete2a()->someAny{
23
-
return[concrete2b()] // expected-error {{function opaque return type was inferred as '[some Any]', which defines the opaque type in terms of itself}}
22
+
func concrete2a()->someAny{ // expected-error {{function opaque return type was inferred as '[some Any]', which defines the opaque type in terms of itself}}
23
+
return[concrete2b()]
24
24
}
25
25
26
-
func concrete2b()->someAny{
26
+
func concrete2b()->someAny{ // expected-error {{function opaque return type was inferred as '[some Any]', which defines the opaque type in terms of itself}}
27
27
return[concrete2a()]
28
28
}
29
29
@@ -33,41 +33,41 @@ func generic1<T>(_ t: T) -> some Any {
33
33
returngeneric1(t)
34
34
}
35
35
36
-
func generic2<T>(_ t:T)->someAny{
37
-
return[generic2(t)] // expected-error {{function opaque return type was inferred as '[some Any]', which defines the opaque type in terms of itself}}
36
+
func generic2<T>(_ t:T)->someAny{ // expected-error {{function opaque return type was inferred as '[some Any]', which defines the opaque type in terms of itself}}
37
+
return[generic2(t)]
38
38
}
39
39
40
40
41
-
func generic1a<T>(_ t:T)->someAny{
42
-
returngeneric1b(t) // expected-error {{function opaque return type was inferred as 'some Any', which defines the opaque type in terms of itself}}
41
+
func generic1a<T>(_ t:T)->someAny{ // expected-error {{function opaque return type was inferred as 'some Any', which defines the opaque type in terms of itself}}
42
+
returngeneric1b(t)
43
43
}
44
44
45
-
func generic1b<T>(_ t:T)->someAny{
45
+
func generic1b<T>(_ t:T)->someAny{ // expected-error {{function opaque return type was inferred as 'some Any', which defines the opaque type in terms of itself}}
46
46
returngeneric1a(t)
47
47
}
48
48
49
49
50
-
func generic2a<T>(_ t:T)->someAny{
51
-
return[generic2b(t)] // expected-error {{function opaque return type was inferred as '[some Any]', which defines the opaque type in terms of itself}}
50
+
func generic2a<T>(_ t:T)->someAny{ // expected-error {{function opaque return type was inferred as '[some Any]', which defines the opaque type in terms of itself}}
51
+
return[generic2b(t)]
52
52
}
53
53
54
-
func generic2b<T>(_ t:T)->someAny{
54
+
func generic2b<T>(_ t:T)->someAny{ // expected-error {{function opaque return type was inferred as '[some Any]', which defines the opaque type in terms of itself}}
55
55
return[generic2a(t)]
56
56
}
57
57
58
58
59
-
func generic3a<T>(_ t:T)->someAny{
60
-
return[generic3b(t)] // expected-error {{function opaque return type was inferred as '[some Any]', which defines the opaque type in terms of itself}}
59
+
func generic3a<T>(_ t:T)->someAny{ // expected-error {{function opaque return type was inferred as '[some Any]', which defines the opaque type in terms of itself}}
60
+
return[generic3b(t)]
61
61
}
62
62
63
-
func generic3b<T>(_ t:T)->someAny{
63
+
func generic3b<T>(_ t:T)->someAny{ // expected-error {{function opaque return type was inferred as '[some Any]', which defines the opaque type in terms of itself}}
64
64
return[generic3a([t])]
65
65
}
66
66
67
-
func very_wide1()->someAny{
68
-
return(very_wide2(),very_wide2()) // expected-error {{function opaque return type was inferred as '(some Any, some Any)', which defines the opaque type in terms of itself}}
67
+
func very_wide1()->someAny{ // expected-error {{function opaque return type was inferred as '(some Any, some Any)', which defines the opaque type in terms of itself}}
68
+
return(very_wide2(),very_wide2())
69
69
}
70
70
71
-
func very_wide2()->someAny{
71
+
func very_wide2()->someAny{ // expected-error {{function opaque return type was inferred as '(some Any, some Any)', which defines the opaque type in terms of itself}}
0 commit comments