Skip to content

Commit

Permalink
Quick Fixes: Fix AssertionError on rendering type parameter
Browse files Browse the repository at this point in the history
 #KT-17404 Fixed
  • Loading branch information
asedunov committed Apr 21, 2017
1 parent b80fbe1 commit c492f33
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.descriptors.CallableDescriptor;
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor;
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
import org.jetbrains.kotlin.diagnostics.Diagnostic;
import org.jetbrains.kotlin.idea.caches.resolve.ResolutionUtils;
Expand Down Expand Up @@ -162,8 +163,9 @@ public static boolean canFunctionOrGetterReturnExpression(@NotNull KtDeclaration
}

public static String renderTypeWithFqNameOnClash(KotlinType type, String nameToCheckAgainst) {
FqName typeFqName = DescriptorUtils.getFqNameSafe(DescriptorUtils.getClassDescriptorForType(type));
FqName fqNameToCheckAgainst = new FqName(nameToCheckAgainst);
ClassifierDescriptor typeClassifierDescriptor = type.getConstructor().getDeclarationDescriptor();
FqName typeFqName = typeClassifierDescriptor != null ? DescriptorUtils.getFqNameSafe(typeClassifierDescriptor) : fqNameToCheckAgainst;
DescriptorRenderer renderer = typeFqName.shortName().equals(fqNameToCheckAgainst.shortName())
? IdeDescriptorRenderers.SOURCE_CODE
: IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES;
Expand Down
4 changes: 4 additions & 0 deletions idea/testData/quickfix/typeMismatch/kt17404.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// "Change type from 'Int' to 'X'" "true"
// ERROR: Cannot use 'X' as reified type parameter. Use a class instead.
inline fun <reified T> inlineReified0(f: (T) -> T) = {}
fun <X> callInlineReified3() = inlineReified0<X>({ x: <caret>Int -> x })
4 changes: 4 additions & 0 deletions idea/testData/quickfix/typeMismatch/kt17404.kt.after
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// "Change type from 'Int' to 'X'" "true"
// ERROR: Cannot use 'X' as reified type parameter. Use a class instead.
inline fun <reified T> inlineReified0(f: (T) -> T) = {}
fun <X> callInlineReified3() = inlineReified0<X>({ x: X -> x })
Original file line number Diff line number Diff line change
Expand Up @@ -9707,6 +9707,12 @@ public void testIntToShortTypeMismatch() throws Exception {
doTest(fileName);
}

@TestMetadata("kt17404.kt")
public void testKt17404() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/kt17404.kt");
doTest(fileName);
}

@TestMetadata("letClassImplementAdditionalInterface.kt")
public void testLetClassImplementAdditionalInterface() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/letClassImplementAdditionalInterface.kt");
Expand Down

0 comments on commit c492f33

Please sign in to comment.