Workaround KT-14531, Partial fix for KT-13600, KT-11620 J2K: Invalid conversion context on plain text pasting

For detailed info see KT-14531
This commit is contained in:
Simon Ogorodnik
2016-10-26 21:34:03 +03:00
parent f8b7ce1011
commit 0462a3d3b6
17 changed files with 436 additions and 78 deletions
@@ -1,3 +1,5 @@
import java.util.ArrayList
fun foo() {
bar(ArrayList<String>())
}
}
@@ -1 +1,3 @@
fun foo() = ArrayList<String>()
import java.util.ArrayList
fun foo() = ArrayList<String>()
@@ -0,0 +1,34 @@
package test;
public class ToBeImportedJava {
public static final String TO_BE_IMPORTED_CONST = "!!!";
public static void staticMethod() {
}
}
public interface IAmbiguousJava {
}
public interface AmbiguousJava {
}
public interface IAmbiguous {
}
public interface Ambiguous {
}
public class Z {
public interface IAmbiguousJava {
}
public interface AmbiguousJava {
}
}
@@ -0,0 +1,32 @@
package test
class ToBeImportedKotlin {
}
interface IAmbiguous {
}
interface Ambiguous {
}
interface IAmbiguousKotlin {
}
interface AmbiguousKotlin {
}
class Z {
interface IAmbiguousKotlin {
}
interface AmbiguousKotlin {
}
}
@@ -0,0 +1,31 @@
import java.util.ArrayList
import test.ToBeImportedJava
import test.ToBeImportedKotlin
import java.util.HashMap
import test.ToBeImportedJava.TO_BE_IMPORTED_CONST
import test.ToBeImportedJava.staticMethod
class Target {
var listOfPlatformType: List<String> = ArrayList()
var unresolved: UnresolvedInterface<UnresolvedGeneric> = UnresolvedImplementation() // Should not add import
var hashMapOfNotImported: Map<ToBeImportedJava, ToBeImportedKotlin> = HashMap()
fun acceptKotlinClass(tbi: ToBeImportedKotlin) {
}
fun acceptJavaClass(tbi: ToBeImportedJava) {
}
var ambiguousKotlin: IAmbiguousKotlin = AmbiguousKotlin() // Should not add import in case of 2 declarations in Kotlin
var ambiguous: IAmbiguous = Ambiguous() // Should not add import in case of ambiguous declarations in Kotlin and in Java
var ambiguousJava: IAmbiguousJava = AmbiguousJava() // Should not add import in case of 2 declarations in Java
fun workWithStatics() {
val a = TO_BE_IMPORTED_CONST
staticMethod()
}
}
@@ -0,0 +1,3 @@
class Target {
<caret>
}
@@ -0,0 +1,22 @@
public List<String> listOfPlatformType = new ArrayList<String>();
UnresolvedInterface<UnresolvedGeneric> unresolved = new UnresolvedImplementation<>(); // Should not add import
Map<ToBeImportedJava, ToBeImportedKotlin> hashMapOfNotImported = new HashMap<>();
void acceptKotlinClass(ToBeImportedKotlin tbi) {
}
void acceptJavaClass(ToBeImportedJava tbi) {
}
IAmbiguousKotlin ambiguousKotlin = new AmbiguousKotlin(); // Should not add import in case of 2 declarations in Kotlin
IAmbiguous ambiguous = new Ambiguous(); // Should not add import in case of ambiguous declarations in Kotlin and in Java
IAmbiguousJava ambiguousJava = new AmbiguousJava(); // Should not add import in case of 2 declarations in Java
void workWithStatics() {
String a = TO_BE_IMPORTED_CONST;
staticMethod();
}
@@ -1,3 +1,5 @@
import java.util.ArrayList
fun foo() {
bar(/*comment*/ArrayList<String>())
}
}
@@ -1,3 +1,5 @@
import java.util.ArrayList
class A {
fun foo() {
val list = ArrayList<String>()
@@ -1,5 +1,8 @@
package to
import java.util.ArrayList
fun foo() {
val list = ArrayList<String>()
list.add(1)
@@ -1,3 +1,5 @@
import java.util.ArrayList
fun foo() {
val list = ArrayList<String>()
list.add(1)