@@ -88,7 +88,11 @@ func (t *Named) Origin() *Named { return t.orig }
88
88
func (t * Named ) TypeParams () * TypeParamList { return t .resolve (nil ).tparams }
89
89
90
90
// SetTypeParams sets the type parameters of the named type t.
91
- func (t * Named ) SetTypeParams (tparams []* TypeParam ) { t .resolve (nil ).tparams = bindTParams (tparams ) }
91
+ // t must not have type arguments.
92
+ func (t * Named ) SetTypeParams (tparams []* TypeParam ) {
93
+ assert (t .targs .Len () == 0 )
94
+ t .resolve (nil ).tparams = bindTParams (tparams )
95
+ }
92
96
93
97
// TypeArgs returns the type arguments used to instantiate the named type t.
94
98
func (t * Named ) TypeArgs () * TypeList { return t .targs }
@@ -100,7 +104,9 @@ func (t *Named) NumMethods() int { return len(t.resolve(nil).methods) }
100
104
func (t * Named ) Method (i int ) * Func { return t .resolve (nil ).methods [i ] }
101
105
102
106
// SetUnderlying sets the underlying type and marks t as complete.
107
+ // t must not have type arguments.
103
108
func (t * Named ) SetUnderlying (underlying Type ) {
109
+ assert (t .targs .Len () == 0 )
104
110
if underlying == nil {
105
111
panic ("underlying type must not be nil" )
106
112
}
@@ -111,7 +117,9 @@ func (t *Named) SetUnderlying(underlying Type) {
111
117
}
112
118
113
119
// AddMethod adds method m unless it is already in the method list.
120
+ // t must not have type arguments.
114
121
func (t * Named ) AddMethod (m * Func ) {
122
+ assert (t .targs .Len () == 0 )
115
123
t .resolve (nil )
116
124
if i , _ := lookupMethod (t .methods , m .pkg , m .name ); i < 0 {
117
125
t .methods = append (t .methods , m )
0 commit comments