File tree 2 files changed +34
-1
lines changed
src/cmd/compile/internal/walk 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -957,7 +957,14 @@ func usemethod(n *ir.CallExpr) {
957
957
if t .NumParams () != 1 || t .Params ().Field (0 ).Type .Kind () != pKind {
958
958
return
959
959
}
960
- if t .NumResults () == 2 && t .Results ().Field (1 ).Type .Kind () != types .TBOOL {
960
+ switch t .NumResults () {
961
+ case 1 :
962
+ // ok
963
+ case 2 :
964
+ if t .Results ().Field (1 ).Type .Kind () != types .TBOOL {
965
+ return
966
+ }
967
+ default :
961
968
return
962
969
}
963
970
Original file line number Diff line number Diff line change
1
+ // compile
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
+ // Make sure that the compiler can analyze non-reflect
8
+ // Type.{Method,MethodByName} calls.
9
+
10
+ package p
11
+
12
+ type I interface {
13
+ MethodByName (string )
14
+ Method (int )
15
+ }
16
+
17
+ type M struct {}
18
+
19
+ func (M ) MethodByName (string ) {}
20
+ func (M ) Method (int ) {}
21
+
22
+ func f () {
23
+ var m M
24
+ I .MethodByName (m , "" )
25
+ I .Method (m , 42 )
26
+ }
You can’t perform that action at this time.
0 commit comments