go/gcimporter15: remove support for Go1.5
Change-Id: I183090131a675237be42cc005719554399704f8d Reviewed-on: https://go-review.googlesource.com/32541 Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
parent
a4fe4f6140
commit
a829b5068d
|
@ -2,9 +2,9 @@
|
||||||
// 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.5
|
// +build go1.6
|
||||||
|
|
||||||
// This file is a copy of $GOROOT/src/go/internal/gcimporter/bimport.go, tagged for go1.5.
|
// This file is a copy of $GOROOT/src/go/internal/gcimporter/bimport.go, tagged for go1.6.
|
||||||
|
|
||||||
package gcimporter
|
package gcimporter
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
// 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.5
|
// +build go1.6
|
||||||
|
|
||||||
// This file is a copy of $GOROOT/src/go/internal/gcimporter/exportdata.go, tagged for go1.5.
|
// This file is a copy of $GOROOT/src/go/internal/gcimporter/exportdata.go, tagged for go1.6.
|
||||||
|
|
||||||
// This file implements FindExportData.
|
// This file implements FindExportData.
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
// 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.5
|
// +build go1.6
|
||||||
|
|
||||||
// This file is a copy of $GOROOT/src/go/internal/gcimporter/gcimporter.go, tagged for go1.5,
|
// This file is a copy of $GOROOT/src/go/internal/gcimporter/gcimporter.go, tagged for go1.6,
|
||||||
// and minimally adjusted to make it build.
|
// and minimally adjusted to make it build.
|
||||||
|
|
||||||
// Package gcimporter15 provides various functions for reading
|
// Package gcimporter15 provides various functions for reading
|
||||||
|
@ -399,7 +399,7 @@ func (p *parser) getPkg(id, name string) *types.Package {
|
||||||
// package exists already and we have an expected package name;
|
// package exists already and we have an expected package name;
|
||||||
// make sure names match or set package name if necessary
|
// make sure names match or set package name if necessary
|
||||||
if pname := pkg.Name(); pname == "" {
|
if pname := pkg.Name(); pname == "" {
|
||||||
setName(pkg, name)
|
pkg.SetName(name)
|
||||||
} else if pname != name {
|
} else if pname != name {
|
||||||
p.errorf("%s package name mismatch: %s (given) vs %s (expected)", id, pname, name)
|
p.errorf("%s package name mismatch: %s (given) vs %s (expected)", id, pname, name)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
// 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.5
|
// +build go1.6
|
||||||
|
|
||||||
// This file is a copy of $GOROOT/src/go/internal/gcimporter/gcimporter_test.go, tagged for go1.5,
|
// This file is a copy of $GOROOT/src/go/internal/gcimporter/gcimporter_test.go, tagged for go1.6,
|
||||||
// and minimally adjusted to make it build with code from (std lib) internal/testenv copied.
|
// and minimally adjusted to make it build with code from (std lib) internal/testenv copied.
|
||||||
|
|
||||||
package gcimporter
|
package gcimporter
|
||||||
|
|
|
@ -1,31 +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.5,!go1.6
|
|
||||||
|
|
||||||
package gcimporter
|
|
||||||
|
|
||||||
import (
|
|
||||||
"go/types"
|
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
func setName(pkg *types.Package, name string) {
|
|
||||||
(*types_Package)(unsafe.Pointer(pkg)).name = name
|
|
||||||
}
|
|
||||||
|
|
||||||
// The underlying type of types_Package is identical to
|
|
||||||
// the underlying type of types.Package. We use it with
|
|
||||||
// package unsafe to set the name field since 1.5 does
|
|
||||||
// not have the Package.SetName method.
|
|
||||||
// TestSetName verifies that the layout with respect to
|
|
||||||
// the name field is correct.
|
|
||||||
type types_Package struct {
|
|
||||||
path string
|
|
||||||
name string
|
|
||||||
scope *types.Scope
|
|
||||||
complete bool
|
|
||||||
imports []*types.Package
|
|
||||||
fake bool
|
|
||||||
}
|
|
|
@ -1,13 +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
|
|
||||||
|
|
||||||
package gcimporter
|
|
||||||
|
|
||||||
import "go/types"
|
|
||||||
|
|
||||||
func setName(pkg *types.Package, name string) {
|
|
||||||
pkg.SetName(name)
|
|
||||||
}
|
|
|
@ -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.5
|
|
||||||
|
|
||||||
package gcimporter
|
|
||||||
|
|
||||||
import (
|
|
||||||
"go/types"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestSetName(t *testing.T) {
|
|
||||||
pkg := types.NewPackage("path", "foo")
|
|
||||||
scope := pkg.Scope()
|
|
||||||
|
|
||||||
// verify setName
|
|
||||||
setName(pkg, "bar")
|
|
||||||
if name := pkg.Name(); name != "bar" {
|
|
||||||
t.Fatalf(`got package name %q; want "bar"`, name)
|
|
||||||
}
|
|
||||||
|
|
||||||
// verify no other fields are changed
|
|
||||||
if pkg.Path() != "path" || pkg.Scope() != scope || pkg.Complete() || pkg.Imports() != nil {
|
|
||||||
t.Fatalf("setName changed other fields")
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue