CodeInliner: fix KNPE
#KT-22733 Fixed #KT-36225 Fixed #EA-206694 Fixed
This commit is contained in:
@@ -217,12 +217,12 @@ class CodeInliner<TCallElement : KtElement>(
|
||||
it[CodeToInline.TYPE_PARAMETER_USAGE_KEY] == parameterName
|
||||
}
|
||||
|
||||
val type = resolvedCall.typeArguments[typeParameter]!!
|
||||
val type = resolvedCall.typeArguments[typeParameter] ?: continue
|
||||
val typeElement = if (explicitTypeArgs != null) { // we use explicit type arguments if available to avoid shortening
|
||||
val explicitArgTypeElement = explicitTypeArgs[index].typeReference?.typeElement ?: continue
|
||||
explicitArgTypeElement.marked(USER_CODE_KEY)
|
||||
} else {
|
||||
psiFactory.createType(IdeDescriptorRenderers.SOURCE_CODE.renderType(type)).typeElement!!
|
||||
psiFactory.createType(IdeDescriptorRenderers.SOURCE_CODE.renderType(type)).typeElement ?: continue
|
||||
}
|
||||
|
||||
val typeClassifier = type.constructor.declarationDescriptor
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
// "Replace with 'foo(list)'" "true"
|
||||
// WITH_RUNTIME
|
||||
|
||||
class Builder<Base : Any> {
|
||||
@Deprecated(message = "", level = DeprecationLevel.WARNING, replaceWith = ReplaceWith("foo(list)"))
|
||||
inline fun <reified T: Base> addFoo(list: List<T>) {
|
||||
|
||||
}
|
||||
|
||||
inline fun <reified T: Base> foo(list: List<T>) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val b = Builder<Number>()
|
||||
b.<caret>addFoo(listOf(1))
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// "Replace with 'foo(list)'" "true"
|
||||
// WITH_RUNTIME
|
||||
|
||||
class Builder<Base : Any> {
|
||||
@Deprecated(message = "", level = DeprecationLevel.WARNING, replaceWith = ReplaceWith("foo(list)"))
|
||||
inline fun <reified T: Base> addFoo(list: List<T>) {
|
||||
|
||||
}
|
||||
|
||||
inline fun <reified T: Base> foo(list: List<T>) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val b = Builder<Number>()
|
||||
b.<caret>foo(listOf(1))
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
class FunOwner<T> {
|
||||
fun callMe0() {}
|
||||
fun callMe1(t: T) {}
|
||||
fun <X> callMe2(x: X) {}
|
||||
}
|
||||
|
||||
fun <T, X> callFun(owner: FunOwner<T>, t: T, x: X) {
|
||||
owner.callMe0()
|
||||
owner.callMe1(t)
|
||||
owner.callMe2<caret>(x)
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class FunOwner<T> {
|
||||
fun callMe0() {}
|
||||
fun callMe1(t: T) {}
|
||||
}
|
||||
|
||||
fun <T, X> callFun(owner: FunOwner<T>, t: T, x: X) {
|
||||
owner.callMe0()
|
||||
owner.callMe1(t)
|
||||
}
|
||||
@@ -7086,6 +7086,11 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
||||
runTest("idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/keepOriginalIfQualified.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt36225.kt")
|
||||
public void testKt36225() throws Exception {
|
||||
runTest("idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/kt36225.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noImplicitTypeArgImportRuntime.kt")
|
||||
public void testNoImplicitTypeArgImportRuntime() throws Exception {
|
||||
runTest("idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/noImplicitTypeArgImportRuntime.kt");
|
||||
|
||||
+5
@@ -95,6 +95,11 @@ public class InlineTestGenerated extends AbstractInlineTest {
|
||||
runTest("idea/testData/refactoring/inline/function/Sequence.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("TypeArguments.kt")
|
||||
public void testTypeArguments() throws Exception {
|
||||
runTest("idea/testData/refactoring/inline/function/TypeArguments.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("UnitReturnType.kt")
|
||||
public void testUnitReturnType() throws Exception {
|
||||
runTest("idea/testData/refactoring/inline/function/UnitReturnType.kt");
|
||||
|
||||
Reference in New Issue
Block a user