1// run 2 3// Copyright 2022 The Go Authors. All rights reserved. 4// Use of this source code is governed by a BSD-style 5// license that can be found in the LICENSE file. 6 7package main 8 9type TaskInput interface { 10 deps() []*taskDefinition 11} 12 13type Value[T any] interface { 14 metaValue 15} 16 17type metaValue interface { 18 TaskInput 19} 20 21type taskDefinition struct { 22} 23 24type taskResult struct { 25 task *taskDefinition 26} 27 28func (tr *taskResult) deps() []*taskDefinition { 29 return nil 30} 31 32func use[T any](v Value[T]) { 33 _, ok := v.(*taskResult) 34 if !ok { 35 panic("output must be *taskResult") 36 } 37} 38 39func main() { 40 tr := &taskResult{&taskDefinition{}} 41 use[string](Value[string](tr)) 42} 43