go/gcimporter15: revert user-visible changes related to aliases
Reason: Decision to back out current alias implementation. For golang/go#16339 (comment). Change-Id: Id2a394d78a8661c767bcc05370b81f79d9bfb714 Reviewed-on: https://go-review.googlesource.com/32756 Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Chris Manghane <cmang@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
58ec10c513
commit
46c63f3841
|
@ -203,19 +203,20 @@ func (p *exporter) obj(obj types.Object) {
|
||||||
p.paramList(sig.Params(), sig.Variadic())
|
p.paramList(sig.Params(), sig.Variadic())
|
||||||
p.paramList(sig.Results(), false)
|
p.paramList(sig.Results(), false)
|
||||||
|
|
||||||
case *types_Alias:
|
// Alias-related code. Keep for now.
|
||||||
// make sure the original is exported before the alias
|
// case *types_Alias:
|
||||||
// (if the alias declaration was invalid, orig will be nil)
|
// // make sure the original is exported before the alias
|
||||||
orig := original(obj)
|
// // (if the alias declaration was invalid, orig will be nil)
|
||||||
if orig != nil && !p.reexported[orig] {
|
// orig := original(obj)
|
||||||
p.obj(orig)
|
// if orig != nil && !p.reexported[orig] {
|
||||||
p.reexported[orig] = true
|
// p.obj(orig)
|
||||||
}
|
// p.reexported[orig] = true
|
||||||
|
// }
|
||||||
|
|
||||||
p.tag(aliasTag)
|
// p.tag(aliasTag)
|
||||||
p.pos(obj)
|
// p.pos(obj)
|
||||||
p.string(obj.Name())
|
// p.string(obj.Name())
|
||||||
p.qualifiedName(orig)
|
// p.qualifiedName(orig)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
log.Fatalf("gcimporter: unexpected object %v (%T)", obj, obj)
|
log.Fatalf("gcimporter: unexpected object %v (%T)", obj, obj)
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build go1.8
|
// Alias-related code. Keep for now.
|
||||||
|
// +build ignore
|
||||||
|
|
||||||
package gcimporter_test
|
package gcimporter_test
|
||||||
|
|
||||||
|
@ -16,7 +17,7 @@ import (
|
||||||
gcimporter "golang.org/x/tools/go/gcimporter15"
|
gcimporter "golang.org/x/tools/go/gcimporter15"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestInvalidAlias(t *testing.T) {
|
func disabledTestInvalidAlias(t *testing.T) {
|
||||||
// parse and typecheck
|
// parse and typecheck
|
||||||
const src = "package p; func InvalidAlias => foo.f"
|
const src = "package p; func InvalidAlias => foo.f"
|
||||||
fset1 := token.NewFileSet()
|
fset1 := token.NewFileSet()
|
||||||
|
|
|
@ -288,7 +288,11 @@ func (p *importer) obj(tag int) {
|
||||||
if pkg, name := p.qualifiedName(); pkg != nil {
|
if pkg, name := p.qualifiedName(); pkg != nil {
|
||||||
orig = pkg.Scope().Lookup(name)
|
orig = pkg.Scope().Lookup(name)
|
||||||
}
|
}
|
||||||
p.declare(types_NewAlias(pos, p.pkgList[0], name, orig))
|
// Alias-related code. Keep for now.
|
||||||
|
_ = pos
|
||||||
|
_ = name
|
||||||
|
_ = orig
|
||||||
|
// p.declare(types_NewAlias(pos, p.pkgList[0], name, orig))
|
||||||
|
|
||||||
default:
|
default:
|
||||||
errorf("unexpected object tag %d", tag)
|
errorf("unexpected object tag %d", tag)
|
||||||
|
|
|
@ -130,6 +130,8 @@ func testDir(t *testing.T, dir string, endTime time.Time) (nimports int) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const testfile = "exports.go"
|
||||||
|
|
||||||
func TestImportTestdata(t *testing.T) {
|
func TestImportTestdata(t *testing.T) {
|
||||||
// This package only handles gc export data.
|
// This package only handles gc export data.
|
||||||
if runtime.Compiler != "gc" {
|
if runtime.Compiler != "gc" {
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
// Copyright 2016 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build go1.6,!go1.8
|
|
||||||
|
|
||||||
package gcimporter
|
|
||||||
|
|
||||||
import (
|
|
||||||
"go/token"
|
|
||||||
"go/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
type types_Alias struct {
|
|
||||||
types.Object
|
|
||||||
dummy int
|
|
||||||
} // satisfies types.Object but will never be encountered
|
|
||||||
|
|
||||||
func types_NewAlias(pos token.Pos, pkg *types.Package, name string, orig types.Object) types.Object {
|
|
||||||
errorf("unexpected alias in non-Go1.8 export data: %s.%s => %v", pkg.Name(), name, orig) // panics
|
|
||||||
panic("unreachable")
|
|
||||||
}
|
|
||||||
|
|
||||||
func original(types.Object) types.Object {
|
|
||||||
panic("unreachable")
|
|
||||||
}
|
|
||||||
|
|
||||||
const testfile = "exports17.go"
|
|
|
@ -1,23 +0,0 @@
|
||||||
// Copyright 2016 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build go1.8
|
|
||||||
|
|
||||||
package gcimporter
|
|
||||||
|
|
||||||
import "go/types"
|
|
||||||
|
|
||||||
type types_Alias => types.Alias
|
|
||||||
|
|
||||||
func types_NewAlias => types.NewAlias
|
|
||||||
|
|
||||||
// TODO(gri) Consider exporting this functionality from go/types (issue 17730).
|
|
||||||
func original(obj types.Object) types.Object {
|
|
||||||
if alias, ok := obj.(*types.Alias); ok {
|
|
||||||
return alias.Orig()
|
|
||||||
}
|
|
||||||
return obj
|
|
||||||
}
|
|
||||||
|
|
||||||
const testfile = "exports18.go"
|
|
|
@ -1,109 +0,0 @@
|
||||||
// Copyright 2011 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// This file is used to generate an object file which
|
|
||||||
// serves as test file for gcimporter_test.go.
|
|
||||||
|
|
||||||
package exports
|
|
||||||
|
|
||||||
import (
|
|
||||||
"go/ast"
|
|
||||||
"go/build"
|
|
||||||
"math"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Issue 3682: Correctly read dotted identifiers from export data.
|
|
||||||
const init1 = 0
|
|
||||||
|
|
||||||
func init() {}
|
|
||||||
|
|
||||||
const (
|
|
||||||
C0 int = 0
|
|
||||||
C1 = 3.14159265
|
|
||||||
C2 = 2.718281828i
|
|
||||||
C3 = -123.456e-789
|
|
||||||
C4 = +123.456E+789
|
|
||||||
C5 = 1234i
|
|
||||||
C6 = "foo\n"
|
|
||||||
C7 = `bar\n`
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
C8 => math.Pi
|
|
||||||
)
|
|
||||||
|
|
||||||
type (
|
|
||||||
T1 int
|
|
||||||
T2 [10]int
|
|
||||||
T3 []int
|
|
||||||
T4 *int
|
|
||||||
T5 chan int
|
|
||||||
T6a chan<- int
|
|
||||||
T6b chan (<-chan int)
|
|
||||||
T6c chan<- (chan int)
|
|
||||||
T7 <-chan *ast.File
|
|
||||||
T8 struct{}
|
|
||||||
T9 struct {
|
|
||||||
a int
|
|
||||||
b, c float32
|
|
||||||
d []string `go:"tag"`
|
|
||||||
}
|
|
||||||
T10 struct {
|
|
||||||
T8
|
|
||||||
T9
|
|
||||||
_ *T10
|
|
||||||
}
|
|
||||||
T11 map[int]string
|
|
||||||
T12 interface{}
|
|
||||||
T13 interface {
|
|
||||||
m1()
|
|
||||||
m2(int) float32
|
|
||||||
}
|
|
||||||
T14 interface {
|
|
||||||
T12
|
|
||||||
T13
|
|
||||||
m3(x ...struct{}) []T9
|
|
||||||
}
|
|
||||||
T15 func()
|
|
||||||
T16 func(int)
|
|
||||||
T17 func(x int)
|
|
||||||
T18 func() float32
|
|
||||||
T19 func() (x float32)
|
|
||||||
T20 func(...interface{})
|
|
||||||
T21 struct{ next *T21 }
|
|
||||||
T22 struct{ link *T23 }
|
|
||||||
T23 struct{ link *T22 }
|
|
||||||
T24 *T24
|
|
||||||
T25 *T26
|
|
||||||
T26 *T27
|
|
||||||
T27 *T25
|
|
||||||
T28 func(T28) T28
|
|
||||||
)
|
|
||||||
|
|
||||||
type (
|
|
||||||
T29 => ast.File
|
|
||||||
T30 => build.Context
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
V0 int
|
|
||||||
V1 = -991.0
|
|
||||||
V2 float32 = 1.2
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
V3 => build.Default
|
|
||||||
)
|
|
||||||
|
|
||||||
func F1() {}
|
|
||||||
func F2(x int) {}
|
|
||||||
func F3() int { return 0 }
|
|
||||||
func F4() float32 { return 0 }
|
|
||||||
func F5(a, b, c int, u, v, w struct{ x, y T1 }, more ...interface{}) (p, q, r chan<- T10)
|
|
||||||
|
|
||||||
func (p *T1) M1()
|
|
||||||
|
|
||||||
func F6 => math.Sin
|
|
||||||
func F7 => ast.IsExported
|
|
||||||
func F8 => build.Import
|
|
Loading…
Reference in New Issue