PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: Microsoft/thrifty (kotlin)

Issue:
Add MPP-compatible mode to thrifty-kotlin-codegen
In order to make multiplatform work, generated code needs to meet certain requirements.  Chiefly, it needs to use _only_ types available in multiplatform code.  Most notably that rules out `IOException`, but there are almost certainly others.

The job here, then is to
a) audit generated kotlin code for JVM-only types, including those in thrifty-runtime like `AsyncClientBase`, and
b) eliminate/mitigate their use (or make the thrity-runtime type an `expect` class, probably).

Pull request:
Closes #401, again

Patch:
diff --git a/thrifty-kotlin-codegen/src/main/kotlin/com/microsoft/thrifty/kgen/KotlinCodeGenerator.kt b/thrifty-kotlin-codegen/src/main/kotlin/com/microsoft/thrifty/kgen/KotlinCodeGenerator.kt
index d3319ce24..b2cfe8709 100644
--- a/thrifty-kotlin-codegen/src/main/kotlin/com/microsoft/thrifty/kgen/KotlinCodeGenerator.kt
+++ b/thrifty-kotlin-codegen/src/main/kotlin/com/microsoft/thrifty/kgen/KotlinCodeGenerator.kt
@@ -512,7 +512,7 @@ class KotlinCodeGenerator(
             typeBuilder.addFunction(FunSpec.builder("hashCode")
                     .addModifiers(KModifier.OVERRIDE)
                     .returns(INT)
-                    .addStatement("return javaClass.hashCode()")
+                    .addStatement("return %S.hashCode()", structClassName.canonicalName)
                     .build())
 
             typeBuilder.addFunction(FunSpec.builder("equals")


Test patch:
diff --git a/thrifty-kotlin-codegen/src/test/kotlin/com/microsoft/thrifty/kgen/KotlinCodeGeneratorTest.kt b/thrifty-kotlin-codegen/src/test/kotlin/com/microsoft/thrifty/kgen/KotlinCodeGeneratorTest.kt
index 9f7125b16..a0b22132d 100644
--- a/thrifty-kotlin-codegen/src/test/kotlin/com/microsoft/thrifty/kgen/KotlinCodeGeneratorTest.kt
+++ b/thrifty-kotlin-codegen/src/test/kotlin/com/microsoft/thrifty/kgen/KotlinCodeGeneratorTest.kt
@@ -1089,6 +1089,21 @@ class KotlinCodeGeneratorTest {
         }
     }
 
+    @Test
+    fun `empty structs do not rely on javaClass for hashCode`() {
+        val thrift = """
+            |namespace kt test.empty
+            |
+            |struct Empty {}
+        """.trimMargin()
+
+        val file = generate(thrift).single()
+        val kt = file.toString()
+
+        kt shouldContain "hashCode(): Int = \"test.empty.Empty\".hashCode()"
+        kt shouldNotContain "javaClass"
+    }
+
     private fun generate(thrift: String, config: (KotlinCodeGenerator.() -> KotlinCodeGenerator)? = null): List<FileSpec> {
         val configOrDefault = config ?: { this }
         return KotlinCodeGenerator()