Add cron jobs to service

This commit is contained in:
dwrz
2026-06-02 12:04:02 +00:00
parent e5238e4081
commit 6fb63c8c90
84 changed files with 3022 additions and 2452 deletions

View File

@@ -242,7 +242,6 @@ import (
"strings"
"golang.org/x/tools/go/types/objectpath"
"golang.org/x/tools/internal/aliases"
)
// IExportShallow encodes "shallow" export data for the specified package.
@@ -767,11 +766,11 @@ func (p *iexporter) doDecl(obj types.Object) {
}
if obj.IsAlias() {
alias, materialized := t.(*types.Alias) // may fail when aliases are not enabled
alias, materialized := t.(*types.Alias) // perhaps false for certain built-ins?
var tparams *types.TypeParamList
if materialized {
tparams = aliases.TypeParams(alias)
tparams = alias.TypeParams()
}
if tparams.Len() == 0 {
w.tag(aliasTag)
@@ -785,7 +784,7 @@ func (p *iexporter) doDecl(obj types.Object) {
if materialized {
// Preserve materialized aliases,
// even of non-exported types.
t = aliases.Rhs(alias)
t = alias.Rhs()
}
w.typ(t, obj.Pkg())
break
@@ -1011,11 +1010,11 @@ func (w *exportWriter) doTyp(t types.Type, pkg *types.Package) {
}
switch t := t.(type) {
case *types.Alias:
if targs := aliases.TypeArgs(t); targs.Len() > 0 {
if targs := t.TypeArgs(); targs.Len() > 0 {
w.startType(instanceType)
w.pos(t.Obj().Pos())
w.typeList(targs, pkg)
w.typ(aliases.Origin(t), pkg)
w.typ(t.Origin(), pkg)
return
}
w.startType(aliasType)

View File

@@ -210,7 +210,6 @@ func iimportCommon(fset *token.FileSet, getPackages GetPackagesFunc, data []byte
p := iimporter{
version: int(version),
ipath: path,
aliases: aliases.Enabled(),
shallow: shallow,
reportf: reportf,
@@ -370,7 +369,6 @@ type iimporter struct {
version int
ipath string
aliases bool
shallow bool
reportf ReportFunc // if non-nil, used to report bugs
@@ -576,7 +574,7 @@ func (r *importReader) obj(pkg *types.Package, name string) {
tparams = r.tparamList()
}
typ := r.typ()
obj := aliases.NewAlias(r.p.aliases, pos, pkg, name, typ, tparams)
obj := aliases.New(pos, pkg, name, typ, tparams)
markBlack(obj) // workaround for golang/go#69912
r.declare(obj)

View File

@@ -11,6 +11,7 @@ import (
"go/token"
"go/types"
"sort"
"strings"
"golang.org/x/tools/internal/aliases"
"golang.org/x/tools/internal/pkgbits"
@@ -26,7 +27,6 @@ type pkgReader struct {
ctxt *types.Context
imports map[string]*types.Package // previously imported packages, indexed by path
aliases bool // create types.Alias nodes
// lazily initialized arrays corresponding to the unified IR
// PosBase, Pkg, and Type sections, respectively.
@@ -36,6 +36,10 @@ type pkgReader struct {
// laterFns holds functions that need to be invoked at the end of
// import reading.
//
// TODO(mdempsky): Is it safe to have a single "later" slice or do
// we need to have multiple passes? See comments on CL 386002 and
// go.dev/issue/52104.
laterFns []func()
// laterFors is used in case of 'type A B' to ensure that B is processed before A.
laterFors map[types.Type]int
@@ -98,7 +102,6 @@ func readUnifiedPackage(fset *token.FileSet, ctxt *types.Context, imports map[st
ctxt: ctxt,
imports: imports,
aliases: aliases.Enabled(),
posBases: make([]string, input.NumElems(pkgbits.RelocPosBase)),
pkgs: make([]*types.Package, input.NumElems(pkgbits.RelocPkg)),
@@ -160,12 +163,11 @@ type reader struct {
// A readerDict holds the state for type parameters that parameterize
// the current unified IR element.
type readerDict struct {
// bounds is a slice of typeInfos corresponding to the underlying
// bounds of the element's type parameters.
bounds []typeInfo
rtbounds []typeInfo // contains constraint types for each parameter in rtparams
rtparams []*types.TypeParam // contains receiver type parameters for an element
// tparams is a slice of the constructed TypeParams for the element.
tparams []*types.TypeParam
tbounds []typeInfo // contains constraint types for each parameter in tparams
tparams []*types.TypeParam // contains type parameters for an element
// derived is a slice of types derived from tparams, which may be
// instantiated while reading the current element.
@@ -355,7 +357,11 @@ func (r *reader) doTyp() (res types.Type) {
return name.Type()
case pkgbits.TypeTypeParam:
return r.dict.tparams[r.Len()]
n := r.Len()
if n < len(r.dict.rtbounds) {
return r.dict.rtparams[n]
}
return r.dict.tparams[n-len(r.dict.rtbounds)]
case pkgbits.TypeArray:
len := int64(r.Uint64())
@@ -518,6 +524,12 @@ func (pr *pkgReader) objIdx(idx pkgbits.Index) (*types.Package, string) {
return objPkg, objName
}
// TODO(mark): This, like the above splitVargenSuffix, is not ideal.
// Ignore generic methods promoted to global scope.
if strings.Contains(objName, ".") {
return objPkg, objName
}
if objPkg.Scope().Lookup(objName) == nil {
dict := pr.objDictIdx(idx)
@@ -536,10 +548,10 @@ func (pr *pkgReader) objIdx(idx pkgbits.Index) (*types.Package, string) {
pos := r.pos()
var tparams []*types.TypeParam
if r.Version().Has(pkgbits.AliasTypeParamNames) {
tparams = r.typeParamNames()
tparams = r.typeParamNames(false)
}
typ := r.typ()
declare(aliases.NewAlias(r.p.aliases, pos, objPkg, objName, typ, tparams))
declare(aliases.New(pos, objPkg, objName, typ, tparams))
case pkgbits.ObjConst:
pos := r.pos()
@@ -549,7 +561,10 @@ func (pr *pkgReader) objIdx(idx pkgbits.Index) (*types.Package, string) {
case pkgbits.ObjFunc:
pos := r.pos()
tparams := r.typeParamNames()
if r.Version().Has(pkgbits.GenericMethods) {
assert(!r.Bool()) // generic methods are read in their defining type
}
tparams := r.typeParamNames(false)
sig := r.signature(nil, nil, tparams)
declare(types.NewFunc(pos, objPkg, objName, sig))
@@ -560,7 +575,7 @@ func (pr *pkgReader) objIdx(idx pkgbits.Index) (*types.Package, string) {
named := types.NewNamed(obj, nil, nil)
declare(obj)
named.SetTypeParams(r.typeParamNames())
named.SetTypeParams(r.typeParamNames(false))
setUnderlying := func(underlying types.Type) {
// If the underlying type is an interface, we need to
@@ -618,6 +633,29 @@ func (pr *pkgReader) objIdx(idx pkgbits.Index) (*types.Package, string) {
named.AddMethod(r.method())
}
if r.Version().Has(pkgbits.GenericMethods) {
for range r.Len() {
// Careful: objIdx is used to read in package-scoped declarations, which
// methods are not. Instead, decode it here. This makes it easier to
// associate it with the type and avoids the main objIdx loop.
idx := r.Reloc(pkgbits.RelocObj)
r := pr.tempReader(pkgbits.RelocObj, idx, pkgbits.SyncObject1)
r.dict = pr.objDictIdx(idx)
pos := r.pos()
assert(r.Bool()) // generic method
pkg, name := r.selector()
rtparams := r.typeParamNames(true)
recv := r.param()
tparams := r.typeParamNames(false)
sig := r.signature(recv, rtparams, tparams)
pr.retireReader(r)
named.AddMethod(types.NewFunc(pos, pkg, name, sig))
}
}
case pkgbits.ObjVar:
pos := r.pos()
typ := r.typ()
@@ -640,9 +678,20 @@ func (pr *pkgReader) objDictIdx(idx pkgbits.Index) *readerDict {
errorf("unexpected object with %v implicit type parameter(s)", implicits)
}
dict.bounds = make([]typeInfo, r.Len())
for i := range dict.bounds {
dict.bounds[i] = r.typInfo()
nreceivers := 0
if r.Version().Has(pkgbits.GenericMethods) {
nreceivers = r.Len()
}
nexplicits := r.Len()
dict.rtbounds = make([]typeInfo, nreceivers)
for i := range dict.rtbounds {
dict.rtbounds[i] = r.typInfo()
}
dict.tbounds = make([]typeInfo, nexplicits)
for i := range dict.tbounds {
dict.tbounds[i] = r.typInfo()
}
dict.derived = make([]derivedInfo, r.Len())
@@ -661,15 +710,24 @@ func (pr *pkgReader) objDictIdx(idx pkgbits.Index) *readerDict {
return &dict
}
func (r *reader) typeParamNames() []*types.TypeParam {
func (r *reader) typeParamNames(isGenMeth bool) []*types.TypeParam {
r.Sync(pkgbits.SyncTypeParamNames)
// Note: This code assumes it only processes objects without
// implement type parameters. This is currently fine, because
// reader is only used to read in exported declarations, which are
// always package scoped.
// Note: This code assumes there are no implicit type parameters.
// This is fine since it only reads exported declarations, which
// never have implicits.
if len(r.dict.bounds) == 0 {
var in []typeInfo
var out *[]*types.TypeParam
if isGenMeth {
in = r.dict.rtbounds
out = &r.dict.rtparams
} else {
in = r.dict.tbounds
out = &r.dict.tparams
}
if len(in) == 0 {
return nil
}
@@ -678,40 +736,34 @@ func (r *reader) typeParamNames() []*types.TypeParam {
// create all the TypeNames and TypeParams, then we construct and
// set the bound type.
r.dict.tparams = make([]*types.TypeParam, len(r.dict.bounds))
for i := range r.dict.bounds {
// We have to save tparams outside of the closure, because typeParamNames
// can be called multiple times with the same dictionary instance.
tparams := make([]*types.TypeParam, len(in))
*out = tparams
for i := range in {
pos := r.pos()
pkg, name := r.localIdent()
tname := types.NewTypeName(pos, pkg, name, nil)
r.dict.tparams[i] = types.NewTypeParam(tname, nil)
tparams[i] = types.NewTypeParam(tname, nil)
}
typs := make([]types.Type, len(r.dict.bounds))
for i, bound := range r.dict.bounds {
typs[i] = r.p.typIdx(bound, r.dict)
// The reader dictionary will continue mutating before we have time
// to call delayed functions; make a local copy of the constraints.
types := make([]types.Type, len(in))
for i, info := range in {
types[i] = r.p.typIdx(info, r.dict)
}
// TODO(mdempsky): This is subtle, elaborate further.
//
// We have to save tparams outside of the closure, because
// typeParamNames() can be called multiple times with the same
// dictionary instance.
//
// Also, this needs to happen later to make sure SetUnderlying has
// been called.
//
// TODO(mdempsky): Is it safe to have a single "later" slice or do
// we need to have multiple passes? See comments on CL 386002 and
// go.dev/issue/52104.
tparams := r.dict.tparams
// This needs to happen later to make sure SetUnderlying has been called.
r.p.later(func() {
for i, typ := range typs {
for i, typ := range types {
tparams[i].SetConstraint(typ)
}
})
return r.dict.tparams
return tparams
}
func (r *reader) method() *types.Func {
@@ -719,7 +771,7 @@ func (r *reader) method() *types.Func {
pos := r.pos()
pkg, name := r.selector()
rparams := r.typeParamNames()
rparams := r.typeParamNames(false)
sig := r.signature(r.param(), rparams, nil)
_ = r.pos() // TODO(mdempsky): Remove; this is a hacker for linker.go.