diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/ReifiedTypeParameterSubstitutionChecker.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/ReifiedTypeParameterSubstitutionChecker.java index 6b1f846602a..70990227b63 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/ReifiedTypeParameterSubstitutionChecker.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/ReifiedTypeParameterSubstitutionChecker.java @@ -46,18 +46,22 @@ public class ReifiedTypeParameterSubstitutionChecker implements CallChecker { !((TypeParameterDescriptor) argumentDeclarationDescription).isReified() ) { context.trace.report( - Errors.TYPE_PARAMETER_AS_REIFIED.on(getCallElement(context), parameter) + Errors.TYPE_PARAMETER_AS_REIFIED.on(getElementToReport(context, parameter.getIndex()), parameter) ); } else if (TypeUtilsKt.cannotBeReified(argument)) { - context.trace.report(Errors.REIFIED_TYPE_FORBIDDEN_SUBSTITUTION.on(getCallElement(context), argument)); + context.trace.report( + Errors.REIFIED_TYPE_FORBIDDEN_SUBSTITUTION.on(getElementToReport(context, parameter.getIndex()), argument)); } } } } @NotNull - private static PsiElement getCallElement(@NotNull BasicCallResolutionContext context) { + private static PsiElement getElementToReport(@NotNull BasicCallResolutionContext context, int parameterIndex) { + if (context.call.getTypeArguments().size() > parameterIndex) { + return context.call.getTypeArguments().get(parameterIndex); + } KtExpression callee = context.call.getCalleeExpression(); return callee != null ? callee : context.call.getCallElement(); } diff --git a/compiler/testData/diagnostics/tests/generics/tpAsReified/InConstructor.kt b/compiler/testData/diagnostics/tests/generics/tpAsReified/InConstructor.kt index 24641a0eaca..a70b1a88fb6 100644 --- a/compiler/testData/diagnostics/tests/generics/tpAsReified/InConstructor.kt +++ b/compiler/testData/diagnostics/tests/generics/tpAsReified/InConstructor.kt @@ -6,7 +6,7 @@ fun main() { C() val a: C = C() - C() + C<A>() val b: C = C() C() diff --git a/compiler/testData/diagnostics/tests/generics/tpAsReified/InFunction.kt b/compiler/testData/diagnostics/tests/generics/tpAsReified/InFunction.kt index e673b9e1fa5..e617acb2794 100644 --- a/compiler/testData/diagnostics/tests/generics/tpAsReified/InFunction.kt +++ b/compiler/testData/diagnostics/tests/generics/tpAsReified/InFunction.kt @@ -8,7 +8,7 @@ fun main() { f() val a: A = f() - f() + f<A>() val b: Int = f() f() diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/reified.kt b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/reified.kt index 2f0513f6bdb..2699a109364 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/reified.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/reified.kt @@ -4,9 +4,9 @@ fun foo(t: T) {} class C(t: T) fun test(d: dynamic) { - foo(d) + foo<dynamic>(d) foo(d) - C(d) + C<dynamic>(d) C(d) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/ArrayOfNothing.kt b/compiler/testData/diagnostics/testsWithStdLib/ArrayOfNothing.kt index 7046e50f6db..20422b72462 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/ArrayOfNothing.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/ArrayOfNothing.kt @@ -38,8 +38,8 @@ fun test4( ) {} fun test5() { - arrayOf() - Array(10) { throw Exception() } + arrayOf<Nothing>() + Array<Nothing>(10) { throw Exception() } } fun foo(): Array = (object {} as Any) as Array diff --git a/compiler/testData/diagnostics/testsWithStdLib/reified/arrayConstruction.kt b/compiler/testData/diagnostics/testsWithStdLib/reified/arrayConstruction.kt index e137ae8a6ca..6c46aac5dc2 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/reified/arrayConstruction.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/reified/arrayConstruction.kt @@ -4,7 +4,7 @@ fun ok1(block: () -> Array): Array = block() inline fun ok2(): Array = Array(1) { null!! } -fun fail2(): Array = ok1 { Array(1) { null!! } } +fun fail2(): Array = ok1 { Array<T>(1) { null!! } } fun ok3(block: () -> Array): Array = ok1 { block() } inline fun ok4(): Array = ok1 { Array(1) { null!! } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/reified/arrayOfNullsReified.kt b/compiler/testData/diagnostics/testsWithStdLib/reified/arrayOfNullsReified.kt index 83e9bfe9ceb..573db585717 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/reified/arrayOfNullsReified.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/reified/arrayOfNullsReified.kt @@ -1,7 +1,7 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE fun foo() { - val x = arrayOfNulls(5) + val x = arrayOfNulls<T>(5) } inline fun bar() { diff --git a/compiler/testData/diagnostics/testsWithStdLib/reified/reifiedNothingSubstitution.kt b/compiler/testData/diagnostics/testsWithStdLib/reified/reifiedNothingSubstitution.kt index 23ab125c796..c16e6b28ba5 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/reified/reifiedNothingSubstitution.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/reified/reifiedNothingSubstitution.kt @@ -6,11 +6,11 @@ inline fun javaClass(): Class = T::class.java fun box() { val a = arrayOf(null!!) - val b = Array(5) { null!! } + val b = Array<Nothing?>(5) { null!! } val c = foo() { null!! } val d = foo { null!! } val e = foo { "1" as Nothing } val e1 = foo { "1" as Nothing? } - val f = javaClass() + val f = javaClass<Nothing>() }