JS: prohibit dynamic on RHS of in and !in operators (see KT-6579)
This commit is contained in:
@@ -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"))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user