• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Change Log
2==========
3
4## Unreleased
5
6## Version 1.16.0
7
8Thanks to [@drawers][drawers], [@rickclephas][rickclephas] for contributing to this release.
9
10_2024-01-18_
11
12 * New: Kotlin 1.9.22.
13 * New: KSP 1.9.22-1.0.16.
14 * New: Add `NameAllocator` API to control keyword pre-allocation (#1803).
15 * Fix: Fix issue with missing `suspend` modifier in `KSTypeReference.toTypeName` (#1793).
16 * Fix: Honour same-package import aliases (#1794).
17 * Fix: Always include parameter docs in the type header (#1800).
18
19## Version 1.15.3
20
21Thanks to [@gabrielittner][gabrielittner] for contributing to this release.
22
23_2023-12-04_
24
25 * Fix: Fix nullability of lambdas in `KSTypeReference.toTypeName` (#1756).
26
27## Version 1.15.2
28
29Thanks to [@evant][evant] for contributing to this release.
30
31_2023-11-30_
32
33 * New: Kotlin 1.9.21.
34 * New: KSP 1.9.21-1.0.15.
35 * New: KSP: more accurately represent function types (#1742).
36
37## Version 1.15.1
38
39_2023-11-19_
40
41 * Fix: Fix a regression introduced by #1637, where a superfluous newline is added to a type's KDoc
42 if it has a primary constructor with no docs (#1727).
43
44## Version 1.15.0
45
46_2023-11-18_
47
48Thanks to [@drawers][drawers], [@fejesjoco][fejesjoco], [@takahirom][takahirom],
49[@martinbonnin][martinbonnin], [@mcarleio][mcarleio] for contributing to this release.
50
51In this release the `:kotlinpoet` module has been converted to a Kotlin Multiplatform module
52(#1654), though for now it only supports the JVM target. **Important**: unless you're building
53with Gradle, you will now need to depend on the `kotlinpoet-jvm` artifact, instead of `kotlinpoet` -
54see [Downloads](index.md#download) for instructions.
55
56 * New: Kotlin 1.9.20.
57 * New: KSP 1.9.20-1.0.14.
58 * New: Extract `TypeSpecHolder` interface for constructs that can hold a TypeSpec and their builders (#1723).
59 * New: Expose relative path from `FileSpec` (#1720).
60 * New: Return the generated path from `FileSpec.writeTo()`. (#1514).
61 * New: Remove default compatibility from unstable types (#1662).
62 * New: Deprecate `TypeSpec.expectClassBuilder()` and `TypeSpec.valueClassBuilder()` (#1589).
63 * New: Add option to convert `KSAnnotation` to `AnnotationSpec` while omitting default values (#1538).
64 * New: Add `FileSpec.builder` convenience for `MemberName` (#1585).
65 * Fix: Set `DecimalFormatSymbols.minusSign` for consistency across locales (#1658).
66 * Fix: Fix link to incremental KSP in KDoc (#1638).
67 * Fix: Emit primary constructor KDoc (#1637).
68 * Change: kotlinx-metadata 0.7.0. This is a breaking change for users of the `:kotlinpoet-metadata`
69   module, as most `Flags`-API extensions have been removed in favor of the now-available first-party versions.
70
71## Version 1.14.2
72
73_2023-05-30_
74
75 * Fix: Fix one more missing API in binary compatibility override in `Annotatable.Builder` (#1581).
76
77## Version 1.14.1
78
79_2023-05-29_
80
81 * Fix: Restore ABI stability for annotatable and documentable builders (#1580).
82
83## Version 1.14.0
84
85_2023-05-29_
86
87Thanks to [@Omico][Omico], [@drawers][drawers], [@RBusarow][RBusarow] for contributing to this release.
88
89 * New: Kotlin 1.8.21.
90 * New: KSP 1.8.21-1.0.11.
91 * New: Enable default methods in Java bytecode (#1561).
92 * New: Group Kotlin and Renovate updates together in Renovate (#1562).
93 * New: Extract trait interface for annotatable constructs and their builders (#1564).
94 * New: Extract trait interface for documentable constructs and their builders (#1571).
95 * New: Document the usage of `STAR` (#1572).
96 * New: Add builder for `FunSpec` which accepts a `MemberName` (#1574).
97 * Fix: Omit public modifier on override function or constructor parameters (#1550).
98 * Fix: Correct handling of members in various types (#1558).
99 * Fix: Function return types now default to `Unit` unless explicitly set (#1559).
100
101    Previously, when `FunSpec` didn't have a return type specified and an expression body was produced, no return
102    type would be emitted. However, starting from `1.14.0`, KotlinPoet will not add `Unit` as a return type in such
103    cases. In order to correct the generated output, you are to specify the actual return type of the `FunSpec`.
104
105    Before `1.14.0`, if omitted, no return type is produced:
106    ```kotlin
107    val funSpec = FunSpec.builder("foo")
108      .addStatement("return 1")
109      .build()
110    ```
111    ```kotlin
112    public fun foo() = 1
113    ```
114
115    From `1.14.0`, the return type defaults to `Unit` if not otherwise set:
116    ```kotlin
117    val funSpec = FunSpec.builder("foo")
118      .addStatement("return 1")
119      .build()
120    ```
121    ```kotlin
122    public fun foo(): Unit = 1 // ❌
123    ```
124
125    To fix it, explicitly define the return type:
126    ```diff
127     val funSpec = FunSpec.builder("foo")
128    +  .returns(INT)
129       .addStatement("return 1")
130       .build()
131    ```
132    ```kotlin
133    public fun foo(): Int = 1 // ✅
134    ```
135
136    Additionally, as part of this change, `FunSpec.returnType` has changed to be non-nullable. This is a source- and
137    binary-compatible change, although if you were performing null-checks then new warnings may appear after upgrade.
138
139 * Fix: Append nested class names to alias during name lookup (#1568).
140 * Fix: Allow PropertySpec with context receivers and without getter or setter (#1575).
141
142## Version 1.13.2
143
144_2023-05-05_
145
146Thanks to [@Squiry][Squiry] for contributing to this release.
147
148* Fix: `KSType.toTypeName` fixed to work with aliased types (#1534).
149
150## Version 1.13.1
151
152_2023-04-28_
153
154Thanks to [@rickclephas][rickclephas] for contributing to this release.
155
156 * Fix: Look at canonical names instead of just package names when generating import aliases (#1519).
157 * Fix: Ignore KSP annotation arguments without a value (#1523).
158 * Fix: Fix arguments handling in `KSType.toTypeName()` (#1529).
159
160## Version 1.13.0
161
162_2023-04-06_
163
164Thanks to [@popematt][popematt], [@bitPogo][bitPogo], [@mars885][mars885], [@sjudd][sjudd], [@Sironheart][Sironheart],
165[@polarene][polarene], [@DeoTimeTheGithubUser][DeoTimeTheGithubUser], [@drawers][drawers] for contributing to this release.
166
167 * New: Kotlin 1.8.0.
168 * New: KSP 1.8.0-1.0.9.
169 * New: Support context receivers on TypeSpecs + extract ContextReceivable API (#1269).
170 * New: Optimize `OriginatingElements` and `TagMap` implementations (#1270).
171 * New: Auto-generate import aliases for types and members (#1355).
172 * New: Insert underscores into large decimal literals (#1384).
173 * New: New factory function `FileSpec.builder(ClassName)` (#1397).
174 * Fix: Fix StackOverflowError when calling `KSTypeArgument.toTypeName()` for a wildcard in a recursive type bound (#1272).
175 * Fix: Fix transitive aliases (#1306).
176 * Fix: Fix Aliases as TypeArgument (#1321).
177 * Fix: Don't escape special characters inside raw strings (#1331).
178 * Fix: Fix KSP interop's output of the annotation parameter value of type Char (#1338).
179 * Fix: Fix KSP interop's output for primitive arrays (#1340).
180 * Fix: Avoid emitting public if `shouldEmitPublicModifier` returns false (#1342).
181 * Fix: Fix context receivers being rendered in an incorrect position when on a nullable/suspending `LambdaTypeName` (#1454).
182 * Fix: Do not use `bestGuess` for `KClass.asClassName` (#1469).
183 * Fix: Handle fake nested types with platform mapped parents (#1472).
184 * Fix: Fix `TypeName` equals (#1477).
185 * Fix: Make equals consistent with compareTo for `ClassName` (#1506).
186
187## Version 1.12.0
188
189_2022-06-13_
190
191Thanks to [@WhosNickDoglio][WhosNickDoglio], [@sullis][sullis], [@DRSchlaubi][DRSchlaubi],
192[@martinbonnin][martinbonnin], [@seriouslyhypersonic][seriouslyhypersonic], [@ephemient][ephemient],
193[@dkilmer][dkilmer], [@aksh1618][aksh1618], [@zsqw123][zsqw123], [@roihershberg][roihershberg] for
194contributing to this release.
195
196 * New: Kotlin 1.7.0.
197 * New: Add support for context receivers.
198 * New: Add support for external property getter.
199 * New: `interop-ksp` API promoted to stable.
200 * Fix: Resolve enum constants when emitting types.
201 * Fix: Fix type argument mapping when processing typealiases with KSP.
202 * Fix: Properly unwrap `KSTypeAlias` with an unused type parameter.
203 * Fix: Unwrap nested `KSTypeAlias`-es recursively.
204 * Fix: Add support for context receivers `@PropertySpec` and fix issues with annotations.
205 * Fix: Treat `header` and `impl` as keywords (workaround for KT-52315).
206 * Fix: Use `%N` instead of `%L` for annotation arg names so keywords are handled.
207 * Fix: Improve handling of long `return` expressions.
208
209## Version 1.11.0
210
211_2022-03-24_
212
213Thanks to [@liujingxing][liujingxing] and [@BoD][BoD] for contributing to this release.
214
215* New: Kotlin scripting support in `FileSpec`.
216
217```kotlin
218val spec = FileSpec.scriptBuilder("Taco")
219  .addStatement("println(%S)", "hello world!")
220  .addKotlinDefaultImports()
221  .build()
222```
223
224Generates a `Taco.kts` file with the following contents:
225
226```kotlin
227println("hello world!")
228```
229
230* New: Emit trailing commas for multi-line parameters and annotations.
231* New: Add `KSAnnotation.toAnnotationSpec()`.
232* New: Add `Unit` and `CharSequence` conversions in `javapoet-interop`.
233* New: Add support for default imports in `FileSpec`.
234  * This is particularly oriented at scripting support, but can also be used in non-script files.
235* New: Update to Kotlin 1.6.10.
236* Fix: Fail compilation if you only pass one string to `ClassName`.
237* Fix: Inline `val` property if its getter is `inline`.
238* Fix: Add `yield` to the list of reserved keywords.
239* Fix: Enforce only allowed parameter modifiers in `ParameterSpec` (i.e. `crossinline`, `vararg`, and `noinline`).
240* Fix: Fix `CodeBlock`s in class delegation getting `toString()`'d instead of participating in code writing.
241* Fix: Error when attempting to convert KSP error types (i.e. if `KSType.isError` is true) to `TypeName`.
242
243## Version 1.10.2
244
245_2021-10-22_
246
247Thanks to [@glureau][glureau] and [@goooler][goooler] for contributing to this release.
248
249* New: Switch `AnnotationSpec.get()` to use the `arrayOf()` syntax instead of `[]`.
250* Fix: Don't wrap aliasing imports with long package names.
251* Fix: Don't wrap type names inside line comments.
252* Fix: Ignore Java's `@Deprecated` annotations on synthetic methods for annotations.
253
254## Version 1.10.1
255
256_2021-09-21_
257
258Thanks to [@evant][evant] for contributing to this release.
259
260 * Fix: Correct generation of typealiases with type args in KSP interop.
261 * Fix: Add missing default `TypeParameterResolver.EMPTY` argument to
262   `fun KSTypeArgument.toTypeName` in KSP interop.
263
264## Version 1.10.0
265
266_2021-09-20_
267
268Thanks to [@martinbonnin][martinbonnin], [@idanakav][idanakav], [@goooler][goooler], and
269[@anandwana001][anandwana001] for contributing to this release.
270
271 * New: Add a new [KSP][ksp] interop artifact. See [docs][ksp-interop-docs] for more details.
272 * New: Add a new [JavaPoet][javapoet] interop artifact. See [docs][javapoet-interop-docs] for more
273   details.
274 * New: Allow copying a `ParameterizedTypeName` with new type arguments via new `copy()` overload.
275 * kotlinx-metadata artifacts have been consolidated to a single `com.squareup:kotlinpoet-metadata`
276   maven artifact. The previous `kotlinpoet-metadata-*` subartifacts are no longer published.
277 * New: `TypeNameAliasTag` has been moved to KotlinPoet's main artifact under `TypeAliasTag`, for
278   reuse with KSP interop.
279 * `ImmutableKm*` classes have been removed. They were deemed to be a needless abstraction over the base `kotlinx-metadata` Km types. All usages of these should be substituted with their non-immutable base types.
280 * Fix: Fix self-referencing type variables in metadata parsing.
281 * Fix: Use delicate APIs rather than noisy logging ones when converting annotation mirrors in
282   `AnnotationSpec.get`.
283 * Fix: Update error message when metadata cannot be read to a more actionable one.
284 * Fix: Avoid escaping already escaped strings.
285 * Add docs about `kotlin-reflect` usage.
286 * Avoid using kotlin-reflect for looking up `Unit` types where possible.
287 * Test all the way up to JDK 17.
288 * Update Kotlin to 1.5.31.
289
290## Version 1.9.0
291
292_2021-06-22_
293
294 * New: Kotlin 1.5.10.
295 * New: Previously deprecated API to interop with Java reflection and Mirror API have been
296   un-deprecated and marked with `@DelicateKotlinPoetApi` annotation.
297 * New: `CodeBlock.Builder.withIndent` helper function.
298 * New: Allow changing initializers and default values in `ParameterSpec.Builder` and
299   `PropertySpec.Builder` after they were set.
300 * New: `MemberName.isExtension` property that instructs KotlinPoet to always import the member,
301   even if conflicting declarations are present in the same scope.
302 * Fix: Escape member names that only contain underscores.
303 * Fix: Always emit an empty primary constructor if it was set via `TypeSpec.primaryConstructor`.
304
305## Version 1.8.0
306
307_2021-03-29_
308
309 * New: Kotlin 1.4.31.
310 * New: Add `KModifier.VALUE` to support `value class` declarations.
311 * New: Allow using a custom `ClassLoader` with `ReflectiveClassInspector`.
312 * New: Update to kotlinx-metadata 0.2.0.
313 * Fix: Ensure `ImmutableKmProperty.toMutable()` copies `fieldSignature`.
314 * Fix: Prevent name clashes between an imported `MemberName` and a member in current scope.
315 * Fix: Prevent name clashes between a type and a supertype with the same name.
316 * Fix: Don't generate empty body for `expect` and `external` functions.
317 * Fix: Don't allow `expect` or `external` classes to initialize supertypes.
318 * Fix: Disallow delegate constructor calls in `external` classes.
319 * Fix: Allow non-public primary constructors inside inline/value classes.
320 * Fix: Allow init blocks inside inline/value classes.
321 * Fix: Omit redundant `abstract` modifiers on members inside interfaces
322
323## Version 1.7.2
324
325_2020-10-20_
326
327 * New: Detect expression bodies with `return·` and `throw·` prefixes.
328 * Fix: Omit visibility modifiers on custom accessors.
329
330## Version 1.7.1
331
332_2020-10-15_
333
334 * Fix: 1.7.0 was published using JDK 11 which set `"org.gradle.jvm.version"` to `"11"` in Gradle
335   metadata, making it impossible to use the library on earlier Java versions (see
336   [#999][issue-999]). 1.7.1 is published with JDK 8, which fixes the problem.
337
338## Version 1.7.0
339
340_2020-10-14_
341
342 * New: Kotlin 1.4.10.
343 * New: Generated code is now compatible with the [explicit API mode][explicit-api-mode] by default.
344 * New: Escape soft and modifier keywords, in addition to hard keywords.
345 * New: Improve enum constants generation for cleaner diffs.
346 * New: Disallow setters on immutable properties.
347 * New: Ensure trailing new lines in expression bodies.
348 * New: Ensure trailing new lines after parameterless custom setters.
349 * Fix: Don't auto-convert properties with custom accessors to primary constructor properties.
350 * Fix: Don't allow parameterless setters with body.
351 * Fix: Prevent auto-wrapping spaces inside escaped keywords.
352
353## Version 1.6.0
354
355_2020-05-28_
356
357 * New: Deprecate Mirror API integrations.
358
359   Mirror API integrations, such as `TypeElement.asClassName()` and
360   `FunSpec.overriding(ExecutableElement)`, are being deprecated in this release. These KotlinPoet
361   APIs are most often used in annotation processors. Since kapt runs annotation processors over
362   stubs, which are Java files, a lot of the Kotlin-specific information gets lost in translation
363   and cannot be accessed by KotlinPoet through the Mirror API integrations. Examples include:
364
365   - Alias types, such as `kotlin.String`, get converted to their JVM representations, such as
366     `java.lang.String`.
367   - Type nullability information is not accessible.
368   - `suspend` functions are seen as simple functions with an additional `Continuation` parameter.
369
370   The correct solution is to switch to [KotlinPoet-metadata][kotlinpoet-metadata] or
371   [KotlinPoet-metadata-specs][kotlinpoet-metadata-specs] API, which fetches Kotlin-specific
372   information from the `@Metadata` annotation and produces correct KotlinPoet Specs. We may explore
373   adding new metadata-based alternatives to the deprecated APIs in the future.
374
375 * New: Kotlin 1.3.72.
376 * New: Improve `MemberName` to support operator overloading.
377 * New: Support generics in `AnnotationSpec`.
378 * New: Add support for functional interfaces.
379 * New: Make more `FunSpec.Builder` members public for easier mutation.
380 * Fix: Properly propagate implicit type and function modifiers in nested declarations.
381 * Fix: Properly escape type names containing `$` character.
382 * Fix: Don't emit `LambdaTypeName` annotations twice.
383 * Fix: Preserve tags in `TypeName.copy()`.
384
385## Version 1.5.0
386
387_2020-01-09_
388
389 KotlinPoet now targets JDK8, which means that executing a build that includes KotlinPoet as a
390 dependency on a machine with an older version of JDK installed won't work. **This has no effect on
391 the code that KotlinPoet produces**: the code can still be compiled against JDK6, as long as it
392 doesn't use any features that were introduced in newer releases.
393
394 * New: Kotlin 1.3.61.
395 * New: Add support for processing FileFacades in KotlinPoet-metadata.
396 * New: Add support for inner nested and companion objects on annotation classes.
397 * New: Improve error messages for mismatched open/close statement characters.
398 * New: Tag `AnnotationSpec`s with the annotation mirror when available.
399 * New: Include annotations on enum entries when creating `TypeSpec`s from metadata.
400 * Fix: Fix metadata parsing for types.
401 * Fix: Allow file names that are Kotlin keywords.
402 * Fix: Properly escape type alias names with backticks.
403 * Fix: Allow creating `TypeSpec`s with names that can be escaped with backticks.
404 * Fix: Properly escape enum constant names with backticks.
405 * Fix: Maintain proper ordering of properties and initializers when emitting a `TypeSpec`.
406   **Note**: with this change, any properties declared after any initializer blocks will not be
407   added to the primary constructor and will instead be emitted inside the `TypeSpec` body.
408 * Fix: Don't emit a leading new line if type KDoc is empty but parameter KDocs are present.
409 * Fix: Ensure KotlinPoet-metadata resolves package names properly.
410
411 ## Version 1.4.4
412
413_2019-11-16_
414
415 * Fix: Support reified inline types in KotlinPoet-metadata.
416
417## Version 1.4.3
418
419_2019-10-30_
420
421 * Fix: Don't emit stubs for abstract functions in KotlinPoet-metadata.
422
423## Version 1.4.2
424
425_2019-10-28_
426
427 * Fix: Properly handle abstract elements in KotlinPoet-metadata.
428 * Fix: Properly handle typealiases in KotlinPoet-metadata.
429 * Fix: Properly render % symbols at the end of KDocs.
430
431## Version 1.4.1
432
433_2019-10-18_
434
435 * New: Add annotations support to `TypeAliasSpec`.
436 * New: Read type annotations from Kotlin `Metadata`.
437 * New: Introduce `ImmutableKmDeclarationContainer`.
438 * Fix: Use full package name for shading `auto-common`.
439 * Fix: Support reading self-type variables (e.g. `Asset<A : Asset<A>>`) from Kotlin `Metadata`.
440
441## Version 1.4.0
442
443_2019-09-24_
444
445 * New: This release introduces the new KotlinPoet-metadata API that makes it easy to introspect
446   Kotlin types and build KotlinPoet Specs based on that data.
447
448   The strategy for type introspection is driven by `ClassInspector`, which is a basic interface for
449   looking up JVM information about a given Class. This optionally is used by the
450   `toTypeSpec()`/`toFileSpec()` APIs in `kotlinpoet-metadata-specs` artifact to inform about
451   Classes with information that isn’t present in metadata (overrides, JVM modifiers, etc). There
452   are two batteries-included implementations available in `ReflectiveClassInspector`
453   (for reflection) and `ElementsClassInspector` (for the javax Elements API in annotation
454   processing). These implementations are available through their respective
455   `kotlinpoet-classinspector-*` artifacts. For more information refer to the
456   [KotlinPoet-metadata-specs README][kotlinpoet-metadata-specs].
457
458   At the time of this release the API is in experimental mode and has to be opted into via the
459   `KotlinPoetMetadataPreview` annotation.
460
461 * New: Kotlin 1.3.50.
462 * New: A new constructor to simplify creation of `ParameterSpec` instances.
463 * New: New `ClassName` constructors.
464 * New: `TypeName` and subclasses can now store tags.
465 * New: Optional parameters added to `toBuilder()` methods of most Specs.
466 * New: `List` overrides for Spec methods that accept `vararg`s.
467 * New: `CodeBlock.Builder.clear()` helper method.
468 * New: `FunSpec.Builder.clearBody()` helper method.
469 * Fix: Properly escape enum constant names.
470 * Fix: Ensure trailing newlines in KDoc and function bodies.
471 * Fix: `TypeVariableName`s with empty bounds will now default to `Any?`.
472 * Fix: Don't emit parens for primary constructors.
473 * Fix: `ClassName`s with empty simple names are not allowed anymore.
474 * Fix: Throw if names contain illegal characters that can't be escaped with backticks.
475
476## Version 1.3.0
477
478_2019-05-30_
479
480 * New: Don't inline annotations in the primary constructor.
481 * New: Force new lines when emitting primary constructors.
482 * New: Support using MemberNames as arguments to %N.
483 * New: Add more ClassName constants: ClassName.STRING, ClassName.LIST, etc.
484 * New: Add ClassName.constructorReference() and MemberName.reference().
485 * New: Make %N accept MemberNames.
486 * New: Escape spaces in import aliases.
487 * New: Escape spaces in ClassNames.
488 * New: Escape spaces in MemberNames.
489 * New: Escape imports containing spaces.
490 * New: Escape package name containing spaces.
491 * New: Use 2-space indents.
492 * New: Only indent one level on annotation values.
493 * Fix: Pass only unique originating elements to Filer.
494 * Fix: Fix bug with MemberNames in same package nested inside a class.
495
496## Version 1.2.0
497
498_2019-03-28_
499
500 * New: Add writeTo(Filer) and originating element API.
501 * New: Make *Spec types taggable.
502 * New: Make FunSpec.Builder#addCode take vararg Any?.
503 * Fix: Import members from default package.
504 * Fix: Add non-wrapping spaces in control flow creation methods.
505 * Fix: Named "value" argument being omitted in annotation array types.
506
507## Version 1.1.0
508
509_2019-02-28_
510
511 * New: Kotlin 1.3.21.
512 * New: Support referencing members using `%M` and `MemberName` type.
513 * New: Add extensions for getting a `MemberName` from a `ClassName`, `KClass` and `Class`.
514 * New: Allow passing `CodeBlock`s as arguments to `%P`.
515 * New: Allow interface delegation for objects.
516 * Fix: Don't emit visible whitespace in `toString()`.
517 * Fix: Prevent line wrapping in weird places inside function signature.
518 * Fix: No line wrapping between val and property name.
519 * Fix: Allow passing line prefix into `LineWrapper` to enable proper line wrapping in KDoc.
520 * Fix: Add newline for `TypeSpec` Kdoc with no tags.
521 * Fix: Add newline for remaining Specs.
522 * Fix: Fix kdoc formatting for property getter/setters.
523 * Fix: Don't wrap single line comments inside `FunSpec`.
524 * Fix: Add non-wrapping package name.
525 * Fix: Remove n^2 algorithm in `CodeWriter.resolve()` by precomputing all of the nested simple names of a `TypeSpec`.
526 * Fix: Fix edge case with empty enum classes.
527 * Fix: Fix Nullable Type Parameter handling in `KType.asTypeName()`.
528 * Fix: Fix incorrect long comment wrapping in `FileSpec`.
529 * Fix: Attach primary constructor param/property KDoc to the element vs emitting it inside the type header.
530
531## Version 1.0.1
532
533_2019-01-02_
534
535 * New: Allow enums without constants.
536 * New: Improved formatting of TypeSpec KDoc.
537 * New: Support @property and @param KDoc tags in TypeSpec.
538 * Fix: Use pre-formatted strings for arguments to %P.
539
540## Version 1.0.0
541
542_2018-12-10_
543
544 * New: Kotlin 1.3.11.
545 * Fix: Prevent wrapping in import statements.
546
547## Version 1.0.0-RC3
548
549_2018-11-28_
550
551 * New: Kotlin 1.3.10.
552 * New: Add `%P` placeholder for string templates.
553 * New: Add support for receiver kdoc.
554 * New: Avoid emitting `Unit` as return type.
555 * New: Add support for empty setters.
556 * New: Add checks for inline classes.
557 * New: Escape property and variable names if keywords.
558 * New: Replace `%>`, `%<`, `%[`, `%]` placeholders with `⇥`, `⇤`, `«`, `»`.
559 * New: Replace `%W` with space, and add `·` as a non-breaking space.
560 * New: Change `TypeName` to sealed class.
561 * New: Documentation improvements.
562 * New: Replace `TypeName` modifier methods with `copy()`.
563 * New: Rename members of `WildcardTypeName` to match with the producer/consumer generics model.
564 * New: Rename `TypeName.nullable` into `TypeName.isNullable`.
565 * New: Rename `LambdaTypeName.suspending` into `LambdaTypeName.isSuspending`.
566 * New: Rename `TypeVariableName.reified` into `TypeVariableName.isReified`.
567 * Fix: Emit star-projection only for types with `Any?` upper bound.
568 * Fix: Fold property with escaped name.
569
570## Version 1.0.0-RC2
571
572_2018-10-22_
573
574 * New: Kotlin 1.2.71.
575 * New: README improvements.
576 * New: Allow opening braces and params in `beginControlFlow()`.
577 * New: Add KDoc to `ParameterSpec`, collapse into parent KDoc.
578 * New: Support `TypeVariable`s in `PropertySpec`.
579 * New: Add parens for annotated types in `LambdaTypeName`.
580 * New: Improve error messaging and documentation for inline properties.
581 * New: Allow sealed classes to declare abstract properties.
582 * New: Added `buildCodeBlock()` helper function.
583 * New: Allow using `CodeBlock`s with statements as property initializers and default parameter values.
584 * New: Rename `NameAllocator.clone()` into `NameAllocator.copy().
585 * New: Rename `TypeName.asNonNullable()` to `TypeName.asNonNull()`.
586 * New: Remove `PropertySpec.varBuilder()` (use `mutable()` instead).
587 * New: Allow importing top-level members in default package.
588 * New: Add overloads to add KDoc to return type.
589 * Fix: Distinguishing `IntArray` and `Array<Int>` when creating `TypeName`.
590 * Fix: Use `TypeName` instead of `ClassName` as parameter type of `plusParameter()`.
591 * Fix: Keep type-parameter variance when constructing `TypeName` from `KType`.
592 * Fix: Don't validate modifiers when merging properties with primary constructor parameters.
593 * Fix: Escape $ characters in formatted strings.
594 * Fix: `FileSpec.Builder` blank package and subfolder fix.
595 * Fix: Append new line at end of parameter KDoc.
596 * Fix: Add parameter KDoc in `toBuilder()`.
597
598## Version 1.0.0-RC1
599
600_2018-07-16_
601
602 * New: Escape keywords in imports and canonical class names.
603 * New: Improve `external` support.
604 * New: Extensions for `KType` and `KTypeParameter`.
605 * New: Add builder methods to simplify adding common kotlin.jvm annotations.
606 * New: Enums are able to have companion objects.
607 * New: Add missing primaryConstructor & companionObject to `TypeSpec#toBuilder()`.
608 * New: Make subtype checking vals inside Kind public.
609 * New: Escape (class/property/function/variable) names automatically if they contain space, hyphen, or other symbols.
610 * New: Improve `ParameterizedTypeName` API.
611 * New: Add `WildcardTypeName.STAR` constant.
612 * New: Expose mutable builder properties and move their validations to build-time.
613 * Fix: Use regular indents for parameter lists.
614 * Fix: Inline annotations on properties defined in primary constructor.
615 * Fix: Use `Any?` as the default type variable bounds.
616 * Fix: Fix importing annotated `TypeName`.
617 * Fix: If any primary constructor property has KDoc, put properties on new lines.
618 * Fix: Properly emit where block in type signature.
619 * Fix: Avoid type name collisions in primary constructor.
620 * Fix: Remove implicit `TypeVariable` bound when more bounds are added.
621 * Fix: Combine annotations and modifiers from constructor params and properties.
622 * Fix: Replace delegate constructor args along with the constructor.
623
624## Version 0.7.0
625
626_2018-02-16_
627
628 * New: Increase indent to 4 spaces.
629 * New: Delegate super interfaces as constructor parameters.
630 * New: Support `PropertySpec`s as `CodeBlock` literals.
631 * New: Support KDoc for `TypeAliasSpec`.
632 * New: Allow for adding an initializer block inside a companion object.
633 * New: Escape name in `ParameterSpec` which is also a keyword.
634 * New: Escape names in statements.
635 * New: Set com.squareup.kotlinpoet as automatic module name.
636 * New: Support suspending lambda types.
637 * New: Support named `LambdaTypeName` parameters.
638 * New: Support dynamic type.
639 * New: Disallow wildcard imports.
640 * New: Depend on Kotlin 1.2.21.
641 * Fix: Correct handling of super-classes/interfaces on anonymous classes.
642 * Fix: Fix boundary filtering to `Any?`.
643 * Fix: Wrap long property initializers.
644 * Fix: Fix formatting and indentation of parameter lists.
645
646## Version 0.6.0
647
648_2017-11-03_
649
650 * New: Support lambda extensions.
651 * New: Support renames in imports like `import bar.Bar as bBar`.
652 * New: Support extension and inline properties.
653 * New: Support reified types.
654 * New: Expose enclosed types inside `LambdaTypeName`.
655 * New: Depend on Kotlin Kotlin 1.1.51.
656 * New: Improved API and formatting of annotations.
657 * New: Improved multiplatform support.
658 * Fix: Escape function and package names if they are a Kotlin keyword.
659 * Fix: Properly format WildcardTypeName's class declaration.
660
661
662## Version 0.5.0
663
664_2017-09-13_
665
666 * New: Rename `addFun()` to `addFunction()`.
667 * New: Rename `KotlinFile` to `FileSpec`.
668 * New: Rename `KotlinFile.addFileAnnotation()` to `addAnnotation()`.
669 * New: Rename `KotlinFile.addFileComment()` to `addComment()`.
670 * New: Support cross-platform code, including `HEADER` and `IMPL` modifiers.
671 * New: Support type variables for type aliases.
672 * New: Support constructor delegation.
673 * New: Support named companion objects.
674 * New: Depend on Kotlin 1.1.4-3.
675 * Fix: Format one parameter per line when there are more than two parameters.
676 * Fix: Don't emit braces when the constructor body is empty.
677 * Fix: Do not invoke superclass constructor when no primary constructor.
678 * Fix: Enforce the right modifiers on functions.
679
680
681## Version 0.4.0
682
683_2017-08-08_
684
685 * New: Change KotlinPoet's extensions like `asClassName()` to be top-level functions.
686 * New: Add declaration-site variance support.
687 * New: Improve handling of single expression bodies.
688 * New: Support file annotations.
689 * New: Support imports from the top-level file.
690 * New: Accept superclass constructor parameters.
691 * New: Support primary constructors using the `constructor` keyword.
692 * Fix: Don't emit setter parameter types.
693 * Fix: Support Kotlin keywords in `NameAllocator`.
694 * Fix: Emit the right default parameters for primary constructors.
695 * Fix: Format annotations properly when used as parameters.
696 * Fix: Recognize imports when emitting nullable types.
697 * Fix: Call through to the superclass constructor when superclass has a no-args constructor.
698 * Fix: Omit class braces if all properties are declared in primary constructor.
699 * Fix: Don't emit empty class bodies.
700 * Fix: Emit the right syntax for declaring multiple generic type constraints.
701 * Fix: Support properties on objects, companions and interfaces.
702 * Fix: Use `AnnotationSpec` for throws.
703
704
705## Version 0.3.0
706
707_2017-06-11_
708
709 * New: Objects and companion objects.
710 * New: `TypeAliasSpec` to create type aliases.
711 * New: `LambdaTypeName` to create lambda types.
712 * New: Collapse property declarations into constructor params.
713 * New: Extension and invoke functions for creating type names: `Runnable::class.asClassName()`.
714 * New: Basic support for expression bodies.
715 * New: Basic support for custom accessors.
716 * New: Remove `Filer` writing and originating elements concept. These stem from `javac` annotation
717   processors.
718 * Fix: Generate valid annotation classes.
719 * Fix: Use `KModifier` for varargs.
720 * Fix: Use `ParameterizedTypeName` for array types.
721 * Fix: Extract Kotlin name from `KClass` instead of Java name.
722 * Fix: Emit valid class literals: `Double::class` instead of `Double.class`.
723 * Fix: Emit modifiers in the expected order.
724 * Fix: Emit the correct syntax for enum classes and overridden members.
725
726
727## Version 0.2.0
728
729_2017-05-21_
730
731 * New: Flip API signatures to be (name, type) instead of (type, name).
732 * New: Support for nullable types.
733 * New: Support delegated properties.
734 * New: Extension functions.
735 * New: Support top-level properties.
736 * Fix: Inheritance should use `:` instead of `extends` and `implements`.
737 * Fix: Make initializerBlock emit `init {}`.
738
739
740## Version 0.1.0
741
742_2017-05-16_
743
744 * Initial public release.
745
746 [kotlinpoet-metadata]: ../kotlinpoet_metadata
747 [kotlinpoet-metadata-specs]: ../kotlinpoet_metadata_specs
748 [explicit-api-mode]: https://kotlinlang.org/docs/reference/whatsnew14.html#explicit-api-mode-for-library-authors
749 [issue-999]: https://github.com/square/kotlinpoet/issues/999
750 [ksp]: https://github.com/google/ksp
751 [ksp-interop-docs]: https://square.github.io/kotlinpoet/interop-ksp/
752 [javapoet]: https://github.com/square/javapoet
753 [javapoet-interop-docs]: https://square.github.io/kotlinpoet/interop-javapoet/
754
755 [martinbonnin]: https://github.com/martinbonnin
756 [idanakav]: https://github.com/idanakav
757 [goooler]: https://github.com/goooler
758 [anandwana001]: https://github.com/anandwana001
759 [evant]: https://github.com/evant
760 [glureau]: https://github.com/glureau
761 [liujingxing]: https://github.com/liujingxing
762 [BoD]: https://github.com/BoD
763 [WhosNickDoglio]: https://github.com/WhosNickDoglio
764 [sullis]: https://github.com/sullis
765 [DRSchlaubi]: https://github.com/DRSchlaubi
766 [seriouslyhypersonic]: https://github.com/seriouslyhypersonic
767 [ephemient]: https://github.com/ephemient
768 [dkilmer]: https://github.com/dkilmer
769 [aksh1618]: https://github.com/aksh1618
770 [zsqw123]: https://github.com/zsqw123
771 [roihershberg]: https://github.com/roihershberg
772 [popematt]: https://github.com/popematt
773 [bitPogo]: https://github.com/bitPogo
774 [mars885]: https://github.com/mars885
775 [sjudd]: https://github.com/sjudd
776 [Sironheart]: https://github.com/Sironheart
777 [polarene]: https://github.com/polarene
778 [DeoTimeTheGithubUser]: https://github.com/DeoTimeTheGithubUser
779 [drawers]: https://github.com/drawers
780 [rickclephas]: https://github.com/rickclephas
781 [Squiry]: https://github.com/Squiry
782 [Omico]: https://github.com/Omico
783 [RBusarow]: https://github.com/RBusarow
784 [fejesjoco]: https://github.com/fejesjoco
785 [takahirom]: https://github.com/takahirom
786 [mcarleio]: https://github.com/mcarleio
787 [gabrielittner]: https://github.com/gabrielittner
788