]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: deal with unsatisfiable type assertion in some instantiations
authorDan Scales <danscales@google.com>
Tue, 7 Dec 2021 00:30:19 +0000 (16:30 -0800)
committerDan Scales <danscales@google.com>
Tue, 7 Dec 2021 21:54:30 +0000 (21:54 +0000)
commitcf1ec173603f950aaccb549602ed0fee57e6b709
tree2843d44296fa6df73c269890a3aac4d64fb93995
parente08d1fba37ad32fbe7e8d57cd75c9a88dfdde87f
cmd/compile: deal with unsatisfiable type assertion in some instantiations

Deal with case where a certain instantiation of a generic
function/method leads to an unsatisfiable type assertion or type case.
In that case, the compiler was causing a fatal error while trying to
create an impossible itab for the dictionary. To deal with that case,
allow ITabLsym() to create a dummy itab even when the concrete type
doesn't implement the interface. This dummy itab is analogous to the
"negative" itabs created on-the-fly by the runtime.

We will use the dummy itab in type asserts and type switches in
instantiations that use that dictionary entry. Since the dummy itab can
never be used for any real value at runtime (since the concrete type
doesn't implement the interface), there will always be a failure for the
corresponding type assertion or a non-match for the corresponding
type-switch case.

Fixes #50002

Change-Id: I1df05b1019533e1fc93dd7ab29f331a74fab9202
Reviewed-on: https://go-review.googlesource.com/c/go/+/369894
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/cmd/compile/internal/reflectdata/reflect.go
test/run.go
test/typeparam/issue50002.go [new file with mode: 0644]