Interpreter function types are represented internally by the AST node of their definition. The conversion operation creates a new node with the type field pointing to the target type. Fixes #936.
22 lines
265 B
Go
22 lines
265 B
Go
package main
|
|
|
|
type T struct {
|
|
v int
|
|
}
|
|
|
|
type comparator func(T, T) bool
|
|
|
|
func sort(items []T, comp comparator) {
|
|
println("in sort")
|
|
}
|
|
|
|
func compT(t0, t1 T) bool { return t0.v < t1.v }
|
|
|
|
func main() {
|
|
a := []T{}
|
|
sort(a, comparator(compT))
|
|
}
|
|
|
|
// Output:
|
|
// in sort
|