obj, index, indirect = lookupFieldOrMethodImpl(T, addressable, pkg, name, foldCase)
- // If we didn't find anything and if we have a type parameter with a core type,
- // see if there is a matching field (but not a method, those need to be declared
- // explicitly in the constraint). If the constraint is a named pointer type (see
- // above), we are ok here because only fields are accepted as results.
+ // If we didn't find anything and if we have a type parameter with a shared underlying
+ // type, see if there is a matching field (but not a method, those need to be declared
+ // explicitly in the constraint). If the constraint is a named pointer type (see above),
+ // we are ok here because only fields are accepted as results.
const enableTParamFieldLookup = false // see go.dev/issue/51576
if enableTParamFieldLookup && obj == nil && isTypeParam(T) {
- if t := coreType(T); t != nil {
+ if t := sharedUnder(nil, T, nil); t != nil {
obj, index, indirect = lookupFieldOrMethodImpl(t, addressable, pkg, name, foldCase)
if _, ok := obj.(*Var); !ok {
obj, index, indirect = nil, nil, false // accept fields (variables) only
obj, index, indirect = lookupFieldOrMethodImpl(T, addressable, pkg, name, foldCase)
- // If we didn't find anything and if we have a type parameter with a core type,
- // see if there is a matching field (but not a method, those need to be declared
- // explicitly in the constraint). If the constraint is a named pointer type (see
- // above), we are ok here because only fields are accepted as results.
+ // If we didn't find anything and if we have a type parameter with a shared underlying
+ // type, see if there is a matching field (but not a method, those need to be declared
+ // explicitly in the constraint). If the constraint is a named pointer type (see above),
+ // we are ok here because only fields are accepted as results.
const enableTParamFieldLookup = false // see go.dev/issue/51576
if enableTParamFieldLookup && obj == nil && isTypeParam(T) {
- if t := coreType(T); t != nil {
+ if t := sharedUnder(nil, T, nil); t != nil {
obj, index, indirect = lookupFieldOrMethodImpl(t, addressable, pkg, name, foldCase)
if _, ok := obj.(*Var); !ok {
obj, index, indirect = nil, nil, false // accept fields (variables) only