Skip to content

Commit

Permalink
public SubstType
Browse files Browse the repository at this point in the history
  • Loading branch information
xushiwei committed May 6, 2022
1 parent d7cc423 commit 501e2d5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion builtin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ func TestSubstVar(t *testing.T) {
}

func TestUnderlying(t *testing.T) {
subst := &substType{}
subst := &SubstType{}
bfReft := &bfRefType{typ: tyInt}
if typ, ok := DerefType(bfReft); !ok || typ != tyInt {
t.Fatal("TestDerefType failed")
Expand Down
20 changes: 10 additions & 10 deletions type_var_and_const.go
Original file line number Diff line number Diff line change
Expand Up @@ -769,36 +769,36 @@ func (p *TypeType) String() string {

// ----------------------------------------------------------------------------

type substType struct {
real types.Object
type SubstType struct {
Real types.Object
}

func (p *substType) Underlying() types.Type {
func (p *SubstType) Underlying() types.Type {
fatal("substitute type")
return nil
}

func (p *substType) String() string {
return fmt.Sprintf("substType{real: %v}", p.real)
func (p *SubstType) String() string {
return fmt.Sprintf("substType{real: %v}", p.Real)
}

func NewSubstVar(pos token.Pos, pkg *types.Package, name string, real types.Object) *types.Var {
return types.NewVar(pos, pkg, name, &substType{real: real})
return types.NewVar(pos, pkg, name, &SubstType{Real: real})
}

func LookupParent(scope *types.Scope, name string, pos token.Pos) (at *types.Scope, obj types.Object) {
if at, obj = scope.LookupParent(name, pos); obj != nil {
if t, ok := obj.Type().(*substType); ok {
obj = t.real
if t, ok := obj.Type().(*SubstType); ok {
obj = t.Real
}
}
return
}

func Lookup(scope *types.Scope, name string) (obj types.Object) {
if obj = scope.Lookup(name); obj != nil {
if t, ok := obj.Type().(*substType); ok {
obj = t.real
if t, ok := obj.Type().(*SubstType); ok {
obj = t.Real
}
}
return
Expand Down

0 comments on commit 501e2d5

Please sign in to comment.