Add assertion for variable as function call with explicit type parameters.
This commit is contained in:
+1
-1
@@ -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}")
|
||||
}
|
||||
|
||||
+2
-2
@@ -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
@@ -1,3 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun <T> invoke(a: Int) {}
|
||||
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun <T> invoke(a: Int) {}
|
||||
}
|
||||
val test = Test()
|
||||
test<Int>(0)
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun <T> invoke(fn: () -> T) {}
|
||||
|
||||
Vendored
-7
@@ -1,7 +0,0 @@
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun <T> invoke(fn: () -> T) {}
|
||||
}
|
||||
val test = Test()
|
||||
test<Int> { 0 }
|
||||
}
|
||||
Reference in New Issue
Block a user