Create from Usage: Do not create type parameter by constuctor reference
#KT-17353 Fixed
This commit is contained in:
+1
@@ -51,6 +51,7 @@ data class CreateTypeParameterData(
|
||||
object CreateTypeParameterByUnresolvedRefActionFactory : KotlinIntentionActionFactoryWithDelegate<KtUserType, CreateTypeParameterData>() {
|
||||
override fun getElementOfInterest(diagnostic: Diagnostic): KtUserType? {
|
||||
val ktUserType = diagnostic.psiElement.getParentOfTypeAndBranch<KtUserType> { referenceExpression } ?: return null
|
||||
if (ktUserType.getParentOfTypeAndBranch<KtConstructorCalleeExpression> { typeReference } != null) return null
|
||||
if (ktUserType.qualifier != null) return null
|
||||
if (ktUserType.getParentOfTypeAndBranch<KtUserType>(true) { qualifier } != null) return null
|
||||
if (ktUserType.typeArgumentList != null) return null
|
||||
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// "Create type parameter 'Test' in class 'C'" "false"
|
||||
// ACTION: Add 'testng' to classpath
|
||||
// ACTION: Create annotation 'Test'
|
||||
// ACTION: Make internal
|
||||
// ACTION: Make private
|
||||
// ACTION: Make protected
|
||||
// ERROR: Unresolved reference: Test
|
||||
class C {
|
||||
@<caret>Test fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Create type parameter 'Test' in class 'C'" "false"
|
||||
// ACTION: Add 'testng' to classpath
|
||||
// ACTION: Create class 'Test'
|
||||
// ACTION: Create test
|
||||
// ERROR: Unresolved reference: Test
|
||||
class C : <caret>Test() {
|
||||
|
||||
}
|
||||
@@ -3537,6 +3537,18 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inAnnotation.kt")
|
||||
public void testInAnnotation() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/createFromUsage/createTypeParameter/inContainingDeclaration/inAnnotation.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inSuperTypeEntry.kt")
|
||||
public void testInSuperTypeEntry() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/createFromUsage/createTypeParameter/inContainingDeclaration/inSuperTypeEntry.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("qualifiedType.kt")
|
||||
public void testQualifiedType() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/createFromUsage/createTypeParameter/inContainingDeclaration/qualifiedType.kt");
|
||||
|
||||
Reference in New Issue
Block a user