]> Cypherpunks repositories - gostls13.git/commitdiff
go/internal/gccgoimporter: skip /*nointerface*/ comment
authorIan Lance Taylor <iant@golang.org>
Tue, 4 Dec 2018 03:20:47 +0000 (19:20 -0800)
committerIan Lance Taylor <iant@golang.org>
Tue, 4 Dec 2018 15:52:48 +0000 (15:52 +0000)
Support for methods marked with "//go:nointerface" was broken by CL
151557, based on CL 150061, which changed the scanner to stop skipping
comments.

Change-Id: I43d5e2cf51bed2dc4ed9d6136ca21aa1223e8df1
Reviewed-on: https://go-review.googlesource.com/c/152378
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
src/go/internal/gccgoimporter/importer_test.go
src/go/internal/gccgoimporter/parser.go
src/go/internal/gccgoimporter/testdata/nointerface.go [new file with mode: 0644]
src/go/internal/gccgoimporter/testdata/nointerface.gox [new file with mode: 0644]

index 9725fd429fb1dfa400b91c298ca4924945dbd762..b659cfc1df166625ef29227c96d7e3234b090d92 100644 (file)
@@ -89,6 +89,7 @@ var importerTests = [...]importerTest{
        {pkgpath: "escapeinfo", name: "NewT", want: "func NewT(data []byte) *T"},
        {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: "nointerface", name: "I", want: "type I int"},
 }
 
 func TestGoxImporter(t *testing.T) {
index 7d075db4cef62a7cbff8eb9c5d4aa960c03a1b4d..5414046be4ef332b819180a420d89884419d3e40 100644 (file)
@@ -541,6 +541,14 @@ func (p *parser) parseNamedType(nlist []int) types.Type {
                // collect associated methods
                for p.tok == scanner.Ident {
                        p.expectKeyword("func")
+                       if p.tok == '/' {
+                               // Skip a /*nointerface*/ comment.
+                               p.expect('/')
+                               p.expect('*')
+                               p.expect(scanner.Ident)
+                               p.expect('*')
+                               p.expect('/')
+                       }
                        p.expect('(')
                        receiver, _ := p.parseParam(pkg)
                        p.expect(')')
diff --git a/src/go/internal/gccgoimporter/testdata/nointerface.go b/src/go/internal/gccgoimporter/testdata/nointerface.go
new file mode 100644 (file)
index 0000000..6a545f2
--- /dev/null
@@ -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) }
diff --git a/src/go/internal/gccgoimporter/testdata/nointerface.gox b/src/go/internal/gccgoimporter/testdata/nointerface.gox
new file mode 100644 (file)
index 0000000..7b73d17
--- /dev/null
@@ -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>