[NI] Use ErrorType in ParseErrorKotlinCallArgument

Previously, there was receiver of type Nothing, which could case result
of the call to be inferred to Nothing too. This could case bogus
UNREACHABLE_CODE diagnostics in cases like this:

```
fun <T> id(x: T) = x
fun test() {
    id(unresolvedReference) // type of statement is 'Nothing'
    // ... everything here is marked as unreachable ...
}
```

This commit changes type of receiver for such calls form Nothing to
ErrorType.
This commit is contained in:
Dmitry Savvinov
2017-11-22 21:43:23 +03:00
parent eadd1355c2
commit 70a1beeff6
2 changed files with 7 additions and 2 deletions
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValueWithSmartCastInfo
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
import org.jetbrains.kotlin.resolve.scopes.receivers.prepareReceiverRegardingCaptureTypes
import org.jetbrains.kotlin.types.ErrorUtils
import org.jetbrains.kotlin.types.UnwrappedType
import org.jetbrains.kotlin.types.expressions.KotlinTypeInfo
@@ -71,7 +72,11 @@ class ParseErrorKotlinCallArgument(
override val dataFlowInfoAfterThisArgument: DataFlowInfo,
builtIns: KotlinBuiltIns
): ExpressionKotlinCallArgument, SimplePSIKotlinCallArgument() {
override val receiver = ReceiverValueWithSmartCastInfo(TransientReceiver(builtIns.nothingType), emptySet(), isStable = true)
override val receiver = ReceiverValueWithSmartCastInfo(
TransientReceiver(ErrorUtils.createErrorType("Error type for ParseError-argument $valueArgument")),
possibleTypes = emptySet(),
isStable = true
)
override val isSafeCall: Boolean get() = false
@@ -57,7 +57,7 @@ fun test3(z: Z) {
//'in' operation
fun test4(collection: Collection<A<*>>) {
id(<!OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>newA<!>() in collection)
<!NI;UNREACHABLE_CODE!>id(newA<Int>() in collection)<!>
id(newA<Int>() in collection)
}
//boolean operations