Add assertion for variable as function call with explicit type parameters.

This commit is contained in:
Stanislav Erokhin
2016-07-25 14:14:20 +03:00
parent b56e84d47f
commit f3be1b8f1f
6 changed files with 5 additions and 17 deletions
@@ -42,7 +42,7 @@ class OperatorCallChecker : CallChecker {
if (resolvedCall is VariableAsFunctionResolvedCall &&
call is CallTransformer.CallForImplicitInvoke && call.itIsVariableAsFunctionCall) {
val outerCall = call.outerCall
if (isConventionCall(outerCall)) {
if (isConventionCall(outerCall) || outerCall.typeArguments.isNotEmpty()) {
throw AssertionError("Illegal resolved call to variable with invoke for $outerCall. " +
"Variable: ${resolvedCall.variableCall.resultingDescriptor}")
}
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.util.OperatorNameConventions
class ReplaceInvokeIntention : SelfTargetingRangeIntention<KtDotQualifiedExpression>(KtDotQualifiedExpression::class.java, "Replace 'invoke' with direct call"), HighPriorityAction {
override fun applicabilityRange(element: KtDotQualifiedExpression): TextRange? {
if (element.calleeName != OperatorNameConventions.INVOKE.asString()) return null
if (element.calleeName != OperatorNameConventions.INVOKE.asString() || element.callExpression?.typeArgumentList != null) return null
return element.callExpression!!.calleeExpression!!.textRange
}
@@ -1,3 +1,4 @@
// IS_APPLICABLE: false
fun test() {
class Test {
operator fun <T> invoke(a: Int) {}
@@ -1,7 +0,0 @@
fun test() {
class Test {
operator fun <T> invoke(a: Int) {}
}
val test = Test()
test<Int>(0)
}
@@ -1,3 +1,4 @@
// IS_APPLICABLE: false
fun test() {
class Test {
operator fun <T> invoke(fn: () -> T) {}
@@ -1,7 +0,0 @@
fun test() {
class Test {
operator fun <T> invoke(fn: () -> T) {}
}
val test = Test()
test<Int> { 0 }
}