[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:
@@ -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
|
||||
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user