Add contract for 'use'

#KT-35216 Fixed
This commit is contained in:
Toshiaki Kameyama
2019-12-20 09:52:00 +09:00
committed by Ilya Gorbunov
parent 043eddb432
commit 941de655c4
5 changed files with 56 additions and 1 deletions
@@ -0,0 +1,25 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package kotlin.jdk7.test
import org.junit.Test
import kotlin.test.assertEquals
class AutoCloseableContractsTest {
@Test
fun shouldHaveBlockExactlyOnceContract() {
class TestAutoCloseable : AutoCloseable {
override fun close() {
}
}
val i: Int
TestAutoCloseable().use {
i = 1
}
assertEquals(1, i)
}
}