Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class KotlinSymbolProvider(private val model: Model, private val settings: Kotli
val fullyQualifiedValueType = "${reference.fullName}$valueSuffix"
return createSymbolBuilder(shape, "List<$valueType>")
.addReferences(reference)
.putProperty(SymbolProperty.FULLY_QUALIFIED_NAME_HINT, "List<$fullyQualifiedValueType>")
.putProperty(SymbolProperty.FULLY_QUALIFIED_NAME_HINT, "kotlin.collections.List<$fullyQualifiedValueType>")
.putProperty(SymbolProperty.MUTABLE_COLLECTION_FUNCTION, "mutableListOf<$valueType>")
.putProperty(SymbolProperty.IMMUTABLE_COLLECTION_FUNCTION, "listOf<$valueType>")
.build()
Expand All @@ -173,7 +173,7 @@ class KotlinSymbolProvider(private val model: Model, private val settings: Kotli
return createSymbolBuilder(shape, "Map<$keyType, $valueType>")
.addReferences(keyReference)
.addReferences(valueReference)
.putProperty(SymbolProperty.FULLY_QUALIFIED_NAME_HINT, "Map<$fullyQualifiedKeyType, $fullyQualifiedValueType>")
.putProperty(SymbolProperty.FULLY_QUALIFIED_NAME_HINT, "kotlin.collections.Map<$fullyQualifiedKeyType, $fullyQualifiedValueType>")
.putProperty(SymbolProperty.MUTABLE_COLLECTION_FUNCTION, "mutableMapOf<$keyType, $valueType>")
.putProperty(SymbolProperty.IMMUTABLE_COLLECTION_FUNCTION, "mapOf<$keyType, $valueType>")
.putProperty(SymbolProperty.ENTRY_EXPRESSION, "Map.Entry<$keyType, $valueType>")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,8 @@ class SymbolProviderTest {
assertEquals("Record", sparseListSymbol.references[0].symbol.name)

// check the fully qualified name hint is set
assertEquals("List<foo.bar.model.Record>", listSymbol.fullNameHint)
assertEquals("List<foo.bar.model.Record?>", sparseListSymbol.fullNameHint)
assertEquals("kotlin.collections.List<foo.bar.model.Record>", listSymbol.fullNameHint)
assertEquals("kotlin.collections.List<foo.bar.model.Record?>", sparseListSymbol.fullNameHint)
}

@Test
Expand Down Expand Up @@ -544,8 +544,8 @@ class SymbolProviderTest {
assertTrue("com.test.model.Record" in sparseRefNames)

// check the fully qualified name hint is set
assertEquals("Map<kotlin.String, com.test.model.Record>", mapSymbol.fullNameHint)
assertEquals("Map<kotlin.String, com.test.model.Record?>", sparseMapSymbol.fullNameHint)
assertEquals("kotlin.collections.Map<kotlin.String, com.test.model.Record>", mapSymbol.fullNameHint)
assertEquals("kotlin.collections.Map<kotlin.String, com.test.model.Record?>", sparseMapSymbol.fullNameHint)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,68 @@ class SmithySdkTest {

assertEquals(KotlinCompilation.ExitCode.OK, compilationResult.exitCode, compileOutputStream.toString())
}

// https://github.com/smithy-lang/smithy-kotlin/issues/1127
@Test
fun `it compiles models with union member names that match their types`() {
val model = """
namespace aws.sdk.kotlin.test

use aws.protocols#awsJson1_0
use smithy.rules#operationContextParams
use smithy.rules#endpointRuleSet
use aws.api#service

@awsJson1_0
@service(sdkId: "UnionOperationTest")
service TestService {
operations: [DeleteObjects],
version: "1"
}

operation DeleteObjects {
input: DeleteObjectsRequest
}

structure DeleteObjectsRequest {
Delete: Foo
}

union Foo {
list: BarList
map: IntegerMap
instant: Timestamp
byteArray: Blob
boolean: Boolean
string: String
bigInteger: BigInteger
bigDecimal: BigDecimal
double: Double
float: Float
long: Long
short: Short
int: Integer
byte: Byte
}

list BarList {
member: Bar
}

map IntegerMap {
key: String
value: Integer
}

string Bar
""".asSmithy()

val compileOutputStream = ByteArrayOutputStream()
val compilationResult = compileSdkAndTest(model = model, outputSink = compileOutputStream, emitSourcesToTmp = Debug.emitSourcesToTemp)
compileOutputStream.flush()

assertEquals(KotlinCompilation.ExitCode.OK, compilationResult.exitCode, compileOutputStream.toString())
}
}

/**
Expand Down
Loading