Raphael
Raphael

Reputation: 10549

After upgrade to Kotlin 1.3 I still can not use contract

I upgraded the Kotlin plugin in IDEA from 1.2.71 to 1.3.0 and made sure the new SDK is the Project SDK:

enter image description here

I expected to be able to use the new kotlin.contracts.contract, but it's deep red!

enter image description here

Information:Kotlin: kotlinc-jvm 1.3.0 (JRE 1.8.0_181-b13)
Error:(9, 9) Kotlin: Error in contract description: Error in contract description
Error:(9, 9) Kotlin: Unresolved reference: contract

What do I have to do to get access to contracts?

Upvotes: 1

Views: 403

Answers (1)

Raphael
Raphael

Reputation: 10549

The language level of the project does not get migrated automatically. Therefore, new language features will not be available (and your code won't break) unless you do something.

Change the language level for your project manually in File | Settings | Build, Execution, Deployment | Compiler | Kotlin Compiler:

enter image description here

Or add a facet to the modules you want to selectively change the level for:

enter image description here

Further steps are necessary to enable contracts which are, after all, an experimental feature, but IDEA will now help you with that:

enter image description here

Upvotes: 2

Related Questions