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
32 lines
395 B
Go
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[]}
|