diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProvider.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProvider.kt index d02227eaadb..87ca62e0ec0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProvider.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProvider.kt @@ -578,6 +578,7 @@ class ControlFlowInformationProvider private constructor( } else if (element is KtParameter) { val owner = element.parent?.parent + if (element.isSingleUnderscore) return@traverse when (owner) { is KtPrimaryConstructor -> if (!element.hasValOrVar()) { val containingClass = owner.getContainingClassOrObject() @@ -590,7 +591,6 @@ class ControlFlowInformationProvider private constructor( is KtFunction -> { val mainFunctionDetector = MainFunctionDetector(trace.bindingContext) val isMain = owner is KtNamedFunction && mainFunctionDetector.isMain(owner) - if (owner is KtFunctionLiteral) return@traverse val functionDescriptor = trace.get(BindingContext.DECLARATION_TO_DESCRIPTOR, owner) as? FunctionDescriptor ?: throw AssertionError(owner.text) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiUtil.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiUtil.java index e2b8e5856cb..6a470f73a7b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiUtil.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiUtil.java @@ -42,7 +42,6 @@ import org.jetbrains.kotlin.parsing.KotlinExpressionParsing; import org.jetbrains.kotlin.psi.psiUtil.KtPsiUtilKt; import org.jetbrains.kotlin.resolve.StatementFilter; import org.jetbrains.kotlin.resolve.StatementFilterKt; -import org.jetbrains.kotlin.types.expressions.OperatorConventions; import java.util.Collection; import java.util.HashSet; @@ -280,9 +279,8 @@ public class KtPsiUtil { if (!(declaration instanceof KtVariableDeclaration)) return false; if (declaration instanceof KtProperty) return true; assert declaration instanceof KtDestructuringDeclarationEntry; - KtDestructuringDeclaration parentDeclaration = (KtDestructuringDeclaration) declaration.getParent(); - List entries = parentDeclaration.getEntries(); - return entries.size() > 1 && entries.get(entries.size() - 1) == declaration; + // We can always replace destructuring entry with _ + return true; } @Nullable diff --git a/compiler/testData/diagnostics/tests/AutoCreatedIt.kt b/compiler/testData/diagnostics/tests/AutoCreatedIt.kt index b7f614eba6a..3a2f3d93ffc 100644 --- a/compiler/testData/diagnostics/tests/AutoCreatedIt.kt +++ b/compiler/testData/diagnostics/tests/AutoCreatedIt.kt @@ -4,7 +4,7 @@ fun text() { "direct:a" on {it -> it.body == ""} to "mock:a" bar {1} bar {it + 1} - bar {it, it1 -> it} + bar {it, it1 -> it} bar1 {1} bar1 {it + 1} @@ -29,4 +29,4 @@ infix fun String.on(predicate : (s : URI) -> Boolean) : class URI(val body : Any) { infix fun to(dest : String) {} -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.kt b/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.kt index b8a44a2e45a..110885cc242 100644 --- a/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.kt +++ b/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.kt @@ -36,8 +36,8 @@ fun main(args : Array) { foo2()({}) foo2(){} (foo2()){} - (foo2()){x -> } - foo2()({x -> }) + (foo2()){x -> } + foo2()({x -> }) val a = fooT1(1)() checkSubtype(a) @@ -72,7 +72,7 @@ fun main1() { } fun test() { - {x : Int -> 1}(); + {x : Int -> 1}(); (fun Int.() = 1)() "sd".(fun Int.() = 1)() val i : Int? = null @@ -80,4 +80,4 @@ fun test() { {}() 1?.(fun Int.() = 1)() 1.{}() -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/Underscore.kt b/compiler/testData/diagnostics/tests/Underscore.kt index 8754d33fc06..d8fafd4f730 100644 --- a/compiler/testData/diagnostics/tests/Underscore.kt +++ b/compiler/testData/diagnostics/tests/Underscore.kt @@ -23,7 +23,7 @@ fun __(___: Int, y: _< } // one underscore parameters for named function are still prohibited -fun oneUnderscore(_: Int) {} +fun oneUnderscore(_: Int) {} fun doIt(f: (Any?) -> Any?) = f(null) diff --git a/compiler/testData/diagnostics/tests/UnusedInDestructuring.kt b/compiler/testData/diagnostics/tests/UnusedInDestructuring.kt index 64e72cd5990..5b5ff5b32b3 100644 --- a/compiler/testData/diagnostics/tests/UnusedInDestructuring.kt +++ b/compiler/testData/diagnostics/tests/UnusedInDestructuring.kt @@ -1,6 +1,6 @@ data class D(val x: Int, val y: Int, val z: Int) fun foo(): Int { - val (x, y, z) = D(1, 2, 3) + val (x, y, z) = D(1, 2, 3) return y + z // x is not used, but we cannot do anything with it } fun bar(): Int { diff --git a/compiler/testData/diagnostics/tests/annotations/forParameterAnnotationResolve.kt b/compiler/testData/diagnostics/tests/annotations/forParameterAnnotationResolve.kt index f5ebfbaf57b..3fe61957748 100644 --- a/compiler/testData/diagnostics/tests/annotations/forParameterAnnotationResolve.kt +++ b/compiler/testData/diagnostics/tests/annotations/forParameterAnnotationResolve.kt @@ -8,7 +8,7 @@ fun foo() { for (@Ann(1) i in 1..100) {} for (@Ann(2) i in 1..100) {} - for (@Ann(3) (x, @Ann(4) y) in bar()) {} + for (@Ann(3) (x, @Ann(4) y) in bar()) {} - for (@Err() (x,y) in bar()) {} -} \ No newline at end of file + for (@Err() (x,y) in bar()) {} +} diff --git a/compiler/testData/diagnostics/tests/controlStructures/valVarLoopParameter.kt b/compiler/testData/diagnostics/tests/controlStructures/valVarLoopParameter.kt index 1a0ab7cdfd2..be09dd797d7 100644 --- a/compiler/testData/diagnostics/tests/controlStructures/valVarLoopParameter.kt +++ b/compiler/testData/diagnostics/tests/controlStructures/valVarLoopParameter.kt @@ -22,11 +22,11 @@ fun f() { } - for (val (i,j) in Coll()) { + for (val (i,j) in Coll()) { } - for (var (i,j) in Coll()) { + for (var (i,j) in Coll()) { } } diff --git a/compiler/testData/diagnostics/tests/declarationChecks/ComponentFunctionReturnTypeMismatch.kt b/compiler/testData/diagnostics/tests/declarationChecks/ComponentFunctionReturnTypeMismatch.kt index ef48870d7e2..9ac63bc9850 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/ComponentFunctionReturnTypeMismatch.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/ComponentFunctionReturnTypeMismatch.kt @@ -4,5 +4,5 @@ class A { } fun a(aa : A) { - val (a: String, b1: String) = aa -} \ No newline at end of file + val (a: String, b1: String) = aa +} diff --git a/compiler/testData/diagnostics/tests/declarationChecks/DataFlowInMultiDeclInFor.kt b/compiler/testData/diagnostics/tests/declarationChecks/DataFlowInMultiDeclInFor.kt index 6808da9546c..1feb317b1f0 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/DataFlowInMultiDeclInFor.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/DataFlowInMultiDeclInFor.kt @@ -8,7 +8,7 @@ class A { } fun foo(list: List) { - for (var (c1, c2, c3) in list) { + for (var (c1, c2, c3) in list) { c1 = 1 c3 + 1 } diff --git a/compiler/testData/diagnostics/tests/declarationChecks/DataFlowInfoInMultiDecl.kt b/compiler/testData/diagnostics/tests/declarationChecks/DataFlowInfoInMultiDecl.kt index d14057b2485..09a8ff45cd5 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/DataFlowInfoInMultiDecl.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/DataFlowInfoInMultiDecl.kt @@ -5,10 +5,10 @@ class A { fun a(aa : A?, b : Any) { if (aa != null) { - val (a1, b1) = aa; + val (a1, b1) = aa; } if (b is A) { - val (a1, b1) = b; + val (a1, b1) = b; } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/declarationChecks/RedeclarationsInMultiDecl.kt b/compiler/testData/diagnostics/tests/declarationChecks/RedeclarationsInMultiDecl.kt index 6344439d5ca..a23f77ad672 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/RedeclarationsInMultiDecl.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/RedeclarationsInMultiDecl.kt @@ -4,11 +4,11 @@ class A { } fun a() { - val (a, a) = A() - val (x, y) = A(); + val (a, a) = A() + val (x, y) = A(); val b = 1 use(b) - val (b, y) = A(); + val (b, y) = A(); } diff --git a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/DoubleDeclForLoop.kt b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/DoubleDeclForLoop.kt index 88661f059c8..96b28fde3b1 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/DoubleDeclForLoop.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/DoubleDeclForLoop.kt @@ -8,7 +8,7 @@ class C { } fun test() { - for ((x, y) in C()) { + for ((x, y) in C()) { } } diff --git a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/FolLoopTypeComponentTypeMismatch.kt b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/FolLoopTypeComponentTypeMismatch.kt index 66a9a88a311..429b1ab17d9 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/FolLoopTypeComponentTypeMismatch.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/FolLoopTypeComponentTypeMismatch.kt @@ -8,7 +8,7 @@ class C { } fun test() { - for ((x: Double, y: Int) in C()) { + for ((x: Double, y: Int) in C()) { } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopComponentFunctionAmbiguity.kt b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopComponentFunctionAmbiguity.kt index 27cd5b37bb9..5d418ef3edd 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopComponentFunctionAmbiguity.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopComponentFunctionAmbiguity.kt @@ -9,7 +9,7 @@ class C { } fun test() { - for ((x, y) in C()) { + for ((x, y) in C()) { } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopComponentFunctionMissing.kt b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopComponentFunctionMissing.kt index 275ae1ecd45..083e33365a7 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopComponentFunctionMissing.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopComponentFunctionMissing.kt @@ -7,7 +7,7 @@ class C { } fun test() { - for ((x, y) in C()) { + for ((x, y) in C()) { } } diff --git a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopMissingLoopParameter.kt b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopMissingLoopParameter.kt index dc5a01b2367..6eac4152c39 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopMissingLoopParameter.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopMissingLoopParameter.kt @@ -6,7 +6,7 @@ fun useDeclaredVariables() { } fun checkersShouldRun() { - for ((@A a, _)) { + for ((@A a, _)) { } } diff --git a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopWithExtensions.kt b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopWithExtensions.kt index 493e39d136b..3d40eb655de 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopWithExtensions.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopWithExtensions.kt @@ -8,7 +8,7 @@ class C { } fun test() { - for ((x, y) in C()) { + for ((x, y) in C()) { } } diff --git a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForWithExplicitTypes.kt b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForWithExplicitTypes.kt index 300010781c0..be8c7dfa707 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForWithExplicitTypes.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForWithExplicitTypes.kt @@ -8,7 +8,7 @@ class C { } fun test() { - for ((x: Int, y: Double) in C()) { + for ((x: Int, y: Double) in C()) { } } diff --git a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/RedeclarationInForLoop.kt b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/RedeclarationInForLoop.kt index dc4f8bc1e86..315d51f0812 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/RedeclarationInForLoop.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/RedeclarationInForLoop.kt @@ -8,7 +8,7 @@ class C { } fun test() { - for ((x, x) in C()) { + for ((x, x) in C()) { } } diff --git a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/SingleDeclForLoop.kt b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/SingleDeclForLoop.kt index d955b6a5df7..36f1248cb9e 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/SingleDeclForLoop.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/SingleDeclForLoop.kt @@ -7,7 +7,7 @@ class C { } fun test() { - for ((x) in C()) { + for ((x) in C()) { } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/destructuringDeclarationAssignedUnresolved.kt b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/destructuringDeclarationAssignedUnresolved.kt index bfb92ebf8c1..145735a840c 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/destructuringDeclarationAssignedUnresolved.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/destructuringDeclarationAssignedUnresolved.kt @@ -5,7 +5,7 @@ fun useDeclaredVariables() { } fun checkersShouldRun() { - val (@A a, _) = unresolved + val (@A a, _) = unresolved } annotation class A diff --git a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/destructuringDeclarationMissingInitializer.kt b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/destructuringDeclarationMissingInitializer.kt index 93b2c5ec179..b8bb6e327dd 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/destructuringDeclarationMissingInitializer.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/destructuringDeclarationMissingInitializer.kt @@ -5,7 +5,7 @@ fun useDeclaredVariables() { } fun checkersShouldRun() { - val (@A a, _) + val (@A a, _) } annotation class A diff --git a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/underscore.kt b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/underscore.kt index 0649ed01f58..c63a0981800 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/underscore.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/underscore.kt @@ -43,6 +43,8 @@ fun test() { val (_, `_`) = A() foo(_, y) + + val (unused, _) = A() } fun foo(x: Int, y: String) {} diff --git a/compiler/testData/diagnostics/tests/declarationChecks/kt2643MultiDeclInControlFlow.kt b/compiler/testData/diagnostics/tests/declarationChecks/kt2643MultiDeclInControlFlow.kt index 2fe35daada8..dbd6261ea55 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/kt2643MultiDeclInControlFlow.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/kt2643MultiDeclInControlFlow.kt @@ -7,7 +7,7 @@ class C { } fun test1(c: C) { - val (a, b) = c + val (a, b) = c } fun test2(c: C) { @@ -16,7 +16,7 @@ fun test2(c: C) { } fun test3(c: C) { - var (a, b) = c + var (a, b) = c a = 3 } @@ -24,4 +24,4 @@ fun test4(c: C) { var (a, b) = c a = 3 a + 1 -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/functionLiterals/DeprecatedSyntax.kt b/compiler/testData/diagnostics/tests/functionLiterals/DeprecatedSyntax.kt index 257f11a149b..cb4b4cff7a1 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/DeprecatedSyntax.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/DeprecatedSyntax.kt @@ -17,8 +17,8 @@ val none = { -> } val parameterWithFunctionType = { a: ((Int) -> Int) -> } // todo fix parser -val newSyntax = { a: Int -> } -val newSyntax1 = { a, b -> } -val newSyntax2 = { a: Int, b: Int -> } -val newSyntax3 = { a, b: Int -> } -val newSyntax4 = { a: Int, b -> } +val newSyntax = { a: Int -> } +val newSyntax1 = { a, b -> } +val newSyntax2 = { a: Int, b: Int -> } +val newSyntax3 = { a, b: Int -> } +val newSyntax4 = { a: Int, b -> } diff --git a/compiler/testData/diagnostics/tests/functionLiterals/ExpectedParametersTypesMismatch.kt b/compiler/testData/diagnostics/tests/functionLiterals/ExpectedParametersTypesMismatch.kt index 635903ce24f..c22d0ebdda4 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/ExpectedParametersTypesMismatch.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/ExpectedParametersTypesMismatch.kt @@ -9,20 +9,20 @@ fun test1() { "" } foo0 { - s: String-> "" + s: String-> "" } foo0 { - x, y -> "" + x, y -> "" } foo1 { "" } foo1 { - s: String -> "" + s: String -> "" } foo1 { - x, y -> "" + x, y -> "" } foo1 { -> 42 @@ -33,12 +33,12 @@ fun test1() { "" } foo2 { - s: String -> "" + s: String -> "" } foo2 { - x -> "" + x -> "" } foo2 { -> 42 } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/functionLiterals/underscopeParameters.kt b/compiler/testData/diagnostics/tests/functionLiterals/underscopeParameters.kt index 3cc0479a83a..8b1f31b0d4c 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/underscopeParameters.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/underscopeParameters.kt @@ -1,8 +1,7 @@ // !CHECK_TYPE -// !DIAGNOSTICS: -UNUSED_PARAMETER -fun foo(block: (Int, String) -> Unit) { } -fun foobar(block: (Double) -> Unit) { } +fun foo(block: (Int, String) -> Unit) { } +fun foobar(block: (Double) -> Unit) { } fun bar() { foo { _, b -> @@ -41,9 +40,9 @@ fun bar() { _ checkType { _() } } - foo { `_`, `_` -> + foo { `_`, `_` -> _ checkType { _() } } - foo(fun(x: Int, _: String) {}) + foo(fun(x: Int, _: String) {}) } diff --git a/compiler/testData/diagnostics/tests/inference/cannotCompleteResolveFunctionLiteralsNoUse.kt b/compiler/testData/diagnostics/tests/inference/cannotCompleteResolveFunctionLiteralsNoUse.kt index 56579573f90..8baaf32bb96 100644 --- a/compiler/testData/diagnostics/tests/inference/cannotCompleteResolveFunctionLiteralsNoUse.kt +++ b/compiler/testData/diagnostics/tests/inference/cannotCompleteResolveFunctionLiteralsNoUse.kt @@ -3,4 +3,4 @@ package f fun h(i: Int, a: Any, r: R, f: (Boolean) -> Int) = 1 fun h(a: Any, i: Int, r: R, f: (Boolean) -> Int) = 1 -fun test() = h(1, 1, 1, { b -> 42 }) +fun test() = h(1, 1, 1, { b -> 42 }) diff --git a/compiler/testData/diagnostics/tests/inference/cannotCompleteResolveWithFunctionLiterals.kt b/compiler/testData/diagnostics/tests/inference/cannotCompleteResolveWithFunctionLiterals.kt index c5fe2c995c3..d8288f24031 100644 --- a/compiler/testData/diagnostics/tests/inference/cannotCompleteResolveWithFunctionLiterals.kt +++ b/compiler/testData/diagnostics/tests/inference/cannotCompleteResolveWithFunctionLiterals.kt @@ -4,7 +4,7 @@ package f fun h(f: (Boolean) -> R) = 1 fun h(f: (String) -> R) = 2 -fun test() = h{ i -> getAnswer() } +fun test() = h{ i -> getAnswer() } fun getAnswer() = 42 diff --git a/compiler/testData/diagnostics/tests/inference/dependantOnVarianceNullable.kt b/compiler/testData/diagnostics/tests/inference/dependantOnVarianceNullable.kt index 1320e4a0ae2..3c085224cd1 100644 --- a/compiler/testData/diagnostics/tests/inference/dependantOnVarianceNullable.kt +++ b/compiler/testData/diagnostics/tests/inference/dependantOnVarianceNullable.kt @@ -5,10 +5,10 @@ import java.util.* import java.util.Collections.* fun foo(list: List) : String { - val w : String = max(list, comparator {o1, o2 -> 1 + val w : String = max(list, comparator {o1, o2 -> 1 }) return w } //from library -fun comparator(fn: (T,T) -> Int): Comparator {} \ No newline at end of file +fun comparator(fn: (T,T) -> Int): Comparator {} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2283.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2283.kt index 3767ac5d201..81b1c6e507f 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2283.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2283.kt @@ -9,5 +9,5 @@ fun Foo.map(f: (A) -> B): Foo = object : Foo fun foo() { val l: Foo = object : Foo {} - val m: Foo = l.map { ppp -> 1 } -} \ No newline at end of file + val m: Foo = l.map { ppp -> 1 } +} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2741.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2741.kt index c44e0e4a283..2c7845f43f8 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2741.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2741.kt @@ -7,5 +7,5 @@ fun _arrayList(vararg values: T) : List = throw Ex class _Pair(val a: A) fun test() { - _arrayList(_Pair(1))._sortBy { it -> xxx } -} \ No newline at end of file + _arrayList(_Pair(1))._sortBy { it -> xxx } +} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2841.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2841.kt index fc9a779053e..fdfb5762cc3 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2841.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2841.kt @@ -9,7 +9,7 @@ public inline fun T.use1(block: (T)-> R) : R { fun main(args: Array) { C().use1 { - w -> // ERROR here + w -> // ERROR here x } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt3007.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt3007.kt index 0e34c12a33f..97cf4d55edd 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,17 +27,17 @@ 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 }) } //from standard library -fun Iterable.fold(initial: R, operation: (R, T) -> R): R {} \ No newline at end of file +fun Iterable.fold(initial: R, operation: (R, T) -> R): R {} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt3150.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt3150.kt index 64ae0ce8d10..4e00b72f47c 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 a16add61495..51ca71634e0 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/NoAmbiguityForDifferentFunctionTypes.kt b/compiler/testData/diagnostics/tests/inference/reportingImprovements/NoAmbiguityForDifferentFunctionTypes.kt index 7d177138b51..a9097b1fbb5 100644 --- a/compiler/testData/diagnostics/tests/inference/reportingImprovements/NoAmbiguityForDifferentFunctionTypes.kt +++ b/compiler/testData/diagnostics/tests/inference/reportingImprovements/NoAmbiguityForDifferentFunctionTypes.kt @@ -9,7 +9,7 @@ fun T.foo(block: (T, T)-> R) = block fun main(args: Array) { C().foo { // no ambiguity here - www -> + www -> xs } } diff --git a/compiler/testData/diagnostics/tests/inference/reportingImprovements/cannotInferParameterTypeWithInference.kt b/compiler/testData/diagnostics/tests/inference/reportingImprovements/cannotInferParameterTypeWithInference.kt index 4de6f18d421..e628ec731b5 100644 --- a/compiler/testData/diagnostics/tests/inference/reportingImprovements/cannotInferParameterTypeWithInference.kt +++ b/compiler/testData/diagnostics/tests/inference/reportingImprovements/cannotInferParameterTypeWithInference.kt @@ -4,7 +4,7 @@ fun foo(block: (T)-> R) = block fun test1() { foo { - x -> // here we have 'cannot infer parameter type' error + x -> // here we have 'cannot infer parameter type' error 43 } } @@ -12,5 +12,5 @@ fun test1() { fun bar(f: (A)->Unit) {} fun test2() { - bar { a -> } // here we don't have 'cannot infer parameter type' error -} \ No newline at end of file + bar { a -> } // here we don't have 'cannot infer parameter type' error +} diff --git a/compiler/testData/diagnostics/tests/inline/kt4869.kt b/compiler/testData/diagnostics/tests/inline/kt4869.kt index 30c39899275..9c353f4e130 100644 --- a/compiler/testData/diagnostics/tests/inline/kt4869.kt +++ b/compiler/testData/diagnostics/tests/inline/kt4869.kt @@ -1,6 +1,6 @@ inline fun foo(f: () -> Unit) { val ff = { f: () -> Unit -> - + f.invoke() } ff(f) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/j+k/samByProjectedType/genericInReturnType.kt b/compiler/testData/diagnostics/tests/j+k/samByProjectedType/genericInReturnType.kt index 73739fa4536..96c6f57c812 100644 --- a/compiler/testData/diagnostics/tests/j+k/samByProjectedType/genericInReturnType.kt +++ b/compiler/testData/diagnostics/tests/j+k/samByProjectedType/genericInReturnType.kt @@ -19,32 +19,32 @@ public class A { // FILE: main.kt fun main() { A().foo { - x -> 1 + x -> x.hashCode() } A.bar { - x -> 1 + x -> x.hashCode() } // baz A.baz { - x -> "" // OK + x -> x.toString() // OK } A.baz { - x -> 1 + x -> x.hashCode() } val block: (String) -> Any? = { - x -> 1 + x -> x.hashCode() } A().foo(block) A.bar(block) val block2: (String) -> CharSequence? = { - x -> "" + x -> x.toString() } A.baz(block) diff --git a/compiler/testData/diagnostics/tests/j+k/samByProjectedType/noAdapterBecuaseOfRecursiveUpperBound.kt b/compiler/testData/diagnostics/tests/j+k/samByProjectedType/noAdapterBecuaseOfRecursiveUpperBound.kt index 13c1030d12f..f1ee7c75ad7 100644 --- a/compiler/testData/diagnostics/tests/j+k/samByProjectedType/noAdapterBecuaseOfRecursiveUpperBound.kt +++ b/compiler/testData/diagnostics/tests/j+k/samByProjectedType/noAdapterBecuaseOfRecursiveUpperBound.kt @@ -16,12 +16,12 @@ public class A { // FILE: main.kt fun main() { A().foo { - x -> + x -> "" } A.bar { - x -> + x -> "" } } diff --git a/compiler/testData/diagnostics/tests/j+k/samByProjectedType/starProjectionComplexUpperBound.kt b/compiler/testData/diagnostics/tests/j+k/samByProjectedType/starProjectionComplexUpperBound.kt index e8e43ca9485..efd82efc5b7 100644 --- a/compiler/testData/diagnostics/tests/j+k/samByProjectedType/starProjectionComplexUpperBound.kt +++ b/compiler/testData/diagnostics/tests/j+k/samByProjectedType/starProjectionComplexUpperBound.kt @@ -27,7 +27,7 @@ fun main() { "" } - val block: (Map) -> CharSequence = { x -> "" } + val block: (Map) -> CharSequence = { x -> x.toString() } A().foo(block) A.bar(block) } diff --git a/compiler/testData/diagnostics/tests/platformTypes/rawTypes/samRaw.kt b/compiler/testData/diagnostics/tests/platformTypes/rawTypes/samRaw.kt index 4e66f885a44..277f20657ae 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/rawTypes/samRaw.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/rawTypes/samRaw.kt @@ -23,5 +23,5 @@ fun main() { B().foo({ println() }, B.bar()) // So you should use SAM constructors when you want to use mix lambdas and Java objects B().foo(Runnable { println() }, B.bar()) - B().foo({ println() }, { it: Any? -> true } ) + B().foo({ println() }, { it: Any? -> it == null } ) } diff --git a/compiler/testData/diagnostics/tests/platformTypes/samAdapterInConstructor.kt b/compiler/testData/diagnostics/tests/platformTypes/samAdapterInConstructor.kt index 3e752b40890..d79b78a3c00 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/samAdapterInConstructor.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/samAdapterInConstructor.kt @@ -1,4 +1,4 @@ -// !DIAGNOSTICS: -UNUSED_VARIABLE +// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER // FILE: A.java import java.util.Comparator; diff --git a/compiler/testData/diagnostics/tests/regressions/Jet124.kt b/compiler/testData/diagnostics/tests/regressions/Jet124.kt index 6fa400a1acc..0f4751a555f 100644 --- a/compiler/testData/diagnostics/tests/regressions/Jet124.kt +++ b/compiler/testData/diagnostics/tests/regressions/Jet124.kt @@ -3,6 +3,6 @@ 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/shadowing/ShadowMultiDeclarationWithFunParameter.kt b/compiler/testData/diagnostics/tests/shadowing/ShadowMultiDeclarationWithFunParameter.kt index d78e76d48a1..8b49aa2d551 100644 --- a/compiler/testData/diagnostics/tests/shadowing/ShadowMultiDeclarationWithFunParameter.kt +++ b/compiler/testData/diagnostics/tests/shadowing/ShadowMultiDeclarationWithFunParameter.kt @@ -6,9 +6,9 @@ class A { fun foo(a: A, c: Int) { val (a, b) = a val arr = Array(2) { A() } - for ((c, d) in arr) { - + for ((c, d) in arr) { + } val e = a.toString() + b + c -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/samAdapters/GenericClass.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/samAdapters/GenericClass.kt index f4263c59e8c..b088fc9fefc 100644 --- a/compiler/testData/diagnostics/tests/syntheticExtensions/samAdapters/GenericClass.kt +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/samAdapters/GenericClass.kt @@ -1,6 +1,6 @@ // FILE: KotlinFile.kt fun foo(javaClass: JavaClass): String { - return javaClass.doSomething("", 1) { s: String -> "" } + return javaClass.doSomething("", 1) { s: String -> "" } } // FILE: JavaClass.java @@ -10,4 +10,4 @@ public class JavaClass { interface I { T doIt(T t); -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/when/whenAndLambdaWithExpectedType.kt b/compiler/testData/diagnostics/tests/when/whenAndLambdaWithExpectedType.kt index b899b3edb98..7a296977469 100644 --- a/compiler/testData/diagnostics/tests/when/whenAndLambdaWithExpectedType.kt +++ b/compiler/testData/diagnostics/tests/when/whenAndLambdaWithExpectedType.kt @@ -12,13 +12,13 @@ val test2: (String) -> Boolean = val test3: (String) -> Boolean = when { - true -> { s -> true } + true -> { s -> true } else -> null!! } val test4: (String) -> Boolean = when { - true -> { s1, s2 -> true } + true -> { s1, s2 -> true } else -> null!! } diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/dynamicCallsWithLambdas.kt b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/dynamicCallsWithLambdas.kt index 49bc59a1630..4ef4ead4421 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/dynamicCallsWithLambdas.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/dynamicCallsWithLambdas.kt @@ -1,3 +1,4 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER // !CHECK_TYPE fun test(d: dynamic) { diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/JvmSyntheticOnDelegate.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/JvmSyntheticOnDelegate.kt index cd3bf91c917..3ff47f32ea4 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/JvmSyntheticOnDelegate.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/JvmSyntheticOnDelegate.kt @@ -1,3 +1,4 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER import kotlin.properties.Delegates class My { @@ -6,4 +7,4 @@ class My { // Both Ok @get:JvmSynthetic val t: String by lazy { "t" } @set:JvmSynthetic var z: String by Delegates.observable("?") { prop, old, new -> old.hashCode() } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/Volatile.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/Volatile.kt index 086da16157d..b830323693d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/Volatile.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/Volatile.kt @@ -1,3 +1,4 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER import kotlin.jvm.Volatile import kotlin.properties.Delegates @@ -9,4 +10,4 @@ class My { @delegate:Volatile var z: String by Delegates.observable("?") { prop, old, new -> old.hashCode() } @field:Volatile val w = 2 -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/functionLiterals/pseudocodeMemoryOverhead.kt b/compiler/testData/diagnostics/testsWithStdLib/functionLiterals/pseudocodeMemoryOverhead.kt index 45f0b25965e..b93b78861ec 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/functionLiterals/pseudocodeMemoryOverhead.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/functionLiterals/pseudocodeMemoryOverhead.kt @@ -33,8 +33,8 @@ private val STRING = CompileTimeType() private val ANY = CompileTimeType() -private val emptyBinaryFun: Function2 = { a, b -> BigInteger("0") } -private val emptyUnaryFun: Function1 = { a -> 1.toLong() } +private val emptyBinaryFun: Function2 = { a, b -> BigInteger("0") } +private val emptyUnaryFun: Function1 = { a -> 1.toLong() } private val unaryOperations: HashMap, Pair, Function1>> = hashMapOf, Pair, Function1>>( @@ -368,4 +368,4 @@ class BigInteger(val value: String) { fun or(o: BigInteger): BigInteger = o fun and(o: BigInteger): BigInteger = o fun xor(o: BigInteger): BigInteger = o -} \ No newline at end of file +} diff --git a/idea/testData/checker/Shadowing.kt b/idea/testData/checker/Shadowing.kt index f3e157134ce..cf101cb141e 100644 --- a/idea/testData/checker/Shadowing.kt +++ b/idea/testData/checker/Shadowing.kt @@ -5,15 +5,15 @@ class A { fun arrayA(): Array = null!! -fun foo(a: A, c: Int) { - val (a, b) = a +fun foo(a: A, c: Int) { + val (a, b) = a val arr = arrayA() - for ((c, d) in arr) { + for ((c, d) in arr) { } } -fun f(p: Int): Int { - val p = 2 - val p = 3 +fun f(p: Int): Int { + val p = 2 + val p = 3 return p -} \ No newline at end of file +} diff --git a/idea/testData/checker/regression/DescructuringDeclarationInForLoop.kt b/idea/testData/checker/regression/DescructuringDeclarationInForLoop.kt index 8e00f614888..8316ff4f40f 100644 --- a/idea/testData/checker/regression/DescructuringDeclarationInForLoop.kt +++ b/idea/testData/checker/regression/DescructuringDeclarationInForLoop.kt @@ -1,3 +1,3 @@ fun main() { - for ((i, j)) {} -} \ No newline at end of file + for ((i, j)) {} +} diff --git a/idea/testData/checker/regression/Jet124.kt b/idea/testData/checker/regression/Jet124.kt index dae33e40d21..9e24d258511 100644 --- a/idea/testData/checker/regression/Jet124.kt +++ b/idea/testData/checker/regression/Jet124.kt @@ -3,6 +3,6 @@ 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 +}