// constructed.
var todoBodies []*ir.Func
-func (r *reader) addBody(fn *ir.Func) {
- r.sync(syncAddBody)
+// Keep in sync with writer.implicitTypes
+// Also see comment there for why r.implicits and r.explicits should
+// never both be non-empty.
+func (r *reader) implicitTypes() []*types.Type {
+ r.sync(syncImplicitTypes)
- // See commont in writer.addBody for why r.implicits and r.explicits
- // should never both be non-empty.
implicits := r.implicits
if len(implicits) == 0 {
implicits = r.explicits
} else {
assert(len(r.explicits) == 0)
}
+ return implicits
+}
+
+func (r *reader) addBody(fn *ir.Func) {
+ r.sync(syncAddBody)
+ implicits := r.implicitTypes()
pri := pkgReaderIndex{r.p, r.reloc(relocBody), implicits}
bodyReader[fn] = pri
// @@@ Function bodies
-func (w *writer) addBody(sig *types2.Signature, block *syntax.BlockStmt, localsIdx map[types2.Object]int) {
+func (w *writer) implicitTypes() map[*types2.TypeParam]int {
+ w.sync(syncImplicitTypes)
+
// TODO(mdempsky): Theoretically, I think at this point we want to
// extend the implicit type parameters list with any new explicit
// type parameters.
} else {
assert(len(w.explicitIdx) == 0)
}
+ return implicitIdx
+}
+func (w *writer) addBody(sig *types2.Signature, block *syntax.BlockStmt, localsIdx map[types2.Object]int) {
w.sync(syncAddBody)
- w.reloc(relocBody, w.p.bodyIdx(w.p.curpkg, sig, block, implicitIdx, localsIdx))
+
+ implicits := w.implicitTypes()
+ w.reloc(relocBody, w.p.bodyIdx(w.p.curpkg, sig, block, implicits, localsIdx))
}
func (pw *pkgWriter) bodyIdx(pkg *types2.Package, sig *types2.Signature, block *syntax.BlockStmt, implicitIdx map[*types2.TypeParam]int, localsIdx map[types2.Object]int) int {