Files
moxa/_test/gen12.go
Marc Vertes f3dbce93a4 interp: improve handling of generic types
When generating a new type, the parameter type was not correctly duplicated in the new AST. This is fixed by making copyNode recursive if needed. The out of order processing of generic types has also been fixed.

Fixes #1488
2023-02-08 11:48:05 +01:00

32 lines
395 B
Go

package main
import (
"fmt"
)
func MapOf[K comparable, V any](m map[K]V) Map[K, V] {
return Map[K, V]{m}
}
type Map[K comparable, V any] struct {
ж map[K]V
}
func (v MapView) Int() Map[string, int] { return MapOf(v.ж.Int) }
type VMap struct {
Int map[string]int
}
type MapView struct {
ж *VMap
}
func main() {
mv := MapView{&VMap{}}
fmt.Println(mv.ж)
}
// Output:
// &{map[]}