Fix minor compile warnings
This commit is contained in:
@@ -121,6 +121,7 @@ class ResolverForProjectImpl<M : ModuleInfo>(
|
||||
// Protected by ("projectContext.storageManager.lock")
|
||||
private val moduleInfoByDescriptor = mutableMapOf<ModuleDescriptorImpl, M>()
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
private val moduleInfoToResolvableInfo: Map<M, M> =
|
||||
modules.flatMap { module -> module.flatten().map { modulePart -> modulePart to module } }.toMap() as Map<M, M>
|
||||
|
||||
@@ -326,6 +327,7 @@ class LazyModuleDependencies<M : ModuleInfo>(
|
||||
yield(moduleDescriptor.builtIns.builtInsModule)
|
||||
}
|
||||
for (dependency in module.dependencies()) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
yield(resolverForProject.descriptorForModule(dependency as M))
|
||||
}
|
||||
if (module.dependencyOnBuiltIns() == ModuleInfo.DependencyOnBuiltIns.LAST) {
|
||||
@@ -337,12 +339,16 @@ class LazyModuleDependencies<M : ModuleInfo>(
|
||||
override val allDependencies: List<ModuleDescriptorImpl> get() = dependencies()
|
||||
|
||||
override val expectedByDependencies by storageManager.createLazyValue {
|
||||
module.expectedBy.map { resolverForProject.descriptorForModule(it as M) }
|
||||
module.expectedBy.map {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
resolverForProject.descriptorForModule(it as M)
|
||||
}
|
||||
}
|
||||
|
||||
override val modulesWhoseInternalsAreVisible: Set<ModuleDescriptorImpl>
|
||||
get() =
|
||||
module.modulesWhoseInternalsAreVisible().mapTo(LinkedHashSet()) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
resolverForProject.descriptorForModule(it as M)
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -166,6 +166,7 @@ class SyntheticClassOrObjectDescriptor(
|
||||
|
||||
override fun getPsiOrParent() = _parent.psiOrParent
|
||||
override fun getParent() = _parent.psiOrParent
|
||||
@Suppress("USELESS_ELVIS")
|
||||
override fun getContainingKtFile() =
|
||||
// in theory `containingKtFile` is `@NotNull` but in practice EA-114080
|
||||
_parent.containingKtFile ?: throw IllegalStateException("containingKtFile was null for $_parent of ${_parent.javaClass}")
|
||||
|
||||
@@ -439,11 +439,11 @@ class CallCompleter(
|
||||
}
|
||||
|
||||
var shouldBeMadeNullable = false
|
||||
expressions.asReversed().forEach { expression ->
|
||||
if (!(expression is KtParenthesizedExpression || expression is KtLabeledExpression || expression is KtAnnotatedExpression)) {
|
||||
shouldBeMadeNullable = hasNecessarySafeCall(expression, trace)
|
||||
expressions.asReversed().forEach { ktExpression ->
|
||||
if (!(ktExpression is KtParenthesizedExpression || ktExpression is KtLabeledExpression || ktExpression is KtAnnotatedExpression)) {
|
||||
shouldBeMadeNullable = hasNecessarySafeCall(ktExpression, trace)
|
||||
}
|
||||
BindingContextUtils.updateRecordedType(updatedType, expression, trace, shouldBeMadeNullable)
|
||||
BindingContextUtils.updateRecordedType(updatedType, ktExpression, trace, shouldBeMadeNullable)
|
||||
}
|
||||
return trace.getType(argumentExpression)
|
||||
}
|
||||
|
||||
@@ -360,7 +360,7 @@ class CallExpressionResolver(
|
||||
initialDataFlowInfoForArguments = initialDataFlowInfoForArguments.disequate(
|
||||
receiverDataFlowValue, DataFlowValue.nullValue(builtIns), languageVersionSettings
|
||||
)
|
||||
} else if (receiver is ReceiverValue) {
|
||||
} else {
|
||||
reportUnnecessarySafeCall(context.trace, receiver.type, callOperationNode, receiver)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ fun isBinaryRemOperator(call: Call): Boolean {
|
||||
val operator = callElement.operationToken
|
||||
if (operator !is KtToken) return false
|
||||
|
||||
val name = OperatorConventions.getNameForOperationSymbol(operator, true, true)
|
||||
val name = OperatorConventions.getNameForOperationSymbol(operator, true, true) ?: return false
|
||||
return name in OperatorConventions.REM_TO_MOD_OPERATION_NAMES.keys
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -41,6 +41,7 @@ internal fun VariableDescriptor.variableKind(
|
||||
return propertyKind(usageModule)
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
if (this is LocalVariableDescriptor && this.isDelegated) {
|
||||
// Local delegated property: normally unstable, but can be treated as stable in legacy mode
|
||||
return if (languageVersionSettings.supportsFeature(LanguageFeature.ProhibitSmartcastsOnLocalDelegatedProperty))
|
||||
|
||||
+5
-1
@@ -117,6 +117,7 @@ class KotlinToResolvedCallTransformer(
|
||||
|
||||
forwardCallToInferenceSession(baseResolvedCall, context, stub, tracingStrategy)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return stub as ResolvedCall<D>
|
||||
}
|
||||
|
||||
@@ -131,7 +132,8 @@ class KotlinToResolvedCallTransformer(
|
||||
}
|
||||
}
|
||||
|
||||
val resolvedCall = ktPrimitiveCompleter.completeResolvedCall(candidate, baseResolvedCall.diagnostics) as ResolvedCall<D>
|
||||
@Suppress("UNCHECKED_CAST") val resolvedCall =
|
||||
ktPrimitiveCompleter.completeResolvedCall(candidate, baseResolvedCall.diagnostics) as ResolvedCall<D>
|
||||
forwardCallToInferenceSession(baseResolvedCall, context, resolvedCall, tracingStrategy)
|
||||
|
||||
resolvedCall
|
||||
@@ -580,6 +582,7 @@ class NewResolvedCallImpl<D : CallableDescriptor>(
|
||||
override val argumentMappingByOriginal: Map<ValueParameterDescriptor, ResolvedCallArgument>
|
||||
get() = resolvedCallAtom.argumentMappingByOriginal
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun getCandidateDescriptor(): D = resolvedCallAtom.candidateDescriptor as D
|
||||
override fun getResultingDescriptor(): D = resultingDescriptor
|
||||
override fun getExtensionReceiver(): ReceiverValue? = extensionReceiver
|
||||
@@ -639,6 +642,7 @@ class NewResolvedCallImpl<D : CallableDescriptor>(
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
resultingDescriptor = run {
|
||||
val candidateDescriptor = resolvedCallAtom.candidateDescriptor
|
||||
val containsCapturedTypes = resolvedCallAtom.candidateDescriptor.returnType?.contains { it is NewCapturedType } ?: false
|
||||
|
||||
+1
@@ -53,6 +53,7 @@ abstract class ManyCandidatesResolver<D : CallableDescriptor>(
|
||||
if (callInfo !is PSIErrorCallInfo<*>) {
|
||||
throw AssertionError("Error call info for $callInfo should be instance of PSIErrorCallInfo")
|
||||
}
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
errorCallsInfo.add(callInfo as PSIErrorCallInfo<D>)
|
||||
}
|
||||
|
||||
|
||||
+6
-2
@@ -260,7 +260,10 @@ class NewResolutionOldInference(
|
||||
|
||||
private fun <D : CallableDescriptor> allCandidatesResult(allCandidates: Collection<MyCandidate>) =
|
||||
OverloadResolutionResultsImpl.nameNotFound<D>().apply {
|
||||
this.allCandidates = allCandidates.map { it.resolvedCall as MutableResolvedCall<D> }
|
||||
this.allCandidates = allCandidates.map {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
it.resolvedCall as MutableResolvedCall<D>
|
||||
}
|
||||
}
|
||||
|
||||
private fun <D : CallableDescriptor> convertToOverloadResults(
|
||||
@@ -315,6 +318,7 @@ class NewResolutionOldInference(
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
resolvedCall as MutableResolvedCall<D>
|
||||
}
|
||||
|
||||
@@ -475,7 +479,7 @@ class NewResolutionOldInference(
|
||||
variable: MyCandidate,
|
||||
invoke: MyCandidate
|
||||
): MyCandidate {
|
||||
val resolvedCallImpl = VariableAsFunctionResolvedCallImpl(
|
||||
@Suppress("UNCHECKED_CAST") val resolvedCallImpl = VariableAsFunctionResolvedCallImpl(
|
||||
invoke.resolvedCall as MutableResolvedCall<FunctionDescriptor>,
|
||||
variable.resolvedCall as MutableResolvedCall<VariableDescriptor>
|
||||
)
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.jetbrains.kotlin.resolve.calls.components.CallableReferenceResolver
|
||||
import org.jetbrains.kotlin.resolve.calls.components.InferenceSession
|
||||
import org.jetbrains.kotlin.resolve.calls.components.PostponedArgumentsAnalyzer
|
||||
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.context.CheckArgumentTypesMode
|
||||
import org.jetbrains.kotlin.resolve.calls.context.ContextDependency
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.buildResultingSubstitutor
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter
|
||||
@@ -551,8 +550,7 @@ class PSICallResolver(
|
||||
|
||||
require(oldCall is CallTransformer.CallForImplicitInvoke) { "Call should be CallForImplicitInvoke, but it is: $oldCall" }
|
||||
|
||||
val dispatchReceiver = oldCall.dispatchReceiver!! // dispatch receiver from CallForImplicitInvoke is always not null
|
||||
return resolveReceiver(context, dispatchReceiver, isSafeCall = false, isForImplicitInvoke = true)
|
||||
return resolveReceiver(context, oldCall.dispatchReceiver, isSafeCall = false, isForImplicitInvoke = true)
|
||||
}
|
||||
|
||||
private fun resolveReceiver(
|
||||
|
||||
@@ -39,6 +39,7 @@ val KotlinCall.psiKotlinCall: PSIKotlinCall
|
||||
return this as PSIKotlinCall
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <D : CallableDescriptor> KotlinCall.getResolvedPsiKotlinCall(trace: BindingTrace): NewResolvedCallImpl<D>? =
|
||||
psiKotlinCall.psiCall.getResolvedCall(trace.bindingContext) as? NewResolvedCallImpl<D>
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.storage.LockBasedLazyResolveStorageManager
|
||||
import javax.inject.Inject
|
||||
|
||||
open class LazyDeclarationResolver @Deprecated("") constructor(
|
||||
open class LazyDeclarationResolver constructor(
|
||||
globalContext: GlobalContext,
|
||||
delegationTrace: BindingTrace,
|
||||
private val topLevelDescriptorProvider: TopLevelDescriptorProvider,
|
||||
|
||||
+2
-2
@@ -464,8 +464,8 @@ open class LazyClassMemberScope(
|
||||
descriptor.returnType = c.wrappedTypeFactory.createDeferredType(trace, { thisDescriptor.defaultType })
|
||||
}
|
||||
|
||||
override fun recordLookup(name: Name, from: LookupLocation) {
|
||||
c.lookupTracker.record(from, thisDescriptor, name)
|
||||
override fun recordLookup(name: Name, location: LookupLocation) {
|
||||
c.lookupTracker.record(location, thisDescriptor, name)
|
||||
}
|
||||
|
||||
// Do not add details here, they may compromise the laziness during debugging
|
||||
|
||||
+2
-2
@@ -62,8 +62,8 @@ class LazyPackageMemberScope(
|
||||
// No extra properties
|
||||
}
|
||||
|
||||
override fun recordLookup(name: Name, from: LookupLocation) {
|
||||
c.lookupTracker.record(from, thisDescriptor, name)
|
||||
override fun recordLookup(name: Name, location: LookupLocation) {
|
||||
c.lookupTracker.record(location, thisDescriptor, name)
|
||||
}
|
||||
|
||||
override fun getClassifierNames(): Set<Name>? = declarationProvider.getDeclarationNames()
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.builtins.isExtensionFunctionType
|
||||
import org.jetbrains.kotlin.builtins.isFunctionType
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
@@ -163,7 +164,7 @@ object CastDiagnosticsUtil {
|
||||
val supertypeWithVariables = TypeCheckingProcedure.findCorrespondingSupertype(subtypeWithVariables, supertype)
|
||||
|
||||
val variables = subtypeWithVariables.constructor.parameters
|
||||
val variableConstructors = variables.map { descriptor -> descriptor.typeConstructor }.toSet()
|
||||
val variableConstructors = variables.map(TypeParameterDescriptor::getTypeConstructor).toSet()
|
||||
|
||||
val substitution: MutableMap<TypeConstructor, TypeProjection> = if (supertypeWithVariables != null) {
|
||||
// Now, let's try to unify Collection<T> and Collection<Foo> solution is a map from T to Foo
|
||||
|
||||
Reference in New Issue
Block a user