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
8 changes: 2 additions & 6 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@ jobs:

- name: Rename cli-shadow to cli
run: |
mv cli/build/distributions/cli-shadow-*.zip cli/build/distributions/cli.zip
mv cli/build/distributions/cli-shadow-*.tar cli/build/distributions/cli.tar

- name: Rename samt-ls-version to samt-ls
run: |
mv language-server/build/libs/samt-ls-*.jar language-server/build/libs/samt-ls.jar
mv cli/build/distributions/cli-shadow.zip cli/build/distributions/cli.zip
mv cli/build/distributions/cli-shadow.tar cli/build/distributions/cli.tar

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
Expand Down
7 changes: 7 additions & 0 deletions cli/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,15 @@ tasks {
shadowJar {
archiveBaseName.set("samt-cli")
archiveClassifier.set("")
archiveVersion.set("")
manifest {
attributes("Main-Class" to "tools.samt.cli.AppKt")
}
}
shadowDistTar {
archiveVersion.set("")
}
shadowDistZip{
archiveVersion.set("")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ internal class SemanticModelPostProcessor(private val controller: DiagnosticCont
is MapType -> {
checkModelType(type.keyType)
checkModelType(type.valueType)

val keyType = type.keyType as ResolvedTypeReference
// error if keyType does not refer to string type
// serializing non-string types as keys is currently not supported,
// but types like integers or enums might be supported in the future
if (keyType.type.let { it != StringType && !(it is AliasType && it.fullyResolvedType?.type == StringType) }) {
keyType.typeNode.reportError(controller) {
message("Map key type must be String")
highlight("expected String", keyType.typeNode.location)
}
}
}

is AliasType -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,25 +129,15 @@ internal class SemanticModelReferenceResolver(
val keyType = resolveAndLinkExpression(scope, keyTypeNode)
val valueType = resolveAndLinkExpression(scope, valueTypeNode)

// error if keyType does not refer to string type
// serializing non-string types as keys is currently not supported,
// but types like integers or enums might be supported in the future
if (keyType.type != StringType) {
keyTypeNode.reportError(controller) {
message("Map key type must be String")
highlight("expected String", keyTypeNode.location)
}
} else {
return ResolvedTypeReference(
type = MapType(
keyType = keyType,
valueType = valueType,
node = expression,
),
typeNode = expression.base,
fullNode = expression,
)
}
return ResolvedTypeReference(
type = MapType(
keyType = keyType,
valueType = valueType,
node = expression,
),
typeNode = expression.base,
fullNode = expression,
)
} else {
expression.reportError(controller) {
message("Map must have exactly two type arguments")
Expand Down
15 changes: 15 additions & 0 deletions compiler/src/test/kotlin/tools/samt/semantic/SemanticModelTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,21 @@ class SemanticModelTest {
)
)
}

@Test
fun `can use typealiases of String as keys in maps`() {
val source = """
package foo

typealias StringAlias = String
typealias StringAliasAlias = StringAlias

record Foo {
arg: Map<StringAliasAlias, String>
}
""".trimIndent()
parseAndCheck(source to emptyList())
}
}

@Nested
Expand Down
1 change: 1 addition & 0 deletions language-server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ tasks {
shadowJar {
archiveBaseName.set("samt-ls")
archiveClassifier.set("")
archiveVersion.set("")
manifest {
attributes("Main-Class" to "tools.samt.ls.AppKt")
}
Expand Down