-// UNREVIEWED
// Copyright 2013 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.
func TestIssue5770(t *testing.T) {
f := mustParse(t, `package p; type S struct{T}`)
var conf Config
- // conf := Config{Importer: importer.Default()}
_, err := conf.Check(f.PkgName.Value, []*syntax.File{f}, nil) // do not crash
want := "undeclared name: T"
if err == nil || !strings.Contains(err.Error(), want) {
}
case *syntax.Name:
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) {
t.Fatal("object X not found")
}
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
// must match the method's name per the choice in the source file.
func TestIssue43088(t *testing.T) {
// type T1 struct {
- // x T2
+ // _ T2
// }
//
// type T2 struct {
- // x struct {
- // x T2
+ // _ struct {
+ // _ T2
// }
// }
n1 := NewTypeName(syntax.Pos{}, nil, "T1", nil)
T1 := NewNamed(n1, nil, nil)
n2 := NewTypeName(syntax.Pos{}, nil, "T2", 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)
- s2 := NewStruct([]*Var{NewField(syntax.Pos{}, nil, "x", T2, false)}, nil)
- s3 := NewStruct([]*Var{NewField(syntax.Pos{}, nil, "x", s2, false)}, nil)
+ s2 := NewStruct([]*Var{NewField(syntax.Pos{}, nil, "_", T2, false)}, nil)
+ s3 := NewStruct([]*Var{NewField(syntax.Pos{}, nil, "_", s2, false)}, nil)
T2.SetUnderlying(s3)
// These calls must terminate (no endless recursion).