go/ssa: make a setNumable interface

Workaround crash on go/ssa in go < 1.13.
See https://github.com/golang/go/issues/29612.

Change-Id: I32687f6ee0baaf223248d5c1631663c73cbbfc65
GitHub-Last-Rev: 6bf28bf927cff6d53bcfaf199701e5451d17305e
GitHub-Pull-Request: golang/tools#162
Reviewed-on: https://go-review.googlesource.com/c/tools/+/195477
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
This commit is contained in:
Denis Isaev 2019-09-15 08:22:58 +00:00 committed by Keith Randall
parent 57610eddc9
commit 4414aad16c

View File

@ -257,6 +257,10 @@ func (f *Function) createSyntacticParams(recv *ast.FieldList, functype *ast.Func
}
}
type setNumable interface {
setNum(int)
}
// numberRegisters assigns numbers to all SSA registers
// (value-defining Instructions) in f, to aid debugging.
// (Non-Instruction Values are named at construction.)
@ -267,9 +271,7 @@ func numberRegisters(f *Function) {
for _, instr := range b.Instrs {
switch instr.(type) {
case Value:
instr.(interface {
setNum(int)
}).setNum(v)
instr.(setNumable).setNum(v)
v++
}
}