diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index a6a6dd973be..0b2b7f55112 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -489,7 +489,7 @@ public interface Errors { DiagnosticFactory0 TYPE_INFERENCE_INCORPORATION_ERROR = DiagnosticFactory0.create(ERROR); DiagnosticFactory1 TYPE_INFERENCE_ONLY_INPUT_TYPES = DiagnosticFactory1.create(ERROR); DiagnosticFactory1 TYPE_INFERENCE_UPPER_BOUND_VIOLATED = DiagnosticFactory1.create(ERROR); - DiagnosticFactory2 TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR); + DiagnosticFactory2 TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR); // Reflection diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index ce6ae995e63..13741f7b8f1 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -609,7 +609,7 @@ public class DefaultErrorMessages { MAP.put(TYPE_INFERENCE_ONLY_INPUT_TYPES, "Type inference failed. The value of the type parameter {0} should be mentioned in input types " + "(argument types, receiver type or expected type). Try to specify it explicitly.", NAME); MAP.put(TYPE_INFERENCE_UPPER_BOUND_VIOLATED, "{0}", TYPE_INFERENCE_UPPER_BOUND_VIOLATED_RENDERER); - MAP.put(TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, "Type inference failed. Expected type mismatch: found: {1} required: {0}", RENDER_TYPE, RENDER_TYPE); + MAP.put(TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, "Type inference failed. Expected type mismatch: inferred type is {1} but {0} was expected", RENDER_TYPE, RENDER_TYPE); MAP.put(WRONG_NUMBER_OF_TYPE_ARGUMENTS, "{0,choice,0#No type arguments|1#Type argument|1<{0,number,integer} type arguments} expected", (Renderer) null); MAP.put(NO_TYPE_ARGUMENTS_ON_RHS, "{0,choice,0#No type arguments|1#Type argument|1<{0,number,integer} type arguments} expected. " + diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/AbstractTracingStrategy.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/AbstractTracingStrategy.java index e4072d8a711..e35b5294805 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/AbstractTracingStrategy.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/AbstractTracingStrategy.java @@ -225,7 +225,7 @@ public abstract class AbstractTracingStrategy implements TracingStrategy { assert substitutedReturnType != null; //todo assert !noExpectedType(data.expectedType) : "Expected type doesn't exist, but there is an expected type mismatch error"; - trace.report(TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH.on(reference, data.expectedType, substitutedReturnType)); + trace.report(TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH.on(call.getCallElement(), data.expectedType, substitutedReturnType)); } else if (status.hasCannotCaptureTypesError()) { trace.report(TYPE_INFERENCE_CANNOT_CAPTURE_TYPES.on(reference, data)); diff --git a/compiler/testData/diagnostics/tests/delegation/DelegationExpectedType.kt b/compiler/testData/diagnostics/tests/delegation/DelegationExpectedType.kt index 98255091ab1..137784e3065 100644 --- a/compiler/testData/diagnostics/tests/delegation/DelegationExpectedType.kt +++ b/compiler/testData/diagnostics/tests/delegation/DelegationExpectedType.kt @@ -20,6 +20,6 @@ class D : A by baz({ it + 1 }) fun boo(t: T): A = AImpl() -class E : A by boo("") +class E : A by boo("") class F : A by AImpl() \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/functionLiterals/assignmentOperationInLambdaWithExpectedType.kt b/compiler/testData/diagnostics/tests/functionLiterals/assignmentOperationInLambdaWithExpectedType.kt index f054b9ca105..2bf117dbd0f 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/assignmentOperationInLambdaWithExpectedType.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/assignmentOperationInLambdaWithExpectedType.kt @@ -11,6 +11,6 @@ fun test(bal: Array) { val e: Unit = run { bar += 4 } - val f: Int = run { bar += 4 } + val f: Int = run { bar += 4 } } fun run(f: () -> T): T = f() \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/functionLiterals/return/SmartCastWithExplicitType.kt b/compiler/testData/diagnostics/tests/functionLiterals/return/SmartCastWithExplicitType.kt index 6a08a9c651c..759fecc30ed 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/return/SmartCastWithExplicitType.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/return/SmartCastWithExplicitType.kt @@ -7,10 +7,10 @@ val a : (Int?) -> Int = l@ { fun let(f: (Int?) -> R): R = null!! -val b: Int = let { +val b: Int = let { if (it != null) return@let it 5 -} +} val c: Int = let { if (it != null) it else 5 diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/expectedTypeMismatchWithInVariance.kt b/compiler/testData/diagnostics/tests/inference/capturedTypes/expectedTypeMismatchWithInVariance.kt index 391d95f276c..7ae561ce4d3 100644 --- a/compiler/testData/diagnostics/tests/inference/capturedTypes/expectedTypeMismatchWithInVariance.kt +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/expectedTypeMismatchWithInVariance.kt @@ -4,6 +4,6 @@ fun foo(a1: Array, a2: Array): T = null!! fun test(a1: Array, a2: Array) { - val c: Int = foo(a1, a2) + val c: Int = foo(a1, a2) } diff --git a/compiler/testData/diagnostics/tests/inference/constraints/kt6320.kt b/compiler/testData/diagnostics/tests/inference/constraints/kt6320.kt index fd2b06233bc..927c9e165a2 100644 --- a/compiler/testData/diagnostics/tests/inference/constraints/kt6320.kt +++ b/compiler/testData/diagnostics/tests/inference/constraints/kt6320.kt @@ -15,6 +15,6 @@ class C class D(foo: C) { fun test(a: C) { - val d: D = D(a) + val d: D = D(a) } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/dependantOnVariance.kt b/compiler/testData/diagnostics/tests/inference/dependantOnVariance.kt index c215f6c0f09..56381cffdac 100644 --- a/compiler/testData/diagnostics/tests/inference/dependantOnVariance.kt +++ b/compiler/testData/diagnostics/tests/inference/dependantOnVariance.kt @@ -13,7 +13,7 @@ fun readFromMyList(l: MyList, = getMyList(int) - val a1 : MyList = getMyList(any) + val a1 : MyList = getMyList(any) val a2 : MyList = getMyList(int) @@ -28,13 +28,13 @@ fun test1(int: Int, any: Any) { val a7 : MyList = getMyList(int) val a8 : MyList = getMyListToReadFrom(int) - val a9 : MyList = getMyListToReadFrom(int) + val a9 : MyList = getMyListToReadFrom(int) val a10 : MyList = getMyList(any) - val a11 : MyList = getMyList(any) + val a11 : MyList = getMyList(any) val a12 : MyList = getMyListToWriteTo(any) - val a13 : MyList = getMyListToWriteTo(any) + val a13 : MyList = getMyListToWriteTo(any) useMyList(getMyList(int), int) useMyList(getMyList(any), int) @@ -42,9 +42,9 @@ fun test1(int: Int, any: Any) { readFromMyList(getMyList(int), any) readFromMyList(getMyList(any), int) - readFromMyList(getMyList(any), int) + readFromMyList(getMyList(any), int) - readFromMyList(getMyListToReadFrom(any), int) + readFromMyList(getMyListToReadFrom(any), int) readFromMyList(getMyListToReadFrom(any), int) readFromMyList(getMyListToReadFrom(int), any) diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2283.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2283.kt index 885332963fc..3767ac5d201 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 } + val m: Foo = l.map { ppp -> 1 } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2883.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2883.kt index 9257e38298d..655fc075a15 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2883.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2883.kt @@ -21,7 +21,7 @@ fun test() { doAction { bar(12) } - val u: Unit = bar(11) + val u: Unit = bar(11) } fun testWithoutInference(col: MutableCollection) { diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt731.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt731.kt index cfca4026897..2a425761287 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt731.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt731.kt @@ -13,6 +13,6 @@ fun A.foo(x: (T)-> G): G { fun main(args: Array) { val a = A(1) - val t: String = a.foo({p -> p}) + val t: String = a.foo({p -> p}) checkSubtype(t) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/typeInferenceExpectedTypeMismatch.kt b/compiler/testData/diagnostics/tests/inference/typeInferenceExpectedTypeMismatch.kt index 05b98feb704..bb82cbf7d16 100644 --- a/compiler/testData/diagnostics/tests/inference/typeInferenceExpectedTypeMismatch.kt +++ b/compiler/testData/diagnostics/tests/inference/typeInferenceExpectedTypeMismatch.kt @@ -3,7 +3,7 @@ package typeInferenceExpectedTypeMismatch import java.util.* fun test() { - val s : Set = newList() + val s : Set = newList() use(s) } @@ -25,7 +25,7 @@ fun foo(o: Out, i: In): Two = throw Exception("$o $i") fun test1(outA: Out, inB: In) { foo(outA, inB) - val b: Two = foo(outA, inB) + val b: Two = foo(outA, inB) use(b) } diff --git a/compiler/testData/diagnostics/tests/numbers/doublesInSimpleConstraints.kt b/compiler/testData/diagnostics/tests/numbers/doublesInSimpleConstraints.kt index afc39d73c97..6aae023b514 100644 --- a/compiler/testData/diagnostics/tests/numbers/doublesInSimpleConstraints.kt +++ b/compiler/testData/diagnostics/tests/numbers/doublesInSimpleConstraints.kt @@ -18,5 +18,5 @@ fun test() { val d = either(11, 2.3) checkSubtype(d) - val e: Float = id(1) + val e: Float = id(1) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/numbers/numbersInSimpleConstraints.kt b/compiler/testData/diagnostics/tests/numbers/numbersInSimpleConstraints.kt index 24bbfefba0c..6f9c3a2b0f5 100644 --- a/compiler/testData/diagnostics/tests/numbers/numbersInSimpleConstraints.kt +++ b/compiler/testData/diagnostics/tests/numbers/numbersInSimpleConstraints.kt @@ -12,9 +12,9 @@ fun otherGeneric(l: List) {} fun test() { val a: Byte = id(1) - val b: Byte = id(300) + val b: Byte = id(300) - val c: Int = id(9223372036854775807) + val c: Int = id(9223372036854775807) val d = id(22) checkSubtype(d) @@ -24,7 +24,7 @@ fun test() { val f: Byte = either(1, 2) - val g: Byte = either(1, 300) + val g: Byte = either(1, 300) other(11) diff --git a/compiler/testData/diagnostics/tests/platformTypes/methodCall/singleton.kt b/compiler/testData/diagnostics/tests/platformTypes/methodCall/singleton.kt index d03b13d7efd..3258b755a55 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/methodCall/singleton.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/methodCall/singleton.kt @@ -4,6 +4,6 @@ interface Foo fun test() { var nullable: Foo? = null - val foo: Collection = java.util.Collections.singleton(nullable) + val foo: Collection = java.util.Collections.singleton(nullable) val foo1: Collection = java.util.Collections.singleton(nullable!!) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/constructorCallType.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/constructorCallType.kt index 813262f1d1c..2db834b529a 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/constructorCallType.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/constructorCallType.kt @@ -19,7 +19,7 @@ val y4: B = B("") val y5: B = B(1) val y6: B = B("") // TODO: doesn't work here but ok on y8 -val y7: B = B(1) +val y7: B = B(1) val y8: B = B("") val y9 = B(1) diff --git a/compiler/testData/diagnostics/tests/smartCasts/inference/intersectionTypes.kt b/compiler/testData/diagnostics/tests/smartCasts/inference/intersectionTypes.kt index 4868d1058f5..39a207bd979 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/inference/intersectionTypes.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/inference/intersectionTypes.kt @@ -28,7 +28,7 @@ fun test(a: A, b: B, c: C) { val k = three(a, b, c) checkSubtype(k) checkSubtype(k) - val l: Int = three(a, b, c) + val l: Int = three(a, b, c) use(d, e, f, g, h, k, l) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.kt index a99a0722e32..d312d4d4e51 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.kt @@ -4,6 +4,6 @@ public @interface A { } // FILE: b.kt -@A(*; IGNORE)!>arrayOf(1, "b")) +@A(*; IGNORE)!>arrayOf(1, "b")) fun test() { } diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.kt index 4ddd7c32fd8..40e6133d414 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.kt @@ -1,5 +1,5 @@ annotation class B(vararg val args: String) -@B(*; IGNORE)!>arrayOf(1, "b")) +@B(*; IGNORE)!>arrayOf(1, "b")) fun test() { } diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsInVariance.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsInVariance.kt index 0014e8ad887..9443c6f0727 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsInVariance.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsInVariance.kt @@ -12,7 +12,7 @@ class MyClass1 @Ann1(arrayOf(Any::class)) class MyClass1a -@Ann1(arrayOf(B1::class)) +@Ann1(arrayOf(B1::class)) class MyClass2 annotation class Ann2(val arg: Array>) @@ -23,5 +23,5 @@ class MyClass3 @Ann2(arrayOf(B1::class)) class MyClass4 -@Ann2(arrayOf(B2::class)) +@Ann2(arrayOf(B2::class)) class MyClass5 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsOutVariance.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsOutVariance.kt index dbb0f113361..4976275b38f 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsOutVariance.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsOutVariance.kt @@ -9,7 +9,7 @@ annotation class Ann1(val arg: Array>) @Ann1(arrayOf(A::class)) class MyClass1 -@Ann1(arrayOf(Any::class)) +@Ann1(arrayOf(Any::class)) class MyClass1a @Ann1(arrayOf(B1::class)) @@ -17,11 +17,11 @@ class MyClass2 annotation class Ann2(val arg: Array>) -@Ann2(arrayOf(A::class)) +@Ann2(arrayOf(A::class)) class MyClass3 @Ann2(arrayOf(B1::class)) class MyClass4 -@Ann2(arrayOf(B2::class)) +@Ann2(arrayOf(B2::class)) class MyClass5 diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotation.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotation.kt index fa0b6e23ca7..96cb7aaeec5 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotation.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotation.kt @@ -7,5 +7,5 @@ fun test1(l: List) { val i: Int = l.firstTyped() - val s: String = l.firstTyped() + val s: String = l.firstTyped() } \ No newline at end of file diff --git a/j2k/testData/fileOrElement/typeParameters/rawTypeCast.kt b/j2k/testData/fileOrElement/typeParameters/rawTypeCast.kt index 762e005b5f9..f2726387a4c 100644 --- a/j2k/testData/fileOrElement/typeParameters/rawTypeCast.kt +++ b/j2k/testData/fileOrElement/typeParameters/rawTypeCast.kt @@ -1,4 +1,4 @@ -// ERROR: Type inference failed. Expected type mismatch: found: java.util.HashMap required: kotlin.Map +// ERROR: Type inference failed. Expected type mismatch: inferred type is java.util.HashMap but kotlin.Map was expected import java.util.* internal object A {