File tree 3 files changed +44
-4
lines changed
src/cmd/compile/internal/noder
3 files changed +44
-4
lines changed Original file line number Diff line number Diff line change @@ -995,6 +995,9 @@ func (subst *subster) node(n ir.Node) ir.Node {
995
995
case ir .OSEND :
996
996
transformSend (m .(* ir.SendStmt ))
997
997
998
+ case ir .OSELECT :
999
+ transformSelect (m .(* ir.SelectStmt ))
1000
+
998
1001
}
999
1002
}
1000
1003
Original file line number Diff line number Diff line change @@ -84,13 +84,13 @@ func (g *irgen) stmt(stmt syntax.Stmt) ir.Node {
84
84
// to know the types of the left and right sides in various cases.
85
85
delay := false
86
86
for _ , e := range lhs {
87
- if e .Typecheck () == 3 {
87
+ if e .Type (). HasTParam () || e . Typecheck () == 3 {
88
88
delay = true
89
89
break
90
90
}
91
91
}
92
92
for _ , e := range rhs {
93
- if e .Typecheck () == 3 {
93
+ if e .Type (). HasTParam () || e . Typecheck () == 3 {
94
94
delay = true
95
95
break
96
96
}
@@ -145,8 +145,20 @@ func (g *irgen) stmt(stmt syntax.Stmt) ir.Node {
145
145
return g .forStmt (stmt )
146
146
case * syntax.SelectStmt :
147
147
n := g .selectStmt (stmt )
148
- transformSelect (n .(* ir.SelectStmt ))
149
- n .SetTypecheck (1 )
148
+
149
+ delay := false
150
+ for _ , ncase := range n .(* ir.SelectStmt ).Cases {
151
+ if ncase .Comm != nil && ncase .Comm .Typecheck () == 3 {
152
+ delay = true
153
+ break
154
+ }
155
+ }
156
+ if delay {
157
+ n .SetTypecheck (3 )
158
+ } else {
159
+ transformSelect (n .(* ir.SelectStmt ))
160
+ n .SetTypecheck (1 )
161
+ }
150
162
return n
151
163
case * syntax.SwitchStmt :
152
164
return g .switchStmt (stmt )
Original file line number Diff line number Diff line change
1
+ // run -gcflags=-G=3
2
+
3
+ // Copyright 2021 The Go Authors. All rights reserved.
4
+ // Use of this source code is governed by a BSD-style
5
+ // license that can be found in the LICENSE file.
6
+
7
+ package main
8
+
9
+ type Constraint [T any ] interface {
10
+ ~ func () T
11
+ }
12
+
13
+ func Foo [T Constraint [T ]]() T {
14
+ var t T
15
+
16
+ t = func () T {
17
+ return t
18
+ }
19
+ return t
20
+ }
21
+
22
+ func main () {
23
+ type Bar func () Bar
24
+ Foo [Bar ]()
25
+ }
You can’t perform that action at this time.
0 commit comments