Source file test/fixedbugs/issue53309.go

     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  
     7  package main
     8  
     9  type TaskInput interface {
    10  	deps() []*taskDefinition
    11  }
    12  
    13  type Value[T any] interface {
    14  	metaValue
    15  }
    16  
    17  type metaValue interface {
    18  	TaskInput
    19  }
    20  
    21  type taskDefinition struct {
    22  }
    23  
    24  type taskResult struct {
    25  	task *taskDefinition
    26  }
    27  
    28  func (tr *taskResult) deps() []*taskDefinition {
    29  	return nil
    30  }
    31  
    32  func use[T any](v Value[T]) {
    33  	_, ok := v.(*taskResult)
    34  	if !ok {
    35  		panic("output must be *taskResult")
    36  	}
    37  }
    38  
    39  func main() {
    40  	tr := &taskResult{&taskDefinition{}}
    41  	use[string](Value[string](tr))
    42  }
    43  

View as plain text