diff --git a/compiler/testData/codegen/box/diagnostics/functions/tailRecursion/realIteratorFoldl.kt b/compiler/testData/codegen/box/diagnostics/functions/tailRecursion/realIteratorFoldl.kt index 74961bc58d9..c0f19b5b79d 100644 --- a/compiler/testData/codegen/box/diagnostics/functions/tailRecursion/realIteratorFoldl.kt +++ b/compiler/testData/codegen/box/diagnostics/functions/tailRecursion/realIteratorFoldl.kt @@ -3,7 +3,7 @@ tailRecursive fun Iterator.foldl(acc : A, foldFunction : (e : T, acc : else foldl(foldFunction(next(), acc), foldFunction) fun box() : String { - val sum = (1..1000000).iterator().foldl(0) { (e : Int, acc : Long) -> + val sum = (1..1000000).iterator().foldl(0) { e : Int, acc : Long -> acc + e } diff --git a/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.kt b/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.kt index 87e4cd62adc..7363b659226 100644 --- a/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.kt +++ b/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.kt @@ -52,16 +52,15 @@ fun main(args : Array) { fun f() : Int.() -> Unit = {} fun main1() { - 1.{Int.() -> 1}(); + 1.(fun Int.() = 1)(); {1}(); - {(x : Int) -> x}(1) - 1.{Int.(x : Int) -> x}(1); + (fun (x : Int) = x)(1) + 1.(fun Int.(x : Int) = x)(1); @l{1}() - 1.({Int.() -> 1})() + 1.((fun Int.() = 1))() 1.(f())() 1.if(true){f()}else{f()}() - 1.if(true){Int.() -> 1}else{f()}() - 1.if(true){Int.() -> 1}else{Int.() -> 1}() + 1.if(true)(fun Int.() {})else{f()}() 1."sdf"() @@ -71,12 +70,12 @@ fun main1() { } fun test() { - {(x : Int) -> 1}(); - {Int.() -> 1}() - "sd".{Int.() -> 1}() + {x : Int -> 1}(); + (fun Int.() = 1)() + "sd".(fun Int.() = 1)() val i : Int? = null - i.{Int.() -> 1}(); + i.(fun Int.() = 1)(); {}() - 1?.{Int.() -> 1}() + 1?.(fun Int.() = 1)() 1.{}() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/FunctionParameterWithoutType.kt b/compiler/testData/diagnostics/tests/FunctionParameterWithoutType.kt index f5a48c1cf6f..430f8918eaf 100644 --- a/compiler/testData/diagnostics/tests/FunctionParameterWithoutType.kt +++ b/compiler/testData/diagnostics/tests/FunctionParameterWithoutType.kt @@ -7,5 +7,5 @@ class A(a) val bar = fun test(a){} -val la = { (a) -> } -val las = { (a: Int) -> } \ No newline at end of file +val la = { a -> } +val las = { a: Int -> } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/FunctionReturnTypes.kt b/compiler/testData/diagnostics/tests/FunctionReturnTypes.kt index 1ed4f0db02b..f24d3f89bed 100644 --- a/compiler/testData/diagnostics/tests/FunctionReturnTypes.kt +++ b/compiler/testData/diagnostics/tests/FunctionReturnTypes.kt @@ -174,12 +174,12 @@ fun testFunctionLiterals() { val x = 2 } - val endsWithAssignment = { () : Int -> + val endsWithAssignment: () -> Int = { var x = 1 x = 333 } - val endsWithReAssignment = { () : Int -> + val endsWithReAssignment: () -> Int = { var x = 1 x += 333 } @@ -196,11 +196,11 @@ fun testFunctionLiterals() { object A {} } - val expectedUnitReturnType1 = { () : Unit -> + val expectedUnitReturnType1: () -> Unit = { val x = 1 } - val expectedUnitReturnType2 = { () : Unit -> + val expectedUnitReturnType2: () -> Unit = { fun meow() : Unit {} object A {} } diff --git a/compiler/testData/diagnostics/tests/UnusedVariables.kt b/compiler/testData/diagnostics/tests/UnusedVariables.kt index 7a52bf525b6..a0d35a26f1c 100644 --- a/compiler/testData/diagnostics/tests/UnusedVariables.kt +++ b/compiler/testData/diagnostics/tests/UnusedVariables.kt @@ -103,11 +103,11 @@ fun testInnerFunctions() { fun testFunctionLiterals() { var x = 1 - var fl = { (): Int -> + var fl = { x } var y = 2 - var fl1 = { (): Unit -> + var fl1 = { doSmth(y) } } diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/deadCode/kt5200DeadCodeInLambdas.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/deadCode/kt5200DeadCodeInLambdas.kt index 0d53ea4e81a..83011b093e7 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/deadCode/kt5200DeadCodeInLambdas.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/deadCode/kt5200DeadCodeInLambdas.kt @@ -2,7 +2,6 @@ fun test1(): String { doCall @local { - () : String -> throw NullPointerException() "b3" //unmarked } @@ -12,7 +11,6 @@ fun test1(): String { fun test2(nonLocal: String, b: Boolean): String { doCall @local { - () : String -> if (b) { return@local "b1" } else { diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt1977.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt1977.kt index 843bd4cb5f2..3f38218b295 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt1977.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt1977.kt @@ -30,7 +30,7 @@ fun test2(s : String) : Int? { 22 } finally { { - (x : Int) -> x + x : Int -> x } } } diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/referenceToPropertyInitializer.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/referenceToPropertyInitializer.kt index f1938f3ff79..346fbe1bcca 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/referenceToPropertyInitializer.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/referenceToPropertyInitializer.kt @@ -2,7 +2,7 @@ package o class TestFunctionLiteral { - val sum: (Int) -> Int = { (x: Int) -> + val sum: (Int) -> Int = { x: Int -> sum(x - 1) + x } val foo: () -> Unit = @l ({ foo() }) diff --git a/compiler/testData/diagnostics/tests/functionLiterals/return/AutoLabels.kt b/compiler/testData/diagnostics/tests/functionLiterals/return/AutoLabels.kt index 8905e01d23a..000b6e20083 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/return/AutoLabels.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/return/AutoLabels.kt @@ -1,18 +1,17 @@ fun f() { - foo {(): Int -> + foo { return@foo 1 } - foo({(): Int -> + foo({ return@foo 1 } ) - foo(a = {(): Int -> + foo(a = { return@foo 1 }) - foo {(): Int -> + foo { foo { - (): Int -> return@foo 1 } return@foo 1 diff --git a/compiler/testData/diagnostics/tests/functionLiterals/return/AutoLabelsNonLocal.kt b/compiler/testData/diagnostics/tests/functionLiterals/return/AutoLabelsNonLocal.kt index 5b07f2a88c6..5211601de3c 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/return/AutoLabelsNonLocal.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/return/AutoLabelsNonLocal.kt @@ -1,7 +1,6 @@ fun f() { - foo {(): Int -> + foo { bar { - (): Int -> return@foo 1 } return@foo 1 diff --git a/compiler/testData/diagnostics/tests/functionLiterals/return/LambdaWithParameter.kt b/compiler/testData/diagnostics/tests/functionLiterals/return/LambdaWithParameter.kt index 58f7fb03550..086ad1b5713 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/return/LambdaWithParameter.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/return/LambdaWithParameter.kt @@ -1,7 +1,7 @@ val flag = true val a /*: (Int) -> String */ = @l { - (i: Int) -> + i: Int -> if (i == 0) return@l i.toString() "Ok" @@ -10,7 +10,7 @@ val a /*: (Int) -> String */ = @l { fun foo(f: (Int) -> T): T = f(0) val b /*:String */ = foo { - (i) -> + i -> if (i == 0) return@foo i.toString() "Ok" diff --git a/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnHasTypeNothing.kt b/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnHasTypeNothing.kt index 28e17358fd5..d2c175f21de 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnHasTypeNothing.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnHasTypeNothing.kt @@ -1,5 +1,5 @@ fun test() { - run1 @f{(): Int -> + run1 @f{ (return@f 1): Nothing } } diff --git a/compiler/testData/diagnostics/tests/functionLiterals/return/SmartCast.kt b/compiler/testData/diagnostics/tests/functionLiterals/return/SmartCast.kt index a3a1dc7ea66..98345e5619d 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/return/SmartCast.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/return/SmartCast.kt @@ -1,6 +1,6 @@ // KT-6822 Smart cast doesn't work inside local returned expression in lambda -val a /* :(Int?) -> Int? */ = @l { (it: Int?) -> // but must be (Int?) -> Int +val a /* :(Int?) -> Int? */ = @l { it: Int? -> // but must be (Int?) -> Int if (it != null) return@l it 5 } diff --git a/compiler/testData/diagnostics/tests/functionLiterals/unusedLiteral.kt b/compiler/testData/diagnostics/tests/functionLiterals/unusedLiteral.kt index 0ee0afc0f92..ea9148e251c 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/unusedLiteral.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/unusedLiteral.kt @@ -1,12 +1,12 @@ fun unusedLiteral(){ - {() -> + { -> val i = 1 } } fun unusedLiteralInDoWhile(){ - do{() -> + do{ -> val i = 1 } while(false) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/incompleteCode/SupertypeOfErrorType.kt b/compiler/testData/diagnostics/tests/incompleteCode/SupertypeOfErrorType.kt index bec1cc248cd..92699d335b9 100644 --- a/compiler/testData/diagnostics/tests/incompleteCode/SupertypeOfErrorType.kt +++ b/compiler/testData/diagnostics/tests/incompleteCode/SupertypeOfErrorType.kt @@ -6,7 +6,7 @@ import java.util.Comparator fun foo() { - val c: Comparator = comparator {(date1, date2) -> + val c: Comparator = comparator { date1, date2 -> if (date1 != null && date2 != null) { date1.compareTo(date2) * -11 } else { diff --git a/compiler/testData/diagnostics/tests/inference/functionPlaceholderError.kt b/compiler/testData/diagnostics/tests/inference/functionPlaceholderError.kt index 869b1b6a2a8..015f6815e29 100644 --- a/compiler/testData/diagnostics/tests/inference/functionPlaceholderError.kt +++ b/compiler/testData/diagnostics/tests/inference/functionPlaceholderError.kt @@ -5,7 +5,7 @@ fun emptyList(): List = throw Exception() fun foo(f: T.() -> Unit, l: List): T = throw Exception("$f$l") fun test() { - val q = foo({ Int.() -> }, emptyList()) //type inference no information for parameter error + val q = foo(fun Int.() {}, emptyList()) //type inference no information for parameter error q: Int foo({}, emptyList()) diff --git a/compiler/testData/diagnostics/tests/inference/kt3184.kt b/compiler/testData/diagnostics/tests/inference/kt3184.kt index 3c801f7d6b8..86773f52862 100644 --- a/compiler/testData/diagnostics/tests/inference/kt3184.kt +++ b/compiler/testData/diagnostics/tests/inference/kt3184.kt @@ -8,7 +8,7 @@ private fun test(value: T, extf: String.(value: T)->Unit) { } fun main(args: Array) { - test(1, {(value) -> println(value)}) + test(1, {value -> println(value)}) } fun tests() { diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1031.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1031.kt index 10bd8f10801..8c41d427093 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1031.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt1031.kt @@ -11,7 +11,7 @@ public fun select(yielder: ()->Iterable i % 2 == 0 } + val z = x where { i: Int -> i % 2 == 0 } val yielder = select(x where { it%2==0 }, { it.toString() }) z : () -> Iterable diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1145.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1145.kt index 9668995c487..6bb167ed719 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1145.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt1145.kt @@ -3,7 +3,7 @@ package d fun test(numbers: Iterable) { - val s = numbers.map{it.toString()}.fold(""){(it, it2) -> it + it2} + val s = numbers.map{it.toString()}.fold(""){it, it2 -> it + it2} s: Int } diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2286.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2286.kt index c39cd683f35..00812285eeb 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2286.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2286.kt @@ -14,7 +14,7 @@ abstract class Buggy { get() = coll.find{ it > 3 } // does not work here val yetAnotherThree : Int - get() = coll.find({ (v:Int) -> v > 3 }) // neither here + get() = coll.find({ v:Int -> v > 3 }) // neither here val extendedGetter : Int get() { diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt3007.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt3007.kt index aba9abbf526..49ac9ad9eef 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt3007.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt3007.kt @@ -8,7 +8,7 @@ enum class SomeEnum { // Doesn't work fun Iterable.some() { - this.fold(SomeEnum.FIRST, {(res : SomeEnum, value) -> + this.fold(SomeEnum.FIRST, {res : SomeEnum, value -> if (res == SomeEnum.FIRST) SomeEnum.FIRST else SomeEnum.SECOND }) } @@ -19,7 +19,7 @@ fun tempFun() : SomeEnum { // Doesn't work fun Iterable.someSimpleWithFun() { - this.fold(SomeEnum.FIRST, {(res : SomeEnum, value) -> + this.fold(SomeEnum.FIRST, {res : SomeEnum, value -> tempFun() }) } @@ -27,14 +27,14 @@ fun Iterable.someSimpleWithFun() { // Works fun Iterable.someSimple() { - this.fold(SomeEnum.FIRST, {(res : SomeEnum, value) -> + this.fold(SomeEnum.FIRST, {res : SomeEnum, value -> SomeEnum.FIRST }) } // Works fun Iterable.someInt() { - this.fold(0, {(res : Int, value) -> + this.fold(0, {res : Int, value -> if (res == 0) 1 else 0 }) } diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt3150.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt3150.kt index c5f06d013ce..64ae0ce8d10 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt3150.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt3150.kt @@ -15,10 +15,10 @@ fun SomeTemplate.query(f: (i: Int) -> Unit) = f fun SomeTemplate.query1(f: (i: Int) -> Unit) = f fun test() { - val mapperFunction = {(i: Int)-> } + val mapperFunction = { i: Int -> } SomeTemplate().query(mapperFunction) // TYPE_MISMATCH: Required Class<[ERROR: CANT_INFER]>, Found (kotlin.Int) -> Unit - SomeTemplate().query {(i: Int)-> } - SomeTemplate().query1 {(i: Int)-> } + SomeTemplate().query { i: Int -> } + SomeTemplate().query1 { i: Int -> } } diff --git a/compiler/testData/diagnostics/tests/inference/reportingImprovements/ErrorTypeAsGenericParameter.kt b/compiler/testData/diagnostics/tests/inference/reportingImprovements/ErrorTypeAsGenericParameter.kt index f64d5e70815..a16add61495 100644 --- a/compiler/testData/diagnostics/tests/inference/reportingImprovements/ErrorTypeAsGenericParameter.kt +++ b/compiler/testData/diagnostics/tests/inference/reportingImprovements/ErrorTypeAsGenericParameter.kt @@ -3,7 +3,7 @@ package a fun foo(block: (T)-> R, second: (T)-> S) = block fun main(args: Array) { - val fff = { (x: Int) -> aaa } + val fff = { x: Int -> aaa } foo(fff, { x -> x + 1 }) } diff --git a/compiler/testData/diagnostics/tests/inference/reportingImprovements/FunctionPlaceholder.kt b/compiler/testData/diagnostics/tests/inference/reportingImprovements/FunctionPlaceholder.kt index afc5efa9897..7ad420b84b1 100644 --- a/compiler/testData/diagnostics/tests/inference/reportingImprovements/FunctionPlaceholder.kt +++ b/compiler/testData/diagnostics/tests/inference/reportingImprovements/FunctionPlaceholder.kt @@ -8,9 +8,9 @@ fun bar(f: (T) -> R) = f fun test() { foo { it } foo { x -> x} - foo { (x: Int) -> x} + foo { x: Int -> x} bar { it + 1 } bar { x -> x + 1} - bar { (x: Int) -> x + 1} + bar { x: Int -> x + 1} } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inline/nonLocalReturns/explicitReturnType.kt b/compiler/testData/diagnostics/tests/inline/nonLocalReturns/explicitReturnType.kt index 6bc79671c9b..df3ddcb01d1 100644 --- a/compiler/testData/diagnostics/tests/inline/nonLocalReturns/explicitReturnType.kt +++ b/compiler/testData/diagnostics/tests/inline/nonLocalReturns/explicitReturnType.kt @@ -11,7 +11,6 @@ fun inlineCallExplicitError(): String { fun inlineCall(): String { inlineFun @lamba { - (): Int -> if (true) { return@lamba 2 } @@ -28,7 +27,6 @@ inline fun inlineFun(s: () -> Int) { fun noInlineCall(): String { noInline @lambda { - (): Int -> if (true) { return@lambda 2 } diff --git a/compiler/testData/diagnostics/tests/inline/nonLocalReturns/nestedNonLocals.kt b/compiler/testData/diagnostics/tests/inline/nonLocalReturns/nestedNonLocals.kt index bfa7e193607..cc40fd4cec1 100644 --- a/compiler/testData/diagnostics/tests/inline/nonLocalReturns/nestedNonLocals.kt +++ b/compiler/testData/diagnostics/tests/inline/nonLocalReturns/nestedNonLocals.kt @@ -16,10 +16,8 @@ class Global(val value: String) fun test1(intKind: Kind, extKind: Kind): Global { var externalResult = doCall @ext { - () : External -> val internalResult = doCall @int { - () : Internal -> if (intKind == Kind.LOCAL) { return@test1 Global("internal to global") } else if (intKind == EXT_RETURN) { diff --git a/compiler/testData/diagnostics/tests/inline/nonLocalReturns/onlyLocalReturnLambda.kt b/compiler/testData/diagnostics/tests/inline/nonLocalReturns/onlyLocalReturnLambda.kt index f9d086fba1c..106852e74af 100644 --- a/compiler/testData/diagnostics/tests/inline/nonLocalReturns/onlyLocalReturnLambda.kt +++ b/compiler/testData/diagnostics/tests/inline/nonLocalReturns/onlyLocalReturnLambda.kt @@ -27,13 +27,13 @@ fun fun3ValueArgument(p: () -> R) { fun fun4(p: () -> R) { - inlineFun @lambda {(): R -> + inlineFun @lambda { return@lambda p(); } } fun fun4ValueArgument(p: () -> R) { - inlineFun (@lambda {(): R -> + inlineFun (@lambda { return@lambda p(); }) } diff --git a/compiler/testData/diagnostics/tests/inline/nonLocalReturns/onlyLocalReturnLambdaBinaryExpr.kt b/compiler/testData/diagnostics/tests/inline/nonLocalReturns/onlyLocalReturnLambdaBinaryExpr.kt index cda4db3b27f..3889bf8a453 100644 --- a/compiler/testData/diagnostics/tests/inline/nonLocalReturns/onlyLocalReturnLambdaBinaryExpr.kt +++ b/compiler/testData/diagnostics/tests/inline/nonLocalReturns/onlyLocalReturnLambdaBinaryExpr.kt @@ -20,7 +20,7 @@ fun fun3(p: () -> R) { } fun fun4(p: () -> R) { - Z() inlineFun @lambda {(): R -> + Z() inlineFun @lambda { return@lambda p(); } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/labels/kt361.kt b/compiler/testData/diagnostics/tests/labels/kt361.kt index 0a08e5df724..6648d6709fa 100644 --- a/compiler/testData/diagnostics/tests/labels/kt361.kt +++ b/compiler/testData/diagnostics/tests/labels/kt361.kt @@ -1,5 +1,5 @@ fun nonlocals(b : Boolean) { - @a{(): Int -> + @a{ fun foo() { if (b) { return@a 1 // The label must be resolved, but an error should be reported for a non-local return diff --git a/compiler/testData/diagnostics/tests/labels/kt3920.kt b/compiler/testData/diagnostics/tests/labels/kt3920.kt index 29a070c5fe8..f75d16f0c2a 100644 --- a/compiler/testData/diagnostics/tests/labels/kt3920.kt +++ b/compiler/testData/diagnostics/tests/labels/kt3920.kt @@ -2,7 +2,7 @@ //KT-3920 Labeling information is lost when passing through some expressions fun test() { - run @f{ (): Int -> + run @f{ val x = if (1 > 2) return@f 1 else 2 2 } diff --git a/compiler/testData/diagnostics/tests/labels/kt4603.kt b/compiler/testData/diagnostics/tests/labels/kt4603.kt index 41d17e014d5..02bb77420d5 100644 --- a/compiler/testData/diagnostics/tests/labels/kt4603.kt +++ b/compiler/testData/diagnostics/tests/labels/kt4603.kt @@ -2,7 +2,7 @@ //KT-4603 Labeling information is lost when passing through local classes or objects fun foo() { - val s = @l{ Int.() -> + val s: Int.() -> Unit = @l{ class Local(val y: Int = this@l) { fun bar() { val x: Int = this@l //unresolved diff --git a/compiler/testData/diagnostics/tests/labels/kt591.kt b/compiler/testData/diagnostics/tests/labels/kt591.kt index 3cf088eee34..fdcdc7b4213 100644 --- a/compiler/testData/diagnostics/tests/labels/kt591.kt +++ b/compiler/testData/diagnostics/tests/labels/kt591.kt @@ -1,9 +1,9 @@ //KT-591 Unresolved label in valid code fun test() { - val a = @a{(Int?).() -> + val a: (Int?).() -> Unit = @a{ if (this != null) { - val b = {String.() -> + val b: String.() -> Unit = { this@a.times(5) // @a Unresolved } } diff --git a/compiler/testData/diagnostics/tests/regressions/Jet121.kt b/compiler/testData/diagnostics/tests/regressions/Jet121.kt index 804e3c5121e..5e4c5140413 100644 --- a/compiler/testData/diagnostics/tests/regressions/Jet121.kt +++ b/compiler/testData/diagnostics/tests/regressions/Jet121.kt @@ -1,7 +1,7 @@ package jet121 fun box() : String { -val answer = apply("OK") { String.() : Int -> +val answer = apply("OK") { get(0) length() } diff --git a/compiler/testData/diagnostics/tests/regressions/Jet124.kt b/compiler/testData/diagnostics/tests/regressions/Jet124.kt index a59f22eb382..6fa400a1acc 100644 --- a/compiler/testData/diagnostics/tests/regressions/Jet124.kt +++ b/compiler/testData/diagnostics/tests/regressions/Jet124.kt @@ -1,8 +1,8 @@ -fun foo1() : (Int) -> Int = { (x: Int) -> x } +fun foo1() : (Int) -> Int = { x: Int -> x } fun foo() { val h : (Int) -> Int = foo1(); h(1) - val m : (Int) -> Int = {(a : Int) -> 1}//foo1() + val m : (Int) -> Int = {a : Int -> 1}//foo1() m(1) } diff --git a/compiler/testData/diagnostics/tests/regressions/kt235.kt b/compiler/testData/diagnostics/tests/regressions/kt235.kt index 05915d5c84b..b8cfe997aac 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt235.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt235.kt @@ -4,32 +4,32 @@ package kt235 fun main(args: Array) { val array = MyArray() - val f = { (): String -> + val f: () -> String = { array[2] = 23 //error: Type mismatch: inferred type is Int (!!!) but String was expected } - val g = {(): String -> + val g: () -> String = { var x = 1 x += 2 //no error, but it should be here } - val h = {(): String -> + val h: () -> String = { var x = 1 x = 2 //the same } val array1 = MyArray1() - val i = { (): String -> + val i: () -> String = { array1[2] = 23 } - val fi = { (): Int -> - array[2] = 23 + val fi: () -> String = { + array[2] = 23 } - val gi = {(): Int -> + val gi: () -> String = { var x = 1 - x += 21 + x += 21 } var m: MyNumber = MyNumber() - val a = { (): MyNumber -> + val a: () -> MyNumber = { m++ } } diff --git a/compiler/testData/diagnostics/tests/regressions/kt353.kt b/compiler/testData/diagnostics/tests/regressions/kt353.kt index 1f6e74143d5..a6633c930fa 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt353.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt353.kt @@ -24,7 +24,7 @@ fun foo(a: A) { } } - val f : () -> Int = { () : Int -> + val f : () -> Int = { a.gen() //type mismatch, but Int can be derived } diff --git a/compiler/testData/diagnostics/tests/regressions/kt385.109.441.kt b/compiler/testData/diagnostics/tests/regressions/kt385.109.441.kt index b1b8f43e5c6..4a0edf60ae1 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt385.109.441.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt385.109.441.kt @@ -17,7 +17,7 @@ fun Iterable.foreach(operation: (element: T) -> Unit) : Unit = iterator() fun Iterable.foreach(operation: (index: Int, element: T) -> Unit) : Unit = iterator() foreach operation fun box() : String { - return generic_invoker( { () : String -> "OK"} ) + return generic_invoker( { "OK"} ) } fun generic_invoker(gen : () -> T) : T { diff --git a/compiler/testData/diagnostics/tests/regressions/kt398.kt b/compiler/testData/diagnostics/tests/regressions/kt398.kt index a6d63cddc40..ebf54e29543 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt398.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt398.kt @@ -1,7 +1,7 @@ // KT-398 Internal error when property initializes with function class X() { - val check = { (a : Any) -> a is T } + val check = { a : Any -> a is T } } fun box() : String { diff --git a/compiler/testData/diagnostics/tests/regressions/kt399.kt b/compiler/testData/diagnostics/tests/regressions/kt399.kt index ed8841417c6..80ecbbbceff 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt399.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt399.kt @@ -1,7 +1,7 @@ // KT-399 Type argument inference not implemented for CALL_EXPRESSION fun getSameTypeChecker(obj: T) : Function1 { - return { (a : Any) -> a is T } + return { a : Any -> a is T } } fun box() : String { diff --git a/compiler/testData/diagnostics/tests/regressions/kt402.kt b/compiler/testData/diagnostics/tests/regressions/kt402.kt index d2afdd4167b..291691d51a4 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt402.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt402.kt @@ -1,8 +1,8 @@ package kt402 fun getTypeChecker() : (Any)->Boolean { - { (a : Any) -> a is T } // reports unsupported + { a : Any -> a is T } // reports unsupported } fun f() : (Any) -> Boolean { - return { (a : Any) -> a is String } + return { a : Any -> a is String } } diff --git a/compiler/testData/diagnostics/tests/regressions/kt411.kt b/compiler/testData/diagnostics/tests/regressions/kt411.kt index 268e2d7cd42..94416cca637 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt411.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt411.kt @@ -13,7 +13,7 @@ fun invoker(gen : () -> Int) : Int = 0 //more tests fun t1() { - val v = @l{ () : Int -> + val v = @l{ return@l 111 } } @@ -41,7 +41,7 @@ fun t3() : String { } ) invoker( - @l{ (): Int -> + @l{ return@l 1 } ) @@ -57,7 +57,7 @@ fun t4() : Int { val h : ()-> String = @l{ return@l "a" } - val g : ()-> String = @l{ () : String -> + val g : ()-> String = @l{ return@l "a" } diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/errors/wrongReceiverForInvokeOnExpression.kt b/compiler/testData/diagnostics/tests/resolve/invoke/errors/wrongReceiverForInvokeOnExpression.kt index 36953d2cfb8..bacdd1929d9 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/errors/wrongReceiverForInvokeOnExpression.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/errors/wrongReceiverForInvokeOnExpression.kt @@ -1,6 +1,6 @@ fun test1() { - 1. { String.(i: Int) -> i }(1) - 1.(@label{ String.(i: Int) -> i })(1) + 1. (fun String.(i: Int) = i )(1) + 1.(fun String.label(i: Int) = i )(1) } fun test2(f: String.(Int) -> Unit) { diff --git a/compiler/testData/diagnostics/tests/resolve/nestedCalls/completeUnmappedArguments.kt b/compiler/testData/diagnostics/tests/resolve/nestedCalls/completeUnmappedArguments.kt index 8f347e71fb8..4214ee72398 100644 --- a/compiler/testData/diagnostics/tests/resolve/nestedCalls/completeUnmappedArguments.kt +++ b/compiler/testData/diagnostics/tests/resolve/nestedCalls/completeUnmappedArguments.kt @@ -7,8 +7,8 @@ fun test() { fun bar(i: Int) = i - bar(foo(xx = zzz(11) { (j: Int) -> j + 7 })) + bar(foo(xx = zzz(11) { j: Int -> j + 7 })) bar(zz = foo( - xx = zzz(12) { (i: Int) -> i + i })) + xx = zzz(12) { i: Int -> i + i })) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/shadowing/ShadowPropertyInClosure.kt b/compiler/testData/diagnostics/tests/shadowing/ShadowPropertyInClosure.kt index 00c0d038398..6490b74f72d 100644 --- a/compiler/testData/diagnostics/tests/shadowing/ShadowPropertyInClosure.kt +++ b/compiler/testData/diagnostics/tests/shadowing/ShadowPropertyInClosure.kt @@ -1,3 +1,3 @@ val i = 17 -val f = { (): Int -> var i = 17; i } +val f: () -> Int = { var i = 17; i } diff --git a/compiler/testData/diagnostics/tests/shadowing/ShadowVariableInNestedClosure.kt b/compiler/testData/diagnostics/tests/shadowing/ShadowVariableInNestedClosure.kt index 29ebe8f2c2e..3d8574972f5 100644 --- a/compiler/testData/diagnostics/tests/shadowing/ShadowVariableInNestedClosure.kt +++ b/compiler/testData/diagnostics/tests/shadowing/ShadowVariableInNestedClosure.kt @@ -1,5 +1,5 @@ fun f(): Int { var i = 17 - { (): Unit -> var i = 18 } + { var i = 18 } return i } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/shadowing/ShadowVariableInNestedClosureParam.kt b/compiler/testData/diagnostics/tests/shadowing/ShadowVariableInNestedClosureParam.kt index 695b1664c49..0b2dcdbbeea 100644 --- a/compiler/testData/diagnostics/tests/shadowing/ShadowVariableInNestedClosureParam.kt +++ b/compiler/testData/diagnostics/tests/shadowing/ShadowVariableInNestedClosureParam.kt @@ -1,5 +1,5 @@ fun ff(): Int { var i = 1 - { (i: Int) -> i } + { i: Int -> i } return i } diff --git a/compiler/testData/diagnostics/tests/thisAndSuper/thisInFunctionLiterals.kt b/compiler/testData/diagnostics/tests/thisAndSuper/thisInFunctionLiterals.kt index c6d8ce909cf..55f5725a631 100644 --- a/compiler/testData/diagnostics/tests/thisAndSuper/thisInFunctionLiterals.kt +++ b/compiler/testData/diagnostics/tests/thisAndSuper/thisInFunctionLiterals.kt @@ -1,17 +1,16 @@ class A(val a:Int) { inner class B() { - fun Char.xx() : Any { + fun Char.xx() : Double.() -> Any { this : Char - val a = { - Double.() -> + val a: Double.() -> Unit = { this : Double this@xx : Char this@B : B this@A : A } - val b = @a{Double.() -> this@a : Double + this@xx : Char} - val c = @a{() -> this@a + this@xx : Char} - return (@a{Double.() -> this@a : Double + this@xx : Char}) + val b: Double.() -> Unit = @a{ this@a : Double + this@xx : Char} + val c = @a{ -> this@a + this@xx : Char} + return (@a{this@a : Double + this@xx : Char}) } } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/thisAndSuper/thisInFunctionLiterals.txt b/compiler/testData/diagnostics/tests/thisAndSuper/thisInFunctionLiterals.txt index 00e6d0ebcb3..f138e8e0427 100644 --- a/compiler/testData/diagnostics/tests/thisAndSuper/thisInFunctionLiterals.txt +++ b/compiler/testData/diagnostics/tests/thisAndSuper/thisInFunctionLiterals.txt @@ -12,6 +12,6 @@ internal final class A { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - internal final fun kotlin.Char.xx(): kotlin.Any + internal final fun kotlin.Char.xx(): kotlin.Double.() -> kotlin.Any } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/arrayConstructor.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/arrayConstructor.kt index bda02d27549..703458ea171 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/arrayConstructor.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/arrayConstructor.kt @@ -1,8 +1,8 @@ package b fun bar() { - val a1 = Array(1, {(i: Int) -> i}) - val a2 = Array(1, {(i: Int) -> "$i"}) + val a1 = Array(1, {i: Int -> i}) + val a2 = Array(1, {i: Int -> "$i"}) val a3 = Array(1, {it}) a1 : Array diff --git a/idea/testData/checker/QualifiedThisInClosures.kt b/idea/testData/checker/QualifiedThisInClosures.kt index ea3eba9fc00..b3171d67a4d 100644 --- a/idea/testData/checker/QualifiedThisInClosures.kt +++ b/idea/testData/checker/QualifiedThisInClosures.kt @@ -5,12 +5,12 @@ val y = this@A : A val z = this : B val Int.xx : Int get() = this : Int - fun Char.xx() : Any { + fun Char.xx() : Double.() -> Unit { this : Char - val a = {Double.() -> this : Double + this@xx : Char} - val b = @a{Double.() -> this@a : Double + this@xx : Char} - val c = @a{() -> this@a + this@xx : Char} - return (@a{Double.() -> this@a : Double + this@xx : Char}) + val a: Double.() -> Unit = { this : Double + this@xx : Char} + val b: Double.() -> Unit = @a{this@a : Double + this@xx : Char} + val c = @a{this@a + this@xx : Char} + return (@a{this@a : Double + this@xx : Char}) } } } diff --git a/idea/testData/checker/infos/SmartCasts.kt b/idea/testData/checker/infos/SmartCasts.kt index 049ddd193b3..d220bf47019 100644 --- a/idea/testData/checker/infos/SmartCasts.kt +++ b/idea/testData/checker/infos/SmartCasts.kt @@ -173,8 +173,8 @@ fun returnFunctionLiteralBlock(a: Any?): Function0 { else return { 1 } } fun returnFunctionLiteral(a: Any?): Function0 = - if (a is Int) { (): Int -> a } - else { () -> 1 } + if (a is Int) (fun (): Int = a) + else { -> 1 } fun mergeSmartCasts(a: Any?) { if (a is String || a is Int) { diff --git a/idea/testData/checker/regression/Jet121.kt b/idea/testData/checker/regression/Jet121.kt index 95183845189..e911e7332b9 100644 --- a/idea/testData/checker/regression/Jet121.kt +++ b/idea/testData/checker/regression/Jet121.kt @@ -1,7 +1,7 @@ package jet121 fun box(): String { - val answer = apply("OK") { String.(): Int -> + val answer = apply("OK") { get(0) length() } diff --git a/idea/testData/checker/regression/Jet124.kt b/idea/testData/checker/regression/Jet124.kt index 5e8088b3e08..dae33e40d21 100644 --- a/idea/testData/checker/regression/Jet124.kt +++ b/idea/testData/checker/regression/Jet124.kt @@ -1,8 +1,8 @@ -fun foo1() : (Int) -> Int = { (x: Int) -> x } +fun foo1() : (Int) -> Int = { x: Int -> x } fun foo() { val h : (Int) -> Int = foo1(); h(1) - val m : (Int) -> Int = {(a : Int) -> 1}//foo1() + val m : (Int) -> Int = {a : Int -> 1}//foo1() m(1) } \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/forStatement/unavailable/beforeInParameterTypeInFunctionLiteral.kt b/idea/testData/quickfix/suppress/forStatement/unavailable/beforeInParameterTypeInFunctionLiteral.kt index 371d30b331c..16b0670d7fa 100644 --- a/idea/testData/quickfix/suppress/forStatement/unavailable/beforeInParameterTypeInFunctionLiteral.kt +++ b/idea/testData/quickfix/suppress/forStatement/unavailable/beforeInParameterTypeInFunctionLiteral.kt @@ -4,7 +4,7 @@ fun foo() { any { - (x: String??) -> + x: String?? -> } }