go/internal/gccgoimporter: update package to match std lib version
This CL updates the importer to match the original code in the std lib
but for the necessary changes to make the code work in x/tools and
with older versions of the std lib.
Notably, it brings over changes from:
https://go-review.googlesource.com/c/152378
Change-Id: Icaa05303a05a226c710b5923d8574f255651fe47
Reviewed-on: https://go-review.googlesource.com/c/152577
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
3832e276fb
commit
555fafe5a2
|
|
@ -92,6 +92,7 @@ var importerTests = [...]importerTest{
|
||||||
{pkgpath: "escapeinfo", name: "NewT", want: "func NewT(data []byte) *T"},
|
{pkgpath: "escapeinfo", name: "NewT", want: "func NewT(data []byte) *T"},
|
||||||
{pkgpath: "issue27856", name: "M", want: "type M struct{E F}"},
|
{pkgpath: "issue27856", name: "M", want: "type M struct{E F}"},
|
||||||
{pkgpath: "v1reflect", name: "Type", want: "type Type interface{Align() int; AssignableTo(u Type) bool; Bits() int; ChanDir() ChanDir; Elem() Type; Field(i int) StructField; FieldAlign() int; FieldByIndex(index []int) StructField; FieldByName(name string) (StructField, bool); FieldByNameFunc(match func(string) bool) (StructField, bool); Implements(u Type) bool; In(i int) Type; IsVariadic() bool; Key() Type; Kind() Kind; Len() int; Method(int) Method; MethodByName(string) (Method, bool); Name() string; NumField() int; NumIn() int; NumMethod() int; NumOut() int; Out(i int) Type; PkgPath() string; Size() uintptr; String() string; common() *commonType; rawString() string; runtimeType() *runtimeType; uncommon() *uncommonType}"},
|
{pkgpath: "v1reflect", name: "Type", want: "type Type interface{Align() int; AssignableTo(u Type) bool; Bits() int; ChanDir() ChanDir; Elem() Type; Field(i int) StructField; FieldAlign() int; FieldByIndex(index []int) StructField; FieldByName(name string) (StructField, bool); FieldByNameFunc(match func(string) bool) (StructField, bool); Implements(u Type) bool; In(i int) Type; IsVariadic() bool; Key() Type; Kind() Kind; Len() int; Method(int) Method; MethodByName(string) (Method, bool); Name() string; NumField() int; NumIn() int; NumMethod() int; NumOut() int; Out(i int) Type; PkgPath() string; Size() uintptr; String() string; common() *commonType; rawString() string; runtimeType() *runtimeType; uncommon() *uncommonType}"},
|
||||||
|
{pkgpath: "nointerface", name: "I", want: "type I int"},
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGoxImporter(t *testing.T) {
|
func TestGoxImporter(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -545,6 +545,14 @@ func (p *parser) parseNamedType(nlist []int) types.Type {
|
||||||
// collect associated methods
|
// collect associated methods
|
||||||
for p.tok == scanner.Ident {
|
for p.tok == scanner.Ident {
|
||||||
p.expectKeyword("func")
|
p.expectKeyword("func")
|
||||||
|
if p.tok == '/' {
|
||||||
|
// Skip a /*nointerface*/ comment.
|
||||||
|
p.expect('/')
|
||||||
|
p.expect('*')
|
||||||
|
p.expect(scanner.Ident)
|
||||||
|
p.expect('*')
|
||||||
|
p.expect('/')
|
||||||
|
}
|
||||||
p.expect('(')
|
p.expect('(')
|
||||||
receiver, _ := p.parseParam(pkg)
|
receiver, _ := p.parseParam(pkg)
|
||||||
p.expect(')')
|
p.expect(')')
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
package nointerface
|
||||||
|
|
||||||
|
type I int
|
||||||
|
|
||||||
|
//go:nointerface
|
||||||
|
func (p *I) Get() int { return int(*p) }
|
||||||
|
|
||||||
|
func (p *I) Set(v int) { *p = I(v) }
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
v3;
|
||||||
|
package nointerface
|
||||||
|
pkgpath nointerface
|
||||||
|
types 3 2 133 17
|
||||||
|
type 1 "I" <type -11>
|
||||||
|
func /*nointerface*/ (p <esc:0x1> <type 2>) Get () <type -11>
|
||||||
|
func (p <esc:0x1> <type 2>) Set (v <type -11>)
|
||||||
|
type 2 *<type 1>
|
||||||
Loading…
Reference in New Issue