var prevType ast.Expr
                for _, spec := range list {
                        spec := spec.(*ast.ValueSpec)
-                       if spec.Type == nil && prevType != nil {
+                       if spec.Type == nil && len(spec.Values) == 0 && prevType != nil {
                                // provide current spec with an explicit type
                                spec.Type = copyConstType(prevType, spec.Pos())
                        }
 
        imports   map[string]int
        hasDotImp bool     // if set, package contains a dot import
        values    []*Value // consts and vars
+       order     int      // sort order of const and var declarations (when we can't use a name)
        types     map[string]*namedType
        funcs     methodSet
 
                        if n, imp := baseTypeName(s.Type); !imp {
                                name = n
                        }
-               case decl.Tok == token.CONST:
-                       // no type is present but we have a constant declaration;
-                       // use the previous type name (w/o more type information
-                       // we cannot handle the case of unnamed variables with
-                       // initializer expressions except for some trivial cases)
+               case decl.Tok == token.CONST && len(s.Values) == 0:
+                       // no type or value is present but we have a constant declaration;
+                       // use the previous type name (possibly the empty string)
                        name = prev
                }
                if name != "" {
                Doc:   decl.Doc.Text(),
                Names: specNames(decl.Specs),
                Decl:  decl,
-               order: len(*values),
+               order: r.order,
        })
        decl.Doc = nil // doc consumed - remove from AST
+
+       // Note: It's important that the order used here is global because the cleanupTypes
+       // methods may move values associated with types back into the global list. If the
+       // order is list-specific, sorting is not deterministic because the same order value
+       // may appear multiple times (was bug, found when fixing #16153).
+       r.order++
 }
 
 // fields returns a struct's fields or an interface's methods.
 
                C4      int
        )
 
-       // Constants with an imported type that needs to be propagated. 
+       // Constants with a single type that is not propagated. 
        const (
-               Default         os.FileMode     = 0644
-               Useless                         = 0312
-               WideOpen                        = 0777
+               Default         = 0644
+               Useless         = 0312
+               WideOpen        = 0777
+       )
+
+       // Constants with an imported type that is propagated. 
+       const (
+               M1      os.FileMode
+               M2
+               M3
        )
 
        // Package constants. 
 
                C4
        )
 
-       // Package constants. 
-       const (
-               _       int     = iota
-               I1
-               I2
-       )
-
-       // Constants with an imported type that needs to be propagated. 
+       // Constants with a single type that is not propagated. 
        const (
                zero            os.FileMode     = 0
                Default                         = 0644
                WideOpen                        = 0777
        )
 
+       // Constants with an imported type that is propagated. 
+       const (
+               zero    os.FileMode     = 0
+               M1
+               M2
+               M3
+       )
+
+       // Package constants. 
+       const (
+               _       int     = iota
+               I1
+               I2
+       )
+
        // Unexported constants counting from blank iota. See issue 9615. 
        const (
                _       = iota
 
                C4      int
        )
 
-       // Constants with an imported type that needs to be propagated. 
+       // Constants with a single type that is not propagated. 
        const (
-               Default         os.FileMode     = 0644
-               Useless                         = 0312
-               WideOpen                        = 0777
+               Default         = 0644
+               Useless         = 0312
+               WideOpen        = 0777
+       )
+
+       // Constants with an imported type that is propagated. 
+       const (
+               M1      os.FileMode
+               M2
+               M3
        )
 
        // Package constants.