New J2K: do not save import statements in files as we print fqNames for calls
This may cause conflicts on shortening fq references post-processing step
This commit is contained in:
@@ -72,7 +72,6 @@ object ConversionsRunner {
|
|||||||
BuiltinMembersConversion(context),
|
BuiltinMembersConversion(context),
|
||||||
ImplicitCastsConversion(context),
|
ImplicitCastsConversion(context),
|
||||||
LiteralConversion(context),
|
LiteralConversion(context),
|
||||||
CollectImportsConversion(context),
|
|
||||||
FilterImportsConversion(context),
|
FilterImportsConversion(context),
|
||||||
MoveInitBlocksToTheEndConversion(context),
|
MoveInitBlocksToTheEndConversion(context),
|
||||||
AddElementsInfoConversion(context)
|
AddElementsInfoConversion(context)
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import org.jetbrains.kotlin.nj2k.types.*
|
|||||||
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.collectDescendantsOfType
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.isExtensionDeclaration
|
import org.jetbrains.kotlin.psi.psiUtil.isExtensionDeclaration
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.cast
|
import org.jetbrains.kotlin.utils.addToStdlib.cast
|
||||||
@@ -74,23 +75,39 @@ class JavaToJKTreeBuilder constructor(
|
|||||||
private fun PsiJavaFile.toJK(): JKFile =
|
private fun PsiJavaFile.toJK(): JKFile =
|
||||||
JKFile(
|
JKFile(
|
||||||
packageStatement?.toJK() ?: JKPackageDeclaration(JKNameIdentifier("")),
|
packageStatement?.toJK() ?: JKPackageDeclaration(JKNameIdentifier("")),
|
||||||
importList.toJK(),
|
importList.toJK(saveImports = false),
|
||||||
with(declarationMapper) { classes.map { it.toJK() } }
|
with(declarationMapper) { classes.map { it.toJK() } }
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun PsiImportList?.toJK(): JKImportList =
|
private fun PsiImportList?.toJK(saveImports: Boolean): JKImportList =
|
||||||
JKImportList(this?.allImportStatements?.mapNotNull { it.toJK() }.orEmpty())
|
JKImportList(this?.allImportStatements?.mapNotNull { it.toJK(saveImports) }.orEmpty()).also { importList ->
|
||||||
|
val innerComments = this?.collectDescendantsOfType<PsiComment>()?.map { comment ->
|
||||||
|
JKCommentElement(comment.text)
|
||||||
|
}.orEmpty()
|
||||||
|
importList.leftNonCodeElements += innerComments
|
||||||
|
}
|
||||||
|
|
||||||
private fun PsiPackageStatement.toJK(): JKPackageDeclaration =
|
private fun PsiPackageStatement.toJK(): JKPackageDeclaration =
|
||||||
JKPackageDeclaration(JKNameIdentifier(packageName))
|
JKPackageDeclaration(JKNameIdentifier(packageName))
|
||||||
.also {
|
.also {
|
||||||
it.assignNonCodeElements(this)
|
it.assignNonCodeElements(this)
|
||||||
|
symbolProvider.provideUniverseSymbol(this, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun PsiImportStatementBase.toJK(saveImports: Boolean): JKImportStatement? {
|
||||||
private fun PsiImportStatementBase.toJK(): JKImportStatement? {
|
val target = when (this) {
|
||||||
val target = resolve()
|
is PsiImportStaticStatement -> resolveTargetClass()
|
||||||
|
else -> resolve()
|
||||||
|
}
|
||||||
val rawName = (importReference?.canonicalText ?: return null) + if (isOnDemand) ".*" else ""
|
val rawName = (importReference?.canonicalText ?: return null) + if (isOnDemand) ".*" else ""
|
||||||
|
|
||||||
|
// We will save only unresolved imports and print all static calls with fqNames
|
||||||
|
// to avoid name clashes in future
|
||||||
|
if (!saveImports) {
|
||||||
|
return if (target == null)
|
||||||
|
JKImportStatement(JKNameIdentifier(rawName))
|
||||||
|
else null
|
||||||
|
}
|
||||||
val name =
|
val name =
|
||||||
target.safeAs<KtLightElement<*, *>>()?.kotlinOrigin?.getKotlinFqName()?.asString()
|
target.safeAs<KtLightElement<*, *>>()?.kotlinOrigin?.getKotlinFqName()?.asString()
|
||||||
?: target.safeAs<KtLightClass>()?.containingFile?.safeAs<KtFile>()?.packageFqName?.asString()?.let { "$it.*" }
|
?: target.safeAs<KtLightClass>()?.containingFile?.safeAs<KtFile>()?.packageFqName?.asString()?.let { "$it.*" }
|
||||||
@@ -944,7 +961,7 @@ class JavaToJKTreeBuilder constructor(
|
|||||||
}.last()
|
}.last()
|
||||||
|
|
||||||
|
|
||||||
fun buildTree(psi: PsiElement): JKTreeRoot? =
|
fun buildTree(psi: PsiElement, saveImports: Boolean): JKTreeRoot? =
|
||||||
when (psi) {
|
when (psi) {
|
||||||
is PsiJavaFile -> psi.toJK()
|
is PsiJavaFile -> psi.toJK()
|
||||||
is PsiExpression -> with(expressionTreeMapper) { psi.toJK() }
|
is PsiExpression -> with(expressionTreeMapper) { psi.toJK() }
|
||||||
@@ -953,8 +970,8 @@ class JavaToJKTreeBuilder constructor(
|
|||||||
is PsiField -> with(declarationMapper) { psi.toJK() }
|
is PsiField -> with(declarationMapper) { psi.toJK() }
|
||||||
is PsiMethod -> with(declarationMapper) { psi.toJK() }
|
is PsiMethod -> with(declarationMapper) { psi.toJK() }
|
||||||
is PsiAnnotation -> with(declarationMapper) { psi.toJK() }
|
is PsiAnnotation -> with(declarationMapper) { psi.toJK() }
|
||||||
is PsiImportList -> psi.toJK()
|
is PsiImportList -> psi.toJK(saveImports)
|
||||||
is PsiImportStatementBase -> psi.toJK()
|
is PsiImportStatementBase -> psi.toJK(saveImports)
|
||||||
is PsiJavaCodeReferenceElement ->
|
is PsiJavaCodeReferenceElement ->
|
||||||
if (psi.parent is PsiReferenceList) {
|
if (psi.parent is PsiReferenceList) {
|
||||||
val factory = JavaPsiFacade.getInstance(psi.project).elementFactory
|
val factory = JavaPsiFacade.getInstance(psi.project).elementFactory
|
||||||
|
|||||||
@@ -21,16 +21,12 @@ import com.intellij.openapi.application.ModalityState
|
|||||||
import com.intellij.openapi.command.CommandProcessor
|
import com.intellij.openapi.command.CommandProcessor
|
||||||
import com.intellij.openapi.diagnostic.Logger
|
import com.intellij.openapi.diagnostic.Logger
|
||||||
import com.intellij.openapi.module.Module
|
import com.intellij.openapi.module.Module
|
||||||
import com.intellij.openapi.progress.EmptyProgressIndicator
|
|
||||||
import com.intellij.openapi.progress.ProcessCanceledException
|
import com.intellij.openapi.progress.ProcessCanceledException
|
||||||
import com.intellij.openapi.progress.ProgressIndicator
|
import com.intellij.openapi.progress.ProgressIndicator
|
||||||
import com.intellij.openapi.progress.ProgressManager
|
import com.intellij.openapi.progress.ProgressManager
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.openapi.util.Computable
|
import com.intellij.openapi.util.Computable
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.*
|
||||||
import com.intellij.psi.PsiExpression
|
|
||||||
import com.intellij.psi.PsiJavaFile
|
|
||||||
import com.intellij.psi.PsiStatement
|
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import org.jetbrains.kotlin.idea.core.util.EDT
|
import org.jetbrains.kotlin.idea.core.util.EDT
|
||||||
@@ -108,9 +104,18 @@ class NewJavaToKotlinConverter(
|
|||||||
symbolProvider.preBuildTree(inputElements)
|
symbolProvider.preBuildTree(inputElements)
|
||||||
val importStorage = ImportStorage()
|
val importStorage = ImportStorage()
|
||||||
val treeBuilder = JavaToJKTreeBuilder(symbolProvider, typeFactory, converterServices, importStorage)
|
val treeBuilder = JavaToJKTreeBuilder(symbolProvider, typeFactory, converterServices, importStorage)
|
||||||
|
|
||||||
|
|
||||||
|
// we want to leave all imports as is in the case when user is converting only imports
|
||||||
|
val saveImports = inputElements.all { element ->
|
||||||
|
element is PsiComment || element is PsiWhiteSpace
|
||||||
|
|| element is PsiImportStatementBase || element is PsiImportList
|
||||||
|
|| element is PsiPackageStatement
|
||||||
|
}
|
||||||
|
|
||||||
val asts = inputElements.mapIndexed { i, element ->
|
val asts = inputElements.mapIndexed { i, element ->
|
||||||
processor.updateState(i, 1, phaseDescription)
|
processor.updateState(i, 1, phaseDescription)
|
||||||
element to treeBuilder.buildTree(element)
|
element to treeBuilder.buildTree(element, saveImports)
|
||||||
}
|
}
|
||||||
|
|
||||||
val context = NewJ2kConverterContext(
|
val context = NewJ2kConverterContext(
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.nj2k.conversions
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.name.FqName
|
|
||||||
import org.jetbrains.kotlin.nj2k.NewJ2kConverterContext
|
|
||||||
import org.jetbrains.kotlin.nj2k.symbols.JKSymbol
|
|
||||||
import org.jetbrains.kotlin.nj2k.symbols.fqNameToImport
|
|
||||||
import org.jetbrains.kotlin.nj2k.tree.*
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.nj2k.types.JKClassType
|
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
|
||||||
|
|
||||||
|
|
||||||
class CollectImportsConversion(context: NewJ2kConverterContext) : RecursiveApplicableConversionBase(context) {
|
|
||||||
override fun applyToElement(element: JKTreeElement): JKTreeElement {
|
|
||||||
when (element) {
|
|
||||||
is JKClassAccessExpression -> addSymbol(element.identifier)
|
|
||||||
is JKFieldAccessExpression -> addSymbol(element.identifier)
|
|
||||||
is JKCallExpression -> addSymbol(element.identifier)
|
|
||||||
is JKAnnotation -> addSymbol(element.classSymbol)
|
|
||||||
is JKNewExpression -> addSymbol(element.classSymbol)
|
|
||||||
is JKInheritanceInfo -> {
|
|
||||||
element.implements
|
|
||||||
}
|
|
||||||
is JKTypeElement -> {
|
|
||||||
element.type.safeAs<JKClassType>()?.also {
|
|
||||||
addSymbol(it.classReference)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return recurse(element)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun addSymbol(symbol: JKSymbol) {
|
|
||||||
symbol.fqNameToImport()?.also { fqName ->
|
|
||||||
context.importStorage.addImport(FqName(fqName))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.nj2k.NewJ2kConverterContext
|
|||||||
import org.jetbrains.kotlin.nj2k.tree.JKImportList
|
import org.jetbrains.kotlin.nj2k.tree.JKImportList
|
||||||
import org.jetbrains.kotlin.nj2k.tree.JKTreeElement
|
import org.jetbrains.kotlin.nj2k.tree.JKTreeElement
|
||||||
|
|
||||||
class FilterImportsConversion(context : NewJ2kConverterContext) : RecursiveApplicableConversionBase(context) {
|
class FilterImportsConversion(context: NewJ2kConverterContext) : RecursiveApplicableConversionBase(context) {
|
||||||
override fun applyToElement(element: JKTreeElement): JKTreeElement {
|
override fun applyToElement(element: JKTreeElement): JKTreeElement {
|
||||||
if (element !is JKImportList) return recurse(element)
|
if (element !is JKImportList) return recurse(element)
|
||||||
element.imports = element.imports.filter { import ->
|
element.imports = element.imports.filter { import ->
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package to
|
package to
|
||||||
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.ArrayList
|
|
||||||
|
|
||||||
|
|
||||||
class JavaClass {
|
class JavaClass {
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package to
|
package to
|
||||||
|
|
||||||
import java.util.ArrayList
|
|
||||||
|
|
||||||
|
|
||||||
class JavaClass {
|
class JavaClass {
|
||||||
internal fun foo() {
|
internal fun foo() {
|
||||||
|
|||||||
+2
-1
@@ -1,3 +1,4 @@
|
|||||||
|
// ERROR: Unresolved reference: Test
|
||||||
// !forceNotNullTypes: false
|
// !forceNotNullTypes: false
|
||||||
// !specifyLocalVariableTypeByDefault: true
|
// !specifyLocalVariableTypeByDefault: true
|
||||||
package test
|
package test
|
||||||
@@ -19,7 +20,7 @@ class Test(str: String) {
|
|||||||
val test: String = "String2"
|
val test: String = "String2"
|
||||||
sout(test)
|
sout(test)
|
||||||
sout(dummy(test))
|
sout(dummy(test))
|
||||||
Test(test)
|
test.Test(test)
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|||||||
+2
-1
@@ -1,3 +1,4 @@
|
|||||||
|
// ERROR: Unresolved reference: Test
|
||||||
// !specifyLocalVariableTypeByDefault: true
|
// !specifyLocalVariableTypeByDefault: true
|
||||||
package test
|
package test
|
||||||
|
|
||||||
@@ -16,7 +17,7 @@ class Test(str: String?) {
|
|||||||
val test: String = "String2"
|
val test: String = "String2"
|
||||||
sout(test)
|
sout(test)
|
||||||
sout(dummy(test))
|
sout(dummy(test))
|
||||||
Test(test)
|
test.Test(test)
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import java.util.HashSet
|
|
||||||
|
|
||||||
internal class Foo {
|
internal class Foo {
|
||||||
fun foo(o: HashSet<*>) {
|
fun foo(o: HashSet<*>) {
|
||||||
val o2: HashSet<*> = o
|
val o2: HashSet<*> = o
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import java.util.HashSet
|
|
||||||
|
|
||||||
internal class Foo {
|
internal class Foo {
|
||||||
fun foo(o: HashSet<*>) {
|
fun foo(o: HashSet<*>) {
|
||||||
var foo = 0
|
var foo = 0
|
||||||
|
|||||||
Vendored
-2
@@ -1,7 +1,5 @@
|
|||||||
package demo
|
package demo
|
||||||
|
|
||||||
import java.util.HashMap
|
|
||||||
|
|
||||||
internal class Test {
|
internal class Test {
|
||||||
constructor() {}
|
constructor() {}
|
||||||
constructor(s: String?) {}
|
constructor(s: String?) {}
|
||||||
|
|||||||
+4
-2
@@ -3,10 +3,12 @@ package test
|
|||||||
object Test {
|
object Test {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
println()// Comment
|
println()
|
||||||
|
// Comment
|
||||||
|
|
||||||
// Comment1
|
|
||||||
foo()
|
foo()
|
||||||
|
// Comment1
|
||||||
|
|
||||||
// Comment2
|
// Comment2
|
||||||
.indexOf("s")
|
.indexOf("s")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import A.Nested
|
|
||||||
|
|
||||||
internal class A @JvmOverloads constructor(nested: Nested? = Nested(Nested.FIELD)) {
|
internal class A @JvmOverloads constructor(nested: Nested? = Nested(Nested.FIELD)) {
|
||||||
internal class Nested(p: Int) {
|
internal class Nested(p: Int) {
|
||||||
companion object {
|
companion object {
|
||||||
@@ -9,5 +7,5 @@ internal class A @JvmOverloads constructor(nested: Nested? = Nested(Nested.FIELD
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal class B {
|
internal class B {
|
||||||
var nested: Nested? = null
|
var nested: A.Nested? = null
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
package pack
|
package pack
|
||||||
|
|
||||||
import pack.A.Nested
|
|
||||||
|
|
||||||
internal class A @JvmOverloads constructor(nested: Nested? = Nested(Nested.FIELD)) {
|
internal class A @JvmOverloads constructor(nested: Nested? = Nested(Nested.FIELD)) {
|
||||||
internal class Nested(p: Int) {
|
internal class Nested(p: Int) {
|
||||||
companion object {
|
companion object {
|
||||||
@@ -11,5 +9,5 @@ internal class A @JvmOverloads constructor(nested: Nested? = Nested(Nested.FIELD
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal class B {
|
internal class B {
|
||||||
var nested: Nested? = null
|
var nested: A.Nested? = null
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
package pack
|
package pack
|
||||||
|
|
||||||
import pack.A.Nested
|
|
||||||
|
|
||||||
internal class A @JvmOverloads constructor(nested: Nested? = Nested(Nested.FIELD)) {
|
internal class A @JvmOverloads constructor(nested: Nested? = Nested(Nested.FIELD)) {
|
||||||
internal class Nested(p: Int) {
|
internal class Nested(p: Int) {
|
||||||
companion object {
|
companion object {
|
||||||
@@ -11,5 +9,5 @@ internal class A @JvmOverloads constructor(nested: Nested? = Nested(Nested.FIELD
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal class B {
|
internal class B {
|
||||||
var nested: Nested? = null
|
var nested: A.Nested? = null
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
import java.util.ArrayList
|
|
||||||
|
|
||||||
internal class A {
|
internal class A {
|
||||||
private val list1 = ArrayList<String>()
|
private val list1 = ArrayList<String>()
|
||||||
private val list2: MutableList<String> = ArrayList()
|
private val list2: MutableList<String> = ArrayList()
|
||||||
|
|||||||
-2
@@ -1,5 +1,3 @@
|
|||||||
import java.util.ArrayList
|
|
||||||
|
|
||||||
internal class A {
|
internal class A {
|
||||||
private val field1: List<String> = ArrayList()
|
private val field1: List<String> = ArrayList()
|
||||||
val field2: List<String> = ArrayList()
|
val field2: List<String> = ArrayList()
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import java.util.ArrayList
|
|
||||||
|
|
||||||
internal class C {
|
internal class C {
|
||||||
fun foo1(list: MutableList<String?>) {
|
fun foo1(list: MutableList<String?>) {
|
||||||
for (i in list.indices) {
|
for (i in list.indices) {
|
||||||
|
|||||||
-2
@@ -1,5 +1,3 @@
|
|||||||
import java.util.HashMap
|
|
||||||
|
|
||||||
internal object Test {
|
internal object Test {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
import java.util.Arrays
|
|
||||||
@@ -1,3 +1,2 @@
|
|||||||
// ERROR: Unresolved reference: ArrayBlockingQueue
|
// ERROR: Unresolved reference: ArrayBlockingQueue
|
||||||
import java.util.Arrays
|
|
||||||
import java.util.concurrent.ArrayBlockingQueue
|
import java.util.concurrent.ArrayBlockingQueue
|
||||||
|
|||||||
-2
@@ -1,8 +1,6 @@
|
|||||||
// ERROR: The integer literal does not conform to the expected type CapturedType(*)
|
// ERROR: The integer literal does not conform to the expected type CapturedType(*)
|
||||||
// ERROR: The integer literal does not conform to the expected type CapturedType(*)
|
// ERROR: The integer literal does not conform to the expected type CapturedType(*)
|
||||||
// ERROR: Type argument is not within its bounds: should be subtype of 'String?'
|
// ERROR: Type argument is not within its bounds: should be subtype of 'String?'
|
||||||
import java.util.HashMap
|
|
||||||
|
|
||||||
internal class G<T : String?>(t: T)
|
internal class G<T : String?>(t: T)
|
||||||
class Java {
|
class Java {
|
||||||
internal fun test() {
|
internal fun test() {
|
||||||
|
|||||||
-2
@@ -1,5 +1,3 @@
|
|||||||
import java.util.ArrayList
|
|
||||||
|
|
||||||
internal object A {
|
internal object A {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
|
|||||||
-2
@@ -1,7 +1,5 @@
|
|||||||
package test
|
package test
|
||||||
|
|
||||||
import java.util.HashMap
|
|
||||||
|
|
||||||
class TestPrimitiveFromMap {
|
class TestPrimitiveFromMap {
|
||||||
fun foo(map: HashMap<String?, Int?>): Int {
|
fun foo(map: HashMap<String?, Int?>): Int {
|
||||||
return map["zzz"]!!
|
return map["zzz"]!!
|
||||||
|
|||||||
-2
@@ -1,5 +1,3 @@
|
|||||||
import java.util.HashMap
|
|
||||||
|
|
||||||
class TestMethodReference {
|
class TestMethodReference {
|
||||||
private val hashMap = HashMap<String, String>()
|
private val hashMap = HashMap<String, String>()
|
||||||
fun update(key: String, msg: String) {
|
fun update(key: String, msg: String) {
|
||||||
|
|||||||
-2
@@ -1,5 +1,3 @@
|
|||||||
import java.util.HashMap
|
|
||||||
|
|
||||||
class TestMethodReference {
|
class TestMethodReference {
|
||||||
private val hashMap = HashMap<String, String>()
|
private val hashMap = HashMap<String, String>()
|
||||||
fun update(key: String, msg: String) {
|
fun update(key: String, msg: String) {
|
||||||
|
|||||||
-2
@@ -1,5 +1,3 @@
|
|||||||
import java.util.ArrayList
|
|
||||||
|
|
||||||
internal interface FooInterface {
|
internal interface FooInterface {
|
||||||
fun foo(): ArrayList<out Foo.SomeClass?>?
|
fun foo(): ArrayList<out Foo.SomeClass?>?
|
||||||
}
|
}
|
||||||
|
|||||||
-2
@@ -1,5 +1,3 @@
|
|||||||
import java.util.HashMap
|
|
||||||
|
|
||||||
class TestClass {
|
class TestClass {
|
||||||
private val hashMap: Map<String, List<Int>> = HashMap()
|
private val hashMap: Map<String, List<Int>> = HashMap()
|
||||||
}
|
}
|
||||||
-1
@@ -1,4 +1,3 @@
|
|||||||
import java.util.ArrayList
|
|
||||||
import java.util.function.Consumer
|
import java.util.function.Consumer
|
||||||
|
|
||||||
internal class Test {
|
internal class Test {
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import java.util.ArrayList
|
|
||||||
|
|
||||||
internal class A {
|
internal class A {
|
||||||
var list: List<String> = ArrayList()
|
var list: List<String> = ArrayList()
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import kotlinApi.KotlinClass.Companion.CONST
|
import kotlinApi.KotlinClass
|
||||||
|
|
||||||
class C {
|
class C {
|
||||||
internal fun bar() {
|
internal fun bar() {
|
||||||
println(CONST)
|
println(KotlinClass.CONST)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Vendored
-2
@@ -1,6 +1,4 @@
|
|||||||
// ERROR: Unresolved reference: LinkedList
|
// ERROR: Unresolved reference: LinkedList
|
||||||
import java.util.ArrayList
|
|
||||||
|
|
||||||
class ForEach {
|
class ForEach {
|
||||||
fun test() {
|
fun test() {
|
||||||
val xs = ArrayList<Any>()
|
val xs = ArrayList<Any>()
|
||||||
|
|||||||
Vendored
-2
@@ -1,6 +1,4 @@
|
|||||||
// ERROR: Unresolved reference: LinkedList
|
// ERROR: Unresolved reference: LinkedList
|
||||||
import java.util.ArrayList
|
|
||||||
|
|
||||||
class Lists {
|
class Lists {
|
||||||
fun test() {
|
fun test() {
|
||||||
val xs: MutableList<Any?> = ArrayList()
|
val xs: MutableList<Any?> = ArrayList()
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import java.util.HashMap
|
|
||||||
|
|
||||||
internal enum class E { A, B, C }
|
internal enum class E { A, B, C }
|
||||||
internal class A {
|
internal class A {
|
||||||
fun foo(list: List<String?>, collection: Collection<Int?>, map: Map<Int, Int?>) {
|
fun foo(list: List<String?>, collection: Collection<Int?>, map: Map<Int, Int?>) {
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import java.util.ArrayList
|
|
||||||
|
|
||||||
internal class A {
|
internal class A {
|
||||||
fun createCollection(): MutableCollection<String> {
|
fun createCollection(): MutableCollection<String> {
|
||||||
return ArrayList()
|
return ArrayList()
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import java.util.ArrayList
|
|
||||||
|
|
||||||
internal class A {
|
internal class A {
|
||||||
private val collection: MutableCollection<String>
|
private val collection: MutableCollection<String>
|
||||||
fun createCollection(): MutableCollection<String> {
|
fun createCollection(): MutableCollection<String> {
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import java.util.HashMap
|
|
||||||
|
|
||||||
internal class IteratorTest {
|
internal class IteratorTest {
|
||||||
var mutableMap1: MutableMap<String, String> = HashMap()
|
var mutableMap1: MutableMap<String, String> = HashMap()
|
||||||
var mutableMap2: MutableMap<String, String> = HashMap()
|
var mutableMap2: MutableMap<String, String> = HashMap()
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
import java.util.ArrayList
|
|
||||||
|
|
||||||
class TestMutableCollection {
|
class TestMutableCollection {
|
||||||
val list: MutableList<String> = ArrayList()
|
val list: MutableList<String> = ArrayList()
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
val it = list.iterator()
|
val it = list.iterator()
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import java.util.ArrayList
|
|
||||||
|
|
||||||
class Test {
|
class Test {
|
||||||
internal var list: List<MutableList<Int>> = ArrayList()
|
internal var list: List<MutableList<Int>> = ArrayList()
|
||||||
fun test() {
|
fun test() {
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import java.util.ArrayList
|
|
||||||
|
|
||||||
class Owner {
|
class Owner {
|
||||||
var list: MutableList<String> = ArrayList()
|
var list: MutableList<String> = ArrayList()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import java.util.ArrayList
|
|
||||||
|
|
||||||
internal class User {
|
internal class User {
|
||||||
fun main() {
|
fun main() {
|
||||||
val list: List<String> = ArrayList()
|
val list: List<String> = ArrayList()
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package org.test
|
package org.test
|
||||||
|
|
||||||
import java.util.ArrayList
|
|
||||||
|
|
||||||
internal class Member
|
internal class Member
|
||||||
internal class User {
|
internal class User {
|
||||||
fun main() {
|
fun main() {
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package test
|
package test
|
||||||
|
|
||||||
import java.util.ArrayList
|
|
||||||
|
|
||||||
class Test {
|
class Test {
|
||||||
private var myProp: String? = null
|
private var myProp: String? = null
|
||||||
private var myIntProp: Int? = null
|
private var myIntProp: Int? = null
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import javaApi.JavaClass
|
import javaApi.JavaClass
|
||||||
import kotlinApi.KotlinClass
|
import kotlinApi.KotlinClass
|
||||||
import java.util.HashMap
|
|
||||||
|
|
||||||
internal class X {
|
internal class X {
|
||||||
operator fun get(index: Int): Int {
|
operator fun get(index: Int): Int {
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import java.util.HashMap
|
|
||||||
|
|
||||||
internal class Test {
|
internal class Test {
|
||||||
fun test(map: HashMap<String?, String?>) {
|
fun test(map: HashMap<String?, String?>) {
|
||||||
map.forEach { (key: String?, value: String?) -> foo(key, value) }
|
map.forEach { (key: String?, value: String?) -> foo(key, value) }
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import java.util.ArrayList
|
|
||||||
|
|
||||||
internal class C<T> {
|
internal class C<T> {
|
||||||
fun foo1(src: Collection<T>) {
|
fun foo1(src: Collection<T>) {
|
||||||
val t = src.iterator().next()
|
val t = src.iterator().next()
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package demo
|
package demo
|
||||||
|
|
||||||
import java.util.HashMap
|
|
||||||
|
|
||||||
internal class Test {
|
internal class Test {
|
||||||
fun main() {
|
fun main() {
|
||||||
val commonMap = HashMap<String, Int>()
|
val commonMap = HashMap<String, Int>()
|
||||||
|
|||||||
-2
@@ -1,7 +1,5 @@
|
|||||||
package demo
|
package demo
|
||||||
|
|
||||||
import java.util.ArrayList
|
|
||||||
|
|
||||||
internal class Test {
|
internal class Test {
|
||||||
fun main() {
|
fun main() {
|
||||||
val common: List<String> = ArrayList()
|
val common: List<String> = ArrayList()
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import java.util.ArrayList
|
|
||||||
|
|
||||||
internal class A {
|
internal class A {
|
||||||
private val field1: List<String> = ArrayList()
|
private val field1: List<String> = ArrayList()
|
||||||
val field2: List<String> = ArrayList()
|
val field2: List<String> = ArrayList()
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package demo
|
package demo
|
||||||
|
|
||||||
import java.util.ArrayList
|
|
||||||
|
|
||||||
class TestJava {
|
class TestJava {
|
||||||
fun f(result: Function1<String?, Unit>) {
|
fun f(result: Function1<String?, Unit>) {
|
||||||
result.invoke("a")
|
result.invoke("a")
|
||||||
|
|||||||
@@ -1,4 +1,2 @@
|
|||||||
import java.util.ArrayList
|
|
||||||
|
|
||||||
internal interface I<T : List<Iterator<String?>?>?>
|
internal interface I<T : List<Iterator<String?>?>?>
|
||||||
internal class C : I<ArrayList<Iterator<String?>?>?>
|
internal class C : I<ArrayList<Iterator<String?>?>?>
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
import java.util.HashMap
|
|
||||||
|
|
||||||
internal class A {
|
internal class A {
|
||||||
fun foo() {
|
fun foo() {
|
||||||
val map1 = getMap1<String, Int>()
|
val map1 = getMap1<String, Int>()
|
||||||
|
|||||||
+1
-2
@@ -2,8 +2,7 @@
|
|||||||
// ERROR: Type mismatch: inferred type is (CapturedType(*)!!..Any?) but String? was expected
|
// ERROR: Type mismatch: inferred type is (CapturedType(*)!!..Any?) but String? was expected
|
||||||
// ERROR: Type mismatch: inferred type is Any? but String? was expected
|
// ERROR: Type mismatch: inferred type is Any? but String? was expected
|
||||||
// ERROR: Type mismatch: inferred type is (CapturedType(*)!!..Any?) but String? was expected
|
// ERROR: Type mismatch: inferred type is (CapturedType(*)!!..Any?) but String? was expected
|
||||||
// ERROR: Type mismatch: inferred type is HashMap<Any?, Any?> but Map<String?, String?> was expected
|
// ERROR: Type mismatch: inferred type is kotlin.collections.HashMap<Any?, Any?> /* = java.util.HashMap<Any?, Any?> */ but Map<String?, String?> was expected
|
||||||
import java.util.HashMap
|
|
||||||
import java.util.Properties
|
import java.util.Properties
|
||||||
|
|
||||||
internal object A {
|
internal object A {
|
||||||
|
|||||||
Reference in New Issue
Block a user