}
// declare all constants
- values := unpackExpr(last.Values)
+ values := syntax.UnpackListExpr(last.Values)
for i, name := range s.NameList {
obj := NewConst(name.Pos(), pkg, name.Value, nil, iota)
}
// declare all variables
- values := unpackExpr(s.Values)
+ values := syntax.UnpackListExpr(s.Values)
for i, name := range s.NameList {
obj := NewVar(name.Pos(), pkg, name.Value, nil)
lhs[i] = obj
if ptyp, _ := rtyp.(*syntax.IndexExpr); ptyp != nil {
rtyp = ptyp.X
if unpackParams {
- for _, arg := range unpackExpr(ptyp.Index) {
+ for _, arg := range syntax.UnpackListExpr(ptyp.Index) {
var par *syntax.Name
switch arg := arg.(type) {
case *syntax.Name:
return false, nil
}
ptr = true
- typ = unparen(pexpr.X) // continue with pointer base type
+ typ = syntax.Unparen(pexpr.X) // continue with pointer base type
}
// typ must be a name, or a C.name cgo selector.
}
}
- // We process non-alias type declarations first, followed by alias declarations,
- // and then everything else. This appears to avoid most situations where the type
- // of an alias is needed before it is available.
- // There may still be cases where this is not good enough (see also go.dev/issue/25838).
- // In those cases Checker.ident will report an error ("invalid use of type alias").
- var aliasList []*TypeName
- var othersList []Object // everything that's not a type
- // phase 1: non-alias type declarations
- for _, obj := range objList {
- if tname, _ := obj.(*TypeName); tname != nil {
- if check.objMap[tname].tdecl.Alias {
- aliasList = append(aliasList, tname)
+ if check.conf._EnableAlias {
+ // With _Alias nodes we can process declarations in any order.
+ for _, obj := range objList {
+ check.objDecl(obj, nil)
+ }
+ } else {
+ // Without _Alias nodes, we process non-alias type declarations first, followed by
+ // alias declarations, and then everything else. This appears to avoid most situations
+ // where the type of an alias is needed before it is available.
+ // There may still be cases where this is not good enough (see also go.dev/issue/25838).
+ // In those cases Checker.ident will report an error ("invalid use of type alias").
+ var aliasList []*TypeName
+ var othersList []Object // everything that's not a type
+ // phase 1: non-alias type declarations
+ for _, obj := range objList {
+ if tname, _ := obj.(*TypeName); tname != nil {
+ if check.objMap[tname].tdecl.Alias {
+ aliasList = append(aliasList, tname)
+ } else {
+ check.objDecl(obj, nil)
+ }
} else {
- check.objDecl(obj, nil)
+ othersList = append(othersList, obj)
}
- } else {
- othersList = append(othersList, obj)
}
- }
- // phase 2: alias type declarations
- for _, obj := range aliasList {
- check.objDecl(obj, nil)
- }
- // phase 3: all other declarations
- for _, obj := range othersList {
- check.objDecl(obj, nil)
+ // phase 2: alias type declarations
+ for _, obj := range aliasList {
+ check.objDecl(obj, nil)
+ }
+ // phase 3: all other declarations
+ for _, obj := range othersList {
+ check.objDecl(obj, nil)
+ }
}
// At this point we may have a non-empty check.methods map; this means that not all