Compare commits

...

1 Commits

Author SHA1 Message Date
Andrey Breslav
e9b646c6b4 Remove useless casts after fixing subtyping for star projections 2015-03-12 14:13:32 +03:00
4 changed files with 9 additions and 10 deletions

View File

@@ -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()))
}
}

View File

@@ -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(

View File

@@ -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<ResolutionCandidate<D>>()
for (type in variantsForExplicitReceiver) {
val membersForThisVariant = if (staticMembers) {

View File

@@ -69,7 +69,7 @@ public fun <C: ResolutionContext<C>> 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())
}
}