From 2f39cb6243eb093f2fe73d467079231f06eae302 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Thu, 12 Mar 2015 14:13:12 +0300 Subject: [PATCH] Remove useless casts after fixing subtyping for star projections --- .../kotlin/load/kotlin/KotlinJvmCheckerProvider.kt | 3 +-- .../jetbrains/kotlin/resolve/calls/CallCompleter.kt | 12 ++++++------ .../kotlin/resolve/calls/tasks/TaskPrioritizer.kt | 2 +- .../jetbrains/kotlin/resolve/calls/util/callUtil.kt | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt index f9f5f111b08..836beb30498 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt @@ -276,8 +276,7 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker { } } else { - // TODO: Compiler bug - doIfNotNull(dataFlowValue, c as ResolutionContext<*>) { + doIfNotNull(dataFlowValue, c) { c.trace.report(Errors.UNNECESSARY_SAFE_CALL.on(c.call.getCallOperationNode().getPsi(), receiverArgument.getType())) } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt index 5f80bfef583..c892cd1aa17 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt @@ -226,7 +226,7 @@ public class CallCompleter( if (valueArgument.isExternal()) return val expression = valueArgument.getArgumentExpression() - val deparenthesized = ArgumentTypeResolver.getLastElementDeparenthesized(expression, context as ResolutionContext<*>) + val deparenthesized = ArgumentTypeResolver.getLastElementDeparenthesized(expression, context) if (deparenthesized == null) return val recordedType = context.trace[BindingContext.EXPRESSION_TYPE, expression] @@ -241,20 +241,20 @@ public class CallCompleter( // For the cases like 'foo(1)' the type of '1' depends on expected type (it can be Int, Byte, etc.), // so while the expected type is not known, it's IntegerValueType(1), and should be updated when the expected type is known. if (recordedType != null && !recordedType.getConstructor().isDenotable()) { - updatedType = ArgumentTypeResolver.updateResultArgumentTypeIfNotDenotable(context as ResolutionContext<*>, expression) + updatedType = ArgumentTypeResolver.updateResultArgumentTypeIfNotDenotable(context, expression) } updatedType = updateRecordedTypeForArgument(updatedType, recordedType, expression, context.trace) // While the expected type is not known, the function literal arguments are not analyzed (to analyze function literal bodies once), // but they should be analyzed when the expected type is known (during the call completion). - if (ArgumentTypeResolver.isFunctionLiteralArgument(expression, context as ResolutionContext<*>)) { + if (ArgumentTypeResolver.isFunctionLiteralArgument(expression, context)) { argumentTypeResolver.getFunctionLiteralTypeInfo( - expression, ArgumentTypeResolver.getFunctionLiteralArgument(expression, context as ResolutionContext<*>), - context as CallResolutionContext<*>, RESOLVE_FUNCTION_ARGUMENTS) + expression, ArgumentTypeResolver.getFunctionLiteralArgument(expression, context), + context, RESOLVE_FUNCTION_ARGUMENTS) } - DataFlowUtils.checkType(updatedType, deparenthesized, context as ResolutionContext<*>) + DataFlowUtils.checkType(updatedType, deparenthesized, context) } private fun completeCallForArgument( diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TaskPrioritizer.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TaskPrioritizer.kt index 2f8b5dcda87..f463d73a93c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TaskPrioritizer.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TaskPrioritizer.kt @@ -176,7 +176,7 @@ public class TaskPrioritizer(private val storageManager: StorageManager) { ) { for (callableDescriptorCollector in c.callableDescriptorCollectors) { c.result.addCandidates { - val variantsForExplicitReceiver = SmartCastUtils.getSmartCastVariants(explicitReceiver, c.context as ResolutionContext<*>) //workaround KT-1969 + val variantsForExplicitReceiver = SmartCastUtils.getSmartCastVariants(explicitReceiver, c.context) val members = Lists.newArrayList>() for (type in variantsForExplicitReceiver) { val membersForThisVariant = if (staticMembers) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt index 40aeba56577..5053568fc00 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt @@ -69,7 +69,7 @@ public fun > Call.hasUnresolvedArguments(context: Resolu return arguments.any { argument -> val expressionType = context.trace.getBindingContext()[BindingContext.EXPRESSION_TYPE, argument] - argument != null && !ArgumentTypeResolver.isFunctionLiteralArgument(argument, context as ResolutionContext<*>) + argument != null && !ArgumentTypeResolver.isFunctionLiteralArgument(argument, context) && (expressionType == null || expressionType.isError()) } }