diff options
author | Robert Findley <rfindley@google.com> | 2021-08-13 15:52:12 -0400 |
---|---|---|
committer | Robert Findley <rfindley@google.com> | 2021-08-19 15:05:05 +0000 |
commit | 69d8fbec7ab74b3b0f8b689a9a251bdf621936aa (patch) | |
tree | dfcf4bf1cd282419062e1754d188c3bc7b32b2ea /src/cmd/compile/internal/types2/typexpr.go | |
parent | 3bdc1799d6ce441d7a972faf1452e34b6dce0826 (diff) | |
download | go-69d8fbec7ab74b3b0f8b689a9a251bdf621936aa.tar.gz go-69d8fbec7ab74b3b0f8b689a9a251bdf621936aa.zip |
cmd/compile/internal/types2: return an error from Instantiate
Change Instantiate to be a function (not a method) and return an error.
Introduce an ArgumentError type to report information about which type
argument led to an error during verification.
This resolves a few concerns with the current API:
- The Checker method set was previously just Files. It is somewhat odd
to add an additional method for instantiation. Passing the checker as
an argument seems cleaner.
- pos, posList, and verify were bound together. In cases where no
verification is required, the call site was somewhat cluttered.
- Callers will likely want to access structured information about why
type information is invalid, and also may not have access to position
information. Returning an argument index solves both these problems;
if callers want to associate errors with an argument position, they
can do this via the resulting index.
We may want to make the first argument an opaque environment rather than
a Checker.
Change-Id: I3bc56d205c13d832b538401a4c91d3917c041225
Reviewed-on: https://go-review.googlesource.com/c/go/+/342152
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/types2/typexpr.go')
-rw-r--r-- | src/cmd/compile/internal/types2/typexpr.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/types2/typexpr.go b/src/cmd/compile/internal/types2/typexpr.go index 4df8ab68a1..241c6d35fe 100644 --- a/src/cmd/compile/internal/types2/typexpr.go +++ b/src/cmd/compile/internal/types2/typexpr.go @@ -444,7 +444,7 @@ func (check *Checker) instantiatedType(x syntax.Expr, targsx []syntax.Expr, def posList[i] = syntax.StartPos(arg) } - typ := check.Instantiate(x.Pos(), base, targs, posList, true) + typ := check.instantiate(x.Pos(), base, targs, posList) def.setUnderlying(typ) // make sure we check instantiation works at least once |