blob: c311ee69425cf28af45bd45d013ae81e91c14eb4 [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.
Two scenarios below:
1. a second (renaming) import is added because the first import is
locally shadowed.
2. a new import is added with a fresh name because the default
name is locally shadowed.
-- 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) {
{
var _ b0.T = x
b0.One()
b0.Two()
} //@ inline(re"F", fresult)
}