EA-109046: Add diagnostic to catch NPE
This commit is contained in:
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.Constrain
|
|||||||
import org.jetbrains.kotlin.types.*
|
import org.jetbrains.kotlin.types.*
|
||||||
import org.jetbrains.kotlin.types.checker.StrictEqualityTypeChecker
|
import org.jetbrains.kotlin.types.checker.StrictEqualityTypeChecker
|
||||||
import org.jetbrains.kotlin.types.typeUtil.*
|
import org.jetbrains.kotlin.types.typeUtil.*
|
||||||
|
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
fun CallableDescriptor.fuzzyReturnType() = returnType?.toFuzzyType(typeParameters)
|
fun CallableDescriptor.fuzzyReturnType() = returnType?.toFuzzyType(typeParameters)
|
||||||
@@ -88,9 +89,13 @@ class FuzzyType(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Diagnostic for EA-109046
|
||||||
|
@Suppress("USELESS_ELVIS")
|
||||||
private fun TypeParameterDescriptor.toOriginal(): TypeParameterDescriptor {
|
private fun TypeParameterDescriptor.toOriginal(): TypeParameterDescriptor {
|
||||||
val callableDescriptor = containingDeclaration as? CallableMemberDescriptor ?: return this
|
val callableDescriptor = containingDeclaration as? CallableMemberDescriptor ?: return this
|
||||||
return callableDescriptor.original.typeParameters[index]
|
val original = callableDescriptor.original ?: error("original = null for $callableDescriptor")
|
||||||
|
val typeParameters = original.typeParameters ?: error("typeParameters = null for $original")
|
||||||
|
return typeParameters[index]
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?) = other is FuzzyType && other.type == type && other.freeParameters == freeParameters
|
override fun equals(other: Any?) = other is FuzzyType && other.type == type && other.freeParameters == freeParameters
|
||||||
|
|||||||
Reference in New Issue
Block a user