Skip to content

[WIP] Generic type nesting #1368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 76 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
72498bf
Adding test to demonstrate issue in nesting
grantnelson-wf Apr 15, 2025
e82fa78
working on identifying where nesting types should get injected
grantnelson-wf Apr 23, 2025
d81a16a
Merge branch 'master' of github.com:gopherjs/gopherjs into genNestedT…
grantnelson-wf Apr 24, 2025
7f949b7
trying to inject nesting types into visitor
grantnelson-wf Apr 25, 2025
624f159
trying to inject nesting types into visitor
grantnelson-wf Apr 25, 2025
9783473
Updating subst
grantnelson-wf May 1, 2025
6581339
Using TypeParamLists
grantnelson-wf May 2, 2025
79a034b
working on nesting types
grantnelson-wf May 5, 2025
e671c77
working on nesting types
grantnelson-wf May 5, 2025
c642f18
working on nesting types
grantnelson-wf May 5, 2025
7e10671
working on nesting types
grantnelson-wf May 6, 2025
0991c16
working on nesting types
grantnelson-wf May 6, 2025
b706b60
working on nesting types
grantnelson-wf May 6, 2025
329e497
working on nesting types
grantnelson-wf May 6, 2025
a94000c
working on nesting types
grantnelson-wf May 6, 2025
c477608
working on nesting types
grantnelson-wf May 6, 2025
16089bc
working on nesting types
grantnelson-wf May 6, 2025
963fe43
working on nesting types
grantnelson-wf May 6, 2025
8073c31
working on nesting types
grantnelson-wf May 7, 2025
c70f619
working on nesting types
grantnelson-wf May 7, 2025
d280c4e
working on nesting types
grantnelson-wf May 7, 2025
d17b6d2
working on nesting types
grantnelson-wf May 7, 2025
925c2bc
working on nesting types
grantnelson-wf May 7, 2025
9cf91d8
working on nesting types
grantnelson-wf May 8, 2025
adcc226
working on nesting types
grantnelson-wf May 8, 2025
23bf10f
working on nesting types
grantnelson-wf May 8, 2025
65600a4
working on nesting types
grantnelson-wf May 9, 2025
2774069
working on nesting types
grantnelson-wf May 9, 2025
f838cea
working on nesting types
grantnelson-wf May 9, 2025
fc32f21
working on nesting types
grantnelson-wf May 9, 2025
f554343
working on nesting types
grantnelson-wf May 9, 2025
79ea77f
working on nesting types
grantnelson-wf May 9, 2025
e8387aa
working on nesting types
grantnelson-wf May 9, 2025
acc62b7
working on nesting types
grantnelson-wf May 9, 2025
9ffd9e4
working on nesting types
grantnelson-wf May 9, 2025
0a8fb71
working on nesting types
grantnelson-wf May 12, 2025
79abcdd
fixing issues in nesting
grantnelson-wf May 12, 2025
b20cb21
fixing some issues in nesting
grantnelson-wf May 14, 2025
7982109
Merge branch 'nestedTypes' of github.com:Workiva/gopherjs into genNes…
grantnelson-wf May 14, 2025
f2aa738
fixing some issues in nesting
grantnelson-wf May 14, 2025
479ff41
Working on resolver improvements
grantnelson-wf May 20, 2025
b00dc85
Working on resolver improvements
grantnelson-wf May 20, 2025
b788e19
Working on resolver improvements
grantnelson-wf May 20, 2025
6a4f2ca
Working on resolver improvements
grantnelson-wf May 20, 2025
51c6a03
Working on resolver improvements
grantnelson-wf May 21, 2025
576e45d
Working on resolver improvements
grantnelson-wf May 21, 2025
67f9293
Merge branch 'master' of github.com:gopherjs/gopherjs into genNestedT…
grantnelson-wf May 22, 2025
7fad33d
Working on resolver improvements
grantnelson-wf May 22, 2025
5ad861b
Working on resolver improvements
grantnelson-wf May 22, 2025
fae1ff3
Merge branch 'nestedTypes2' of github.com:Workiva/gopherjs into genNe…
grantnelson-wf May 29, 2025
3426eb5
clean up after merge
grantnelson-wf May 29, 2025
6700467
working on DCE
grantnelson-wf May 29, 2025
eccb518
Merge branch 'nestedTypes2' of github.com:Workiva/gopherjs into genNe…
grantnelson-wf May 30, 2025
a11512a
Working on DCE filter
grantnelson-wf May 30, 2025
ff9d0bd
Working on DCE filter
grantnelson-wf May 30, 2025
2e9d8b8
Working on DCE filter
grantnelson-wf Jun 2, 2025
d7490d2
Working on DCE filter
grantnelson-wf Jun 2, 2025
aeefe20
Working on DCE filter
grantnelson-wf Jun 3, 2025
12e9efa
Working on DCE filter
grantnelson-wf Jun 3, 2025
8810895
Working on DCE filter
grantnelson-wf Jun 3, 2025
2189175
Working on DCE filter
grantnelson-wf Jun 3, 2025
fefa301
Working on DCE filter
grantnelson-wf Jun 3, 2025
9dd562f
Working on DCE filter
grantnelson-wf Jun 3, 2025
d3a277d
Working on DCE filter
grantnelson-wf Jun 4, 2025
77c439f
Working on DCE filter
grantnelson-wf Jun 4, 2025
182ee8e
Working on DCE filter
grantnelson-wf Jun 4, 2025
c39ab18
Working on DCE filter
grantnelson-wf Jun 4, 2025
4582ec5
Working on DCE filter
grantnelson-wf Jun 4, 2025
f0158b6
Working on DCE filter
grantnelson-wf Jun 4, 2025
af1a5ef
Working on DCE filter
grantnelson-wf Jun 4, 2025
be1aa59
Working on DCE filter
grantnelson-wf Jun 4, 2025
8f6dc7f
Working on DCE filter
grantnelson-wf Jun 4, 2025
6a8e9df
Testing finding nests
grantnelson-wf Jun 4, 2025
56c1bdb
Testing finding nests
grantnelson-wf Jun 4, 2025
21d596d
Testing finding nests
grantnelson-wf Jun 4, 2025
3e81f6c
Merge branch 'master' of github.com:gopherjs/gopherjs into genNestedT…
grantnelson-wf Jun 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion compiler/internal/typeparams/collect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ func TestVisitor(t *testing.T) {
info, pkg := f.Check("pkg/test", file)

lookupObj := func(name string) types.Object {
return srctesting.LookupObj(pkg, name)
obj := srctesting.LookupObj(pkg, name)
if obj == nil {
t.Fatalf("Object %q not found", name)
}
return obj
}
lookupType := func(name string) types.Type { return lookupObj(name).Type() }
lookupDecl := func(name string) ast.Node {
Expand Down
21 changes: 21 additions & 0 deletions compiler/internal/typeparams/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package typeparams
import (
"fmt"
"go/types"
"sort"
"strings"

"github.com/gopherjs/gopherjs/compiler/internal/symbol"
Expand Down Expand Up @@ -270,3 +271,23 @@ func (i PackageInstanceSets) Add(instances ...Instance) {
func (i PackageInstanceSets) ID(inst Instance) int {
return i.Pkg(inst.Object.Pkg()).ID(inst)
}

func (i PackageInstanceSets) String() string {
pkgName := make([]string, 0, len(i))
for pkg := range i {
pkgName = append(pkgName, pkg)
}
sort.Strings(pkgName)
buf := strings.Builder{}
for _, pkg := range pkgName {
buf.WriteString(pkg)
buf.WriteString(":\n")
iset := i[pkg]
for _, inst := range iset.values {
buf.WriteString("\t")
buf.WriteString(inst.String())
buf.WriteString("\n")
}
}
return buf.String()
}
2 changes: 1 addition & 1 deletion compiler/internal/typeparams/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (im *InstanceMap[V]) Keys() []Instance {
func (im *InstanceMap[V]) String() string {
entries := make([]string, 0, im.Len())
im.Iterate(func(key Instance, value V) {
entries = append(entries, fmt.Sprintf("%v:%v", key, value))
entries = append(entries, fmt.Sprintf("%v:%v", key.String(), value))
})
sort.Strings(entries)
return `{` + strings.Join(entries, `, `) + `}`
Expand Down
Loading