diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index c346d474..a2f73156 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -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 diff --git a/cli/build.gradle.kts b/cli/build.gradle.kts index b10bd80d..a1a5ed1c 100644 --- a/cli/build.gradle.kts +++ b/cli/build.gradle.kts @@ -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("") + } } diff --git a/compiler/src/main/kotlin/tools/samt/semantic/SemanticModelPostProcessor.kt b/compiler/src/main/kotlin/tools/samt/semantic/SemanticModelPostProcessor.kt index 17d110eb..5749f57c 100644 --- a/compiler/src/main/kotlin/tools/samt/semantic/SemanticModelPostProcessor.kt +++ b/compiler/src/main/kotlin/tools/samt/semantic/SemanticModelPostProcessor.kt @@ -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 -> { diff --git a/compiler/src/main/kotlin/tools/samt/semantic/SemanticModelReferenceResolver.kt b/compiler/src/main/kotlin/tools/samt/semantic/SemanticModelReferenceResolver.kt index aa6af97e..9d7f3c17 100644 --- a/compiler/src/main/kotlin/tools/samt/semantic/SemanticModelReferenceResolver.kt +++ b/compiler/src/main/kotlin/tools/samt/semantic/SemanticModelReferenceResolver.kt @@ -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") diff --git a/compiler/src/test/kotlin/tools/samt/semantic/SemanticModelTest.kt b/compiler/src/test/kotlin/tools/samt/semantic/SemanticModelTest.kt index 042405f4..88209ba0 100644 --- a/compiler/src/test/kotlin/tools/samt/semantic/SemanticModelTest.kt +++ b/compiler/src/test/kotlin/tools/samt/semantic/SemanticModelTest.kt @@ -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 + } + """.trimIndent() + parseAndCheck(source to emptyList()) + } } @Nested diff --git a/language-server/build.gradle.kts b/language-server/build.gradle.kts index 3bc10077..f30ceafd 100644 --- a/language-server/build.gradle.kts +++ b/language-server/build.gradle.kts @@ -22,6 +22,7 @@ tasks { shadowJar { archiveBaseName.set("samt-ls") archiveClassifier.set("") + archiveVersion.set("") manifest { attributes("Main-Class" to "tools.samt.ls.AppKt") }