Skip to content

Commit 4136c02

Browse files
authored
Revert "fix: address issues caused by shape members named result (#1430)"
This reverts commit d132423.
1 parent d132423 commit 4136c02

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

.changes/ebc2a1ba-151a-48ed-afcd-0679c9d3a9ef.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/StructureGenerator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class StructureGenerator(
138138
write("var result = #1L#2L", memberNameSymbolIndex[sortedMembers[0]]!!.first, selectHashFunctionForShape(sortedMembers[0]))
139139
if (sortedMembers.size > 1) {
140140
sortedMembers.drop(1).forEach { memberShape ->
141-
write("result = 31 * result + (this.#1L#2L)", memberNameSymbolIndex[memberShape]!!.first, selectHashFunctionForShape(memberShape))
141+
write("result = 31 * result + (#1L#2L)", memberNameSymbolIndex[memberShape]!!.first, selectHashFunctionForShape(memberShape))
142142
}
143143
}
144144
write("return result")

codegen/smithy-kotlin-codegen/src/test/kotlin/software/amazon/smithy/kotlin/codegen/rendering/StructureGeneratorTest.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,14 @@ class StructureGeneratorTest {
134134
val expected = """
135135
override fun hashCode(): kotlin.Int {
136136
var result = bar
137-
result = 31 * result + (this.baz ?: 0)
138-
result = 31 * result + (this.byteValue?.toInt() ?: 0)
139-
result = 31 * result + (this.defaultString.hashCode())
140-
result = 31 * result + (this.foo?.hashCode() ?: 0)
141-
result = 31 * result + (this.`object`?.hashCode() ?: 0)
142-
result = 31 * result + (this.quux?.hashCode() ?: 0)
143-
result = 31 * result + (this.requiredInt)
144-
result = 31 * result + (this.requiredIntButNullable ?: 0)
137+
result = 31 * result + (baz ?: 0)
138+
result = 31 * result + (byteValue?.toInt() ?: 0)
139+
result = 31 * result + (defaultString.hashCode())
140+
result = 31 * result + (foo?.hashCode() ?: 0)
141+
result = 31 * result + (`object`?.hashCode() ?: 0)
142+
result = 31 * result + (quux?.hashCode() ?: 0)
143+
result = 31 * result + (requiredInt)
144+
result = 31 * result + (requiredIntButNullable ?: 0)
145145
return result
146146
}
147147
""".formatForTest()
@@ -474,7 +474,7 @@ class StructureGeneratorTest {
474474
val expectedHashCodeContent = """
475475
override fun hashCode(): kotlin.Int {
476476
var result = bar?.hashCode() ?: 0
477-
result = 31 * result + (this.foo?.contentHashCode() ?: 0)
477+
result = 31 * result + (foo?.contentHashCode() ?: 0)
478478
return result
479479
}
480480
""".formatForTest()
@@ -784,7 +784,7 @@ class StructureGeneratorTest {
784784
val expected = """
785785
override fun hashCode(): kotlin.Int {
786786
var result = aInt ?: 0
787-
result = 31 * result + (this.bInt)
787+
result = 31 * result + (bInt)
788788
return result
789789
}
790790
""".formatForTest()

0 commit comments

Comments
 (0)