go/internal/gccgoimporter: use types.NewInterface (not NewInterface2) for builds before Go 1.11

For https://github.com/golang/lint/issues/402.

Change-Id: I06d944aaa168fb595ff96eb27a7d6e7da344ebd6
Reviewed-on: https://go-review.googlesource.com/118564
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
This commit is contained in:
Robert Griesemer 2018-06-13 10:59:32 -07:00
parent 9d855108b0
commit 6f857df7d4
3 changed files with 35 additions and 1 deletions

View File

@ -0,0 +1,21 @@
// 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.
// +build !go1.11
package gccgoimporter
import "go/types"
func newInterface(methods []*types.Func, embeddeds []types.Type) *types.Interface {
named := make([]*types.Named, len(embeddeds))
for i, e := range embeddeds {
var ok bool
named[i], ok = e.(*types.Named)
if !ok {
panic("embedding of non-defined interfaces in interfaces is not supported before Go 1.11")
}
}
return types.NewInterface(methods, named)
}

View File

@ -0,0 +1,13 @@
// 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.
// +build go1.11
package gccgoimporter
import "go/types"
func newInterface(methods []*types.Func, embeddeds []types.Type) *types.Interface {
return types.NewInterface2(methods, embeddeds)
}

View File

@ -602,7 +602,7 @@ func (p *parser) parseInterfaceType(pkg *types.Package) types.Type {
} }
p.expect('}') p.expect('}')
return types.NewInterface2(methods, embeddeds) return newInterface(methods, embeddeds)
} }
// PointerType = "*" ("any" | Type) . // PointerType = "*" ("any" | Type) .