KT-6795 J2K: When converting to type with projections, omit redundant use-site projections

#KT-6795 Fixed
This commit is contained in:
Valentin Kipyatkov
2015-03-30 13:50:23 +03:00
parent 7e50f72d5b
commit c66b20b204
11 changed files with 19 additions and 9 deletions
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.idea.intentions.RemoveExplicitTypeArguments
import org.jetbrains.kotlin.idea.intentions.SimplifyNegatedBinaryExpressionIntention
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.IfThenToElvisIntention
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.IfThenToSafeAccessIntention
import org.jetbrains.kotlin.idea.quickfix.RemoveModifierFix
import org.jetbrains.kotlin.idea.quickfix.RemoveRightPartOfBinaryExpressionFix
import org.jetbrains.kotlin.j2k.PostProcessor
import org.jetbrains.kotlin.psi.*
@@ -54,6 +55,11 @@ public class J2kPostProcessor(override val contextToAnalyzeIn: PsiElement) : Pos
}
}
Errors.REDUNDANT_PROJECTION -> { ->
val fix = RemoveModifierFix.createRemoveProjectionFactory(true).createActions(problem).single() as RemoveModifierFix
fix.invoke()
}
else -> super.fixForProblem(problem)
}
}
@@ -94,6 +94,10 @@ public class RemoveModifierFix extends JetIntentionAction<JetModifierListOwner>
@Override
public void invoke(@NotNull Project project, Editor editor, JetFile file) throws IncorrectOperationException {
invoke();
}
public void invoke() throws IncorrectOperationException {
JetModifierListOwner newElement = (JetModifierListOwner) element.copy();
element.replace(removeModifier(newElement, modifier));
}
@@ -4,7 +4,7 @@ import kotlinApi.KotlinClass
public abstract class C(field: Int) : KotlinClass(field) {
override fun foo(mutableCollection: MutableCollection<String>, nullableCollection: Collection<out Int>?): MutableList<Any> {
override fun foo(mutableCollection: MutableCollection<String>, nullableCollection: Collection<Int>?): MutableList<Any> {
return super.foo(mutableCollection, nullableCollection)
}
}
@@ -1,2 +1,2 @@
fun pushAll(src: Collection<out E>) {
fun pushAll(src: Collection<E>) {
}
@@ -1 +1 @@
list as List<out String>
list as List<String>
@@ -1 +1 @@
class CC<T : INode, K : Node> : A() where T : Comparable<in T>, K : Collection<in K>
class CC<T : INode, K : Node> : A() where T : Comparable<T>, K : Collection<in K>
@@ -1 +1 @@
class C<T : INode> where T : Comparable<in T>
class C<T : INode> where T : Comparable<T>
@@ -1 +1 @@
class C<T : INode> : A() where T : Comparable<in T>
class C<T : INode> : A() where T : Comparable<T>
@@ -1,2 +1,2 @@
fun <T : Any, K : Node> max(coll: Collection<out T>): T where T : Comparable<in T>, K : Collection<in K> {
fun <T : Any, K : Node> max(coll: Collection<T>): T where T : Comparable<T>, K : Collection<in K> {
}
@@ -1 +1 @@
trait I<T : INode, K : Node> : II where T : Comparable<in T>, K : Collection<in K>
trait I<T : INode, K : Node> : II where T : Comparable<T>, K : Collection<in K>
@@ -1,2 +1,2 @@
fun <T : Any> max(coll: Collection<out T>): T where T : Comparable<in T> {
fun <T : Any> max(coll: Collection<T>): T where T : Comparable<T> {
}