[KLIB tool] Migrate 'dump-metadata' tests to K/N test infra
This commit is contained in:
committed by
Space Team
parent
57e004e2b0
commit
aa9b901926
@@ -2,33 +2,12 @@
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
import org.jetbrains.kotlin.UtilsKt
|
||||
|
||||
buildscript {
|
||||
apply from: "$rootDir/kotlin-native/gradle/kotlinGradlePlugin.gradle"
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin'
|
||||
apply plugin: 'konan'
|
||||
|
||||
ext.useCustomDist = UtilsKt.getUseCustomDist(project)
|
||||
|
||||
konanArtifacts {
|
||||
def testFiles = fileTree('src/test/testData') {
|
||||
include "*.kt"
|
||||
}
|
||||
testFiles.files.each { file ->
|
||||
def name = file.name
|
||||
library(name.take(name.lastIndexOf('.'))) {
|
||||
srcFiles file.absolutePath
|
||||
|
||||
// Build the compiler before building the test unless a custom path to the distribution is specified.
|
||||
if (!useCustomDist) {
|
||||
dependsOn ':dist'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions.freeCompilerArgs += ['-Xskip-prerelease-check']
|
||||
@@ -51,13 +30,4 @@ dependencies {
|
||||
test {
|
||||
dependsOn 'cleanTest'
|
||||
// Specify a path to the distribution that is used in the tests.
|
||||
systemProperty('konan.home', UtilsKt.getKotlinNativeDist(project))
|
||||
dependsOn konanArtifacts.collect { it.getByTarget('host') }
|
||||
if (useCustomDist) {
|
||||
// Use the klib utility from the distribution
|
||||
def distClasspath = fileTree("${UtilsKt.getKotlinNativeDist(project)}/konan/lib") {
|
||||
include "**/*.jar"
|
||||
}
|
||||
classpath = distClasspath + sourceSets.test.runtimeClasspath - sourceSets.main.runtimeClasspath
|
||||
}
|
||||
}
|
||||
|
||||
-348
@@ -1,348 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.cli.klib.test
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import kotlin.test.*
|
||||
import org.jetbrains.kotlin.cli.klib.*
|
||||
import org.jetbrains.kotlin.konan.target.Distribution
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import java.nio.file.Paths
|
||||
|
||||
class DumpMetadataTest {
|
||||
|
||||
private fun testLibrary(name: String) = LIBRARY_DIRECTORY.resolve("$name.klib").toFile().absolutePath
|
||||
|
||||
private fun dumpMetadata(library: String, printOutput: Boolean = false, expected: () -> String) {
|
||||
val output = StringBuilder()
|
||||
val lib = Library(library, null)
|
||||
lib.dumpMetadata(output, false, null)
|
||||
if (printOutput) {
|
||||
println(output.trim().toString())
|
||||
}
|
||||
assertEquals(
|
||||
StringUtil.convertLineSeparators(expected()),
|
||||
StringUtil.convertLineSeparators(output.trim().toString()),
|
||||
"klib \"dump-metadata\" test failed for library: $library"
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Stdlib content should be printed without exceptions`() {
|
||||
val output = StringBuilder()
|
||||
val distributionPath = System.getProperty("konan.home")
|
||||
Library(Distribution(distributionPath).stdlib, null).dumpMetadata(output, false, null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun topLevelFunctions() = dumpMetadata(testLibrary("TopLevelFunctions")) {
|
||||
"""
|
||||
package <root> {
|
||||
annotation class A constructor() : Annotation
|
||||
annotation class B constructor() : Annotation
|
||||
class Foo constructor()
|
||||
@A @B fun a()
|
||||
fun Foo.e()
|
||||
fun f1(x: Foo)
|
||||
fun f2(x: Foo, y: Foo): Int
|
||||
inline fun i1(block: () -> Foo)
|
||||
inline fun i2(noinline block: () -> Foo)
|
||||
inline fun i3(crossinline block: () -> Foo)
|
||||
fun i4(block: (Foo) -> Int)
|
||||
fun i5(block: (Foo, Foo) -> Int)
|
||||
fun i6(block: Foo.() -> Int)
|
||||
fun i7(block: Foo.(Foo) -> Int)
|
||||
fun <T> t1(x: Foo)
|
||||
fun <T> t2(x: T)
|
||||
fun <T, F> t3(x: T, y: F)
|
||||
inline fun <reified T> t4(x: T)
|
||||
fun <T : Number> t5(x: T)
|
||||
}
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun constructors() = dumpMetadata(testLibrary("Constructors")) {
|
||||
"""
|
||||
package <root> {
|
||||
annotation class A constructor() : Annotation
|
||||
class Bar @A constructor(x: Int)
|
||||
class Baz private constructor(x: Int)
|
||||
|
||||
class Foo constructor(x: Int) {
|
||||
constructor()
|
||||
constructor(x: Double)
|
||||
constructor(x: Double, y: Int)
|
||||
protected constructor(x: String)
|
||||
@A constructor(x: Foo)
|
||||
}
|
||||
|
||||
class Qux protected constructor(x: Int)
|
||||
|
||||
class Typed<T> constructor(x: Int) {
|
||||
constructor()
|
||||
constructor(x: Double)
|
||||
constructor(x: Double, y: Int)
|
||||
protected constructor(x: String)
|
||||
@A constructor(x: Foo)
|
||||
}
|
||||
|
||||
}
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun objects() = dumpMetadata(testLibrary("Objects")) {
|
||||
"""
|
||||
package <root> {
|
||||
|
||||
object A {
|
||||
fun a()
|
||||
}
|
||||
|
||||
class B constructor() {
|
||||
|
||||
companion object {
|
||||
fun b()
|
||||
}
|
||||
|
||||
object C {
|
||||
fun c()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class D constructor() {
|
||||
|
||||
companion object E {
|
||||
fun e()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun classes() = dumpMetadata(testLibrary("Classes")) {
|
||||
"""
|
||||
package <root> {
|
||||
|
||||
class A constructor() {
|
||||
val aVal: Int = 0
|
||||
var aVar: String
|
||||
fun aFun()
|
||||
|
||||
inner class B constructor() {
|
||||
val bVal: Int = 0
|
||||
var bVar: String
|
||||
fun bFun()
|
||||
|
||||
inner class C constructor() {
|
||||
val cVal: Int = 0
|
||||
var cVar: String
|
||||
fun cFun()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class E constructor() {
|
||||
val eVal: Int = 0
|
||||
var eVar: String
|
||||
fun eFun()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
data class F constructor(fVal: Int, fVar: String) {
|
||||
val fVal: Int
|
||||
var fVar: String
|
||||
operator fun component1(): Int
|
||||
operator fun component2(): String
|
||||
fun copy(fVal: Int = ..., fVar: String = ...): F
|
||||
override fun equals(other: Any?): Boolean
|
||||
fun fFun()
|
||||
override fun hashCode(): Int
|
||||
override fun toString(): String
|
||||
}
|
||||
|
||||
class FinalImpl constructor() : OpenImpl {
|
||||
override val iVal: Int = 0
|
||||
override var iVar: String
|
||||
override fun iFun()
|
||||
}
|
||||
|
||||
interface Interface {
|
||||
val iVal: Int
|
||||
var iVar: String
|
||||
fun iFun()
|
||||
}
|
||||
|
||||
open class OpenImpl constructor() : Interface {
|
||||
override val iVal: Int = 0
|
||||
override var iVar: String
|
||||
override fun iFun()
|
||||
}
|
||||
|
||||
}
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun methodModality() = dumpMetadata(testLibrary("MethodModality")) {
|
||||
"""
|
||||
package <root> {
|
||||
|
||||
abstract class AbstractClass constructor() : Interface {
|
||||
abstract fun abstractFun()
|
||||
override fun interfaceFun()
|
||||
}
|
||||
|
||||
class FinalClass constructor() : OpenClass {
|
||||
override fun openFun1()
|
||||
final override fun openFun2()
|
||||
}
|
||||
|
||||
interface Interface {
|
||||
fun interfaceFun()
|
||||
}
|
||||
|
||||
open class OpenClass constructor() : AbstractClass {
|
||||
override fun abstractFun()
|
||||
fun finalFun()
|
||||
open fun openFun1()
|
||||
open fun openFun2()
|
||||
}
|
||||
|
||||
}
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun functionModifiers() = dumpMetadata(testLibrary("FunctionModifiers")) {
|
||||
"""
|
||||
package <root> {
|
||||
|
||||
class Foo constructor() {
|
||||
fun f1()
|
||||
infix fun f2(x: Int)
|
||||
suspend fun f3()
|
||||
tailrec fun f4()
|
||||
fun f5(vararg x: Int)
|
||||
operator fun plus(x: Int)
|
||||
}
|
||||
|
||||
}
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
@Test
|
||||
// TODO: Support enum entry methods in serialization/deserialization.
|
||||
fun enum() = dumpMetadata(testLibrary("Enum")) {
|
||||
"""
|
||||
package <root> {
|
||||
|
||||
enum class E private constructor(x: Int = ...) : Enum<E> {
|
||||
enum entry A
|
||||
enum entry B
|
||||
enum entry C
|
||||
val enumVal: Int = 0
|
||||
var enumVar: String
|
||||
val x: Int
|
||||
open fun enumFun(): Int
|
||||
}
|
||||
|
||||
}
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
@Test
|
||||
// TODO: Support getter/setter annotations in serialization/deserialization.
|
||||
fun accessors() = dumpMetadata(testLibrary("Accessors")) {
|
||||
"""
|
||||
package custom.pkg {
|
||||
annotation class A constructor() : Annotation
|
||||
|
||||
class Foo constructor() {
|
||||
@A val annotated: Int = 0
|
||||
var annotatedAccessors: Int
|
||||
@A get
|
||||
@A set
|
||||
val annotatedGetter: Int = 0
|
||||
@A get
|
||||
var annotatedSetter: Int
|
||||
@A set
|
||||
var privateSetter: Int
|
||||
private set
|
||||
protected val protectedSimple: Int = 0
|
||||
val simple: Int = 0
|
||||
}
|
||||
|
||||
}
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun topLevelPropertiesCustomPackage() = dumpMetadata(testLibrary("TopLevelPropertiesCustomPackage")) {
|
||||
"""
|
||||
package custom.pkg {
|
||||
typealias MyTransformer = (String) -> Int
|
||||
val v1: Int = 1
|
||||
val v2: String = "hello"
|
||||
val v3: (String) -> Int
|
||||
val v4: MyTransformer /* = (String) -> Int */
|
||||
}
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun topLevelPropertiesRootPackage() = dumpMetadata(testLibrary("TopLevelPropertiesRootPackage")) {
|
||||
"""
|
||||
package <root> {
|
||||
typealias MyTransformer = (String) -> Int
|
||||
val v1: Int = 1
|
||||
val v2: String = "hello"
|
||||
val v3: (String) -> Int
|
||||
val v4: MyTransformer /* = (String) -> Int */
|
||||
}
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun topLevelPropertiesWithClassesCustomPackage() = dumpMetadata(testLibrary("TopLevelPropertiesWithClassesCustomPackage")) {
|
||||
"""
|
||||
package custom.pkg {
|
||||
object Bar
|
||||
class Foo constructor()
|
||||
typealias MyTransformer = (String) -> Int
|
||||
val v1: Int = 1
|
||||
val v2: String = "hello"
|
||||
val v3: (String) -> Int
|
||||
val v4: MyTransformer /* = (String) -> Int */
|
||||
}
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun topLevelPropertiesWithClassesRootPackage() = dumpMetadata(testLibrary("TopLevelPropertiesWithClassesRootPackage")) {
|
||||
"""
|
||||
package <root> {
|
||||
object Bar
|
||||
class Foo constructor()
|
||||
typealias MyTransformer = (String) -> Int
|
||||
val v1: Int = 1
|
||||
val v2: String = "hello"
|
||||
val v3: (String) -> Int
|
||||
val v4: MyTransformer /* = (String) -> Int */
|
||||
}
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
companion object {
|
||||
val LIBRARY_DIRECTORY = Paths.get("build/konan/libs").resolve(HostManager.hostName)
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package custom.pkg
|
||||
|
||||
annotation class A
|
||||
|
||||
class Foo {
|
||||
val simple = 0
|
||||
|
||||
private val privateSimple = 0
|
||||
|
||||
protected val protectedSimple = 0
|
||||
|
||||
var privateSetter = 0
|
||||
private set
|
||||
|
||||
@A val annotated = 0
|
||||
|
||||
val annotatedGetter = 0
|
||||
@A get
|
||||
|
||||
var annotatedSetter = 0
|
||||
@A set
|
||||
|
||||
var annotatedAccessors = 0
|
||||
@A set
|
||||
@A get
|
||||
}
|
||||
-68
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
class A {
|
||||
fun aFun() {}
|
||||
val aVal = 0
|
||||
var aVar = ""
|
||||
|
||||
inner class B {
|
||||
fun bFun() {}
|
||||
val bVal = 0
|
||||
var bVar = ""
|
||||
|
||||
inner class C {
|
||||
fun cFun() {}
|
||||
val cVal = 0
|
||||
var cVar = ""
|
||||
}
|
||||
|
||||
private inner class D {
|
||||
fun dFun() {}
|
||||
val dVal = 0
|
||||
var dVar = ""
|
||||
}
|
||||
}
|
||||
|
||||
class E {
|
||||
fun eFun() {}
|
||||
val eVal = 0
|
||||
var eVar = ""
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
data class F(val fVal: Int, var fVar: String) {
|
||||
fun fFun() {}
|
||||
}
|
||||
|
||||
interface Interface {
|
||||
fun iFun()
|
||||
val iVal: Int
|
||||
var iVar: String
|
||||
}
|
||||
|
||||
open class OpenImpl: Interface {
|
||||
override fun iFun() {}
|
||||
override val iVal = 0
|
||||
override var iVar = ""
|
||||
}
|
||||
|
||||
class FinalImpl: OpenImpl() {
|
||||
override fun iFun() {}
|
||||
override val iVal = 0
|
||||
override var iVar = ""
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("UNUSED_PARAMETER")
|
||||
|
||||
annotation class A
|
||||
|
||||
class Foo(x: Int) {
|
||||
constructor(): this(0)
|
||||
constructor(x: Double): this(x.toInt())
|
||||
constructor(x: Double, y: Int): this(y)
|
||||
|
||||
private constructor(x: Long): this(0)
|
||||
protected constructor(x: String): this(0)
|
||||
@A constructor(x: Foo) : this(0)
|
||||
}
|
||||
|
||||
class Bar @A constructor(x: Int)
|
||||
class Baz private constructor(x: Int)
|
||||
class Qux protected constructor(x: Int)
|
||||
|
||||
class Typed<T>(x: Int) {
|
||||
constructor(): this(0)
|
||||
constructor(x: Double): this(x.toInt())
|
||||
constructor(x: Double, y: Int): this(y)
|
||||
|
||||
private constructor(x: Long): this(0)
|
||||
protected constructor(x: String): this(0)
|
||||
@A constructor(x: Foo) : this(0)
|
||||
}
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
enum class E(val x: Int = 0) {
|
||||
A,
|
||||
B,
|
||||
C(1) {
|
||||
override fun enumFun() = 42
|
||||
};
|
||||
|
||||
open fun enumFun(): Int = 0
|
||||
val enumVal = 0
|
||||
var enumVar = ""
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
class Foo {
|
||||
fun f1() {}
|
||||
infix fun f2(x: Int) {}
|
||||
suspend fun f3() {}
|
||||
operator fun plus(x: Int) {}
|
||||
tailrec fun f4() {}
|
||||
fun f5(vararg x: Int) {}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
interface Interface {
|
||||
fun interfaceFun()
|
||||
}
|
||||
|
||||
abstract class AbstractClass: Interface {
|
||||
override fun interfaceFun() {}
|
||||
abstract fun abstractFun()
|
||||
}
|
||||
|
||||
open class OpenClass: AbstractClass() {
|
||||
override fun abstractFun() {}
|
||||
open fun openFun1() {}
|
||||
open fun openFun2() {}
|
||||
fun finalFun() {}
|
||||
}
|
||||
|
||||
class FinalClass: OpenClass() {
|
||||
override fun openFun1() {}
|
||||
final override fun openFun2() {}
|
||||
}
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
object A {
|
||||
fun a() {}
|
||||
}
|
||||
|
||||
class B {
|
||||
companion object {
|
||||
fun b() {}
|
||||
}
|
||||
|
||||
object C {
|
||||
fun c() {}
|
||||
}
|
||||
}
|
||||
|
||||
class D {
|
||||
companion object E {
|
||||
fun e() {}
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("UNUSED_PARAMETER")
|
||||
|
||||
annotation class A
|
||||
annotation class B
|
||||
|
||||
class Foo
|
||||
|
||||
fun f1(x: Foo): Unit {}
|
||||
fun f2(x: Foo, y: Foo) = 0
|
||||
|
||||
// inline
|
||||
inline fun i1(block: () -> Foo) {}
|
||||
inline fun i2(noinline block: () -> Foo) {}
|
||||
inline fun i3(crossinline block: () -> Foo) {}
|
||||
|
||||
// callable args
|
||||
fun i4(block: (Foo) -> Int) {}
|
||||
fun i5(block: (Foo, Foo) -> Int) {}
|
||||
fun i6(block: Foo.() -> Int) {}
|
||||
fun i7(block: Foo.(Foo) -> Int) {}
|
||||
|
||||
// type parameters
|
||||
fun <T> t1(x: Foo) {}
|
||||
fun <T> t2(x: T) {}
|
||||
fun <T, F> t3(x: T, y: F) {}
|
||||
inline fun <reified T> t4(x: T) {}
|
||||
fun <T: Number> t5(x: T) {}
|
||||
|
||||
// extension
|
||||
fun Foo.e() {}
|
||||
|
||||
// annotations
|
||||
@A @B fun a() {}
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("UNUSED_PARAMETER")
|
||||
|
||||
package custom.pkg
|
||||
|
||||
typealias MyTransformer = (String) -> Int
|
||||
|
||||
// top-level properties
|
||||
val v1 = 1
|
||||
val v2 = "hello"
|
||||
val v3: (String) -> Int = { it.length }
|
||||
val v4: MyTransformer = v3
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("UNUSED_PARAMETER")
|
||||
|
||||
typealias MyTransformer = (String) -> Int
|
||||
|
||||
// top-level properties
|
||||
val v1 = 1
|
||||
val v2 = "hello"
|
||||
val v3: (String) -> Int = { it.length }
|
||||
val v4: MyTransformer = v3
|
||||
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("UNUSED_PARAMETER")
|
||||
|
||||
package custom.pkg
|
||||
|
||||
class Foo
|
||||
|
||||
typealias MyTransformer = (String) -> Int
|
||||
|
||||
// top-level properties
|
||||
val v1 = 1
|
||||
val v2 = "hello"
|
||||
val v3: (String) -> Int = { it.length }
|
||||
val v4: MyTransformer = v3
|
||||
|
||||
object Bar
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("UNUSED_PARAMETER")
|
||||
|
||||
class Foo
|
||||
|
||||
typealias MyTransformer = (String) -> Int
|
||||
|
||||
// top-level properties
|
||||
val v1 = 1
|
||||
val v2 = "hello"
|
||||
val v3: (String) -> Int = { it.length }
|
||||
val v4: MyTransformer = v3
|
||||
|
||||
object Bar
|
||||
Reference in New Issue
Block a user