mirror of
https://github.com/golang/go.git
synced 2025-11-11 06:01:06 +00:00
In certain cases, the declkared type of an OpIData is interface{}.
This was not expected (since interface{} is a pair, right?) and
thus caused a crash. What is intended is that these be treated as
a byteptr, so do that instead (this is what happens in 1.15).
Fixes #42568.
Change-Id: Id7c9e5dc2cbb5d7c71c6748832491ea62b0b339f
Reviewed-on: https://go-review.googlesource.com/c/go/+/270057
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
25 lines
415 B
Go
25 lines
415 B
Go
// compile
|
|
|
|
// Copyright 2020 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// Ensure that late expansion correctly handles an OpIData with type interface{}
|
|
|
|
package p
|
|
|
|
type S struct{}
|
|
|
|
func (S) M() {}
|
|
|
|
type I interface {
|
|
M()
|
|
}
|
|
|
|
func f(i I) {
|
|
o := i.(interface{})
|
|
if _, ok := i.(*S); ok {
|
|
o = nil
|
|
}
|
|
println(o)
|
|
}
|