KT-15309 Don't apply "Fix with 'asDynamic'" to member extension funcitons
This commit is contained in:
+2
-2
@@ -65,7 +65,7 @@ class MigrateExternalExtensionFix(declaration: KtNamedDeclaration)
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun fixNativeClass(containingClass: KtClassOrObject) {
|
private fun fixNativeClass(containingClass: KtClassOrObject) {
|
||||||
val membersToFix = containingClass.declarations.filterIsInstance<KtCallableDeclaration>().filter { isMemberDeclaration(it) }. map {
|
val membersToFix = containingClass.declarations.filterIsInstance<KtCallableDeclaration>().filter { isMemberDeclaration(it) && !isMemberExtensionDeclaration(it) }. map {
|
||||||
it to fetchJsNativeAnnotations(it)
|
it to fetchJsNativeAnnotations(it)
|
||||||
}.filter {
|
}.filter {
|
||||||
it.second.annotations.isNotEmpty()
|
it.second.annotations.isNotEmpty()
|
||||||
@@ -251,7 +251,7 @@ class MigrateExternalExtensionFix(declaration: KtNamedDeclaration)
|
|||||||
val e = diagnostic.psiElement
|
val e = diagnostic.psiElement
|
||||||
when (diagnostic.factory) {
|
when (diagnostic.factory) {
|
||||||
ErrorsJs.WRONG_EXTERNAL_DECLARATION -> {
|
ErrorsJs.WRONG_EXTERNAL_DECLARATION -> {
|
||||||
if (isMemberExtensionDeclaration(e)) {
|
if (isMemberExtensionDeclaration(e) && e.getParentOfType<KtClassOrObject>(true) == null) {
|
||||||
return MigrateExternalExtensionFix(e as KtNamedDeclaration)
|
return MigrateExternalExtensionFix(e as KtNamedDeclaration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// "Fix with 'asDynamic'" "true"
|
// "Fix with 'asDynamic'" "true"
|
||||||
// JS
|
// JS
|
||||||
|
// ERROR: Declaration of such kind (extension function) cant be external
|
||||||
|
|
||||||
external class B {
|
external class B {
|
||||||
@nativeGetter
|
@nativeGetter
|
||||||
@@ -15,4 +16,6 @@ external class B {
|
|||||||
fun<T> exp(t: T)
|
fun<T> exp(t: T)
|
||||||
|
|
||||||
fun dontTouch(): Nothing = definedExternally
|
fun dontTouch(): Nothing = definedExternally
|
||||||
|
|
||||||
|
fun B.doNotTouchNestedExtensionMembers(): Nothing = definedExternally
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,12 @@
|
|||||||
// "Fix with 'asDynamic'" "true"
|
// "Fix with 'asDynamic'" "true"
|
||||||
// JS
|
// JS
|
||||||
|
// ERROR: Declaration of such kind (extension function) cant be external
|
||||||
|
|
||||||
external class B {
|
external class B {
|
||||||
|
|
||||||
fun dontTouch(): Nothing = definedExternally
|
fun dontTouch(): Nothing = definedExternally
|
||||||
|
|
||||||
|
fun B.doNotTouchNestedExtensionMembers(): Nothing = definedExternally
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
|||||||
@@ -6558,6 +6558,12 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
|||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/migration/jsExternal/nativeSetterExtensionFunJsRuntime.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/migration/jsExternal/nativeSetterExtensionFunJsRuntime.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nestedExtension01.kt")
|
||||||
|
public void testNestedExtension01() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/migration/jsExternal/nestedExtension01.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("idea/testData/quickfix/migration/missingConstructorKeyword")
|
@TestMetadata("idea/testData/quickfix/migration/missingConstructorKeyword")
|
||||||
|
|||||||
-1
@@ -53,5 +53,4 @@ public class SourceMapGenerationSmokeTestGenerated extends AbstractSourceMapGene
|
|||||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/sourcemap/methodCallInMethod.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/sourcemap/methodCallInMethod.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user