Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final updates to runtime and codegen fixes #352

Merged
merged 13 commits into from
Feb 27, 2025

Conversation

andrewparmet
Copy link
Collaborator

@andrewparmet andrewparmet commented Feb 26, 2025

Uncovered a few bugs when starting to demonstrate some internal upgrades.

  • A few message interface implementation bugs
  • Removed files break Buf breaking checks

Puts back a non-null accessor generator option for oneof fields.

New extension number reservation has been approved: protocolbuffers/protobuf#20485

@@ -89,7 +89,7 @@ fun Project.enablePublishing(defaultJars: Boolean = true) {
configure(KotlinMultiplatform(JavadocJar.Empty()))
}
pluginManager.withPlugin(KotlinPlugins.JVM) {
configure(KotlinJvm(JavadocJar.Empty(), true))
configure(KotlinJvm(JavadocJar.Empty()))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the default value.

subprojects {
group = "${rootProject.group}.thirdparty"
}
group = "com.toasttab.protokt.thirdparty"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was getting clobbered by the common-conventions plugin - we've been publishing to the wrong group since that change went in.

@@ -61,7 +70,7 @@ internal object Implements {
}

private fun TypeSpec.Builder.delegateProperties(msg: Message, ctx: Context, canonicalName: String, fieldName: String) {
val fieldsByName = msg.fields.filterIsInstance<StandardField>().associateBy { it.fieldName }
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't exclude overrides that are oneofs.

@@ -77,7 +77,7 @@ internal object Implements {
field.name,
(field.returnType.classifier as KClass<*>).asTypeName()
.let {
if (assumeNotNull) {
if (assumeNotNull && !field.returnType.isMarkedNullable) {
Copy link
Collaborator Author

@andrewparmet andrewparmet Feb 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't delegate a field and mark it as non-nullable if the delegated field is nullable in the interface.

@@ -159,6 +159,9 @@ private class MessageGenerator(
.build()
)
}
if (property.overrides) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the name of a field is the same as the field on the interface and we generate a non-null accessor for it, the override needs to be on the generated delegating property, not the non-null accessor.

@@ -56,7 +56,6 @@ private fun generateFdpObjectNames(files: List<FileDescriptorProto>): Map<String
Pair(
fdp.name,
fdp.fileOptions.protokt.fileDescriptorObjectName.takeIf { it.isNotEmpty() }
?: fdp.fileOptions.default.javaOuterClassname.takeIf { it.isNotEmpty() }
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore all Java options.

@andrewparmet andrewparmet changed the title Final updates Final updates to runtime and codegen fixes Feb 26, 2025
@andrewparmet andrewparmet marked this pull request as ready for review February 26, 2025 02:08
@@ -43,11 +45,7 @@ internal object Nullability {
type !in setOf(FieldType.Message, FieldType.Enum)

fun propertyType(o: Oneof) =
if (o.generateNonNullAccessor) {
Copy link
Collaborator Author

@andrewparmet andrewparmet Feb 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was previously non-functional but now that it can sometimes be true, it was causing compilation failure.

@andrewparmet andrewparmet merged commit d5fcf93 into open-toast:main Feb 27, 2025
37 checks passed
@andrewparmet andrewparmet deleted the final-updates branch February 27, 2025 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants