Go's type checker, go/types, with the packages it and its export-data reader need, taken from
golang/go so cohere can check a Go program
once for every platform it builds for. Upstream's code is BSD-licensed (LICENSE, PATENTS), and our changes are
commits on top of it.
Taken at go1.27.1, upstream commit 862c888e612ac346c7c4d99c9392bdfd265f33b0 ("[release-branch.go1.27] go1.27.1").
Test files and testdata are left out.
| Here | Upstream |
|---|---|
types |
src/go/types |
internal/types/errors |
src/internal/types/errors |
internal/goversion |
src/internal/goversion |
gcimporter |
src/go/internal/gcimporter |
exportdata |
src/internal/exportdata |
pkgbits |
src/internal/pkgbits |
saferio |
src/internal/saferio |
The first commit is upstream's text with only the import paths rewritten to this module. Every change of ours after it is a commit of one concern.
typesdrops two linkname shims, which only Go's own tree can satisfy.typeschecks a package once for every build at once (types/variational.gosays how). A package-level object keeps one identity across builds and only its properties vary by build. A unit of work runs under the builds it holds in, and runs again for each group of builds whose reads differ.gcimporterreads each object of a package's export data the first time it is looked up.canonicalis ours: it spells the fork's types as cohere's platform census spells go/types', so a check projected to one build compares exactly with that build's plain answers.
- Fetch upstream at the new tag:
git clone --depth 1 --branch go1.N.M --filter=blob:none --sparse https://github.com/golang/go, thengit sparse-checkout setthe seven upstream directories above. - On a branch of this repository off the first commit's line, lay upstream's non-test files out as the table says and rewrite the import paths, the same way the first commit did. Commit that as "go1.N.M as upstream has it".
- Re-apply our commits on top, one at a time, with
git cherry-pick.go/typesis generated fromcmd/compile/internal/types2, so a conflict is usually a changed line beside one of our marked sites (each says "cohere's variational spike"). Resolve each against the commit's own message. - Run the fork's tests, and cohere's driver proof over its root on every build. A release is in only when every build projects exactly.
- Move cohere's submodule at
libraries/go/go-typesto the new head.