JS: prohibit dynamic on RHS of in and !in operators (see KT-6579)

This commit is contained in:
Alexey Andreev
2016-12-08 17:31:20 +03:00
parent fc6eaa015f
commit a2d45153ba
9 changed files with 34 additions and 73 deletions
@@ -18,9 +18,12 @@ package org.jetbrains.kotlin.js.resolve.diagnostics
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.psi.KtArrayAccessExpression
import org.jetbrains.kotlin.psi.KtBinaryExpression
import org.jetbrains.kotlin.psi.KtWhenConditionInRange
import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker
import org.jetbrains.kotlin.resolve.calls.checkers.CallCheckerContext
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.types.expressions.OperatorConventions
import org.jetbrains.kotlin.types.isDynamic
object JsDynamicCallChecker : CallChecker {
@@ -32,5 +35,11 @@ object JsDynamicCallChecker : CallChecker {
if (element is KtArrayAccessExpression && element.indexExpressions.size > 1) {
context.trace.report(ErrorsJs.WRONG_OPERATION_WITH_DYNAMIC.on(reportOn, "indexed access with more than one index"))
}
if (element is KtBinaryExpression && element.operationToken in OperatorConventions.IN_OPERATIONS ||
element is KtWhenConditionInRange
) {
context.trace.report(ErrorsJs.WRONG_OPERATION_WITH_DYNAMIC.on(reportOn, "`in` operation"))
}
}
}