Kotlin 1.0 Beta 2 is Out!

Andrey Breslav

The first update to our Beta is here! We are stabilizing, so it’s mostly bug-fixing and changes to the standard library.

Language changes

We are now enforcing single-instantiation inheritance constraint on type parameters: the same T can not have both List<Int> and List<String> as its upper bounds. This has been always forbidden for classes, now the same check applies for type parameters.

Diagnostics were improved for the cases when a smart cast is impossible:

class C {
    var x: String? = ""
    fun foo(): String {
        if (x != null) return x // ERROR: smart cast to String is impossible, 
                                // because 'x' is a member variable

Also, the compiler is now smart enough to warn us when a value is always null at a particular point:

    var x: Foo? = ...
    if (x != null) return
    x?.bar() // WARNING: bar() will never run, because x is always null here

Library changes

We cleaning up the APIs of the standard library. Most visible changes this time concern ranges. We intended the common use cases such as “if (x in 1..10)” or “for (i in 1..10)” to remain without changes, but did some renaming and hierarchy rearrangements under the hoods:

  • Double and Float progressions are dropped
  • Byte and Short progressions are deprecated, the .. operator for bytes and shorts now returns IntRange
  • Range<T> renamed to ClosedRange<T> and its end property renamed to endInclusive
  • Progression<T> is deprecated in favor of concrete progression implementations instead: IntProgression, LongProrgession, CharProgression
  • start and end properties in progressions are renamed to first and last

Then, utility extensions for strings were generalized to work with CharSequence where possible.

The filterIsInstance extension now requires an explicit specification of its type parameter:

foo(list.filterIsInstance()) // error: what is the type the checks are done for?!
foo(list.filterIsInstance<Bar>()) // OK: we are checking for Bar

NOTE: To reduce the size of the runtime library (which is especially important for Android applications), we removed the kotlin.dom and kotlin.browser packages from the standard library. They are now available as a separate library, kotlinx.dom. If you’re using any of these packages in your project, please add the new library as a dependency and update the import statements in your code (change kotlin.dom and kotlin.browser to kotlinx.dom and kotlinx.browser). Otherwise, the API of the library has not changed.

Other changes:

  • Added
    • in-place reversing and sorting for MutableLists and Arrays
    • naturalOrder and reverseOrder comparators
    • mapNotNull, mapIndexedNotNull, filterIndexed
    • String.toByte()
  • Deprecated (run Code Cleanup to migrate your code)
    • Function.toGenerator
    • toLinkedList
  • Dropped
    • join, merge
    • Delegates.lazy
    • FileTreeWalk.filter, File.recurse, BufferedReader.lines and lineIterator
    • assert, check and require with non-lazy message argument


Dokka, the new documentation generation tool for Kotlin projects, has finally reached a full release. Dokka supports mixed-language projects and understands KDoc comments in Kotlin code and JavaDoc comments in Java code. Dokka has plugins for Gradle, Maven and Ant, so you can easily integrate it with the build system of your project. Download Dokka and find more information on the Dokka project site.

IDE changes

  • Completion now works for Java static members and members of objects. Just press Ctrl+Space for the second time:

  • Completion inside string templates has been added. For using it type "$name."

  • Now we can choose exact position of a breakpoint while debugging expressions with lambdas:

  • And finally, a bunch of intention actions have been added for importing Java statics, object members and enum entries. And there is an analogous one to *-import static members from Java classes or entries from enum classes


IntelliJ IDEA 15 and Android Studio will suggest you to update Kotlin automatically. If this does not happen, you can do it manually through Plugin Manager.

Comments below can no longer be edited.

36 Responses to Kotlin 1.0 Beta 2 is Out!

  1. Даниил Водопьян says:

    November 16, 2015

    What’s with Delegates.lazy? What went wrong with it and what to use instead?

  2. Christian says:

    November 16, 2015

    filterIndexed Finally!

    String.toByte() is that a typo and should by toBytes()?

    • ilya.gorbunov says:

      November 16, 2015

      It’s a string-to-number conversion, like toInt(), toDouble() etc

    • Sergey Mashkov says:

      November 16, 2015

      String.toByte() is a function to parse a string as a number. To get bytes you need toByteArray

  3. Niek Haarman says:

    November 17, 2015

    How should we handle the ClosedRange construct with the .. operator? Typing ‘1..2’ yields a Range, which is marked as deprecated. However, the following is not allowed:


    fun testRange(range: ClosedRange) {

    • Andrey Breslav says:

      November 17, 2015

      1..2 yields IntRange. Your example works for me:

      fun test() {
          testRange(1..2) // No error
      fun testRange(range: ClosedRange<Int>) {

      Please clarify your question.

  4. Christian says:

    November 17, 2015

    Is there an online example of Dokka documentation?

  5. Yested FW was updated to Kotlin Beta 2. | Yested Framework says:

    November 17, 2015

    […] Yested FW was updated to Kotlin Beta 2. […]

  6. changmin.jeon says:

    November 17, 2015

    While coding android application, the following code cause error after Kotlin’s plugins were updated.
    var intent = Intent(this, BGMService::class.java)
    Error:(72, 30) None of the following functions can be called with the arguments supplied:
    public constructor Intent(packageContext: android.content.Context!, cls: java.lang.Class<*>!) defined in android.content.Intent
    public constructor Intent(action: kotlin.String!, uri: android.net.Uri!) defined in android.content.Intent

    • yanex says:

      November 17, 2015

      It works for me. Can you provide some more details? Slack or email (yan.zhulanow[at]jetbrains.com) is also ok.

      • changmin.jeon says:

        November 18, 2015

        It’s working. It was my mistake. sorry for confusing your team.

  7. Tonisi says:

    November 18, 2015

    Well done team.

    Any chance Kotlin will support union types as TypeScript and Ceylon does? It’s really useful.

    • Andrey Breslav says:

      November 18, 2015

      We are looking for ways of supporting something like union types for JavaScript interop

      • Tonisi says:

        November 18, 2015

        That’s amazing news. Will this include flow sensitive typing?

  8. Alexey Romanov says:

    November 20, 2015

    Why are Byte and Short progressions deprecated?

  9. Entreprenorskapital » RoboVM 1.11 released – experimental Bitcode support, iOS 9 and Kotlin! says:

    November 20, 2015

    […] on the latest Kotlin Beta, you can now create cross-platform Android and iOS app in Kotlin from within RoboVM Studio or […]

  10. Entreprenorskapital » RoboVM 1.11 released – experimental Bitcode support, iOS 9.1 and Kotlin! says:

    November 20, 2015

    […] on the latest Kotlin Beta, you can now create cross-platform Android and iOS app in Kotlin from within RoboVM Studio or […]

  11. Takuya Miyamoto says:

    November 21, 2015

    Android Studio 1.5 complains the following:

    12:33:45 AM Plugin Error: Kotlin threw an uncaught AssertionError. Disable Plugin
    12:33:45 AM AssertionError: Recursion detected on input: onCreate under LockBasedStorageManager@2ca87264 (org.jetbrains.kotlin.idea.caches.resolve.GlobalContextUtilsKt.withCompositeExceptionTrackerUnderSameLock(globalContextUtils.kt:27))

    • Takuya Miyamoto says:

      November 21, 2015

      The stacktrace is here.

      Recursion detected on input: onCreate under LockBasedStorageManager@4d04582c (org.jetbrains.kotlin.idea.caches.resolve.GlobalContextUtilsKt.withCompositeExceptionTrackerUnderSameLock(globalContextUtils.kt:27))
      java.lang.AssertionError: Recursion detected on input: onCreate under LockBasedStorageManager@4d04582c (org.jetbrains.kotlin.idea.caches.resolve.GlobalContextUtilsKt.withCompositeExceptionTrackerUnderSameLock(globalContextUtils.kt:27))
      at org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaScope.getContributedFunctions(LazyJavaScope.kt:216)
      at org.jetbrains.kotlin.resolve.jvm.kotlinSignature.SignaturesPropagationData.getSuperFunctionsForMethod(SignaturesPropagationData.java:308)
      at org.jetbrains.kotlin.resolve.jvm.kotlinSignature.SignaturesPropagationData.(SignaturesPropagationData.java:88)
      at org.jetbrains.kotlin.load.java.components.TraceBasedExternalSignatureResolver.resolvePropagatedSignature(TraceBasedExternalSignatureResolver.java:63)
      at org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaClassMemberScope.resolveMethodSignature(LazyJavaClassMemberScope.kt:425)
      at org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaScope.resolveMethodToFunctionDescriptor(LazyJavaScope.kt:123)
      at org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaScope$functions$1.invoke(LazyJavaScope.kt:82)
      at org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaScope$functions$1.invoke(LazyJavaScope.kt:54)
      at org.jetbrains.kotlin.storage.LockBasedStorageManager$MapBasedMemoizedFunction.invoke(LockBasedStorageManager.java:389)
      at org.jetbrains.kotlin.storage.LockBasedStorageManager$MapBasedMemoizedFunctionToNotNull.invoke(LockBasedStorageManager.java:453)
      at org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaScope.getContributedFunctions(LazyJavaScope.kt:216)
      at org.jetbrains.kotlin.idea.caches.resolve.JavaResolutionUtils.resolveMethod(JavaResolveExtension.kt:96)
      at org.jetbrains.kotlin.idea.caches.resolve.JavaResolutionUtils.getJavaMethodDescriptor(JavaResolveExtension.kt:43)
      at org.jetbrains.kotlin.idea.caches.resolve.JavaResolutionUtils.getJavaMethodDescriptor$default(JavaResolveExtension.kt:37)
      at org.jetbrains.kotlin.idea.search.ideaExtensions.KotlinPropertyAccessorsReferenceSearcher.propertyName(KotlinPropertyAccessorsReferenceSearcher.kt:55)
      at org.jetbrains.kotlin.idea.search.ideaExtensions.KotlinPropertyAccessorsReferenceSearcher.processQuery(KotlinPropertyAccessorsReferenceSearcher.kt:37)
      at org.jetbrains.kotlin.idea.search.ideaExtensions.KotlinPropertyAccessorsReferenceSearcher.processQuery(KotlinPropertyAccessorsReferenceSearcher.kt:34)
      at com.intellij.openapi.application.QueryExecutorBase$2.run(QueryExecutorBase.java:44)
      at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:867)
      at com.intellij.openapi.application.QueryExecutorBase.execute(QueryExecutorBase.java:42)
      at com.intellij.util.ExecutorsQuery.processResults(ExecutorsQuery.java:43)
      at com.intellij.util.AbstractQuery.forEach(AbstractQuery.java:75)
      at com.intellij.util.MergeQuery.processSubQuery(MergeQuery.java:84)
      at com.intellij.util.MergeQuery.forEach(MergeQuery.java:56)
      at com.intellij.util.UniqueResultsQuery.process(UniqueResultsQuery.java:66)
      at com.intellij.util.UniqueResultsQuery.forEach(UniqueResultsQuery.java:56)
      at com.intellij.find.findUsages.JavaFindUsagesHelper.addElementUsages(JavaFindUsagesHelper.java:604)
      at com.intellij.find.findUsages.JavaFindUsagesHelper.processElementUsages(JavaFindUsagesHelper.java:139)
      at com.intellij.codeInsight.daemon.impl.UnusedSymbolUtil.processUsages(UnusedSymbolUtil.java:265)
      at com.intellij.codeInsight.daemon.impl.UnusedSymbolUtil.weAreSureThereAreNoUsages(UnusedSymbolUtil.java:168)
      at com.intellij.codeInsight.daemon.impl.UnusedSymbolUtil.isMethodReferenced(UnusedSymbolUtil.java:148)
      at com.intellij.codeInsight.daemon.impl.analysis.PostHighlightingVisitor.processMethod(PostHighlightingVisitor.java:440)
      at com.intellij.codeInsight.daemon.impl.analysis.PostHighlightingVisitor.processIdentifier(PostHighlightingVisitor.java:262)
      at com.intellij.codeInsight.daemon.impl.analysis.PostHighlightingVisitor.collectHighlights(PostHighlightingVisitor.java:199)
      at com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl$3.run(HighlightVisitorImpl.java:184)
      at com.intellij.codeInsight.daemon.impl.analysis.RefCountHolder.analyze(RefCountHolder.java:308)
      at com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl.analyze(HighlightVisitorImpl.java:177)
      at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.analyzeByVisitors(GeneralHighlightingPass.java:297)
      at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.access$200(GeneralHighlightingPass.java:64)
      at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass$4.run(GeneralHighlightingPass.java:300)
      at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.analyze(DefaultHighlightVisitor.java:86)
      at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.analyzeByVisitors(GeneralHighlightingPass.java:297)
      at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.collectHighlights(GeneralHighlightingPass.java:266)
      at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.collectInformationWithProgress(GeneralHighlightingPass.java:205)
      at com.intellij.codeInsight.daemon.impl.ProgressableTextEditorHighlightingPass.doCollectInformation(ProgressableTextEditorHighlightingPass.java:97)
      at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:67)
      at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$1$1.run(PassExecutorService.java:444)
      at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1103)
      at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$1.run(PassExecutorService.java:435)
      at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:452)
      at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:402)
      at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
      at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:432)
      at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:408)
      at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask.exec(JobLauncherImpl.java:189)
      at jsr166e.ForkJoinTask.doExec(ForkJoinTask.java:260)
      at jsr166e.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:858)
      at jsr166e.ForkJoinPool.scan(ForkJoinPool.java:1687)
      at jsr166e.ForkJoinPool.runWorker(ForkJoinPool.java:1642)
      at jsr166e.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:109)

    • Andrey Breslav says:

      November 21, 2015

      Please submit bug reports to the issue tracker: https://youtrack.jetbrains.com/issues/KT

  12. Agustin says:

    December 4, 2015

    Well done!.

    Would be possible to add preprocessor conditional compilation? Like C++ #ifdef would be awesome!.

    • Andrey Breslav says:

      December 4, 2015

      What is your use case for #ifdef?

      • Agustin says:

        December 5, 2015

        I’m writting an agnostic OpenGL engine (using Kotlin) and i was thinking on doing something like this:

        public class enum Attribute
        // Desktop.
        #ifdef TARGET_OPENGL

          //  Mobile.

        #else defined(TARGET_OPENGL_ES)

           //  Javascript WebGL

        #else defined (TARGET_WEBGL)

        • Andrey Breslav says:

          December 7, 2015

          Kotlin enums do not support things like HALF_FLOAT = GL_HALF_FLOAT, but you can use simple val‘s for that.

          • Agustin says:

            December 8, 2015

            I actually wrote the example wrong.

            public class enum Attribute(public val eID)
            #ifdef TARGET_OPENGL
            #elseif defined(TARGET_OPENGLES)

            • Andrey Breslav says:

              December 8, 2015

              Ok, now I see, thanks.

            • Andrey Breslav says:

              December 8, 2015

              You can do this without #ifdef. Let’s say that TARGET_OPENGL is a simple boolean constant, then we can say

              public class enum Attribute(public val eID) {
                      if (TARGET_OPENGL) GL.GL_HALF_FLOAT 
                      else if (GL.GL_HALF_FLOAT_OES) GL.GL_HALF_FLOAT_OES 
                      else ...)

              The only thing that can not be done this way is adding/removing a constant depending on a condition