mirror of
https://github.com/golang/go
synced 2024-11-18 12:44:49 -07:00
go.tools/ssa: accommodate go/types changes to value,ok-mode inferred types.
The required changes were surprisingly minimal (I was hoping for a net code deletion) because ssa is essentially doing its own type inference for the three value,ok operators---and it continues to have to do so. To see why, consider: var i interface{}; var ok bool i, ok := (map[string]string)(nil)[""] Before, go/types inferred interface{} for the RHS of the assignment, and now it infers (interface{}, bool), yet neither of these is what ssa needs: it needs to know that the map values were strings so that it can emit a lookup of the right type followed by a conversion from string to interface{}. TBR=gri CC=golang-dev https://golang.org/cl/11988044
This commit is contained in:
parent
508186a765
commit
e7016436a6
@ -225,7 +225,8 @@ func (b *builder) exprN(fn *Function, e ast.Expr) Value {
|
||||
tuple = fn.emit(lookup)
|
||||
|
||||
case *ast.TypeAssertExpr:
|
||||
return emitTypeTest(fn, b.expr(fn, e.X), fn.Pkg.typeOf(e), e.Lparen)
|
||||
t := fn.Pkg.typeOf(e).(*types.Tuple).At(0).Type()
|
||||
return emitTypeTest(fn, b.expr(fn, e.X), t, e.Lparen)
|
||||
|
||||
case *ast.UnaryExpr: // must be receive <-
|
||||
typ = fn.Pkg.typeOf(e.X).Underlying().(*types.Chan).Elem()
|
||||
@ -393,7 +394,7 @@ func (b *builder) addr(fn *Function, e ast.Expr, escaping bool) lvalue {
|
||||
last := len(sel.Index()) - 1
|
||||
return &address{
|
||||
addr: emitFieldSelection(fn, v, sel.Index()[last], true, e.Sel.Pos()),
|
||||
expr: e.Sel, // TODO plus e itself?
|
||||
expr: e.Sel,
|
||||
object: sel.Obj(),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user