commit | f15e2ea88d6fce1602827a463e510044dfc6ab26 | [log] [tgz] |
---|---|---|
author | Egor Andreevich <egor@squareup.com> | Thu Dec 26 23:09:34 2019 -0500 |
committer | GitHub <noreply@github.com> | Thu Dec 26 23:09:34 2019 -0500 |
tree | bad4596051aa2b6443c84a640b3262302082423d | |
parent | 49a0aad011f32ae7cdcf5b88062449c573b5be37 [diff] |
Lift the requirement for file names to not be keywords (#854) * Lift the requirement for file names to not be keywords * Test
diff --git a/kotlinpoet/src/main/java/com/squareup/kotlinpoet/FileSpec.kt b/kotlinpoet/src/main/java/com/squareup/kotlinpoet/FileSpec.kt index 73d4081..edf2989 100644 --- a/kotlinpoet/src/main/java/com/squareup/kotlinpoet/FileSpec.kt +++ b/kotlinpoet/src/main/java/com/squareup/kotlinpoet/FileSpec.kt
@@ -223,10 +223,6 @@ val annotations = mutableListOf<AnnotationSpec>() - init { - require(name.isName) { "not a valid file name: $name" } - } - /** * Add an annotation to the file. *
diff --git a/kotlinpoet/src/test/java/com/squareup/kotlinpoet/FileWritingTest.kt b/kotlinpoet/src/test/java/com/squareup/kotlinpoet/FileWritingTest.kt index 505147a..e4b343e 100644 --- a/kotlinpoet/src/test/java/com/squareup/kotlinpoet/FileWritingTest.kt +++ b/kotlinpoet/src/test/java/com/squareup/kotlinpoet/FileWritingTest.kt
@@ -285,4 +285,12 @@ |class Taco |""".trimMargin()) } + + @Test fun fileWithKeywordName() { + val type = TypeSpec.classBuilder("fun").build() + FileSpec.get("", type).writeTo(filer) + + val testPath = fsRoot.resolve("fun.kt") + assertThat(Files.exists(testPath)).isTrue() + } }