| Just because a package (e.g. log) is imported by the caller, | |
| and the name log is in scope, doesn't mean the name in scope | |
| refers to the package: it could be locally shadowed. | |
| In all three scenarios in this file and import-shadow-2.txtar, a renaming | |
| import with a fresh name is added because the usual name is locally | |
| shadowed: in cases 1, 2 an existing import is shadowed by (respectively) | |
| a local constant, parameter; in case 3 there is no existing import. | |
| -- go.mod -- | |
| module testdata | |
| go 1.12 | |
| -- a/a.go -- | |
| package a | |
| import ( | |
| "testdata/b" | |
| "log" | |
| ) | |
| func A() { | |
| const log = "shadow" | |
| b.B() //@ inline(re"B", bresult) | |
| } | |
| var _ log.Logger | |
| -- b/b.go -- | |
| package b | |
| import "log" | |
| func B() { | |
| log.Printf("") | |
| } | |
| -- bresult -- | |
| package a | |
| import ( | |
| "log" | |
| log0 "log" | |
| ) | |
| func A() { | |
| const log = "shadow" | |
| log0.Printf("") //@ inline(re"B", bresult) | |
| } | |
| var _ log.Logger |