fix tests in org.jetbrains.kotlin.js.test.semantics
This commit is contained in:
+16
-16
@@ -5,9 +5,9 @@ public fun public_baz(i: Int) {
|
||||
native public fun public_baz(a: String) {
|
||||
}
|
||||
|
||||
fun internal_baz(i: Int) {
|
||||
internal fun internal_baz(i: Int) {
|
||||
}
|
||||
native fun internal_baz(a: String) {
|
||||
internal native fun internal_baz(a: String) {
|
||||
}
|
||||
|
||||
private fun private_baz(i: Int) {
|
||||
@@ -21,9 +21,9 @@ public class PublicClass {
|
||||
native public fun public_baz(a: String) {
|
||||
}
|
||||
|
||||
fun internal_baz(i: Int) {
|
||||
internal fun internal_baz(i: Int) {
|
||||
}
|
||||
native fun internal_baz(a: String) {
|
||||
native internal fun internal_baz(a: String) {
|
||||
}
|
||||
|
||||
private fun private_baz(i: Int) {
|
||||
@@ -35,15 +35,15 @@ public class PublicClass {
|
||||
val call_private_native_baz = { private_baz("native") }
|
||||
}
|
||||
|
||||
class InternalClass {
|
||||
internal class InternalClass {
|
||||
public fun public_baz(i: Int) {
|
||||
}
|
||||
native public fun public_baz(a: String) {
|
||||
}
|
||||
|
||||
fun internal_baz(i: Int) {
|
||||
internal fun internal_baz(i: Int) {
|
||||
}
|
||||
native fun internal_baz(a: String) {
|
||||
native internal fun internal_baz(a: String) {
|
||||
}
|
||||
|
||||
private fun private_baz(i: Int) {
|
||||
@@ -61,9 +61,9 @@ private class PrivateClass {
|
||||
native public fun public_baz(a: String) {
|
||||
}
|
||||
|
||||
fun internal_baz(i: Int) {
|
||||
internal fun internal_baz(i: Int) {
|
||||
}
|
||||
native fun internal_baz(a: String) {
|
||||
native internal fun internal_baz(a: String) {
|
||||
}
|
||||
|
||||
private fun private_baz(i: Int) {
|
||||
@@ -81,9 +81,9 @@ open public class OpenPublicClass {
|
||||
native public fun public_baz(a: String) {
|
||||
}
|
||||
|
||||
fun internal_baz(i: Int) {
|
||||
internal fun internal_baz(i: Int) {
|
||||
}
|
||||
native fun internal_baz(a: String) {
|
||||
native internal fun internal_baz(a: String) {
|
||||
}
|
||||
|
||||
private fun private_baz(i: Int) {
|
||||
@@ -95,15 +95,15 @@ open public class OpenPublicClass {
|
||||
val call_private_native_baz = { private_baz("native") }
|
||||
}
|
||||
|
||||
open class OpenInternalClass {
|
||||
internal open class OpenInternalClass {
|
||||
public fun public_baz(i: Int) {
|
||||
}
|
||||
native public fun public_baz(a: String) {
|
||||
}
|
||||
|
||||
fun internal_baz(i: Int) {
|
||||
internal fun internal_baz(i: Int) {
|
||||
}
|
||||
native fun internal_baz(a: String) {
|
||||
native internal fun internal_baz(a: String) {
|
||||
}
|
||||
|
||||
private fun private_baz(i: Int) {
|
||||
@@ -121,9 +121,9 @@ open private class OpenPrivateClass {
|
||||
native public fun public_baz(a: String) {
|
||||
}
|
||||
|
||||
fun internal_baz(i: Int) {
|
||||
internal fun internal_baz(i: Int) {
|
||||
}
|
||||
native fun internal_baz(a: String) {
|
||||
native internal fun internal_baz(a: String) {
|
||||
}
|
||||
|
||||
private fun private_baz(i: Int) {
|
||||
|
||||
+6
-6
@@ -2,29 +2,29 @@ package foo
|
||||
|
||||
public class A
|
||||
|
||||
fun A(a: Int){}
|
||||
internal fun A(a: Int){}
|
||||
|
||||
public class B(a: Int)
|
||||
|
||||
fun B(){}
|
||||
internal fun B(){}
|
||||
|
||||
fun C(a: Int){}
|
||||
internal fun C(a: Int){}
|
||||
|
||||
public class C
|
||||
|
||||
fun D(){}
|
||||
internal fun D(){}
|
||||
|
||||
public class D(a: Int)
|
||||
|
||||
//Testing
|
||||
|
||||
fun testClass(name: String, f: () -> Unit) {
|
||||
internal fun testClass(name: String, f: () -> Unit) {
|
||||
val fs = f.toString()
|
||||
|
||||
if ("$name(" !in fs) throw Exception("Name of class '$name' unexpectedly mangled: $fs")
|
||||
}
|
||||
|
||||
fun testFun(name: String, f: () -> Unit) {
|
||||
internal fun testFun(name: String, f: () -> Unit) {
|
||||
val fs = f.toString()
|
||||
|
||||
if ("$name(" in fs) throw Exception("Name of fun '$name' unexpectedly not mangled: $fs")
|
||||
|
||||
@@ -3,16 +3,16 @@ package foo
|
||||
// CHECK_CONTAINS_NO_CALLS: multiplyInline
|
||||
// CHECK_NOT_CALLED: runNoinline
|
||||
|
||||
inline fun multiply(a: Int, b: Int) = a * b
|
||||
internal inline fun multiply(a: Int, b: Int) = a * b
|
||||
|
||||
inline fun run(a: Int, b: Int, func: (Int, Int) -> Int) = func(a, b)
|
||||
internal inline fun run(a: Int, b: Int, func: (Int, Int) -> Int) = func(a, b)
|
||||
|
||||
fun multiplyInline(a: Int, b: Int) = run(a, b, ::multiply)
|
||||
internal fun multiplyInline(a: Int, b: Int) = run(a, b, ::multiply)
|
||||
|
||||
|
||||
inline fun runNoinline(a: Int, b: Int, noinline func: (Int, Int) -> Int) = func(a, b)
|
||||
internal inline fun runNoinline(a: Int, b: Int, noinline func: (Int, Int) -> Int) = func(a, b)
|
||||
|
||||
fun multiplyNoinline(a: Int, b: Int) = runNoinline(a, b, ::multiply)
|
||||
internal fun multiplyNoinline(a: Int, b: Int) = runNoinline(a, b, ::multiply)
|
||||
|
||||
|
||||
fun box(): String {
|
||||
|
||||
@@ -5,9 +5,9 @@ package foo
|
||||
// A copy of stdlib run function.
|
||||
// Copied to not to depend on run implementation.
|
||||
// It's important, that the body is just `return fn()`.
|
||||
inline fun evaluate<T>(fn: ()->T): T = fn()
|
||||
internal inline fun evaluate<T>(fn: ()->T): T = fn()
|
||||
|
||||
fun test(n: Int): Int {
|
||||
internal fun test(n: Int): Int {
|
||||
return evaluate {
|
||||
var i = n
|
||||
var sum = 0
|
||||
|
||||
@@ -2,11 +2,11 @@ package foo
|
||||
|
||||
// CHECK_NOT_CALLED_IN_SCOPE: scope=multiply function=multiply$f
|
||||
|
||||
class A(val a: Int)
|
||||
internal class A(val a: Int)
|
||||
|
||||
inline fun <T, R> with2(receiver: T, arg1: R, arg2: R, f: T.(R, R) -> R): R = receiver.f(arg1, arg2)
|
||||
internal inline fun <T, R> with2(receiver: T, arg1: R, arg2: R, f: T.(R, R) -> R): R = receiver.f(arg1, arg2)
|
||||
|
||||
fun multiply(a: Int, b: Int, c: Int): Int = with2(A(a), b, c) { x, y -> a*x*y }
|
||||
internal fun multiply(a: Int, b: Int, c: Int): Int = with2(A(a), b, c) { x, y -> a*x*y }
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(105, multiply(3, 5, 7))
|
||||
|
||||
+4
-4
@@ -2,19 +2,19 @@ package foo
|
||||
|
||||
// CHECK_CONTAINS_NO_CALLS: squareMultipliedByTwo
|
||||
|
||||
inline fun inline1(a: Int): Int {
|
||||
internal inline fun inline1(a: Int): Int {
|
||||
return a
|
||||
}
|
||||
|
||||
inline fun inline2(a: Int): Int {
|
||||
internal inline fun inline2(a: Int): Int {
|
||||
return inline1(a) + inline1(a)
|
||||
}
|
||||
|
||||
inline fun inline3(a: Int): Int {
|
||||
internal inline fun inline3(a: Int): Int {
|
||||
return inline1(a) * inline2(a)
|
||||
}
|
||||
|
||||
fun squareMultipliedByTwo(a: Int): Int {
|
||||
internal fun squareMultipliedByTwo(a: Int): Int {
|
||||
return inline3(a)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,24 +2,24 @@ package foo
|
||||
|
||||
// CHECK_CONTAINS_NO_CALLS: squareMultipliedByTwo
|
||||
|
||||
inline fun inline1(a: Int): Int {
|
||||
internal inline fun inline1(a: Int): Int {
|
||||
return a
|
||||
}
|
||||
|
||||
inline fun inline2(a: Int): Int {
|
||||
internal inline fun inline2(a: Int): Int {
|
||||
val a1 = inline1(a)
|
||||
if (a1 == 0) return 0
|
||||
return a1 + inline1(a)
|
||||
}
|
||||
|
||||
inline fun inline3(a: Int): Int {
|
||||
internal inline fun inline3(a: Int): Int {
|
||||
val i = inline2(a)
|
||||
val i1 = inline1(a) * i
|
||||
if (i == i1) return 0
|
||||
return i1
|
||||
}
|
||||
|
||||
fun squareMultipliedByTwo(a: Int): Int {
|
||||
internal fun squareMultipliedByTwo(a: Int): Int {
|
||||
return inline3(a)
|
||||
}
|
||||
|
||||
|
||||
@@ -3,15 +3,15 @@ package foo
|
||||
// CHECK_CONTAINS_NO_CALLS: identity
|
||||
// CHECK_CONTAINS_NO_CALLS: sumNoInline
|
||||
|
||||
inline fun sum(a: Int, b: Int = 0): Int {
|
||||
internal inline fun sum(a: Int, b: Int = 0): Int {
|
||||
return a + b
|
||||
}
|
||||
|
||||
fun identity(a: Int): Int {
|
||||
internal fun identity(a: Int): Int {
|
||||
return sum(a)
|
||||
}
|
||||
|
||||
fun sumNoInline(a: Int, b: Int): Int {
|
||||
internal fun sumNoInline(a: Int, b: Int): Int {
|
||||
return sum(a, b)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,15 +2,15 @@ package foo
|
||||
|
||||
// CHECK_CONTAINS_NO_CALLS: doNothingNoInline
|
||||
|
||||
inline fun <T> doNothing1(a: T): T {
|
||||
internal inline fun <T> doNothing1(a: T): T {
|
||||
return a
|
||||
}
|
||||
|
||||
inline fun <T> doNothing2(a: T, f: (T) -> T): T {
|
||||
internal inline fun <T> doNothing2(a: T, f: (T) -> T): T {
|
||||
return f(a)
|
||||
}
|
||||
|
||||
fun doNothingNoInline(a: Int): Int {
|
||||
internal fun doNothingNoInline(a: Int): Int {
|
||||
return doNothing2(a, { x -> doNothing1(x)})
|
||||
}
|
||||
|
||||
|
||||
@@ -3,15 +3,15 @@ package foo
|
||||
// CHECK_CONTAINS_NO_CALLS: doNothingInt
|
||||
// CHECK_CONTAINS_NO_CALLS: doNothingStr
|
||||
|
||||
inline fun <T> doNothing(a: T): T {
|
||||
internal inline fun <T> doNothing(a: T): T {
|
||||
return a
|
||||
}
|
||||
|
||||
fun doNothingInt(a: Int): Int {
|
||||
internal fun doNothingInt(a: Int): Int {
|
||||
return doNothing(a)
|
||||
}
|
||||
|
||||
fun doNothingStr(a: String): String {
|
||||
internal fun doNothingStr(a: String): String {
|
||||
return doNothing(a)
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -2,11 +2,11 @@ package foo
|
||||
|
||||
// CHECK_CONTAINS_NO_CALLS: multiplyNoInline
|
||||
|
||||
inline fun multiply(a: Int, b: Int): Int {
|
||||
internal inline fun multiply(a: Int, b: Int): Int {
|
||||
return a * b
|
||||
}
|
||||
|
||||
fun multiplyNoInline(a: Int, b: Int): Int {
|
||||
internal fun multiplyNoInline(a: Int, b: Int): Int {
|
||||
var c = a - 1
|
||||
var d = b - 1
|
||||
return (c++) + (d++) + multiply(c, d) - (--c + --d)
|
||||
|
||||
@@ -4,7 +4,7 @@ package foo
|
||||
// CHECK_CONTAINS_NO_CALLS: doNothing2
|
||||
// CHECK_CONTAINS_NO_CALLS: doNothing3
|
||||
|
||||
class Inline {
|
||||
internal class Inline {
|
||||
public inline fun <T> identity1 (x: T): T {
|
||||
return x
|
||||
}
|
||||
@@ -18,15 +18,15 @@ class Inline {
|
||||
}
|
||||
}
|
||||
|
||||
fun doNothing1 (inline1: Inline, a: Int): Int {
|
||||
internal fun doNothing1 (inline1: Inline, a: Int): Int {
|
||||
return inline1.identity1(a)
|
||||
}
|
||||
|
||||
fun doNothing2 (inline2: Inline, a: Int): Int {
|
||||
internal fun doNothing2 (inline2: Inline, a: Int): Int {
|
||||
return inline2.identity2(a, {it})
|
||||
}
|
||||
|
||||
fun doNothing3 (inline3: Inline): Int {
|
||||
internal fun doNothing3 (inline3: Inline): Int {
|
||||
return inline3.identity3({11})
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package foo
|
||||
|
||||
// CHECK_CONTAINS_NO_CALLS: sumEven
|
||||
|
||||
inline fun filteredReduce(a: Array<Int>, predicate: (Int) -> Boolean, reduceFun: (Int, Int) -> Int): Int {
|
||||
internal inline fun filteredReduce(a: Array<Int>, predicate: (Int) -> Boolean, reduceFun: (Int, Int) -> Int): Int {
|
||||
var result = 0
|
||||
|
||||
for (element in a) {
|
||||
@@ -15,7 +15,7 @@ inline fun filteredReduce(a: Array<Int>, predicate: (Int) -> Boolean, reduceFun:
|
||||
return result
|
||||
}
|
||||
|
||||
fun sumEven(a: Array<Int>): Int {
|
||||
internal fun sumEven(a: Array<Int>): Int {
|
||||
return filteredReduce(a, { x -> x % 2 == 0}, { x, y -> x + y})
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ package foo
|
||||
|
||||
// CHECK_CONTAINS_NO_CALLS: maxBySquare
|
||||
|
||||
data class Result(var value: Int = 0, var invocationCount: Int = 0)
|
||||
internal data class Result(var value: Int = 0, var invocationCount: Int = 0)
|
||||
|
||||
inline fun maxBy(a: Array<Int>, keyFun: (Int) -> Int): Int {
|
||||
internal inline fun maxBy(a: Array<Int>, keyFun: (Int) -> Int): Int {
|
||||
var maxVal = a[0]
|
||||
var maxKey = keyFun(maxVal)
|
||||
|
||||
@@ -20,7 +20,7 @@ inline fun maxBy(a: Array<Int>, keyFun: (Int) -> Int): Int {
|
||||
return maxVal
|
||||
}
|
||||
|
||||
fun maxBySquare(a: Array<Int>, r: Result): Result {
|
||||
internal fun maxBySquare(a: Array<Int>, r: Result): Result {
|
||||
var invocationCount = 0
|
||||
val maxVal = maxBy(a, { x -> invocationCount++; x * x;})
|
||||
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ package foo
|
||||
|
||||
// CHECK_CONTAINS_NO_CALLS: add
|
||||
|
||||
data class IntPair(public var fst: Int, public var snd: Int) {
|
||||
internal data class IntPair(public var fst: Int, public var snd: Int) {
|
||||
inline public fun getFst(): Int { return fst }
|
||||
inline public fun setFst(v: Int) { fst = v }
|
||||
|
||||
@@ -10,7 +10,7 @@ data class IntPair(public var fst: Int, public var snd: Int) {
|
||||
inline public fun setSnd(v: Int) { this.snd = v }
|
||||
}
|
||||
|
||||
fun add(p: IntPair, toFst: Int, toSnd: Int) {
|
||||
internal fun add(p: IntPair, toFst: Int, toSnd: Int) {
|
||||
val fst = p.getFst()
|
||||
p.setFst(fst + toFst)
|
||||
|
||||
|
||||
@@ -2,22 +2,22 @@ package foo
|
||||
|
||||
// CHECK_CONTAINS_NO_CALLS: factAbsNoInline1
|
||||
|
||||
class State(value: Int) {
|
||||
internal class State(value: Int) {
|
||||
public var value: Int = value
|
||||
}
|
||||
|
||||
inline fun multiply(state: State, factor: Int) {
|
||||
internal inline fun multiply(state: State, factor: Int) {
|
||||
state.value *= factor
|
||||
}
|
||||
|
||||
inline fun abs(state: State) {
|
||||
internal inline fun abs(state: State) {
|
||||
val value = state.value
|
||||
if (value < 0) {
|
||||
multiply(state, -1)
|
||||
}
|
||||
}
|
||||
|
||||
inline fun factAbs(state: State) {
|
||||
internal inline fun factAbs(state: State) {
|
||||
abs(state)
|
||||
|
||||
if (state.value == 0) {
|
||||
@@ -32,12 +32,12 @@ inline fun factAbs(state: State) {
|
||||
}
|
||||
}
|
||||
|
||||
fun factAbsNoInline1(state: State): Int {
|
||||
internal fun factAbsNoInline1(state: State): Int {
|
||||
factAbs(state)
|
||||
return state.value
|
||||
}
|
||||
|
||||
fun factAbsNoInline2(n: Int): Int {
|
||||
internal fun factAbsNoInline2(n: Int): Int {
|
||||
return factAbsNoInline1(State(n))
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -2,9 +2,9 @@ package foo
|
||||
|
||||
// CHECK_CONTAINS_NO_CALLS: test
|
||||
|
||||
inline fun sum(x: Int, y: Int): Int = js("x + y")
|
||||
internal inline fun sum(x: Int, y: Int): Int = js("x + y")
|
||||
|
||||
fun test(x: Int, y: Int): Int = sum(sum(x, x), sum(y, y))
|
||||
internal fun test(x: Int, y: Int): Int = sum(sum(x, x), sum(y, y))
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(4, test(1, 1))
|
||||
|
||||
@@ -2,9 +2,9 @@ package foo
|
||||
|
||||
// CHECK_CONTAINS_NO_CALLS: test
|
||||
|
||||
inline fun sum(x: Int, y: Int): Int = js("var a = x; a + y")
|
||||
internal inline fun sum(x: Int, y: Int): Int = js("var a = x; a + y")
|
||||
|
||||
fun test(x: Int, y: Int): Int {
|
||||
internal fun test(x: Int, y: Int): Int {
|
||||
val xx = sum(x, x)
|
||||
js("var a = 0;")
|
||||
val yy = sum(y, y)
|
||||
|
||||
@@ -4,11 +4,11 @@ package foo
|
||||
// CHECK_NOT_CALLED_IN_SCOPE: scope=multiplyBy2 function=multiplyBy2$f_0
|
||||
// CHECK_NOT_CALLED_IN_SCOPE: scope=multiplyBy2 function=run
|
||||
|
||||
inline fun runLambdaInLambda<T>(noinline inner: (T) -> T, outer: ((T) -> T, T) -> T, arg: T): T {
|
||||
internal inline fun runLambdaInLambda<T>(noinline inner: (T) -> T, outer: ((T) -> T, T) -> T, arg: T): T {
|
||||
return outer(inner, arg)
|
||||
}
|
||||
|
||||
fun multiplyBy2(x: Int): Int {
|
||||
internal fun multiplyBy2(x: Int): Int {
|
||||
return runLambdaInLambda({ it * 2 }, { f, x -> f(x) }, x)
|
||||
}
|
||||
|
||||
|
||||
@@ -3,15 +3,15 @@ package foo
|
||||
// CHECK_CONTAINS_NO_CALLS: capturedInLambda
|
||||
// CHECK_CONTAINS_NO_CALLS: declaredInLambda
|
||||
|
||||
data class State(var count: Int = 0)
|
||||
internal data class State(var count: Int = 0)
|
||||
|
||||
inline fun repeatAction(times: Int, action: () -> Unit) {
|
||||
internal inline fun repeatAction(times: Int, action: () -> Unit) {
|
||||
for (i in 1..times) {
|
||||
action()
|
||||
}
|
||||
}
|
||||
|
||||
fun capturedInLambda(state: State, a: Int, b: Int): Int {
|
||||
internal fun capturedInLambda(state: State, a: Int, b: Int): Int {
|
||||
@inline fun State.inc() {
|
||||
count++
|
||||
}
|
||||
@@ -24,7 +24,7 @@ fun capturedInLambda(state: State, a: Int, b: Int): Int {
|
||||
}
|
||||
|
||||
|
||||
fun declaredInLambda(state: State, a: Int, b: Int): Int {
|
||||
internal fun declaredInLambda(state: State, a: Int, b: Int): Int {
|
||||
repeatAction(a) {
|
||||
@inline fun State.inc() {
|
||||
count++
|
||||
|
||||
@@ -3,13 +3,13 @@ package foo
|
||||
// CHECK_CONTAINS_NO_CALLS: localWithCapture
|
||||
// CHECK_CONTAINS_NO_CALLS: localWithoutCapture
|
||||
|
||||
inline fun repeatAction(times: Int, action: () -> Unit) {
|
||||
internal inline fun repeatAction(times: Int, action: () -> Unit) {
|
||||
for (i in 1..times) {
|
||||
action()
|
||||
}
|
||||
}
|
||||
|
||||
fun localWithoutCapture(a: Int, b: Int): Int {
|
||||
internal fun localWithoutCapture(a: Int, b: Int): Int {
|
||||
var sum = 0
|
||||
|
||||
@inline fun inc(x: Int): Int {
|
||||
@@ -23,7 +23,7 @@ fun localWithoutCapture(a: Int, b: Int): Int {
|
||||
return sum
|
||||
}
|
||||
|
||||
fun localWithCapture(a: Int, b: Int): Int {
|
||||
internal fun localWithCapture(a: Int, b: Int): Int {
|
||||
var sum = 0
|
||||
|
||||
@inline fun inc() {
|
||||
|
||||
@@ -2,15 +2,15 @@ package foo
|
||||
|
||||
// CHECK_CONTAINS_NO_CALLS: add
|
||||
|
||||
data class State(var count: Int = 0)
|
||||
internal data class State(var count: Int = 0)
|
||||
|
||||
inline fun repeatAction(times: Int, action: () -> Unit) {
|
||||
internal inline fun repeatAction(times: Int, action: () -> Unit) {
|
||||
for (i in 1..times) {
|
||||
action()
|
||||
}
|
||||
}
|
||||
|
||||
fun add(state: State, a: Int, b: Int): Int {
|
||||
internal fun add(state: State, a: Int, b: Int): Int {
|
||||
@inline fun inc(a: Int): Int {
|
||||
return a + 1
|
||||
}
|
||||
|
||||
+3
-3
@@ -3,13 +3,13 @@ package foo
|
||||
// CHECK_CONTAINS_NO_CALLS: localWithCapture
|
||||
// CHECK_CONTAINS_NO_CALLS: localWithoutCapture
|
||||
|
||||
inline fun repeatAction(times: Int, action: () -> Unit) {
|
||||
internal inline fun repeatAction(times: Int, action: () -> Unit) {
|
||||
for (i in 1..times) {
|
||||
action()
|
||||
}
|
||||
}
|
||||
|
||||
fun localWithoutCapture(a: Int, b: Int): Int {
|
||||
internal fun localWithoutCapture(a: Int, b: Int): Int {
|
||||
var mult = 0
|
||||
|
||||
repeatAction(a) {
|
||||
@@ -25,7 +25,7 @@ fun localWithoutCapture(a: Int, b: Int): Int {
|
||||
return mult
|
||||
}
|
||||
|
||||
fun localWithCapture(a: Int, b: Int): Int {
|
||||
internal fun localWithCapture(a: Int, b: Int): Int {
|
||||
var mult = 0
|
||||
|
||||
repeatAction(a) {
|
||||
|
||||
@@ -2,11 +2,11 @@ package foo
|
||||
|
||||
// CHECK_CONTAINS_NO_CALLS: add
|
||||
|
||||
inline fun run(action: () -> Int): Int {
|
||||
internal inline fun run(action: () -> Int): Int {
|
||||
return action()
|
||||
}
|
||||
|
||||
fun add(a: Int, b: Int): Int {
|
||||
internal fun add(a: Int, b: Int): Int {
|
||||
var sum = a + b
|
||||
|
||||
@inline fun getSum(): Int {
|
||||
|
||||
@@ -36,17 +36,17 @@ private object O {
|
||||
}
|
||||
}
|
||||
|
||||
fun test1(x: Int, y: Int): Int = apply(x) { it * y }
|
||||
internal fun test1(x: Int, y: Int): Int = apply(x) { it * y }
|
||||
|
||||
fun test2(m: M, x: Int, y: Int): Int = m.applyM(x) { it * y }
|
||||
internal fun test2(m: M, x: Int, y: Int): Int = m.applyM(x) { it * y }
|
||||
|
||||
fun test3(n: N, x: Int, y: Int): Int = n.applyN(x) { it * y }
|
||||
internal fun test3(n: N, x: Int, y: Int): Int = n.applyN(x) { it * y }
|
||||
|
||||
object LTest : L() {
|
||||
internal object LTest : L() {
|
||||
fun test4(l: L, x: Int, y: Int): Int = l.applyL(x) { it * y }
|
||||
}
|
||||
|
||||
fun test5(x: Int, y: Int): Int = O.OInner.applyO(x) { it * y }
|
||||
internal fun test5(x: Int, y: Int): Int = O.OInner.applyO(x) { it * y }
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(6, test1(2, 3))
|
||||
|
||||
@@ -3,11 +3,11 @@ package foo
|
||||
// CHECK_CALLED_IN_SCOPE: scope=multiplyBy2 function=multiplyBy2$f
|
||||
// CHECK_NOT_CALLED_IN_SCOPE: scope=multiplyBy2 function=run
|
||||
|
||||
inline fun run<T>(noinline func: (T) -> T, arg: T): T {
|
||||
internal inline fun run<T>(noinline func: (T) -> T, arg: T): T {
|
||||
return func(arg)
|
||||
}
|
||||
|
||||
fun multiplyBy2(x: Int): Int {
|
||||
internal fun multiplyBy2(x: Int): Int {
|
||||
return run({ it * 2 }, x)
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -5,7 +5,7 @@ package foo
|
||||
// CHECK_CONTAINS_NO_CALLS: test2
|
||||
// CHECK_CONTAINS_NO_CALLS: test3
|
||||
|
||||
inline fun concat(vararg strings: String): String {
|
||||
internal inline fun concat(vararg strings: String): String {
|
||||
var result = ""
|
||||
|
||||
for (string in strings) {
|
||||
@@ -15,15 +15,15 @@ inline fun concat(vararg strings: String): String {
|
||||
return result
|
||||
}
|
||||
|
||||
fun test1(): String {
|
||||
internal fun test1(): String {
|
||||
return concat()
|
||||
}
|
||||
|
||||
fun test2(): String {
|
||||
internal fun test2(): String {
|
||||
return concat("a", "b", "c")
|
||||
}
|
||||
|
||||
fun test3(list: Array<String>): String {
|
||||
internal fun test3(list: Array<String>): String {
|
||||
return concat(*list)
|
||||
}
|
||||
|
||||
|
||||
@@ -11,15 +11,15 @@ import test.*
|
||||
// CHECK_CONTAINS_NO_CALLS: testFinalInline2
|
||||
// CHECK_CONTAINS_NO_CALLS: testClassObject
|
||||
|
||||
fun testFinalInline(): String {
|
||||
internal fun testFinalInline(): String {
|
||||
return Z().finalInline({"final"})
|
||||
}
|
||||
|
||||
fun testFinalInline2(instance: InlineTrait): String {
|
||||
internal fun testFinalInline2(instance: InlineTrait): String {
|
||||
return instance.finalInline({"final2"})
|
||||
}
|
||||
|
||||
fun testClassObject(): String {
|
||||
internal fun testClassObject(): String {
|
||||
return InlineTrait.finalInline({"classobject"})
|
||||
}
|
||||
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
|
||||
package test
|
||||
|
||||
trait InlineTrait {
|
||||
internal trait InlineTrait {
|
||||
|
||||
inline final fun finalInline(s: () -> String): String {
|
||||
internal inline final fun finalInline(s: () -> String): String {
|
||||
return s()
|
||||
}
|
||||
|
||||
companion object {
|
||||
inline final fun finalInline(s: () -> String): String {
|
||||
internal inline final fun finalInline(s: () -> String): String {
|
||||
return s()
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import utils.*
|
||||
|
||||
// CHECK_CONTAINS_NO_CALLS: test
|
||||
|
||||
fun test(s: String): String = log(s + ";")
|
||||
internal fun test(s: String): String = log(s + ";")
|
||||
|
||||
fun box(): String {
|
||||
assertEquals("a;", test("a"))
|
||||
|
||||
+2
-2
@@ -2,9 +2,9 @@ import utils.*
|
||||
|
||||
// CHECK_CONTAINS_NO_CALLS: test
|
||||
|
||||
fun multiplyBy2(x: Int): Int = x * 2
|
||||
internal fun multiplyBy2(x: Int): Int = x * 2
|
||||
|
||||
fun test(x: Int): Int = apply(x, ::multiplyBy2)
|
||||
internal fun test(x: Int): Int = apply(x, ::multiplyBy2)
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(6, test(3))
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// CHECK_CONTAINS_NO_CALLS: test
|
||||
|
||||
fun test(x: Int, y: Int): Int = utils.sum(x, y)
|
||||
internal fun test(x: Int, y: Int): Int = utils.sum(x, y)
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(3, test(1, 2))
|
||||
|
||||
+2
-2
@@ -2,9 +2,9 @@ import utils.*
|
||||
|
||||
// CHECK_CONTAINS_NO_CALLS: test
|
||||
|
||||
class A(val n: Int)
|
||||
internal class A(val n: Int)
|
||||
|
||||
fun test(a: A, m: Int): Int = apply(a) { n * m }
|
||||
internal fun test(a: A, m: Int): Int = apply(a) { n * m }
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(6, test(A(2), 3))
|
||||
|
||||
@@ -2,7 +2,7 @@ import utils.*
|
||||
|
||||
// CHECK_CONTAINS_NO_CALLS: test
|
||||
|
||||
fun test(x: Int): Int = apply(x) { it * 2 }
|
||||
internal fun test(x: Int): Int = apply(x) { it * 2 }
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(6, test(3))
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import utils.*
|
||||
|
||||
fun test(x: Int): Int = apply(x) { it * 2 }
|
||||
internal fun test(x: Int): Int = apply(x) { it * 2 }
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(6, test(3))
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import utils.*
|
||||
|
||||
// CHECK_CONTAINS_NO_CALLS: test
|
||||
|
||||
fun test(x: Int, y: Int): Int = apply(x) { it + y }
|
||||
internal fun test(x: Int, y: Int): Int = apply(x) { it + y }
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(3, test(1, 2))
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import utils.*
|
||||
|
||||
// CHECK_CONTAINS_NO_CALLS: test
|
||||
|
||||
fun test(x: Int, y: Int): Int = apply(x) { it + 1 } * y
|
||||
internal fun test(x: Int, y: Int): Int = apply(x) { it + 1 } * y
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(6, test(1, 3))
|
||||
|
||||
@@ -2,7 +2,7 @@ import utils.*
|
||||
|
||||
// CHECK_CONTAINS_NO_CALLS: test
|
||||
|
||||
fun test(a: A, y: Int): Int = a.plus(y)
|
||||
internal fun test(a: A, y: Int): Int = a.plus(y)
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(5, test(A(2), 3))
|
||||
|
||||
@@ -2,7 +2,7 @@ import utils.*
|
||||
|
||||
// CHECK_CONTAINS_NO_CALLS: test
|
||||
|
||||
fun test(x: Int, y: Int): Int = sum(x, y)
|
||||
internal fun test(x: Int, y: Int): Int = sum(x, y)
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(3, test(1, 2))
|
||||
|
||||
@@ -4,10 +4,10 @@ package foo
|
||||
// CHECK_NOT_CALLED: f2
|
||||
// CHECK_BREAKS_COUNT: function=test count=3
|
||||
|
||||
var even = arrayListOf<Int>()
|
||||
var odd = arrayListOf<Int>()
|
||||
internal var even = arrayListOf<Int>()
|
||||
internal var odd = arrayListOf<Int>()
|
||||
|
||||
inline fun f2(x: Int): Unit {
|
||||
internal inline fun f2(x: Int): Unit {
|
||||
if (x % 2 == 0) {
|
||||
even.add(x)
|
||||
return
|
||||
@@ -17,7 +17,7 @@ inline fun f2(x: Int): Unit {
|
||||
return
|
||||
}
|
||||
|
||||
inline fun f1(x: Boolean, y: Int, z: Int): Unit {
|
||||
internal inline fun f1(x: Boolean, y: Int, z: Int): Unit {
|
||||
if (x) {
|
||||
return f2(y)
|
||||
}
|
||||
@@ -25,7 +25,7 @@ inline fun f1(x: Boolean, y: Int, z: Int): Unit {
|
||||
return f2(z)
|
||||
}
|
||||
|
||||
fun test(x: Boolean, y: Int, z: Int): Unit = f1(x, y, z)
|
||||
internal fun test(x: Boolean, y: Int, z: Int): Unit = f1(x, y, z)
|
||||
|
||||
fun box(): String {
|
||||
test(true, 2, 1)
|
||||
|
||||
@@ -7,24 +7,24 @@ package foo
|
||||
|
||||
var log = ""
|
||||
|
||||
inline fun run1(fn: ()->Int): Int {
|
||||
internal inline fun run1(fn: ()->Int): Int {
|
||||
log += "1;"
|
||||
return 1 + fn()
|
||||
}
|
||||
|
||||
inline fun run2(fn: ()->Int): Int {
|
||||
internal inline fun run2(fn: ()->Int): Int {
|
||||
log += "2;"
|
||||
return 2 + run1(fn)
|
||||
}
|
||||
|
||||
inline fun run3(fn: ()->Int): Int {
|
||||
internal inline fun run3(fn: ()->Int): Int {
|
||||
log += "3;"
|
||||
return 3 + run2(fn)
|
||||
}
|
||||
|
||||
fun test1(x: Int): Int = run3 { x }
|
||||
internal fun test1(x: Int): Int = run3 { x }
|
||||
|
||||
fun test2(x: Int): Int {
|
||||
internal fun test2(x: Int): Int {
|
||||
val result = 1 + run3 { x }
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package foo
|
||||
// CHECK_CONTAINS_NO_CALLS: test
|
||||
// CHECK_VARS_COUNT: function=test count=0
|
||||
|
||||
inline fun sign(x: Int): Int {
|
||||
internal inline fun sign(x: Int): Int {
|
||||
if (x < 0) return -1
|
||||
|
||||
if (x == 0) return 0
|
||||
@@ -11,7 +11,7 @@ inline fun sign(x: Int): Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
fun test(x: Int, y: Int): Int {
|
||||
internal fun test(x: Int, y: Int): Int {
|
||||
if (x != 0) {
|
||||
return sign(x)
|
||||
}
|
||||
|
||||
+2
-2
@@ -6,9 +6,9 @@ package foo
|
||||
// A copy of stdlib run function.
|
||||
// Copied to not to depend on run implementation.
|
||||
// It's important, that the body is just `return fn()`.
|
||||
inline fun evaluate<T>(fn: ()->T): T = fn()
|
||||
internal inline fun evaluate<T>(fn: ()->T): T = fn()
|
||||
|
||||
fun test(x: Int): Int =
|
||||
internal fun test(x: Int): Int =
|
||||
evaluate {
|
||||
evaluate { 2 } * evaluate { x }
|
||||
}
|
||||
|
||||
@@ -3,13 +3,13 @@ package foo
|
||||
// CHECK_CONTAINS_NO_CALLS: test
|
||||
// CHECK_VARS_COUNT: function=test count=0
|
||||
|
||||
class A(val x: Int) {
|
||||
internal class A(val x: Int) {
|
||||
inline fun f(): Int = x
|
||||
|
||||
inline fun ff(): Int = f()
|
||||
}
|
||||
|
||||
fun test(a: A): Int = a.ff()
|
||||
internal fun test(a: A): Int = a.ff()
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(1, test(A(1)))
|
||||
|
||||
@@ -3,13 +3,13 @@ package foo
|
||||
// CHECK_CONTAINS_NO_CALLS: test
|
||||
// CHECK_VARS_COUNT: function=test count=1
|
||||
|
||||
inline fun sum(x: Int, y: Int): Int {
|
||||
internal inline fun sum(x: Int, y: Int): Int {
|
||||
if (x == 0 || y == 0) return 0
|
||||
|
||||
return x + y
|
||||
}
|
||||
|
||||
fun test(x: Int, y: Int): Int {
|
||||
internal fun test(x: Int, y: Int): Int {
|
||||
val sum: Int
|
||||
sum = sum(x, y)
|
||||
return sum
|
||||
|
||||
@@ -3,13 +3,13 @@ package foo
|
||||
// CHECK_CONTAINS_NO_CALLS: test
|
||||
// CHECK_VARS_COUNT: function=test count=1
|
||||
|
||||
inline fun sum(x: Int, y: Int): Int {
|
||||
internal inline fun sum(x: Int, y: Int): Int {
|
||||
if (x == 0 || y == 0) return 0
|
||||
|
||||
return x + y
|
||||
}
|
||||
|
||||
fun test(x: Int, y: Int): Int {
|
||||
internal fun test(x: Int, y: Int): Int {
|
||||
val sum = sum(x, y)
|
||||
return sum
|
||||
}
|
||||
|
||||
+2
-2
@@ -3,9 +3,9 @@ package foo
|
||||
// CHECK_NOT_CALLED_IN_SCOPE: scope=test function=even
|
||||
// CHECK_NOT_CALLED_IN_SCOPE: scope=test function=filter_azvtw4$
|
||||
|
||||
fun even(x: Int) = x % 2 == 0
|
||||
internal fun even(x: Int) = x % 2 == 0
|
||||
|
||||
fun test(a: List<Int>) = a.filter(::even)
|
||||
internal fun test(a: List<Int>) = a.filter(::even)
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(listOf(2, 4), test(listOf(1, 2, 3, 4)))
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ package foo
|
||||
|
||||
// CHECK_CONTAINS_NO_CALLS: test
|
||||
|
||||
fun test(a: Int, b: Int): Int {
|
||||
internal fun test(a: Int, b: Int): Int {
|
||||
var c = 0
|
||||
|
||||
b.times {
|
||||
|
||||
@@ -2,7 +2,7 @@ package foo
|
||||
|
||||
// CHECK_CONTAINS_NO_CALLS: test
|
||||
|
||||
fun test(a: Int, b: Int): Int {
|
||||
internal fun test(a: Int, b: Int): Int {
|
||||
var res = 0
|
||||
|
||||
with (a + b) {
|
||||
|
||||
@@ -2,7 +2,7 @@ package foo
|
||||
|
||||
// CHECK_CONTAINS_NO_CALLS: test
|
||||
|
||||
fun test(x: Int, y: Int): Int =
|
||||
internal fun test(x: Int, y: Int): Int =
|
||||
with (x + x) {
|
||||
val xx = this
|
||||
|
||||
|
||||
+2
-2
@@ -2,9 +2,9 @@ package foo
|
||||
|
||||
// CHECK_CONTAINS_NO_CALLS: test
|
||||
|
||||
var counter = 0
|
||||
internal var counter = 0
|
||||
|
||||
fun test(a: Int) {
|
||||
internal fun test(a: Int) {
|
||||
a.times {
|
||||
counter += 1
|
||||
}
|
||||
|
||||
@@ -3,15 +3,15 @@ package foo
|
||||
// CHECK_CONTAINS_NO_CALLS: testImplicitThis
|
||||
// CHECK_CONTAINS_NO_CALLS: testExplicitThis
|
||||
|
||||
class A(var value: Int)
|
||||
internal class A(var value: Int)
|
||||
|
||||
fun testImplicitThis(a: A, newValue: Int) {
|
||||
internal fun testImplicitThis(a: A, newValue: Int) {
|
||||
with (a) {
|
||||
value = newValue
|
||||
}
|
||||
}
|
||||
|
||||
fun testExplicitThis(a: A, newValue: Int) {
|
||||
internal fun testExplicitThis(a: A, newValue: Int) {
|
||||
with (a) {
|
||||
this.value = newValue
|
||||
}
|
||||
|
||||
@@ -9,28 +9,28 @@ class State() {
|
||||
public var value: Int = 0
|
||||
}
|
||||
|
||||
inline fun test1(state: State) {
|
||||
internal inline fun test1(state: State) {
|
||||
loop@ for (i in 1..10) {
|
||||
state.value++
|
||||
if (i == 2) break@loop
|
||||
}
|
||||
}
|
||||
|
||||
inline fun test2(state: State) {
|
||||
internal inline fun test2(state: State) {
|
||||
loop@ for (i in 1..10) {
|
||||
test1(state)
|
||||
if (i == 2) break@loop
|
||||
}
|
||||
}
|
||||
|
||||
inline fun test3(state: State) {
|
||||
internal inline fun test3(state: State) {
|
||||
loop@ for (i in 1..10) {
|
||||
test2(state)
|
||||
if (i == 2) break@loop
|
||||
}
|
||||
}
|
||||
|
||||
fun test(state: State) {
|
||||
internal fun test(state: State) {
|
||||
test3(state)
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -8,7 +8,7 @@ class State() {
|
||||
public var value: Int = 0
|
||||
}
|
||||
|
||||
fun test(state: State) {
|
||||
internal fun test(state: State) {
|
||||
@inline fun test3() {
|
||||
@inline fun test2() {
|
||||
@inline fun test1() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package foo
|
||||
|
||||
native
|
||||
open class A(val a: Int) {
|
||||
internal open class A(val a: Int) {
|
||||
fun g(): Int = noImpl
|
||||
fun m(): Int = noImpl
|
||||
|
||||
@@ -11,7 +11,7 @@ open class A(val a: Int) {
|
||||
open fun baz(i: Int): String = noImpl
|
||||
}
|
||||
|
||||
class B(val b: Int) : A(b / 2) {
|
||||
internal class B(val b: Int) : A(b / 2) {
|
||||
override fun foo(i: Int): String = "B.foo($i: Int)"
|
||||
|
||||
fun boo(): String = "B.boo()"
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package foo
|
||||
|
||||
val PACKAGE = "Kotlin.modules.JS_TESTS.foo"
|
||||
internal val PACKAGE = "Kotlin.modules.JS_TESTS.foo"
|
||||
|
||||
fun funToString(name: String) = eval("$PACKAGE.$name.toString()") as String
|
||||
internal fun funToString(name: String) = eval("$PACKAGE.$name.toString()") as String
|
||||
|
||||
native("\"O\"") val foo: String = noImpl
|
||||
native("boo") val bar: String = noImpl
|
||||
internal native("\"O\"") val foo: String = noImpl
|
||||
internal native("boo") val bar: String = noImpl
|
||||
|
||||
class A
|
||||
native("__proto__") val Any.proto: String get() = noImpl
|
||||
native("__proto__") val A.proto: String get() = noImpl
|
||||
internal class A
|
||||
internal native("__proto__") val Any.proto: String get() = noImpl
|
||||
internal native("__proto__") val A.proto: String get() = noImpl
|
||||
|
||||
fun actual(foo: String, native("boo") bar: String) = foo + bar
|
||||
fun expected(foo: String, boo: String) = foo + boo
|
||||
internal fun actual(foo: String, native("boo") bar: String) = foo + bar
|
||||
internal fun expected(foo: String, boo: String) = foo + boo
|
||||
|
||||
fun box(): String {
|
||||
val OK = "OK"
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package foo
|
||||
|
||||
native
|
||||
class A(val v: String)
|
||||
internal class A(val v: String)
|
||||
|
||||
class B {
|
||||
internal class B {
|
||||
fun bar(a: A, extLambda: A.(Int, String) -> String): String = a.extLambda(7, "_rr_")
|
||||
}
|
||||
|
||||
native
|
||||
fun nativeBox(b: B): String = noImpl
|
||||
internal fun nativeBox(b: B): String = noImpl
|
||||
|
||||
fun box(): String {
|
||||
val r = nativeBox(B())
|
||||
|
||||
Reference in New Issue
Block a user