| 1 |
|
| 2 |
This test renames a receiver, type parameter, parameter or result var |
| 3 |
whose name matches a package-level decl. Prior to go1.22, this used to |
| 4 |
cause a spurious shadowing error because of an edge case in the |
| 5 |
behavior of types.Scope for function parameters and results. |
| 6 |
|
| 7 |
This is a regression test for issue #60752, a bug in the type checker. |
| 8 |
|
| 9 |
-- go.mod -- |
| 10 |
module example.com |
| 11 |
go 1.18 |
| 12 |
|
| 13 |
-- a/type.go -- |
| 14 |
package a |
| 15 |
|
| 16 |
type t int |
| 17 |
|
| 18 |
-- a/recv.go -- |
| 19 |
package a |
| 20 |
|
| 21 |
func (v t) _() {} //@ rename("v", "t", recv) |
| 22 |
|
| 23 |
-- a/param.go -- |
| 24 |
package a |
| 25 |
|
| 26 |
func _(v t) {} //@ rename("v", "t", param) |
| 27 |
|
| 28 |
-- a/result.go -- |
| 29 |
package a |
| 30 |
|
| 31 |
func _() (v t) { return } //@ rename("v", "t", result) |
| 32 |
|
| 33 |
-- a/typeparam.go -- |
| 34 |
package a |
| 35 |
|
| 36 |
func _[v t]() {} //@ renameerr("v", "t", re"would shadow (.|\n)*type.go:3:6") |
| 37 |
|
| 38 |
-- b/b.go -- |
| 39 |
package b |
| 40 |
|
| 41 |
import _ "example.com/a" |
| 42 |
|
| 43 |
-- @param/a/param.go -- |
| 44 |
@@ -3 +3 @@ |
| 45 |
-func _(v t) {} //@ rename("v", "t", param) |
| 46 |
+func _(t t) {} //@ rename("v", "t", param) |
| 47 |
-- @recv/a/recv.go -- |
| 48 |
@@ -3 +3 @@ |
| 49 |
-func (v t) _() {} //@ rename("v", "t", recv) |
| 50 |
+func (t t) _() {} //@ rename("v", "t", recv) |
| 51 |
-- @result/a/result.go -- |
| 52 |
@@ -3 +3 @@ |
| 53 |
-func _() (v t) { return } //@ rename("v", "t", result) |
| 54 |
+func _() (t t) { return } //@ rename("v", "t", result) |