Releases: JetBrains/kotlin
Releases · JetBrains/kotlin
Kotlin 1.0.0 Release Candidate
Important notes
To get rid of all the old code, this version requires recompilation of all dependencies.
EAP users must recompile their code as well, although the compiler won't demand this (IllegalAccessError
is likely to be thrown at runtime)
What's new
- Language
- new
@delegate:
use-site target for annotation (e.g.@delegate:Transient
) - private top-level Kotlin classes should be compiled to package private java classes
- unfinished multiline comment is an error
- previously deprecated language constructs are now errors
- type ckecking for use-site variance fixed
- generic functions are compared for specificity through solving a constraint system
- having multiple
vararg
parameters for one function is prohibited - super-calls to functions with default parameters are prohibited (pass all arguments explicitly)
- implicit receiver behavior fixed
as
-import removes original names if they were imported before- user code is not allowed in
kotlin.**
packages - type parameters of extension properties allowed to be indirectly used by the receiver type
- members of private classes can-not be accessed from non-private inline functions
- new
- Java interop
forEach
from Kotlin's library is preferred toforEach
fromjava.lang.Iterable
- synthesized declarations (like JavaBeans properties and SAM-converted methods) are now resolved on par with members
- support added for Java setters that return values
- previously depreacted Java declarations removed from generated code
- private setters allowed for
lateinit
properties - wildcards are not generated for redundant type projections (use
List<@JvmWildcard Foo>
instead ofList<out Foo>
) @Nullable
/@NotNull
annotations from different standard Java packages recognized (javax.annotations
, Guava, Android, etc)
- Standard Library
- diagnostics for multiple conflicting Kotlin runtime versions in classpath
- some functions have been made inline
- many inline functions (most of them one-liners) can no longer be called from Java code. This will help us reduce the size of the runtime library in the future.
- library code rearranged into more granular packages (no source changes should be required)
associate
andassociateBy
are added to aid construction of maps
associate and associateBy (instead of toMap/toMapBy)groupBy
with key- and value-selector functionsMap.getOrElse()
andMap.getOrPut()
now treat keys associated withnull
values as missing.Map.getOrImplicitDefault()
has been made internalmutableListOf
,mutableSetOf
,mutableMapOf
added to construct mutable collections.linkedListOf
is deprecatedtoMutableList
added instead oftoArrayList
. The latter is deprecatedkotlin.system.exitProcess
instead ofSystem.exit
File.deleteRecursively
only returnsfalse
in case of incomplete deletionFile.copyRecursively
allows overwriting by specifying argumentoverwrite=true
- changed
File.copyTo
behavior to be likeFiles.copy
from JDK8. - more specific return type for
File.inputStream
,File.outputStream
,String.byteInputStream
. - IO utility functions taking charset name as a string are deprecated, use ones with
Charset
parameter. File.useLines
andReader.readLines
are introducedFile.(buffered)reader/writer
now return less specificInputStreamReader/OutputStreamWriter
and use UTF-8 encoding by defaultSequence
andIterable
SAM constructor-like functions- Comparator- and comparison-related functions are moved to
kotlin.comparisons
package (not imported by default) - new properties in
MatchResult
:groupValues
anddestructured
— provided for easier handling of regular expression match results Lazy
is now an interface open for implementationkotlin.system.measureTimeNano
renamed tomeasureNanoTime
.plusElement
andminusElement
functions as a synonyms forlist + element
andlist - element
.kotlin.test.assertFailsWith
withClass<T>
parameter is deprecated, use an overload withKClass<T>
.toLinkedMap
is deprecated.- UTF_32 charset properties added to
Chatsets
- Tools
- To enable Android Extensions, use:
apply plugin: 'kotlin-android-extensions'
- To enable Android Extensions, use:
- IDE
- Intention to replace iteration over map entries with a loop using a destructuring declaration
- Inspection and quickfix to cleanup redundant visibility modifiers
- Inspection to replace 'assert' calls checking that a variable is not null with !! or
?: error(...)
- Show "Kotlin not configured" notification when opening a .kt file in the IDE if the Kotlin runtime is not configured for the corresponding module
- Action to generate the toString() method
- Support for implementing members by primary constructor parameters
- Parameter info popup works for showing type parameters
- Completion offers name variants based on unresolved identifiers in current file
- Quickfix for adding missing branches to a
when
expression - Support for moving nested classes to the upper level or into another top-level class
@Suppress
now works for IDE inspections
Kotlin 1.0.0 Beta 4 Update 2
Bugfix update:
- Gradle Plugin for Android
- Instant Run support for Android Studio
- Compatibility with IntelliJ IDEA 16
Kotlin 1.0.0 Beta 4
Hot-fix update: Wrong JDK in class path for Android
See What's new here
Kotlin 1.0.0 Beta 4
Language
- Primary constructor is resolved in the same scope as secondary constructors
yield
is reserved as a keywordasync
is reserved in some contextstypeof
is reserved as a keyword. In JS, usejsTypeOf()
sealed
when reserved- Multiple fixes in the overload resolution algorithm.
- The curious case of
File.listFiles
- The curious case of
KPropertyN
now extendFunctionN
, i.e.list.map(String::length)
works now- Duplicate bounds for type parameters forbidden
- Multiple class bounds for type parameters forbidden
Array<Nothing>
andArray<Nothing?>
are prohibitedif
with noelse
is not an expressionvalues()
andvalueOf()
in enums are preferred to member of companion objects- Better scheme of translation of variant types to Java
@JvmSuppressWildards
and@JvmWildcard
added- Statics inherited by companion object are visible without qualification in the outer class and its subclasses
- Absolute package references dropped. Use alias imports instead
- Overloads are compared according to actual arguments only
- Deprecations lifted to errors:
Enum.values
, local sealed classes, private setter for open property
Library
kotlin-test.jar
extracted- Extensions are moved to specific packages (no source changes required for Kotlin code)
javaPrimitiveType
andjavaObjectType
added forKClass
IntArray(5) { it * 3 }
and other initializers supported for primitive arrays- Semantics of
null
in maps is going to change minWith(comparator)
/maxWith(comparator)
supportedtoMap((T)
-> Pair<K,V>)` supportedFileTreeWalk
:- constructor is deprecated, preferred construction with fluent builder methods
treeFilter
is deprecated, recursive filtering now happens inonStart
- File utilities behavior changes and deprecations
IDE
- New precise incremental compilation (experimental)
- Rename for unresolved references
- Create From Usage for callable references
- Go to Test and Create Test for top-level functions
- Intention to convert anonymous function to a lambda
- Go to Class and Search Everywhere show Kotlin built-in types
- Debugger: Skip simple getters supported
Kotlin 1.0.0 Beta 3
What's new
- Library
increment
deprecated in Progressions in favor ofstep
property to Progressions,for
-loops updated to refer tostep
contains()
and other similar extensions now accept supertypes of the element of the collectionDelegates.mapVal
andmapVar
,MapVal
,MapVar
,FixedMapVal
,FixedMapVar
are deprecatedString.toCharArray()
introduced instead ofString.getChars()
;String.toCharList()
deprecatedMutableCollection.removeAll(predicate: (T) -> Boolean)
and similar forretainAll
addedsequence(initialValueFunction, nextValueFunction)
doesn't evaluate first value until it's requested by sequence iteratorsequenceOf(Progression)
deprecatedflatten
operation forSequence<Iterable<...>>
added
- Language
- No references to
PropertyMetadata
are generated in the byte code - Suffixes to numeric literals, such as
1baz
are prohibited - Comma-separated conditions in
when
without an argument are prohibited (KT-5143) - Annotation classes can't be instantiated (KT-4391)
- Arrays of annotations supported as annotation arguments (KT-10136)
- Generic types in catch clauses (including reified T) are prohibited (KT-9816)
protected
members are allowed in companion objects- Calls to non-
@JvmStatic
protected
members of companion objects from subclasses are marked as errors (unsupported) - "
…
" is reserved as a token (KT-9708) - Enum entry can not be used as a type (KT-5401)
Enum.values
is deprecated in favor ofEnum.values()
private
setters are now deprecated foropen
properties- Local
sealed
classes are deprecated - Use of uninitialized variables in lambdas / object literals / local functions is forbidden
- Overriding setter cannot weaken visibility
- Inner classes are no longer allowed inside enum entries
- Implicit receiver smart casts are supported
- Older deprecations have become errors
- No references to
build-1.0.0-beta-3594
Kotlin 1.0.0 Beta 2
What's New
- Language
- Single-instantiation inheritance for type parameters
- More precise "smart cast impossible" (the reason is given now)
- "Always null" warningadded
- Library
- Ranges
Double
andFloat
progressions are droppedByte
andShort
progressions are deprecated, the..
operator for bytes and shorts now returnsIntRange
Range<T>
renamed toClosedRange<T>
and itsend
property renamed toendInclusive
Progression<T>
is deprecated in favor of concrete progression implementations instead:IntProgression
,LongProrgession
,CharProgression
start
andend
properties in progressions are renamed tofirst
andlast
kotlin.dom
andkotlin.browser
moved out as a separate library: kotlinx.dom- Strings/CharSequences
- String utility extensions were generalized to take
CharSequence
where possible
- String utility extensions were generalized to take
- Added
- in-place reversing and sorting for
MutableList
s andArray
s naturalOrder
andreverseOrder
comparatorsmapNotNull
,mapIndexedNotNull
,filterIndexed
String.toByte()
- in-place reversing and sorting for
- Сhanged
- Explicit type parameter specification for
filterIsInstance
now is required
- Explicit type parameter specification for
- Deprecated
Function.toGenerator
toLinkedList
- Dropped
join
,merge
Delegates.lazy
FileTreeWalk.filter
,File.recurse
,BufferedReader.lines
andlineIterator
assert
,check
andrequire
with non-lazy message argument
- Ranges
- IDE
- Completion of java static members and members from objects on second
Ctrl-Space
- Intention action to import Java statics, object members or enum entries
- Intention action to import all Java static members from the given class or enum entries from the given enum class
- Completion in string templates works after
"$name."
- Debugger supports choosing where to put a breakpoint: inside or outside a single-lined lambda
- Completion of java static members and members from objects on second
Kotlin 1.0. Beta
Bug fixes
- Semantics of companion object initialization fixed,
INSTANCE
field deprecated for companion objects - Use-site targets fixed for
@JvmName
- Exposing Java package-private types through
internal
declarations is allowed - Access to
Enum.values
from within enums fixed - Issues with Android 4 and
DefaultImpls
classes fixed - Method count optimized for delegated properties on Android
- Two
main()
functions can't appear in the same file
Kotlin 1.0.0 Beta Candidate
Language
- Imports from objects
@Deprecated
supportsERROR
andHIDDEN
levels (@HiddenDeclaration
is deprecated)- Smart casts for captured local
var
's that are not modified in lambdas - Single-file classes can have many
main()
's internal
visibility checked in the compiler- No defensive copying needed for varargs
- All Java methods with matching signatures are operators
- Rename:
unaryMinus
/unaryPlus
for unary operators - Rename:
getValue
/setValue
for delegated properties - Checks for operator signatures at declarations sites
infix
modifier for infix functions- Rename
sparam
annotation target tosetparam
@UnsafeVariance
annotationfun foo<T>()
deprecated in favor offun <T> foo()
- Constraints on type parameters should occur either in
where
or in<…>
x is Array<Foo>
forbidden in favor ofx is Array<*> && x.isArrayOf<Foo>()
- Callable references restricted to support bound references later
PropertyMetadata
deprecated in favor ofKProperty<*>
if
with noelse
in expression position is an error- Letters and digits right before/after string and char literals are prohibited
invoke
convention for extension functions is removed- Visibility requirements for members
- Protected members in objects are prohibited
final
in interfaces is prohibited- Visibility for local classes is prohibited
- Local interfaces are prohibited
- Private setters for non-private lateinit vars are prohibited
- Nothing-returning functions must declare return type explicitly
- Annotations on multi-declarations are prohibited
- Checks for escaped identifiers (backticks) to conform to JVM requirements
- Supertypes of the form
T.() -> Foo
are prohibited Foo<Int>.Bar
is prohibited- Type parameters for properties are prohibited unless they are used in the receiver type
- Parameter annotations and default values in function types are prohibited
inline
properties are prohibited;;
is reserved for future use
Libraries
- Formerly deprecated declarations have been dropped
size()
,length()
etc are made propertiesList.remove(int)
is renamed toremoveAt
Collection<E>.contains(Any?)
,Map<K, V>.get(Any?)
and other similar function are now type-safe:contains(E)
,get(K)
containsRaw
,getRaw
extensions and alike are defined for the Java-like utyped behaviorRegex
API changes:matchEntire
added,match
/matchAll
renamed tofind
/findAll
, alsoregex in string
can be used isntead ofregex.hasMatch(string)
listOf()
doesn't make a defensive copyStringBuilder {}
function deprecated in favor ofbuildString {}
- Rename:
merge
->zip
,join
removed (usejoinToString
),mapNotNull
deprecated to be changed later
Java interop
- Java classes inherit static from supertypes
List<Nothing>
is compiled to raw List to facilitate subtyping in Java- Support "static overrides" for Java fields
- Top-level privates are private to file
- Names of
internal
functions and properties are mangled - Kotlin classes see inherited statics and members of inherited companion objects
@Synchronized
and@Volatile
are inapplicable to unimplemented functionsisFoo()
instead ofgetIsFoo()
for properties namedisFoo
- Old package facades are dropped
- Inheritance rules comply with Java 8
is
distinguishesMutableList
fromList
and supports functions of different aritiesInt
,String
and other basic types areSerializable
@JvmField
is required to make something a fieldINSTANCE
for objects (instead ofINSTANCE$
)- Constant pool stings are resued to reduce metadata sizes
@KotlinSignature
is deprecated- Java sees defaul implementations of methods in the interface
Foo
as statics inFoo.DefaultImpls
class - Constants from Java libraries are inlined into Kotlin byte code
@publicField
is deprecated
Tools
- Compiler daemon enabled by default in the IDE
- Parallel Compilation of Independent Modules in the daemon mode
- External annotations support removed
IDE
- Parameter Info everywhere
- Completion for callable references after
::
- Actions to generated
equals()/hashCode()
- Actions to generate secondary constructors
- '*'-imports configuration
- Unit-testing support
Kotlin M14
What's new
- Language
- New syntax for backing field access
- Operators require a modifier (
operator
) - Compile-time constants are prefixed with
const
- Annotations on file classes supported
private
on the top level is now private to fileinternal
is checked in the compiler (not only IDE)private
in interfaces is truly private nowequals
in data classes compares arrays by calling their.equals()
method (which works by identity)lateinit
val
‘s are prohibited- many cases of inheritance and other degrees of freedom are prohibited for data classed (see this blog post)
protected
andinternal
members are prohibited in interfaces_
,__
,___
are forbidden as in identifiersidentityEquals()
function is deprecated in favor of===
- Standard Library API subdivided into part classes such as
CollectionsKt
- IDE
- Introduce backing property refactoring
- Move property initializer to declaration refactoring
- Add unambiguous imports on-the-fly
- Completion for overridden members