Minor, remove unnecessary type parameter in CallChecker#check

This commit is contained in:
Alexander Udalov
2016-03-16 11:24:50 +03:00
parent 2c81824689
commit 3944d56ac2
18 changed files with 35 additions and 64 deletions
@@ -16,33 +16,23 @@
package org.jetbrains.kotlin.load.kotlin
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory0
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
import org.jetbrains.kotlin.load.java.components.JavaAnnotationMapper
import org.jetbrains.kotlin.load.java.descriptors.JavaConstructorDescriptor
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.FqNameUnsafe
import org.jetbrains.kotlin.psi.KtAnnotationEntry
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
import org.jetbrains.kotlin.resolve.calls.model.ExpressionValueArgument
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeUtils
import java.lang.annotation.Target
class JavaAnnotationCallChecker : CallChecker {
override fun <F : CallableDescriptor> check(resolvedCall: ResolvedCall<F>, context: BasicCallResolutionContext) {
override fun check(resolvedCall: ResolvedCall<*>, context: BasicCallResolutionContext) {
val resultingDescriptor = resolvedCall.resultingDescriptor.original
if (resultingDescriptor !is JavaConstructorDescriptor ||
resultingDescriptor.containingDeclaration.kind != ClassKind.ANNOTATION_CLASS) return
@@ -59,10 +49,7 @@ class JavaAnnotationCallChecker : CallChecker {
}
}
private fun reportErrorsOnPositionedArguments(
resolvedCall: ResolvedCall<*>,
context: BasicCallResolutionContext
) {
private fun reportErrorsOnPositionedArguments(resolvedCall: ResolvedCall<*>, context: BasicCallResolutionContext) {
getJavaAnnotationCallValueArgumentsThatShouldBeNamed(resolvedCall).forEach {
reportOnValueArgument(context, it, ErrorsJvm.POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION)
}
@@ -16,7 +16,6 @@
package org.jetbrains.kotlin.resolve.jvm.checkers
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
@@ -29,7 +28,7 @@ import org.jetbrains.kotlin.types.KotlinTypeImpl
import org.jetbrains.kotlin.types.TypeProjectionImpl
class JavaClassOnCompanionChecker : CallChecker {
override fun <F : CallableDescriptor> check(resolvedCall: ResolvedCall<F>, context: BasicCallResolutionContext) {
override fun check(resolvedCall: ResolvedCall<*>, context: BasicCallResolutionContext) {
val descriptor = resolvedCall.resultingDescriptor
if (descriptor !is PropertyDescriptor || descriptor.name.asString() != "javaClass") return
@@ -16,7 +16,6 @@
package org.jetbrains.kotlin.resolve.jvm.checkers
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.resolve.DescriptorUtils
@@ -28,8 +27,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.parentsWithSelf
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
class ProtectedInSuperClassCompanionCallChecker : CallChecker {
override fun <F : CallableDescriptor> check(resolvedCall: ResolvedCall<F>, context: BasicCallResolutionContext) {
override fun check(resolvedCall: ResolvedCall<*>, context: BasicCallResolutionContext) {
val targetDescriptor = resolvedCall.resultingDescriptor.original
// Protected non-JVM static
if (targetDescriptor.visibility != Visibilities.PROTECTED) return
@@ -48,4 +46,4 @@ class ProtectedInSuperClassCompanionCallChecker : CallChecker {
}
}
}
}
}
@@ -17,7 +17,6 @@
package org.jetbrains.kotlin.resolve.jvm.checkers
import org.jetbrains.kotlin.builtins.ReflectionTypes
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.load.java.JvmAbi
@@ -45,7 +44,7 @@ class ReflectionAPICallChecker(private val module: ModuleDescriptor, storageMana
setOf(reflectionTypes.kProperty0, reflectionTypes.kProperty1, reflectionTypes.kProperty2)
}
override fun <F : CallableDescriptor> check(resolvedCall: ResolvedCall<F>, context: BasicCallResolutionContext) {
override fun check(resolvedCall: ResolvedCall<*>, context: BasicCallResolutionContext) {
if (isReflectionAvailable) return
val descriptor = resolvedCall.resultingDescriptor
@@ -16,7 +16,6 @@
package org.jetbrains.kotlin.resolve.jvm.checkers
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.getSuperCallExpression
import org.jetbrains.kotlin.resolve.calls.callUtil.usesDefaultArguments
import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker
@@ -25,9 +24,9 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
class SuperCallWithDefaultArgumentsChecker : CallChecker {
override fun <F : CallableDescriptor> check(resolvedCall: ResolvedCall<F>, context: BasicCallResolutionContext) {
override fun check(resolvedCall: ResolvedCall<*>, context: BasicCallResolutionContext) {
val superCallExpression = getSuperCallExpression(resolvedCall.call)
if (superCallExpression == null || !resolvedCall.usesDefaultArguments()) return
context.trace.report(ErrorsJvm.SUPER_CALL_WITH_DEFAULT_PARAMETERS.on(superCallExpression.parent, resolvedCall.resultingDescriptor.name.asString()))
}
}
}
@@ -17,7 +17,6 @@
package org.jetbrains.kotlin.resolve.jvm.checkers
import com.intellij.psi.util.PsiTreeUtil
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
import org.jetbrains.kotlin.psi.KtExpression
@@ -30,8 +29,8 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
class TraitDefaultMethodCallChecker : CallChecker {
override fun <F : CallableDescriptor> check(resolvedCall: ResolvedCall<F>, context: BasicCallResolutionContext) {
if (getSuperCallExpression(resolvedCall.getCall()) == null) return
override fun check(resolvedCall: ResolvedCall<*>, context: BasicCallResolutionContext) {
if (getSuperCallExpression(resolvedCall.call) == null) return
val targetDescriptor = resolvedCall.resultingDescriptor.original
val containerDescriptor = targetDescriptor.containingDeclaration
@@ -16,7 +16,6 @@
package org.jetbrains.kotlin.resolve.jvm.checkers
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.diagnostics.Errors.UNSUPPORTED
import org.jetbrains.kotlin.psi.KtCallableReferenceExpression
import org.jetbrains.kotlin.psi.KtNameReferenceExpression
@@ -26,7 +25,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
class UnsupportedSyntheticCallableReferenceChecker : CallChecker {
override fun <F : CallableDescriptor> check(resolvedCall: ResolvedCall<F>, context: BasicCallResolutionContext) {
override fun check(resolvedCall: ResolvedCall<*>, context: BasicCallResolutionContext) {
val expression = context.call.callElement
if (expression !is KtNameReferenceExpression || expression.parent !is KtCallableReferenceExpression) return
@@ -16,7 +16,6 @@
package org.jetbrains.kotlin.resolve
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
import org.jetbrains.kotlin.diagnostics.Errors
@@ -31,7 +30,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.Receiver
import org.jetbrains.kotlin.resolve.scopes.utils.parentsWithSelf
object ConstructorHeaderCallChecker : CallChecker {
override fun <F : CallableDescriptor> check(resolvedCall: ResolvedCall<F>, context: BasicCallResolutionContext) {
override fun check(resolvedCall: ResolvedCall<*>, context: BasicCallResolutionContext) {
val dispatchReceiverClass = resolvedCall.dispatchReceiver.classDescriptorForImplicitReceiver
val extensionReceiverClass = resolvedCall.extensionReceiver.classDescriptorForImplicitReceiver
@@ -16,10 +16,9 @@
package org.jetbrains.kotlin.resolve.calls.checkers
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
interface CallChecker {
fun <F : CallableDescriptor> check(resolvedCall: ResolvedCall<F>, context: BasicCallResolutionContext)
fun check(resolvedCall: ResolvedCall<*>, context: BasicCallResolutionContext)
}
@@ -16,7 +16,6 @@
package org.jetbrains.kotlin.resolve.calls.checkers
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
@@ -25,7 +24,7 @@ import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.typeUtil.isArrayOfNothing
class CallReturnsArrayOfNothingChecker : CallChecker {
override fun <F : CallableDescriptor> check(resolvedCall: ResolvedCall<F>, context: BasicCallResolutionContext) {
override fun check(resolvedCall: ResolvedCall<*>, context: BasicCallResolutionContext) {
val returnType = resolvedCall.resultingDescriptor.returnType
if (returnType.containsArrayOfNothing()) {
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.resolve.scopes.LexicalScope
import org.jetbrains.kotlin.types.expressions.CaptureKind
class CapturingInClosureChecker : CallChecker {
override fun <F : CallableDescriptor> check(resolvedCall: ResolvedCall<F>, context: BasicCallResolutionContext) {
override fun check(resolvedCall: ResolvedCall<*>, context: BasicCallResolutionContext) {
val variableResolvedCall = if (resolvedCall is VariableAsFunctionResolvedCall) resolvedCall.variableCall else resolvedCall
val variableDescriptor = variableResolvedCall.resultingDescriptor as? VariableDescriptor
if (variableDescriptor != null) {
@@ -75,5 +75,3 @@ class CapturingInClosureChecker : CallChecker {
return false
}
}
@@ -67,7 +67,7 @@ class InlineChecker implements CallChecker {
}
@Override
public <F extends CallableDescriptor> void check(@NotNull ResolvedCall<F> resolvedCall, @NotNull BasicCallResolutionContext context) {
public void check(@NotNull ResolvedCall<?> resolvedCall, @NotNull BasicCallResolutionContext context) {
KtExpression expression = context.call.getCalleeExpression();
if (expression == null) {
return;
@@ -16,7 +16,6 @@
package org.jetbrains.kotlin.resolve.calls.checkers
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
@@ -27,7 +26,7 @@ import java.lang.ref.WeakReference
class InlineCheckerWrapper : CallChecker {
private var checkersCache: WeakReference<MutableMap<DeclarationDescriptor, CallChecker>>? = null
override fun <F : CallableDescriptor> check(resolvedCall: ResolvedCall<F>, context: BasicCallResolutionContext) {
override fun check(resolvedCall: ResolvedCall<*>, context: BasicCallResolutionContext) {
if (context.isAnnotationContext) return
var parentDescriptor: DeclarationDescriptor? = context.scope.ownerDescriptor
@@ -47,4 +46,4 @@ class InlineCheckerWrapper : CallChecker {
checkersCache = checkersCache ?: WeakReference(map)
return map.getOrPut(descriptor) { InlineChecker(descriptor) }
}
}
}
@@ -17,7 +17,6 @@
package org.jetbrains.kotlin.resolve.calls.checkers
import org.jetbrains.kotlin.builtins.isExtensionFunctionType
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
@@ -25,7 +24,7 @@ import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCallIm
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
class InvokeConventionChecker : CallChecker {
override fun <F : CallableDescriptor> check(resolvedCall: ResolvedCall<F>, context: BasicCallResolutionContext) {
override fun check(resolvedCall: ResolvedCall<*>, context: BasicCallResolutionContext) {
if (resolvedCall is VariableAsFunctionResolvedCallImpl) {
val functionCall = resolvedCall.functionCall
val variableCall = resolvedCall.variableCall
@@ -19,7 +19,10 @@ package org.jetbrains.kotlin.resolve.calls.checkers;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor;
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
import org.jetbrains.kotlin.diagnostics.Errors;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.psi.KtExpression;
@@ -32,9 +35,7 @@ import java.util.Map;
public class ReifiedTypeParameterSubstitutionChecker implements CallChecker {
@Override
public <F extends CallableDescriptor> void check(
@NotNull ResolvedCall<F> resolvedCall, @NotNull BasicCallResolutionContext context
) {
public void check(@NotNull ResolvedCall<?> resolvedCall, @NotNull BasicCallResolutionContext context) {
Map<TypeParameterDescriptor, KotlinType> typeArguments = resolvedCall.getTypeArguments();
for (Map.Entry<TypeParameterDescriptor, KotlinType> entry : typeArguments.entrySet()) {
TypeParameterDescriptor parameter = entry.getKey();
@@ -16,7 +16,6 @@
package org.jetbrains.kotlin.resolve.calls.checkers
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
@@ -24,11 +23,11 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
class SafeCallChecker : CallChecker {
override fun <F : CallableDescriptor> check(resolvedCall: ResolvedCall<F>, context: BasicCallResolutionContext) {
override fun check(resolvedCall: ResolvedCall<*>, context: BasicCallResolutionContext) {
val operationNode = resolvedCall.call.callOperationNode ?: return
if (operationNode.elementType == KtTokens.SAFE_ACCESS && resolvedCall.explicitReceiverKind == ExplicitReceiverKind.NO_EXPLICIT_RECEIVER) {
context.trace.report(Errors.UNEXPECTED_SAFE_CALL.on(operationNode.psi))
}
}
}
}
@@ -24,7 +24,6 @@ import com.google.gwt.dev.js.rhino.CodePosition
import com.google.gwt.dev.js.rhino.ErrorReporter
import com.google.gwt.dev.js.rhino.Utils.isEndOfLine
import com.intellij.openapi.util.TextRange
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory1
@@ -63,7 +62,7 @@ class JsCallChecker(
}
}
override fun <F : CallableDescriptor> check(resolvedCall: ResolvedCall<F>, context: BasicCallResolutionContext) {
override fun check(resolvedCall: ResolvedCall<*>, context: BasicCallResolutionContext) {
if (context.isAnnotationContext || !resolvedCall.isJsCall()) return
val expression = resolvedCall.call.callElement
@@ -16,18 +16,18 @@
package org.jetbrains.kotlin.android.synthetic.diagnostic
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.android.synthetic.descriptors.AndroidSyntheticPackageFragmentDescriptor
import org.jetbrains.kotlin.android.synthetic.diagnostic.ErrorsAndroid.*
import org.jetbrains.kotlin.android.synthetic.res.AndroidSyntheticProperty
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.android.synthetic.diagnostic.ErrorsAndroid.*
import org.jetbrains.kotlin.android.synthetic.descriptors.AndroidSyntheticPackageFragmentDescriptor
import org.jetbrains.kotlin.android.synthetic.res.AndroidSyntheticProperty
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
import org.jetbrains.kotlin.psi.KtExpression
class AndroidExtensionPropertiesCallChecker : CallChecker {
override fun <F : CallableDescriptor> check(resolvedCall: ResolvedCall<F>, context: BasicCallResolutionContext) {
override fun check(resolvedCall: ResolvedCall<*>, context: BasicCallResolutionContext) {
val expression = context.call.calleeExpression ?: return
val propertyDescriptor = resolvedCall.resultingDescriptor as? PropertyDescriptor ?: return
@@ -53,5 +53,4 @@ class AndroidExtensionPropertiesCallChecker : CallChecker {
val warning = if (type.contains('.')) SYNTHETIC_UNRESOLVED_WIDGET_TYPE else SYNTHETIC_INVALID_WIDGET_TYPE
report(warning.on(expression, type))
}
}
}