| 1 |
Test of failure to inline because callee references a |
| 2 |
package-level decl that is shadowed by caller. |
| 3 |
|
| 4 |
Observe that the first call to f can be inlined because |
| 5 |
the shadowing has not yet occurred; but the second call |
| 6 |
to f is within the scope of the local constant v. |
| 7 |
|
| 8 |
-- go.mod -- |
| 9 |
module testdata |
| 10 |
go 1.18 |
| 11 |
|
| 12 |
-- a/a.go -- |
| 13 |
package a |
| 14 |
|
| 15 |
func _() { |
| 16 |
f() //@ inline(re"f", result) |
| 17 |
const v = 1 |
| 18 |
f() //@ inline(re"f", re"v.*shadowed.*by.*const.*line 5") |
| 19 |
} |
| 20 |
|
| 21 |
func _[v any]() { |
| 22 |
f() //@ inline(re"f", re"v.*shadowed.*by.*typename.*line 9") |
| 23 |
} |
| 24 |
|
| 25 |
func f() int { return v } |
| 26 |
|
| 27 |
var v int |
| 28 |
|
| 29 |
-- result -- |
| 30 |
package a |
| 31 |
|
| 32 |
func _() { |
| 33 |
_ = v //@ inline(re"f", result) |
| 34 |
const v = 1 |
| 35 |
f() //@ inline(re"f", re"v.*shadowed.*by.*const.*line 5") |
| 36 |
} |
| 37 |
|
| 38 |
func _[v any]() { |
| 39 |
f() //@ inline(re"f", re"v.*shadowed.*by.*typename.*line 9") |
| 40 |
} |
| 41 |
|
| 42 |
func f() int { return v } |
| 43 |
|
| 44 |
var v int |