Compare commits

...

17 Commits

Author SHA1 Message Date
Natalia Ukhorskaya
22add1ee89 Correct resource path for flavors in android-extensions-plugin
(cherry picked from commit 51abb021bc)
2015-12-04 17:25:02 +03:00
Natalia Ukhorskaya
2ecc21b440 Do not cache AndroidModule in IDEAndroidLayoutXmlManager
(cherry picked from commit c523817)
2015-12-04 17:22:50 +03:00
Dmitry Jemerov
0113ccaad1 fix compilation after changes in markdown library
(cherry picked from commit ce9012c)
2015-12-03 15:33:25 +01:00
Natalia Ukhorskaya
41141fbe23 Fix NoSuchMethod in android-extensions-plugin
#KT-10263 Fixed
(cherry picked from commit a197fc8)
2015-12-03 16:19:12 +03:00
Nikolay Krasko
1d076154b1 Exclude idl2k module from build in beta3 2015-12-02 17:46:43 +03:00
Mikhail Glukhikh
58d78011c0 Creating deep copy of local function declaration instructions in CFA, regression test #KT-10243 Fixed
(cherry picked from commit 60e457167d)
2015-12-01 23:50:02 +03:00
Zalim Bashorov
b33ad0c528 Minor: don't process changes for incremental build during rebuild 2015-12-01 21:27:45 +03:00
Ilya Gorbunov
6dbec92bfe Remove replacement with upcast. Remove deprecation from *Raw methods until beta4. 2015-12-01 19:51:12 +03:00
Alexey Sedunov
bb57825d21 Introduce Variable: Forbid multi-declaration for collections and arrays
#KT-10242 Fixed
2015-12-01 19:39:56 +03:00
Alexey Sedunov
ddb50031d8 Introduce Variable: Suggest choosing between single variable and multi-declaration
#KT-10242 Fixed
2015-12-01 19:36:34 +03:00
Nikolay Krasko
50dcd08cb5 Enable auto-increment 2015-12-01 15:27:00 +03:00
Pavel V. Talanov
df6298de39 Minor, getModuleInfo: improve on failure messages 2015-12-01 14:55:41 +03:00
Pavel V. Talanov
a9c1e57230 getModuleInfo: Provide utility to default to null instead of logging an error
Use it to workaround cases when java resolve references some unexpected classes/files, referencing non-physical Dummy.java in particular
2015-12-01 14:55:39 +03:00
Pavel V. Talanov
378a964c2f getModuleInfo: Correct module info for members of light classes for decompiled Kotlin classes 2015-12-01 14:55:38 +03:00
Stanislav Erokhin
170a0393f6 Revert "Original type is taken into account when intersecting possible types in resolve #KT-10232 Fixed"
This reverts commit fe04cc513b.
2015-12-01 13:02:45 +03:00
Nikolay Krasko
95d4dd4962 Enable bootstrapping in branch 2015-12-01 00:02:09 +03:00
Nikolay Krasko
288248c964 Remove android extension plugin from relay 2015-11-30 23:58:28 +03:00
38 changed files with 373 additions and 205 deletions

View File

@@ -88,12 +88,5 @@
origin.version="${relay.origin.version}"
plugin.subdir="BareKotlin"
substituted.version="${relay.substitute.version}"/>
<substitudeVersionInPlugin
plugin.jar.name="kotlin-android-extensions"
plugin.path="${relay.plugins.dir}/kotlin-android-extensions-plugin-${relay.origin.version}.zip"
origin.version="${relay.origin.version}"
plugin.subdir="KotlinAndroidExtensions"
substituted.version="${relay.substitute.version}"/>
</target>
</project>

View File

@@ -40,7 +40,7 @@ import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory
import java.util.*
public class JvmPlatformParameters(
public val moduleByJavaClass: (JavaClass) -> ModuleInfo
public val moduleByJavaClass: (JavaClass) -> ModuleInfo?
) : PlatformAnalysisParameters
@@ -68,7 +68,10 @@ public object JvmAnalyzerFacade : AnalyzerFacade<JvmPlatformParameters>() {
// We don't have full control over idea resolve api so we allow for a situation which should not happen in Kotlin.
// For example, type in a java library can reference a class declared in a source root (is valid but rare case)
// Providing a fallback strategy in this case can hide future problems, so we should at least log to be able to diagnose those
val resolverForReferencedModule = resolverForProject.tryGetResolverForModule(referencedClassModule as M)
@Suppress("UNCHECKED_CAST")
val resolverForReferencedModule = referencedClassModule?.let { resolverForProject.tryGetResolverForModule(it as M) }
val resolverForModule = resolverForReferencedModule ?: run {
LOG.warn("Java referenced $referencedClassModule from $moduleInfo\nReferenced class was: $javaClass\n")
// in case referenced class lies outside of our resolver, resolve the class as if it is inside our module

View File

@@ -66,4 +66,6 @@ public interface Pseudocode {
List<? extends Instruction> getUsages(@Nullable PseudoValue value);
boolean isSideEffectFree(@NotNull Instruction instruction);
Pseudocode copy();
}

View File

@@ -458,6 +458,41 @@ public class PseudocodeImpl implements Pseudocode {
return mutableInstructionList.get(targetPosition);
}
@Override
public PseudocodeImpl copy() {
PseudocodeImpl result = new PseudocodeImpl(correspondingElement);
result.repeatWhole(this);
return result;
}
private void repeatWhole(PseudocodeImpl originalPseudocode) {
Map<Label, Label> originalToCopy = Maps.newLinkedHashMap();
Multimap<Instruction, Label> originalLabelsForInstruction = HashMultimap.create();
int labelCount = 0;
for (PseudocodeLabel label : originalPseudocode.labels) {
originalToCopy.put(label, label.copy(labelCount++));
originalLabelsForInstruction.put(getJumpTarget(label), label);
}
for (Label label : originalToCopy.values()) {
labels.add((PseudocodeLabel) label);
}
for (Instruction originalInstruction : originalPseudocode.mutableInstructionList) {
repeatLabelsBindingForInstruction(originalInstruction, originalToCopy, originalLabelsForInstruction);
Instruction copy = copyInstruction(originalInstruction, originalToCopy);
addInstruction(copy);
if (originalInstruction == originalPseudocode.errorInstruction && copy instanceof SubroutineExitInstruction) {
errorInstruction = (SubroutineExitInstruction) copy;
}
if (originalInstruction == originalPseudocode.exitInstruction && copy instanceof SubroutineExitInstruction) {
exitInstruction = (SubroutineExitInstruction) copy;
}
if (originalInstruction == originalPseudocode.sinkInstruction && copy instanceof SubroutineSinkInstruction) {
sinkInstruction = (SubroutineSinkInstruction) copy;
}
}
parent = originalPseudocode.parent;
}
public int repeatPart(@NotNull Label startLabel, @NotNull Label finishLabel, int labelCount) {
PseudocodeImpl originalPseudocode = ((PseudocodeLabel) startLabel).getPseudocode();

View File

@@ -57,5 +57,5 @@ public class LocalFunctionDeclarationInstruction(
override fun toString(): String = "d(${render(element)})"
override fun createCopy(): InstructionImpl =
LocalFunctionDeclarationInstruction(element, body, lexicalScope)
LocalFunctionDeclarationInstruction(element, body.copy(), lexicalScope)
}

View File

@@ -197,7 +197,7 @@ class GenericCandidateResolver(private val argumentTypeResolver: ArgumentTypeRes
val possibleTypes = context.dataFlowInfo.getPossibleTypes(dataFlowValue)
if (possibleTypes.isEmpty()) return type
return TypeIntersector.intersectTypes(KotlinTypeChecker.DEFAULT, possibleTypes + type)
return TypeIntersector.intersectTypes(KotlinTypeChecker.DEFAULT, possibleTypes)
}
fun <D : CallableDescriptor> completeTypeInferenceDependentOnFunctionArgumentsForCall(context: CallCandidateResolutionContext<D>) {

View File

@@ -38,7 +38,7 @@ fun <T : CharSequence?> foo(x: T) {
<!DEBUG_INFO_SMARTCAST!>x<!>.length
x<!UNNECESSARY_SAFE_CALL!>?.<!>length
x.bar1()
<!DEBUG_INFO_SMARTCAST!>x<!>.bar1()
x.bar2()
<!DEBUG_INFO_SMARTCAST!>x<!>.bar3()
}

View File

@@ -0,0 +1,16 @@
val f: Boolean = true
private fun doUpdateRegularTasks() {
try {
while (f) {
val xmlText = <!UNRESOLVED_REFERENCE!>getText<!>()
if (<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>xmlText<!> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>==<!> null) {}
else {
<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>xmlText<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>value<!> = 0 // !!!
}
}
}
finally {
fun execute() {}
}
}

View File

@@ -0,0 +1,4 @@
package
public val f: kotlin.Boolean = true
private fun doUpdateRegularTasks(): kotlin.Unit

View File

@@ -1,15 +0,0 @@
// Type inference failed after smart cast
interface A<T>
interface B<T> : A<T>
fun <T> foo(b: A<T>) = b
fun <T> test(a: A<T>) {
if (a is Any) {
// Error:(9, 9) Kotlin: Type inference failed: fun <T> foo(b: A<T>): kotlin.Unit
// cannot be applied to (A<T>)
foo(a)
}
foo(a) // ok
}

View File

@@ -1,16 +0,0 @@
package
public fun </*0*/ T> foo(/*0*/ b: A<T>): A<T>
public fun </*0*/ T> test(/*0*/ a: A<T>): kotlin.Unit
public interface A</*0*/ T> {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface B</*0*/ T> : A<T> {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}

View File

@@ -12546,6 +12546,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("kt10243.kt")
public void testKt10243() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/regressions/kt10243.kt");
doTest(fileName);
}
@TestMetadata("kt127.kt")
public void testKt127() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/regressions/kt127.kt");
@@ -14742,12 +14748,6 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("kt10232.kt")
public void testKt10232() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/kt10232.kt");
doTest(fileName);
}
@TestMetadata("kt1461.kt")
public void testKt1461() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/kt1461.kt");

View File

@@ -59,7 +59,7 @@ fun createModuleResolverProvider(
val jvmPlatformParameters = JvmPlatformParameters {
javaClass: JavaClass ->
val psiClass = (javaClass as JavaClassImpl).getPsi()
psiClass.getModuleInfo()
psiClass.getNullableModuleInfo()
}
val resolverForProject = analyzerFacade.setupResolverForProject(

View File

@@ -28,13 +28,20 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.roots.ModuleRootManager
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
import org.jetbrains.kotlin.utils.sure
fun PsiElement.getModuleInfo(): IdeaModuleInfo {
fun logAndReturnDefault(message: String): IdeaModuleInfo {
LOG.error("Could not find correct module information.\nReason: $message")
return NotUnderContentRootModuleInfo
}
fun PsiElement.getModuleInfo(): IdeaModuleInfo = this.getModuleInfo { reason ->
LOG.error("Could not find correct module information.\nReason: $reason")
NotUnderContentRootModuleInfo
}.sure { "Defaulting to NotUnderContentRootModuleInfo so null is not possible" }
fun PsiElement.getNullableModuleInfo(): IdeaModuleInfo? = this.getModuleInfo { reason ->
LOG.warn("Could not find correct module information.\nReason: $reason")
null
}
private fun PsiElement.getModuleInfo(onFailure: (String) -> IdeaModuleInfo?): IdeaModuleInfo? {
if (this is KtLightElement<*, *>) return this.getModuleInfoForLightElement()
val containingJetFile = (this as? KtElement)?.getContainingFile() as? KtFile
@@ -43,7 +50,7 @@ fun PsiElement.getModuleInfo(): IdeaModuleInfo {
val doNotAnalyze = containingJetFile?.doNotAnalyze
if (doNotAnalyze != null) {
return logAndReturnDefault(
return onFailure(
"Should not analyze element: ${getText()} in file ${containingJetFile?.getName() ?: " <no file>"}\n$doNotAnalyze"
)
}
@@ -53,15 +60,13 @@ fun PsiElement.getModuleInfo(): IdeaModuleInfo {
if (containingJetFile is KtCodeFragment) {
return containingJetFile.getContext()?.getModuleInfo()
?: logAndReturnDefault("Analyzing code fragment of type ${containingJetFile.javaClass} with no context element\nText:\n${containingJetFile.getText()}")
?: onFailure("Analyzing code fragment of type ${containingJetFile.javaClass} with no context element\nText:\n${containingJetFile.getText()}")
}
val project = getProject()
val containingFile = getContainingFile()
?: return logAndReturnDefault("Analyzing element of type $javaClass with no containing file\nText:\n${getText()}")
val containingFile = containingFile ?: return onFailure("Analyzing element of type $javaClass with no containing file\nText:\n$text")
val virtualFile = containingFile.getOriginalFile().getVirtualFile()
?: return logAndReturnDefault("Analyzing non-physical file $containingFile of type ${containingFile.javaClass}")
val virtualFile = containingFile.originalFile.virtualFile
?: return onFailure("Analyzing element of type $javaClass in non-physical file $containingFile of type ${containingFile.javaClass}\nText:\n$text")
return getModuleInfoByVirtualFile(
project,
@@ -115,8 +120,13 @@ private fun getModuleInfoByVirtualFile(project: Project, virtualFile: VirtualFil
}
private fun KtLightElement<*, *>.getModuleInfoForLightElement(): IdeaModuleInfo {
if (this is KtLightClassForDecompiledDeclaration) {
return getModuleInfoByVirtualFile(getProject(), getContainingFile().getVirtualFile(), false)
val decompiledClass = this.getParentOfType<KtLightClassForDecompiledDeclaration>(strict = false)
if (decompiledClass != null) {
return getModuleInfoByVirtualFile(
project,
containingFile.virtualFile.sure { "Decompiled class should be build from physical file" },
false
)
}
val element = getOrigin() ?: when (this) {
is FakeLightClassForFileOfPackage -> this.getContainingFile()!!

View File

@@ -179,7 +179,7 @@ object KDocRenderer {
}
}
MarkdownTokenTypes.TEXT,
MarkdownTokenTypes.CODE,
MarkdownTokenTypes.CODE_LINE,
MarkdownTokenTypes.WHITE_SPACE,
MarkdownTokenTypes.COLON,
MarkdownTokenTypes.SINGLE_QUOTE,

View File

@@ -24,7 +24,7 @@ import com.intellij.openapi.command.impl.FinishMarkAction
import com.intellij.openapi.command.impl.StartMarkAction
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.Messages
import com.intellij.openapi.ui.popup.JBPopupFactory
import com.intellij.openapi.util.Key
import com.intellij.openapi.util.TextRange
import com.intellij.psi.*
@@ -32,6 +32,7 @@ import com.intellij.psi.util.PsiTreeUtil
import com.intellij.refactoring.HelpID
import com.intellij.refactoring.introduce.inplace.OccurrencesChooser
import com.intellij.refactoring.util.CommonRefactoringUtil
import com.intellij.ui.components.JBList
import com.intellij.util.SmartList
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
@@ -378,13 +379,29 @@ object KotlinIntroduceVariableHandler : KotlinIntroduceHandlerBase() {
CommonRefactoringUtil.showErrorHint(project, editor, message, INTRODUCE_VARIABLE, HelpID.INTRODUCE_VARIABLE)
}
private fun KtExpression.chooseApplicableComponentFunctions(haveOccurrencesToReplace: Boolean): List<FunctionDescriptor>? {
if (haveOccurrencesToReplace) return emptyList()
private fun KtExpression.chooseApplicableComponentFunctions(
haveOccurrencesToReplace: Boolean,
editor: Editor?,
callback: (List<FunctionDescriptor>) -> Unit
) {
if (haveOccurrencesToReplace) return callback(emptyList())
val functions = getApplicableComponentFunctions(this)
if (functions.size <= 1) return emptyList()
if (functions.size <= 1) return callback(emptyList())
return functions
if (ApplicationManager.getApplication().isUnitTestMode) return callback(functions)
if (editor == null) return callback(emptyList())
val list = JBList("Create single variable", "Create destructuring declaration")
JBPopupFactory.getInstance()
.createListPopupBuilder(list)
.setMovable(true)
.setResizable(false)
.setRequestFocus(true)
.setItemChoosenCallback { callback(if (list.selectedIndex == 0) emptyList() else functions) }
.createPopup()
.showInBestPositionFor(editor)
}
private fun executeMultiDeclarationTemplate(
@@ -517,67 +534,67 @@ object KotlinIntroduceVariableHandler : KotlinIntroduceHandlerBase() {
commonContainer = container
}
val componentFunctions = physicalExpression.chooseApplicableComponentFunctions(replaceOccurrence) ?: return@Pass
val validator = NewDeclarationNameValidator(
commonContainer,
calculateAnchor(commonParent, commonContainer, allReplaces),
NewDeclarationNameValidator.Target.VARIABLES
)
val suggestedNames = if (componentFunctions.isNotEmpty()) {
val collectingValidator = CollectingNameValidator(filter = validator)
componentFunctions.map { suggestNamesForComponent(it, project, collectingValidator) }
}
else {
KotlinNameSuggester.suggestNamesByExpressionAndType(expression,
substringInfo?.type,
bindingContext,
validator,
"value").singletonList()
}
val introduceVariableContext = IntroduceVariableContext(
expression, suggestedNames, allReplaces, commonContainer, commonParent,
replaceOccurrence, noTypeInference, expressionType, componentFunctions, bindingContext, resolutionFacade
)
project.executeCommand(INTRODUCE_VARIABLE, null) {
runWriteAction { introduceVariableContext.runRefactoring() }
val property = introduceVariableContext.propertyRef ?: return@executeCommand
if (editor == null) {
onNonInteractiveFinish?.invoke(property)
return@executeCommand
physicalExpression.chooseApplicableComponentFunctions(replaceOccurrence, editor) { componentFunctions ->
val validator = NewDeclarationNameValidator(
commonContainer,
calculateAnchor(commonParent, commonContainer, allReplaces),
NewDeclarationNameValidator.Target.VARIABLES
)
val suggestedNames = if (componentFunctions.isNotEmpty()) {
val collectingValidator = CollectingNameValidator(filter = validator)
componentFunctions.map { suggestNamesForComponent(it, project, collectingValidator) }
}
else {
KotlinNameSuggester.suggestNamesByExpressionAndType(expression,
substringInfo?.type,
bindingContext,
validator,
"value").singletonList()
}
val introduceVariableContext = IntroduceVariableContext(
expression, suggestedNames, allReplaces, commonContainer, commonParent,
replaceOccurrence, noTypeInference, expressionType, componentFunctions, bindingContext, resolutionFacade
)
project.executeCommand(INTRODUCE_VARIABLE, null) {
runWriteAction { introduceVariableContext.runRefactoring() }
editor.caretModel.moveToOffset(property.textOffset)
editor.selectionModel.removeSelection()
val property = introduceVariableContext.propertyRef ?: return@executeCommand
if (!isInplaceAvailable) return@executeCommand
PsiDocumentManager.getInstance(project).commitDocument(editor.document)
PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(editor.document)
when (property) {
is KtProperty -> {
KotlinVariableInplaceIntroducer(
property,
introduceVariableContext.reference,
introduceVariableContext.references.toTypedArray(),
suggestedNames.single(),
/*todo*/ false,
/*todo*/ false,
expressionType,
noTypeInference,
project,
editor
).startInplaceIntroduceTemplate()
if (editor == null) {
onNonInteractiveFinish?.invoke(property)
return@executeCommand
}
is KtMultiDeclaration -> {
executeMultiDeclarationTemplate(project, editor, property, suggestedNames)
}
editor.caretModel.moveToOffset(property.textOffset)
editor.selectionModel.removeSelection()
else -> throw AssertionError("Unexpected declaration: ${property.getElementTextWithContext()}")
if (!isInplaceAvailable) return@executeCommand
PsiDocumentManager.getInstance(project).commitDocument(editor.document)
PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(editor.document)
when (property) {
is KtProperty -> {
KotlinVariableInplaceIntroducer(
property,
introduceVariableContext.reference,
introduceVariableContext.references.toTypedArray(),
suggestedNames.single(),
/*todo*/ false,
/*todo*/ false,
expressionType,
noTypeInference,
project,
editor
).startInplaceIntroduceTemplate()
}
is KtMultiDeclaration -> {
executeMultiDeclarationTemplate(project, editor, property, suggestedNames)
}
else -> throw AssertionError("Unexpected declaration: ${property.getElementTextWithContext()}")
}
}
}
}

View File

@@ -16,19 +16,37 @@
package org.jetbrains.kotlin.idea.refactoring.introduce.introduceVariable
import org.jetbrains.kotlin.builtins.PrimitiveType
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.idea.analysis.analyzeInContext
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.imports.importableFqName
import org.jetbrains.kotlin.idea.util.getResolutionScope
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtPsiFactory
import org.jetbrains.kotlin.psi.createExpressionByPattern
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
import org.jetbrains.kotlin.types.typeUtil.supertypes
import org.jetbrains.kotlin.util.isValidOperator
import org.jetbrains.kotlin.utils.addToStdlib.singletonList
fun getApplicableComponentFunctions(expression: KtExpression): List<FunctionDescriptor> {
val facade = expression.getResolutionFacade()
val scope = expression.getResolutionScope(facade.analyze(expression), facade)
val context = facade.analyze(expression)
val builtIns = facade.moduleDescriptor.builtIns
val forbiddenClasses = arrayListOf(builtIns.collection, builtIns.array)
PrimitiveType.values().mapTo(forbiddenClasses) { builtIns.getPrimitiveArrayClassDescriptor(it) }
context.getType(expression)?.let {
if ((it.singletonList() + it.supertypes()).any {
val fqName = it.constructor.declarationDescriptor?.importableFqName
forbiddenClasses.any { it.fqNameSafe == fqName }
}) return emptyList()
}
val scope = expression.getResolutionScope(context, facade)
val psiFactory = KtPsiFactory(expression)
@Suppress("UNCHECKED_CAST")

View File

@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun foo() {
<selection>arrayOf("1", "2", "3")</selection>
}

View File

@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun foo() {
val arrayOf = arrayOf("1", "2", "3")
}

View File

@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun foo() {
<selection>intArrayOf(1, 2, 3)</selection>
}

View File

@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun foo() {
val intArrayOf = intArrayOf(1, 2, 3)
}

View File

@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun foo() {
<selection>listOf(1, 2, 3)</selection>
}

View File

@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun foo() {
val listOf = listOf(1, 2, 3)
}

View File

@@ -0,0 +1,46 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.idea.caches.resolve
import com.intellij.psi.JavaPsiFacade
import com.intellij.psi.PsiElementFactory
import com.intellij.psi.search.GlobalSearchScope
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
import org.junit.Assert
public class CustomModuleInfoTest : KotlinLightCodeInsightFixtureTestCase() {
override fun getProjectDescriptor() = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
fun testModuleInfoForMembersOfLightClassForDecompiledFile() {
//NOTE: any class with methods from stdlib will do
val collectionsKtClass = JavaPsiFacade.getInstance(project).findClass("kotlin.CollectionsKt", GlobalSearchScope.allScope(project))!!
val classModuleInfo = collectionsKtClass.getModuleInfo()
Assert.assertTrue(classModuleInfo is LibraryInfo)
val methods = collectionsKtClass.methods
Assert.assertTrue(methods.isNotEmpty())
methods.forEach {
Assert.assertEquals("Members of decompiled class should have the same module info", classModuleInfo, it.getModuleInfo())
}
}
fun testModuleInfoForPsiCreatedByJavaPsiFactory() {
val dummyClass = PsiElementFactory.SERVICE.getInstance(project).createClass("A")
val moduleInfo = dummyClass.getNullableModuleInfo()
Assert.assertEquals("Should be null for psi created by factory", null, moduleInfo)
}
}

View File

@@ -516,6 +516,24 @@ public class ExtractionTestGenerated extends AbstractExtractionTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/introduceVariable/multiDeclarations"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("array.kt")
public void testArray() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/introduceVariable/multiDeclarations/array.kt");
doIntroduceVariableTest(fileName);
}
@TestMetadata("intArray.kt")
public void testIntArray() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/introduceVariable/multiDeclarations/intArray.kt");
doIntroduceVariableTest(fileName);
}
@TestMetadata("list.kt")
public void testList() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/introduceVariable/multiDeclarations/list.kt");
doIntroduceVariableTest(fileName);
}
@TestMetadata("notOperators.kt")
public void testNotOperators() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/introduceVariable/multiDeclarations/notOperators.kt");

View File

@@ -211,6 +211,10 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
updateJavaMappings(chunk, compilationErrors, context, dirtyFilesHolder, filesToCompile, generatedClasses)
updateLookupStorage(chunk, lookupTracker, dataManager, dirtyFilesHolder, filesToCompile)
if (JavaBuilderUtil.isForcedRecompilationAllJavaModules(context)) {
return OK
}
val caches = filesToCompile.keySet().map { incrementalCaches[it]!! }
processChanges(context, chunk, filesToCompile.values(), allCompiledFiles, dataManager, caches, changesInfo)

View File

@@ -85,7 +85,6 @@
<!--NB! kotlin-js-library should be built before kotlin-gradle-plugin-->
<!--because it is used in tests but cannot be added as test-dependency-->
<!--(kotlin-gradle-plugin module will be recognized as kotlin-js module)-->
<module>tools/idl2k</module>
<module>tools/kotlin-js-library</module>
<module>tools/kotlin-annotation-processing</module>
<module>examples/annotation-processor-example</module>

View File

@@ -438,21 +438,20 @@ public operator fun ShortArray.contains(element: Short): Boolean {
/**
* Returns `true` if [element] is found in the collection.
*/
@Deprecated("Array and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("contains(element as T)"))
@Deprecated("Array and element have incompatible types. Upcast element to Any? if you're sure. Replacement will be provided in beta4.")
@kotlin.jvm.JvmName("containsAny")
@kotlin.internal.LowPriorityInOverloadResolution
public operator fun <T> Array<out T>.contains(element: T): Boolean {
return contains(element as T)
return contains(element)
}
/**
* Returns `true` if [element] is found in the array.
* Allows to overcome type-safety restriction of `contains` that requires to pass an element of type `T`.
*/
@Deprecated("Array and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("contains(element as Any?)"))
@Suppress("NOTHING_TO_INLINE")
public inline fun <T> Array<out T>.containsRaw(element: Any?): Boolean {
return contains(element as Any?)
return contains(element)
}
/**
@@ -1321,12 +1320,12 @@ public fun ShortArray.indexOf(element: Short): Int {
/**
* Returns first index of [element], or -1 if the collection does not contain element.
*/
@Deprecated("Array and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("indexOf(element as T)"))
@Deprecated("Array and element have incompatible types. Upcast element to Any? if you're sure. Replacement will be provided in beta4.")
@kotlin.jvm.JvmName("indexOfAny")
@kotlin.internal.LowPriorityInOverloadResolution
@Suppress("NOTHING_TO_INLINE")
public fun <T> Array<out T>.indexOf(element: T): Int {
return indexOf(element as T)
return indexOf(element)
}
/**
@@ -1549,10 +1548,9 @@ public inline fun ShortArray.indexOfLast(predicate: (Short) -> Boolean): Int {
* Returns first index of [element], or -1 if the array does not contain element.
* Allows to overcome type-safety restriction of `indexOf` that requires to pass an element of type `T`.
*/
@Deprecated("Array and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("indexOf(element as Any?)"))
@Suppress("NOTHING_TO_INLINE")
public inline fun <T> Array<out T>.indexOfRaw(element: Any?): Int {
return indexOf(element as Any?)
return indexOf(element)
}
/**
@@ -1872,22 +1870,21 @@ public fun ShortArray.lastIndexOf(element: Short): Int {
/**
* Returns last index of [element], or -1 if the collection does not contain element.
*/
@Deprecated("Array and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("lastIndexOf(element as T)"))
@Deprecated("Array and element have incompatible types. Upcast element to Any? if you're sure. Replacement will be provided in beta4.")
@kotlin.jvm.JvmName("lastIndexOfAny")
@kotlin.internal.LowPriorityInOverloadResolution
@Suppress("NOTHING_TO_INLINE")
public fun <T> Array<out T>.lastIndexOf(element: T): Int {
return lastIndexOf(element as T)
return lastIndexOf(element)
}
/**
* Returns last index of [element], or -1 if the array does not contain element.
* Allows to overcome type-safety restriction of `lastIndexOf` that requires to pass an element of type `T`.
*/
@Deprecated("Array and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("lastIndexOf(element as Any?)"))
@Suppress("NOTHING_TO_INLINE")
public inline fun <T> Array<out T>.lastIndexOfRaw(element: Any?): Int {
return lastIndexOf(element as Any?)
return lastIndexOf(element)
}
/**

View File

@@ -64,21 +64,20 @@ public operator fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.contains(ele
/**
* Returns `true` if [element] is found in the collection.
*/
@Deprecated("Collection and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("contains(element as T)"))
@Deprecated("Collection and element have incompatible types. Upcast element to Any? if you're sure. Replacement will be provided in beta4.")
@kotlin.jvm.JvmName("containsAny")
@kotlin.internal.LowPriorityInOverloadResolution
public operator fun <T> Iterable<T>.contains(element: T): Boolean {
return contains(element as T)
return contains(element)
}
/**
* Returns `true` if [element] is found in the collection.
* Allows to overcome type-safety restriction of `contains` that requires to pass an element of type `T`.
*/
@Deprecated("Collection and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("contains(element as Any?)"))
@Suppress("NOTHING_TO_INLINE")
public inline fun Iterable<*>.containsRaw(element: Any?): Boolean {
return contains(element as Any?)
return contains(element)
}
/**
@@ -281,23 +280,23 @@ public fun <@kotlin.internal.OnlyInputTypes T> List<T>.indexOf(element: T): Int
/**
* Returns first index of [element], or -1 if the collection does not contain element.
*/
@Deprecated("Collection and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("indexOf(element as T)"))
@Deprecated("Collection and element have incompatible types. Upcast element to Any? if you're sure. Replacement will be provided in beta4.")
@kotlin.jvm.JvmName("indexOfAny")
@kotlin.internal.LowPriorityInOverloadResolution
@Suppress("NOTHING_TO_INLINE")
public fun <T> Iterable<T>.indexOf(element: T): Int {
return indexOf(element as T)
return indexOf(element)
}
/**
* Returns first index of [element], or -1 if the collection does not contain element.
*/
@Deprecated("List and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("indexOf(element as T)"))
@Deprecated("List and element have incompatible types. Upcast element to Any? if you're sure. Replacement will be provided in beta4.")
@kotlin.jvm.JvmName("indexOfAny")
@kotlin.internal.LowPriorityInOverloadResolution
@Suppress("NOTHING_TO_INLINE")
public fun <T> List<T>.indexOf(element: T): Int {
return indexOf(element as T)
return indexOf(element)
}
/**
@@ -355,17 +354,15 @@ public inline fun <T> List<T>.indexOfLast(predicate: (T) -> Boolean): Int {
* Returns first index of [element], or -1 if the collection does not contain element.
* Allows to overcome type-safety restriction of `indexOf` that requires to pass an element of type `T`.
*/
@Deprecated("Collection and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("indexOf(element as Any?)"))
@Suppress("NOTHING_TO_INLINE")
public inline fun Iterable<*>.indexOfRaw(element: Any?): Int {
return indexOf(element as Any?)
return indexOf(element)
}
/**
* Returns first index of [element], or -1 if the list does not contain element.
* Allows to overcome type-safety restriction of `indexOf` that requires to pass an element of type `T`.
*/
@Deprecated("List and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("indexOf(element as Any?)"))
@Suppress("NOTHING_TO_INLINE")
public inline fun <T> List<T>.indexOfRaw(element: Any?): Int {
return (this as List<Any?>).indexOf(element)
@@ -461,40 +458,38 @@ public fun <@kotlin.internal.OnlyInputTypes T> List<T>.lastIndexOf(element: T):
/**
* Returns last index of [element], or -1 if the collection does not contain element.
*/
@Deprecated("Collection and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("lastIndexOf(element as T)"))
@Deprecated("Collection and element have incompatible types. Upcast element to Any? if you're sure. Replacement will be provided in beta4.")
@kotlin.jvm.JvmName("lastIndexOfAny")
@kotlin.internal.LowPriorityInOverloadResolution
@Suppress("NOTHING_TO_INLINE")
public fun <T> Iterable<T>.lastIndexOf(element: T): Int {
return lastIndexOf(element as T)
return lastIndexOf(element)
}
/**
* Returns last index of [element], or -1 if the collection does not contain element.
*/
@Deprecated("List and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("lastIndexOf(element as T)"))
@Deprecated("List and element have incompatible types. Upcast element to Any? if you're sure. Replacement will be provided in beta4.")
@kotlin.jvm.JvmName("lastIndexOfAny")
@kotlin.internal.LowPriorityInOverloadResolution
@Suppress("NOTHING_TO_INLINE")
public fun <T> List<T>.lastIndexOf(element: T): Int {
return lastIndexOf(element as T)
return lastIndexOf(element)
}
/**
* Returns last index of [element], or -1 if the collection does not contain element.
* Allows to overcome type-safety restriction of `lastIndexOf` that requires to pass an element of type `T`.
*/
@Deprecated("Collection and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("lastIndexOf(element as Any?)"))
@Suppress("NOTHING_TO_INLINE")
public inline fun Iterable<*>.lastIndexOfRaw(element: Any?): Int {
return lastIndexOf(element as Any?)
return lastIndexOf(element)
}
/**
* Returns last index of [element], or -1 if the list does not contain element.
* Allows to overcome type-safety restriction of `lastIndexOf` that requires to pass an element of type `T`.
*/
@Deprecated("List and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("lastIndexOf(element as Any?)"))
@Suppress("NOTHING_TO_INLINE")
public inline fun <T> List<T>.lastIndexOfRaw(element: Any?): Int {
return (this as List<Any?>).lastIndexOf(element)

View File

@@ -22,21 +22,20 @@ public operator fun <@kotlin.internal.OnlyInputTypes T> Sequence<T>.contains(ele
/**
* Returns `true` if [element] is found in the collection.
*/
@Deprecated("Sequence and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("contains(element as T)"))
@Deprecated("Sequence and element have incompatible types. Upcast element to Any? if you're sure. Replacement will be provided in beta4.")
@kotlin.jvm.JvmName("containsAny")
@kotlin.internal.LowPriorityInOverloadResolution
public operator fun <T> Sequence<T>.contains(element: T): Boolean {
return contains(element as T)
return contains(element)
}
/**
* Returns `true` if [element] is found in the sequence.
* Allows to overcome type-safety restriction of `contains` that requires to pass an element of type `T`.
*/
@Deprecated("Sequence and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("contains(element as Any?)"))
@Suppress("NOTHING_TO_INLINE")
public inline fun Sequence<*>.containsRaw(element: Any?): Boolean {
return contains(element as Any?)
return contains(element)
}
/**
@@ -146,12 +145,12 @@ public fun <@kotlin.internal.OnlyInputTypes T> Sequence<T>.indexOf(element: T):
/**
* Returns first index of [element], or -1 if the collection does not contain element.
*/
@Deprecated("Sequence and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("indexOf(element as T)"))
@Deprecated("Sequence and element have incompatible types. Upcast element to Any? if you're sure. Replacement will be provided in beta4.")
@kotlin.jvm.JvmName("indexOfAny")
@kotlin.internal.LowPriorityInOverloadResolution
@Suppress("NOTHING_TO_INLINE")
public fun <T> Sequence<T>.indexOf(element: T): Int {
return indexOf(element as T)
return indexOf(element)
}
/**
@@ -185,10 +184,9 @@ public inline fun <T> Sequence<T>.indexOfLast(predicate: (T) -> Boolean): Int {
* Returns first index of [element], or -1 if the sequence does not contain element.
* Allows to overcome type-safety restriction of `indexOf` that requires to pass an element of type `T`.
*/
@Deprecated("Sequence and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("indexOf(element as Any?)"))
@Suppress("NOTHING_TO_INLINE")
public inline fun Sequence<*>.indexOfRaw(element: Any?): Int {
return indexOf(element as Any?)
return indexOf(element)
}
/**
@@ -239,22 +237,21 @@ public fun <@kotlin.internal.OnlyInputTypes T> Sequence<T>.lastIndexOf(element:
/**
* Returns last index of [element], or -1 if the collection does not contain element.
*/
@Deprecated("Sequence and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("lastIndexOf(element as T)"))
@Deprecated("Sequence and element have incompatible types. Upcast element to Any? if you're sure. Replacement will be provided in beta4.")
@kotlin.jvm.JvmName("lastIndexOfAny")
@kotlin.internal.LowPriorityInOverloadResolution
@Suppress("NOTHING_TO_INLINE")
public fun <T> Sequence<T>.lastIndexOf(element: T): Int {
return lastIndexOf(element as T)
return lastIndexOf(element)
}
/**
* Returns last index of [element], or -1 if the sequence does not contain element.
* Allows to overcome type-safety restriction of `lastIndexOf` that requires to pass an element of type `T`.
*/
@Deprecated("Sequence and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("lastIndexOf(element as Any?)"))
@Suppress("NOTHING_TO_INLINE")
public inline fun Sequence<*>.lastIndexOfRaw(element: Any?): Int {
return lastIndexOf(element as Any?)
return lastIndexOf(element)
}
/**

View File

@@ -109,7 +109,6 @@ public operator fun <@kotlin.internal.OnlyInputTypes K, V> Map<out K, V>.get(key
* Allows to overcome type-safety restriction of `get` that requires to pass a key of type `K`.
*/
@Suppress("NOTHING_TO_INLINE")
@Deprecated("Map and key have incompatible types. Upcast key to Any? if you're sure.", ReplaceWith("get(key as Any?)"))
public inline fun <K, V> Map<K, V>.getRaw(key: Any?): V? = get(key as Any?)
/**
@@ -120,7 +119,6 @@ public inline fun <K, V> Map<K, V>.getRaw(key: Any?): V? = get(key as Any?)
public fun <@kotlin.internal.OnlyInputTypes K> Map<out K, *>.containsKey(key: K): Boolean = (this as Map<K, *>).containsKey(key)
@Suppress("NOTHING_TO_INLINE")
@Deprecated("Map and key have incompatible types. Upcast key to Any? if you're sure.", ReplaceWith("containsKey(key as Any?)"))
public inline fun <K> Map<K, *>.containsKeyRaw(key: Any?): Boolean = containsKey(key)
/**
@@ -131,7 +129,6 @@ public inline fun <K> Map<K, *>.containsKeyRaw(key: Any?): Boolean = containsKey
public fun <K, @kotlin.internal.OnlyInputTypes V> Map<K, V>.containsValue(value: V): Boolean = this.containsValue(value)
@Suppress("NOTHING_TO_INLINE")
@Deprecated("Map and value have incompatible types. Upcast value to Any? if you're sure.", ReplaceWith("containsValue(value as Any?)"))
public inline fun <K> Map<K, *>.containsValueRaw(value: Any?): Boolean = containsValue(value)

View File

@@ -13,10 +13,10 @@ import java.util.*
public fun <@kotlin.internal.OnlyInputTypes T> Collection<T>.containsAll(elements: Collection<T>): Boolean = this.containsAll(elements)
@Suppress("NOTHING_TO_INLINE")
@Deprecated("Collections have incompatible types. Upcast either to Collection<Any?> if you're sure.", ReplaceWith("containsAll(elements as Collection<Any?>)"))
@Deprecated("Collections have incompatible types. Upcast either to Collection<Any?> if you're sure.", ReplaceWith("containsAll<Any?>(elements)"))
public inline fun Collection<*>.containsAllRaw(elements: Collection<Any?>): Boolean = containsAll(elements)
@Deprecated("Collections have incompatible types. Upcast either to Collection<Any?> if you're sure.", ReplaceWith("containsAll(elements as Collection<Any?>)"))
@Deprecated("Collections have incompatible types. Upcast either to Collection<Any?> if you're sure.", ReplaceWith("containsAll<Any?>(elements)"))
@kotlin.jvm.JvmName("containsAllOfAny")
@kotlin.internal.LowPriorityInOverloadResolution
public fun <E> Collection<E>.containsAll(elements: Collection<Any?>): Boolean = containsAll(elements)
@@ -32,10 +32,9 @@ public fun <E> Collection<E>.containsAll(elements: Collection<Any?>): Boolean =
public fun <@kotlin.internal.OnlyInputTypes T> MutableCollection<out T>.remove(element: T): Boolean = (this as MutableCollection<T>).remove(element)
@Suppress("NOTHING_TO_INLINE")
@Deprecated("Collection and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("remove(element as Any?)"))
public inline fun <E> MutableCollection<E>.removeRaw(element: Any?): Boolean = remove(element)
@Deprecated("Collection and element have incompatible types. Upcast element to Any? if you're sure.", ReplaceWith("remove(element as T)"))
@Deprecated("Collection and element have incompatible types. Upcast element to Any? if you're sure. Replacement will be provided in beta4.")
@kotlin.jvm.JvmName("removeAny")
@kotlin.internal.LowPriorityInOverloadResolution
public fun <T> MutableCollection<out T>.remove(element: T): Boolean = remove(element)
@@ -50,10 +49,10 @@ public fun <T> MutableCollection<out T>.remove(element: T): Boolean = remove(ele
public fun <@kotlin.internal.OnlyInputTypes T> MutableCollection<out T>.removeAll(elements: Collection<T>): Boolean = (this as MutableCollection<T>).removeAll(elements)
@Suppress("NOTHING_TO_INLINE")
@Deprecated("Collections have incompatible types. Upcast elements to Collection<Any?> if you're sure.", ReplaceWith("removeAll(elements as Collection<Any?>)"))
@Deprecated("Collections have incompatible types. Upcast elements to Collection<Any?> if you're sure.", ReplaceWith("removeAll<Any?>(elements)"))
public inline fun <E> MutableCollection<E>.removeAllRaw(elements: Collection<Any?>): Boolean = removeAll(elements)
@Deprecated("Collections have incompatible types. Upcast elements to Collection<Any?> if you're sure.", ReplaceWith("removeAll(elements as Collection<Any?>)"))
@Deprecated("Collections have incompatible types. Upcast elements to Collection<Any?> if you're sure.", ReplaceWith("removeAll<Any?>(elements)"))
@kotlin.jvm.JvmName("removeAllOfAny")
@kotlin.internal.LowPriorityInOverloadResolution
public fun <E> MutableCollection<E>.removeAll(elements: Collection<Any?>): Boolean = removeAll(elements)
@@ -68,10 +67,10 @@ public fun <E> MutableCollection<E>.removeAll(elements: Collection<Any?>): Boole
public fun <@kotlin.internal.OnlyInputTypes T> MutableCollection<out T>.retainAll(elements: Collection<T>): Boolean = (this as MutableCollection<T>).retainAll(elements)
@Suppress("NOTHING_TO_INLINE")
@Deprecated("Collections have incompatible types. Upcast elements to Collection<Any?> if you're sure.", ReplaceWith("retainAll(elements as Collection<Any?>)"))
@Deprecated("Collections have incompatible types. Upcast elements to Collection<Any?> if you're sure.", ReplaceWith("retainAll<Any?>(elements)"))
public inline fun <E> MutableCollection<E>.retainAllRaw(elements: Collection<Any?>): Boolean = retainAll(elements)
@Deprecated("Collections have incompatible types. Upcast elements to Collection<Any?> if you're sure.", ReplaceWith("retainAll(elements as Collection<Any?>)"))
@Deprecated("Collections have incompatible types. Upcast elements to Collection<Any?> if you're sure.", ReplaceWith("retainAll<Any?>(elements)"))
@kotlin.jvm.JvmName("retainAllOfAny")
@kotlin.internal.LowPriorityInOverloadResolution
public fun <E> MutableCollection<E>.retainAll(elements: Collection<Any?>): Boolean = retainAll(elements as Collection<Any?>)
@@ -102,15 +101,15 @@ public fun <E> MutableList<E>.remove(index: Int): E = removeAt(index)
@Deprecated("Use property 'length' instead.", ReplaceWith("length"))
public fun CharSequence.length(): Int = length
@Deprecated("Map and key have incompatible types. Upcast key to Any? if you're sure.", ReplaceWith("get(key as K)"))
@Deprecated("Map and key have incompatible types. Upcast key to Any? if you're sure. Replacement will be provided in beta4.")
@kotlin.internal.LowPriorityInOverloadResolution
public inline operator fun <K, V> Map<out K, V>.get(key: K): V? = get(key)
@Deprecated("Map and key have incompatible types. Upcast key to Any? if you're sure.", ReplaceWith("containsKey(key as K)"))
@Deprecated("Map and key have incompatible types. Upcast key to Any? if you're sure. Replacement will be provided in beta4.")
@kotlin.internal.LowPriorityInOverloadResolution
public inline fun <K, V> Map<out K, V>.containsKey(key: K): Boolean = containsKey(key)
@Deprecated("Map and value have incompatible types. Upcast value to Any? if you're sure.", ReplaceWith("containsValue(value as V)"))
@Deprecated("Map and value have incompatible types. Upcast value to Any? if you're sure. Replacement will be provided in beta4.")
@kotlin.internal.LowPriorityInOverloadResolution
public inline fun <K, V> Map<K, V>.containsValue(value: V): Boolean = containsValue(value as Any?)

View File

@@ -28,6 +28,12 @@
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-gradle-plugin</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-gradle-plugin-api</artifactId>

View File

@@ -16,12 +16,13 @@
package org.jetbrains.kotlin.android
import org.jetbrains.kotlin.gradle.plugin.KotlinGradleSubplugin
import org.gradle.api.Project
import com.android.build.gradle.BaseExtension
import com.android.build.gradle.api.AndroidSourceSet
import org.gradle.api.Project
import org.gradle.api.tasks.compile.AbstractCompile
import org.jetbrains.kotlin.gradle.plugin.KotlinGradleSubplugin
import org.jetbrains.kotlin.gradle.plugin.SubpluginOption
import org.jetbrains.kotlin.gradle.plugin.android.AndroidGradleWrapper
import org.w3c.dom.Document
import java.io.File
import javax.xml.parsers.DocumentBuilderFactory
@@ -43,12 +44,12 @@ public class AndroidSubplugin : KotlinGradleSubplugin {
fun addVariant(sourceSet: AndroidSourceSet) {
pluginOptions += SubpluginOption("variant", sourceSet.name + ';' +
mainSourceSet.res.srcDirs.joinToString(";") { it.absolutePath })
sourceSet.res.srcDirs.joinToString(";") { it.absolutePath })
}
addVariant(mainSourceSet)
val flavorSourceSets = androidExtension.productFlavors.map { sourceSets.findByName(it.name) }.filterNotNull()
val flavorSourceSets = AndroidGradleWrapper.getProductFlavorsSourceSets(androidExtension).filterNotNull()
for (sourceSet in flavorSourceSets) {
addVariant(sourceSet)
}

View File

@@ -2,6 +2,7 @@ package org.jetbrains.kotlin.gradle.plugin.android
import com.android.build.gradle.BaseExtension
import com.android.build.gradle.BasePlugin
import com.android.build.gradle.api.AndroidSourceSet
import com.android.build.gradle.api.ApkVariant
import com.android.build.gradle.api.BaseVariant
import com.android.build.gradle.api.TestVariant
@@ -67,6 +68,11 @@ class AndroidGradleWrapper {
return variant.getProductFlavors().iterator().collect { it.getName() }
}
@NotNull
static def List<AndroidSourceSet> getProductFlavorsSourceSets(BaseExtension extension) {
return extension.productFlavors.iterator().collect { extension.sourceSets.findByName(it.name) }
}
@NotNull
static def DefaultDomainObjectSet<TestVariant> getTestVariants(BaseExtension extension) {
if (extension.getMetaClass().getMetaMethod("getTestVariants")) {

View File

@@ -34,7 +34,8 @@ fun elements(): List<GenericFunction> {
only(Iterables, Sequences, ArraysOfObjects)
doc { "Returns `true` if [element] is found in the collection." }
returns("Boolean")
deprecate { f -> with(DocExtensions) { Deprecation("${f.collection.capitalize()} and element have incompatible types. Upcast element to Any? if you're sure.", "contains(element as T)") } }
deprecate { f -> with(DocExtensions) { Deprecation("${f.collection.capitalize()} and element have incompatible types. Upcast element to Any? if you're sure. Replacement will be provided in beta4.") } }
body { "return contains(element)" }
annotations("""
@kotlin.jvm.JvmName("containsAny")
@kotlin.internal.LowPriorityInOverloadResolution
@@ -51,7 +52,7 @@ fun elements(): List<GenericFunction> {
}
receiverAsterisk(Iterables, Sequences) { true }
inline(true)
deprecate { f -> with(DocExtensions) { Deprecation("${f.collection.capitalize()} and element have incompatible types. Upcast element to Any? if you're sure.", "contains(element as Any?)") } }
body { "return contains(element)" }
annotations("""@Suppress("NOTHING_TO_INLINE")""")
returns("Boolean")
}
@@ -109,7 +110,8 @@ fun elements(): List<GenericFunction> {
only(Iterables, Sequences, ArraysOfObjects, Lists)
doc { "Returns first index of [element], or -1 if the collection does not contain element." }
returns("Int")
deprecate { f -> with(DocExtensions) { Deprecation("${f.collection.capitalize()} and element have incompatible types. Upcast element to Any? if you're sure.", "indexOf(element as T)") } }
deprecate { f -> with(DocExtensions) { Deprecation("${f.collection.capitalize()} and element have incompatible types. Upcast element to Any? if you're sure. Replacement will be provided in beta4.") } }
body { "return indexOf(element)" }
annotations("""
@kotlin.jvm.JvmName("indexOfAny")
@kotlin.internal.LowPriorityInOverloadResolution
@@ -127,7 +129,7 @@ fun elements(): List<GenericFunction> {
}
receiverAsterisk(Iterables, Sequences) { true }
inline(true)
deprecate { f -> with(DocExtensions) { Deprecation("${f.collection.capitalize()} and element have incompatible types. Upcast element to Any? if you're sure.", "indexOf(element as Any?)") } }
body { "return indexOf(element)" }
annotations("""@Suppress("NOTHING_TO_INLINE")""")
returns("Int")
body(Lists) { "return (this as List<Any?>).indexOf(element)" }
@@ -187,7 +189,8 @@ fun elements(): List<GenericFunction> {
only(Iterables, Sequences, ArraysOfObjects, Lists)
doc { "Returns last index of [element], or -1 if the collection does not contain element." }
returns("Int")
deprecate { f -> with(DocExtensions) { Deprecation("${f.collection.capitalize()} and element have incompatible types. Upcast element to Any? if you're sure.", "lastIndexOf(element as T)") } }
deprecate { f -> with(DocExtensions) { Deprecation("${f.collection.capitalize()} and element have incompatible types. Upcast element to Any? if you're sure. Replacement will be provided in beta4.") } }
body { "return lastIndexOf(element)" }
annotations("""
@kotlin.jvm.JvmName("lastIndexOfAny")
@kotlin.internal.LowPriorityInOverloadResolution
@@ -205,7 +208,7 @@ fun elements(): List<GenericFunction> {
}
receiverAsterisk(Iterables, Sequences) { true }
inline(true)
deprecate { f -> with(DocExtensions) { Deprecation("${f.collection.capitalize()} and element have incompatible types. Upcast element to Any? if you're sure.", "lastIndexOf(element as Any?)") } }
body { "return lastIndexOf(element)" }
annotations("""@Suppress("NOTHING_TO_INLINE")""")
returns("Int")
body(Lists) { "return (this as List<Any?>).lastIndexOf(element)" }

View File

@@ -33,16 +33,26 @@ import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
public class IDEAndroidLayoutXmlFileManager(val module: Module) : AndroidLayoutXmlFileManager(module.project) {
override val androidModule: AndroidModule? by lazy { module.androidFacet?.toAndroidModuleInfo() }
override val androidModule: AndroidModule?
get() = module.androidFacet?.toAndroidModuleInfo()
private val moduleData: CachedValue<AndroidModuleData> by lazy {
cachedValue(project) {
CachedValueProvider.Result.create(super.getModuleData(), getPsiTreeChangePreprocessor())
@Volatile
private var _moduleData: CachedValue<AndroidModuleData>? = null
override fun getModuleData(): AndroidModuleData {
if (androidModule == null) {
_moduleData = null
}
else {
if (_moduleData == null) {
_moduleData = cachedValue(project) {
CachedValueProvider.Result.create(super.getModuleData(), getPsiTreeChangePreprocessor())
}
}
}
return _moduleData?.value ?: AndroidModuleData.EMPTY
}
override fun getModuleData() = moduleData.value
private fun getPsiTreeChangePreprocessor(): PsiTreeChangePreprocessor {
return project.getExtensions(PsiTreeChangePreprocessor.EP_NAME).first { it is AndroidPsiTreeChangePreprocessor }
}

View File

@@ -4,19 +4,18 @@
<property name="ideaVersion" value="143.1015.7"/>
<property name="kotlin.bootstrap.branch" value=""/>
<property name="kotlin.bootstrap.branch.locator" value=""/>
<property name="kotlin.bootstrap.locator" value="buildType:bt345,tag:bootstrap,status:SUCCESS${kotlin.bootstrap.branch.locator}"/>
<property name="kotlin.bootstrap.locator.force" value="false"/>
<property name="kotlin.bootstrap.branch" value="beta3"/>
<property name="kotlin.bootstrap.branch.locator" value=",branch:beta3"/>
<property name="kotlin.bootstrap.locator" value="buildType:bt345,tag:pre_release,status:SUCCESS${kotlin.bootstrap.branch.locator}"/>
<property name="kotlin.bootstrap.locator.force" value="true"/>
<property name="markdown.locator" value="buildType:IntelliJMarkdownParser_Build,status:SUCCESS"/>
<property name="bootstrap.build.no.tests" value="false"/>
<!-- Uncomment to enable force version increment in branch. Set override.version.disabled to temporary disable feature without commits -->
<!--
<property name="override.version.url" value="https://teamcity.jetbrains.com/guestAuth/app/rest/builds/?locator=buildType:bt345,status:SUCCESS,count:1${kotlin.bootstrap.branch.locator}"/>
-->
<!--<property name="override.version.disabled" value="true"/>-->
<condition property="isWindows">