diff options
author | Tim King <taking@google.com> | 2021-09-22 09:50:15 -0700 |
---|---|---|
committer | Tim King <taking@google.com> | 2022-04-22 17:17:20 +0000 |
commit | d567bc1c220c9afb5f71dc38550ef8b0262ff544 (patch) | |
tree | bf728634567d86d32e86038077f80345d88b71c8 /go/ssa/create.go | |
parent | 5d7ca8a1b5bc80222ed6375e345ba8b6e24e9515 (diff) | |
download | golang-x-tools-d567bc1c220c9afb5f71dc38550ef8b0262ff544.tar.gz |
go/ssa: monomorphize generic instantiations.
Monomorphize the instantiation of generic functions. Applies type
substitution while building the function instantiation.
Adds a new BuilderMode, ssa.InstantiateGenerics, to enable
monomorphization. InstantiateGenerics is turned on by the flag 'G' in
tools that specify the BuilderMode.
Adds a parameterized field to Program to detect when a MethodValue is
parameterized.
Thunk creation creates new MethodExpr selections. Adds a new methodExpr
type to construct a MethodExpr from outside of types, and selection
interface to generalize a *methodExpr and *types.Selection.
Tests x/tools/go/ssa/interp against the runnable examples in
$GOROOT/test/typeparam/*.go. Some additional models to support files.
Misc. cleanup:
- adding (*canonizer).instantiateMethod to create a canonical
representative of a method.
- documenting builder.go
- adding (*subster).types that applies type substitution to a list.
Updates golang/go#48525
Change-Id: I885a4223900feaa3664e35caf8618d11ba16a2a7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/356315
Reviewed-by: Dominik Honnef <dominik@honnef.co>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
Run-TryBot: Tim King <taking@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'go/ssa/create.go')
-rw-r--r-- | go/ssa/create.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/go/ssa/create.go b/go/ssa/create.go index 403baae28..345d9acfb 100644 --- a/go/ssa/create.go +++ b/go/ssa/create.go @@ -38,6 +38,7 @@ func NewProgram(fset *token.FileSet, mode BuilderMode) *Program { h := typeutil.MakeHasher() // protected by methodsMu, in effect prog.methodSets.SetHasher(h) + prog.runtimeTypes.SetHasher(h) return prog } @@ -106,8 +107,8 @@ func memberFromObject(pkg *Package, obj types.Object, syntax ast.Node) { pos: obj.Pos(), Pkg: pkg, Prog: pkg.Prog, - info: pkg.info, _TypeParams: tparams, + info: pkg.info, } pkg.created.Add(fn) if syntax == nil { |