THRIFT-6200: Use the declaring package for arguments in the Go -remote stub - #3817
slachiewicz wants to merge 1 commit into
Conversation
4cf6aa5 to
ca1d148
Compare
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. One related case that fits THRIFT-6200 but is not covered by this change: the container/exception branch of // ParentA.thrift
namespace go parenta
service ParentService {
void takeList(1: list<i32> xs),
}
// ChildB.thrift
include "ParentA.thrift"
namespace go childb
service ChildService extends ParentA.ParentService {
}That is with the compiler built from this branch. thrift/compiler/cpp/src/thrift/generate/t_go_generator.cc Lines 3027 to 3030 in ca1d148 🤖 Generated with Claude Code |
ca1d148 to
779f34d
Compare
|
Folded into the amended commit.
This comment was created with AI assistance. |
…e stub Client: go The stub qualified two things with the package it was generated into even when they live in an included file, and the stub then did not compile: - an enum argument, written as package_name_aliased unconditionally while the struct branch a few lines below already resolves the package with module_name(); - the args struct of a container or exception argument on a function inherited from a service declared in an included file. func_to_service recorded only the declaring service's name, so its package was lost. func_to_service now records the service itself, the enum and container branches resolve the package the same way the struct branch does, and the stub imports the package of every ancestor service, so a function inherited across more than one include level resolves too. lib/go/test built includestest but none of its -remote packages, which is why this stayed green. NamespacedService gains list, map and exception arguments and now extends a service in a new NamespacedBaseTest.thrift, so Extended2Service inherits functions from one and two include levels away; its three -remote packages join the check list. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
779f34d to
a0c1b38
Compare
A service method that takes an enum declared in an included file generates a
-remotestub that does not compile. The stub qualifies the enum with the service's own package:Numberzis declared inThriftTest.thriftand generated intothrifttest, which the stub already imports.The container/exception branch has the same defect one step removed. It reads the argument through the function's args struct, and when the function is inherited from a service declared in an included file the constructor is qualified with the wrong package as well:
func_to_servicerecorded only the declaring service's name. It now records the service itself, the enum and container branches resolve the package withmodule_name()the way the struct branch already did, and the stub imports the package of every ancestor service, so a function inherited across two include levels resolves too.lib/go/testbuildsincludestestbut none of its-remotepackages, which is why this never showed up.NamespacedServicegainslist,mapand exception arguments and extends a service in a newNamespacedBaseTest.thrift, soExtended2Serviceinherits functions from one and two include levels away. Its three-remotepackages are added to thechecklist.Regenerating every IDL under
test/,lib/go/test/andtutorial/with master's generator and with this one touches 5 of 332 generated files, all-remotestubs of the two test IDLs: theNumberzline intest_service-remoteandextended_service-remote, thebaseListconstructor innamespaced_service-remote, and inextended2_service-remotethe four constructors plus the import of the grandparent package.Still out of scope, and shared with the enum and struct branches: a type declared in a file the program reaches only transitively, used as an argument by an inherited function, still resolves to a package the stub does not import.
Independent of #3812; different code path, no shared lines.
This change was created with AI assistance.