protobuf-go/internal/filedesc
Joe Tsai f98dd98c15 internal/filedesc: defer evaluation of weak reference until actual use
Suppose some init logic performs protobuf reflection.
If so, it will cause the lazy descriptor init logic to be executed.
This is problematic for weak fields since we can not be certain that
all weak references have been registered at this point in time.
This is a fundamental issue with with weak dependencies,
since it means that we cannot enforce any ordering constraints
on the weak dependency unless we directly import the weakly referenced package
(which would defeat the point of weak imports).

Alleviate the problem by pushing evaluation of weak reference to
actual usage. This does not completely fix the problem,
but signifcantly reduces the probability of it being problematic.
In general, people should avoid interacting with weak fields at init time.

Change-Id: Ie5957ddedd61333e72ee9a1bba0c53dace65547c
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/188982
Reviewed-by: Damien Neil <dneil@google.com>
2019-08-05 21:31:06 +00:00
..
build_test.go all: implement proto1 weak fields 2019-07-15 18:44:12 +00:00
build.go reflect/protoregistry: add conflict override 2019-07-18 17:47:11 +00:00
desc_init.go
desc_lazy.go internal/filedesc: defer evaluation of weak reference until actual use 2019-08-05 21:31:06 +00:00
desc_list_gen.go
desc_list.go reflect/protoreflect: add FileDescriptor.SourceLocations 2019-07-13 00:15:59 +00:00
desc_test.go proto: move T->*T wrappers from internal/scalar to proto 2019-07-12 17:35:01 +00:00
desc.go internal/filedesc: defer evaluation of weak reference until actual use 2019-08-05 21:31:06 +00:00
placeholder.go reflect/protoreflect: add FileDescriptor.SourceLocations 2019-07-13 00:15:59 +00:00