mirror of
https://github.com/golang/go
synced 2024-11-24 04:10:14 -07:00
7eeec1f6e4
For type assertions, if either src or dst type has shape, we must convert them to dynamic type assertions. Fixes #53309 Change-Id: Ia3362fa67c011febcbdb5b26f856d081b5c366de Reviewed-on: https://go-review.googlesource.com/c/go/+/411617 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Keith Randall <khr@golang.org>
43 lines
657 B
Go
43 lines
657 B
Go
// run
|
|
|
|
// Copyright 2022 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.
|
|
|
|
package main
|
|
|
|
type TaskInput interface {
|
|
deps() []*taskDefinition
|
|
}
|
|
|
|
type Value[T any] interface {
|
|
metaValue
|
|
}
|
|
|
|
type metaValue interface {
|
|
TaskInput
|
|
}
|
|
|
|
type taskDefinition struct {
|
|
}
|
|
|
|
type taskResult struct {
|
|
task *taskDefinition
|
|
}
|
|
|
|
func (tr *taskResult) deps() []*taskDefinition {
|
|
return nil
|
|
}
|
|
|
|
func use[T any](v Value[T]) {
|
|
_, ok := v.(*taskResult)
|
|
if !ok {
|
|
panic("output must be *taskResult")
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
tr := &taskResult{&taskDefinition{}}
|
|
use(Value[string](tr))
|
|
}
|