blob: 9d1abdb9e9562e830bdbd90a3cca2f76901e0424 [file] [log] [blame]
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 below, 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"
import "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
-- go.mod --
module testdata
go 1.12
-- a/a.go --
package a
import "testdata/b"
var x b.T
func A(b int) {
x.F() //@ inline(re"F", fresult)
}
-- b/b.go --
package b
type T struct{}
func (T) F() {
One()
Two()
}
func One() {}
func Two() {}
-- fresult --
package a
import (
"testdata/b"
b0 "testdata/b"
)
var x b.T
func A(b int) {
b0.One()
b0.Two() //@ inline(re"F", fresult)
}
-- d/d.go --
package d
import "testdata/e"
func D() {
const log = "shadow"
e.E() //@ inline(re"E", eresult)
}
-- e/e.go --
package e
import "log"
func E() {
log.Printf("")
}
-- eresult --
package d
import (
log0 "log"
)
func D() {
const log = "shadow"
log0.Printf("") //@ inline(re"E", eresult)
}