mirror of
https://github.com/golang/go
synced 2024-11-08 05:36:13 -07:00
cmd/compile/internal/types2: review of issues_test.go
The changes between (equivalent, and reviewed) go/types/issues_test.go and issues_test.go can be seen by comparing patchset 1 and 3. The actual change is just removing the "// UNREVIEWED" marker and making making some minor code adjustments to match go/types's version more closely. Change-Id: I26f3f700d12db69fc68161a6b0dc081a0e9cd0d4 Reviewed-on: https://go-review.googlesource.com/c/go/+/294473 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
378f73e2d5
commit
89eb2b55b9
@ -1,4 +1,3 @@
|
|||||||
// UNREVIEWED
|
|
||||||
// Copyright 2013 The Go Authors. All rights reserved.
|
// Copyright 2013 The Go Authors. All rights reserved.
|
||||||
// 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.
|
||||||
@ -29,7 +28,6 @@ func mustParse(t *testing.T, src string) *syntax.File {
|
|||||||
func TestIssue5770(t *testing.T) {
|
func TestIssue5770(t *testing.T) {
|
||||||
f := mustParse(t, `package p; type S struct{T}`)
|
f := mustParse(t, `package p; type S struct{T}`)
|
||||||
var conf Config
|
var conf Config
|
||||||
// conf := Config{Importer: importer.Default()}
|
|
||||||
_, err := conf.Check(f.PkgName.Value, []*syntax.File{f}, nil) // do not crash
|
_, err := conf.Check(f.PkgName.Value, []*syntax.File{f}, nil) // do not crash
|
||||||
want := "undeclared name: T"
|
want := "undeclared name: T"
|
||||||
if err == nil || !strings.Contains(err.Error(), want) {
|
if err == nil || !strings.Contains(err.Error(), want) {
|
||||||
@ -76,7 +74,7 @@ var (
|
|||||||
}
|
}
|
||||||
case *syntax.Name:
|
case *syntax.Name:
|
||||||
if x.Value == "nil" {
|
if x.Value == "nil" {
|
||||||
want = NewInterfaceType(nil, nil) // interface{}
|
want = NewInterfaceType(nil, nil) // interface{} (for now, go/types types this as "untyped nil")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if want != nil && !Identical(tv.Type, want) {
|
if want != nil && !Identical(tv.Type, want) {
|
||||||
@ -387,9 +385,6 @@ func TestIssue28005(t *testing.T) {
|
|||||||
t.Fatal("object X not found")
|
t.Fatal("object X not found")
|
||||||
}
|
}
|
||||||
iface := obj.Type().Underlying().(*Interface) // object X must be an interface
|
iface := obj.Type().Underlying().(*Interface) // object X must be an interface
|
||||||
if iface == nil {
|
|
||||||
t.Fatalf("%s is not an interface", obj)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Each iface method m is embedded; and m's receiver base type name
|
// Each iface method m is embedded; and m's receiver base type name
|
||||||
// must match the method's name per the choice in the source file.
|
// must match the method's name per the choice in the source file.
|
||||||
@ -529,22 +524,22 @@ func TestIssue34921(t *testing.T) {
|
|||||||
|
|
||||||
func TestIssue43088(t *testing.T) {
|
func TestIssue43088(t *testing.T) {
|
||||||
// type T1 struct {
|
// type T1 struct {
|
||||||
// x T2
|
// _ T2
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// type T2 struct {
|
// type T2 struct {
|
||||||
// x struct {
|
// _ struct {
|
||||||
// x T2
|
// _ T2
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
n1 := NewTypeName(syntax.Pos{}, nil, "T1", nil)
|
n1 := NewTypeName(syntax.Pos{}, nil, "T1", nil)
|
||||||
T1 := NewNamed(n1, nil, nil)
|
T1 := NewNamed(n1, nil, nil)
|
||||||
n2 := NewTypeName(syntax.Pos{}, nil, "T2", nil)
|
n2 := NewTypeName(syntax.Pos{}, nil, "T2", nil)
|
||||||
T2 := NewNamed(n2, nil, nil)
|
T2 := NewNamed(n2, nil, nil)
|
||||||
s1 := NewStruct([]*Var{NewField(syntax.Pos{}, nil, "x", T2, false)}, nil)
|
s1 := NewStruct([]*Var{NewField(syntax.Pos{}, nil, "_", T2, false)}, nil)
|
||||||
T1.SetUnderlying(s1)
|
T1.SetUnderlying(s1)
|
||||||
s2 := NewStruct([]*Var{NewField(syntax.Pos{}, nil, "x", T2, false)}, nil)
|
s2 := NewStruct([]*Var{NewField(syntax.Pos{}, nil, "_", T2, false)}, nil)
|
||||||
s3 := NewStruct([]*Var{NewField(syntax.Pos{}, nil, "x", s2, false)}, nil)
|
s3 := NewStruct([]*Var{NewField(syntax.Pos{}, nil, "_", s2, false)}, nil)
|
||||||
T2.SetUnderlying(s3)
|
T2.SetUnderlying(s3)
|
||||||
|
|
||||||
// These calls must terminate (no endless recursion).
|
// These calls must terminate (no endless recursion).
|
||||||
|
Loading…
Reference in New Issue
Block a user