Compare commits

...

63 Commits

Author SHA1 Message Date
Yan Zhulanow
65feaf9a4a 191: 191: Fix test compilation, remove deleted test
(cherry picked from commit 7c0233dfeb)
2019-03-06 13:41:52 +03:00
Nicolay Mitropolsky
558d1edd39 Uast: getMaybeLightElement cleanup
(cherry picked from commit f664499708)
2019-03-06 13:41:51 +03:00
Nicolay Mitropolsky
492dd24897 Uast: testing resolve for method called on variables of parametrized types
(cherry picked from commit ec1badf60d)
2019-03-06 13:41:51 +03:00
Nicolay Mitropolsky
710134b4a6 Uast: type-parameter references resolves to type-parameters
(cherry picked from commit 5268cd4663)
2019-03-06 13:41:51 +03:00
Nicolay Mitropolsky
c253404622 Uast: TypeReferences log test added
(cherry picked from commit ec26ea4e36)
2019-03-06 13:41:51 +03:00
Nicolay Mitropolsky
94a88c5c19 Uast: ResolveEverythingTest tests for generics added
(cherry picked from commit adb13b2f9e)
2019-03-06 13:41:51 +03:00
Nicolay Mitropolsky
8ac926d3e2 Uast: resolving references to local function declarations
(cherry picked from commit 337f16194a)
2019-03-06 13:41:51 +03:00
Nicolay Mitropolsky
1dcad35f21 Uast: making KotlinUSimpleReferenceExpression able to resolve to types
(cherry picked from commit 72860fb695)
2019-03-06 13:41:50 +03:00
Nicolay Mitropolsky
6df81c5fc7 Uast: setup for KotlinUastResolveEverythingTest
(cherry picked from commit e1e1e53e4a)
2019-03-06 13:41:50 +03:00
Nicolay Mitropolsky
6c0cec151e Uast: support for KtDelegatedSuperTypeEntry (KT-30033)
(cherry picked from commit 9c674cb7c3)
2019-03-06 13:41:50 +03:00
Nicolay Mitropolsky
22b2fc0c9f Uast multiresolve key description fix
(cherry picked from commit c151be5547)
2019-03-06 13:41:50 +03:00
Natalia Selezneva
48596fe2c7 Add scripting resolver extension to plugin-kotlin-extensions.xml
(cherry picked from commit ae22bdee15)
2019-03-06 13:16:19 +03:00
Natalia Selezneva
7fcc915fc4 Fix saving Kotlin Scripting Setting to xml
^KT-30146 Fixed

(cherry picked from commit bc1e836f01)
2019-03-06 13:14:38 +03:00
Natalia Selezneva
7c4e5dbb09 Do not threat modifications inside lambdas in KtScriptInitializer block as out of code block
(cherry picked from commit 48433110a4)
2019-03-06 13:14:10 +03:00
Natalia Selezneva
4b12826e99 Optimize MemberVisibilityCanBePrivateInspection: check that descriptor is in class before resolving it
(cherry picked from commit 49277bb5e4)
2019-03-06 13:13:51 +03:00
Natalia Selezneva
fab11884cc KtScriptInitializer doesn't has a descriptor
(cherry picked from commit 560acd631c)
2019-03-06 13:13:33 +03:00
Natalia Selezneva
800ccdcc1d Optimize ChangeVisibilityModifierIntention: do not analyze element if declaration isn't local
(cherry picked from commit 3b4d1dd7bf)
2019-03-06 13:13:12 +03:00
Natalia Selezneva
0d16f0de42 Optimize KotlinUFunctionCallExpression.isAnnotationArgumentArrayExpression
(cherry picked from commit 869fb46c0b)
2019-03-06 13:12:52 +03:00
Toshiaki Kameyama
d191510b42 Add intention to replace '!isNotEmpty()' to 'isEmpty()'
#KT-30123 Fixed

(cherry picked from commit 6b35c06d50)
2019-03-06 11:19:18 +03:00
Toshiaki Kameyama
536ab732cd Import members from: suggest on type reference
#KT-29927 Fixed

(cherry picked from commit 6b5ba272a0)
2019-03-06 11:18:25 +03:00
Dmitry Gridin
e100e3ec58 Fix KT-26965
(cherry picked from commit 2a940f5b0a)
2019-03-06 11:15:14 +03:00
Dereck Bridie
e6a560c49c #KT-26965 Add inspection + quickfix for replacing Collection<T>.count() with .size
(cherry picked from commit 4156a76129)
2019-03-06 11:13:48 +03:00
Mikhail Zarechenskiy
f1636cab67 Swap arguments for diagnostic message about incompatible enums
This commit is restoring previous behavior changed in c4b69b65 and
 fixing `DiagnosticMessageTestGenerated.testIncompatibleEnums` test
2019-03-06 10:49:53 +03:00
Mikhail Zarechenskiy
15a60b8640 Gradually prohibit comparison of incompatible enums
#KT-22043 Fixed
2019-03-05 14:23:50 +03:00
Mikhail Zarechenskiy
86395bc6dc Refactoring: move getRepresentativeUpperBound method to core
Plus prettify it a bit
2019-03-05 14:23:32 +03:00
Mikhail Zarechenskiy
a8345c25f0 Increment metadata version and improve message for error type
Follow-up of 617bed1b
2019-03-05 14:23:13 +03:00
Shagen Ogandzhanian
017d99de4c Fix for npm publishing configuration
This reverts commit 0188cd5330.
Turns out it's not a url after all
2019-03-05 11:32:15 +03:00
Toshiaki Kameyama
bb020202aa map.get() with not-null assertion: add quick-fixes
#KT-30010 Fixed

(cherry picked from commit d67c793a9b)
2019-03-05 09:57:14 +03:00
Toshiaki Kameyama
e111863ee2 Add inspection to replace Java Map.forEach with Kotlin's forEach
#KT-17278 Fixed

(cherry picked from commit 1a818970c3)
2019-03-05 09:56:32 +03:00
Mikhail Glukhikh
d940851bdf Fix "make constructor parameter a property" for vararg case
Same should work for annotated parameters
#KT-29312 Fixed

(cherry picked from commit 9e2ee6183c)
2019-03-05 09:55:50 +03:00
Mikhail Glukhikh
868c22b4cf Don't report "Unsafe call with ? extension receiver" with smart-cast
#KT-29499 Fixed

(cherry picked from commit c714e599ea)
2019-03-05 09:55:19 +03:00
Mikhail Glukhikh
a8755cef36 Don't report "main parameter not necessary" in objects #KT-29414 Fixed
(cherry picked from commit 4d19120d84)
2019-03-05 09:55:01 +03:00
Mikhail Glukhikh
1629c46177 MPP web builder: upgrade Ktor version to 1.1.3 #KT-29918 Fixed
(cherry picked from commit 022c625d2d)
2019-03-05 09:54:16 +03:00
Wil
3dfd560470 Minor: typo fix in Writer.buffered docs
(cherry picked from commit d3ac50f694)
2019-03-04 21:03:15 +03:00
Ilya Gorbunov
f745c84574 Do not expose internal copyOfUninitializedElements and copyOfNulls
(cherry picked from commit 640699e076)
2019-03-04 21:03:06 +03:00
Ilya Gorbunov
502a6086d6 Rewrite copyOfUninitializedElements with templates without using copyRangeTo
(cherry picked from commit 2e9497f8f8)
2019-03-04 21:03:05 +03:00
Ilya Gorbunov
1050b9d19b Rewrite copyInto without using copyRangeTo
Rename array copying implementation to arrayCopy

(cherry picked from commit c1a51d44a4)
2019-03-04 21:03:04 +03:00
Ilya Gorbunov
7954c1fced Move sorting implementations for Native to kotlin.collections
- Move Array.sortWith to generated code

(cherry picked from commit b8d9e896c2)
2019-03-04 21:03:02 +03:00
Ilya Gorbunov
5454bed997 Swap mismatched docs for Result.onSuccess/onFailure KT-30109
(cherry picked from commit 19bd326810)
2019-03-04 20:59:51 +03:00
Ilya Gorbunov
c361b184d9 Improve double-to-ulong conversion tests
#KT-27108

(cherry picked from commit 908009bf42)
2019-03-04 20:59:50 +03:00
Mikhail Glukhikh
4b1c847863 Remove FIR provider from IDE to prevent exceptions like KT-30243
This commit is a work-around for 1.3.30
2019-03-04 14:44:47 +03:00
Dmitry Gridin
1162c1be5f Fix KNPE from "Create" quick fix
#KT-27289 Fixed

(cherry picked from commit dce2139eb0)
2019-03-04 13:57:40 +03:00
Dmitry Gridin
b55d69c36b Refactoring
(cherry picked from commit 78bee70946)
2019-03-04 13:56:27 +03:00
Dmitry Gridin
0af1dc35a4 Fix "Introduce import alias" on extensions
#KT-30214 Fixed

(cherry picked from commit 5927032143)
2019-03-04 13:55:04 +03:00
Dmitry Gridin
ef27fe4e0e Fix caret position in "Convert function to property" intention
#KT-19944 Fixed

(cherry picked from commit 41f3316981)
2019-03-04 13:53:13 +03:00
Dmitry Gridin
614c68280f Refactoring & fix warnings
(cherry picked from commit 29a63ae58c)
2019-03-04 13:52:20 +03:00
Dmitry Gridin
bfbdd3f2fb Fix false positive "Redundant companion reference"
#KT-30166 Fixed

(cherry picked from commit 304007f602)
2019-03-04 13:51:24 +03:00
Dmitry Gridin
157ad173ec Add inspection to remove redundant qualifier name
#KT-12134 Fixed

(cherry picked from commit 3756b6f54d)
2019-03-04 13:50:54 +03:00
Dmitry Gridin
dfbe43fe16 Move canBePossibleToDropReceiver to Companion object & fix warnings
(cherry picked from commit d0c3a28996)
2019-03-04 13:50:28 +03:00
Andrey Uskov
3dc42d2525 Fix memory leak in gradle import
#KT-30076 Fixed

(cherry picked from commit 25dc81c2bd)
2019-03-04 01:46:59 +03:00
Andrey Uskov
919d527aa7 Minor. Reformat code in multiplatform project importer
(cherry picked from commit 3919898d19)
2019-03-04 01:46:10 +03:00
Andrey Uskov
45991a69ff Fix creation of KotlinSDK. GradleFacetImportTest fixed
(cherry picked from commit 735f86a50e)
2019-03-04 01:45:38 +03:00
Andrey Uskov
a134e568f2 Change class hierarchy of KotlinSourceRootType. Deadlock during concurrent classloading fixed
#KT-30137 Fixed

(cherry picked from commit 325ed8eb32)
2019-03-04 01:45:03 +03:00
Vyacheslav Gerasimov
3af23f2d3f Build: Add diagnostic for publish() helper
(cherry picked from commit f7428e7161)
2019-03-02 18:50:58 +03:00
Vyacheslav Gerasimov
7572ee4122 Build: Fix artifacts signing for maven central
With gradle > 5.0 `publish()` helper call should be done before
`noDefaultJar()` or any other artifact hacks, otherwise singing plugin doesn't sign any jars

(cherry picked from commit a42f607ecf)
2019-03-02 18:50:44 +03:00
Vyacheslav Gerasimov
41f3415b4a Build: Apply java plugin in kotlin-annotation-processing-embeddable
Otherwise artifact signature works incorrectly for this project

(cherry picked from commit df3aa48c9b)
2019-03-02 18:50:28 +03:00
Vyacheslav Gerasimov
9dbd7269cb Build: properly remove artifact from archives in runtimeJar helper
(cherry picked from commit f4c157a9bc)
2019-03-02 18:50:16 +03:00
Alexander Udalov
dd3d2311a8 Prohibit type parameters in class literals in annotation arguments
#KT-27799 Fixed

(cherry picked from commit 736ac12374)
2019-03-01 11:37:05 +01:00
Alexander Udalov
b28e71730b Support non-trivial default argument values in expected functions on JVM
#KT-22818 Fixed

(cherry picked from commit b8bc79e17c)
2019-03-01 11:35:22 +01:00
nikita.movshin
5e91bc5697 Added changelog for 1.3.30 2019-02-28 12:23:00 +03:00
Stanislav Erokhin
ef209999f7 Update Kotlin/Native: 1.2-eap-8089 2019-02-28 11:32:58 +03:00
Igor Chevdar
d364505652 Fixes of wrapped descriptors
Supported complex annotations
Supported type parameters in classes
2019-02-27 17:53:38 +03:00
Alexander Podkhalyuzin
30d2a1ae2a Do not go to the same type twice during contains search
This fixes exponent in algorithm for scala.FunctionN.curried, where N can be up to 22.

#KT-29435 Fixed

(cherry picked from commit 6098e97ae5)
2019-02-27 14:19:36 +03:00
376 changed files with 5500 additions and 8853 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -32,6 +32,8 @@ sourceSets {
"test" { projectDefault() }
}
publish()
runtimeJar()
sourcesJar()
javadocJar()
@@ -39,5 +41,3 @@ javadocJar()
testsJar()
projectTest()
publish()

View File

@@ -35,14 +35,26 @@ fun Project.testsJar(body: Jar.() -> Unit = {}): Jar {
}
}
var Project.artifactsRemovedDiagnosticFlag: Boolean
get() = extra.has("artifactsRemovedDiagnosticFlag") && extra["artifactsRemovedDiagnosticFlag"] == true
set(value) {
extra["artifactsRemovedDiagnosticFlag"] = value
}
fun Project.removeArtifacts(configuration: Configuration, task: Task) {
configuration.artifacts.removeAll { artifact ->
artifact.file in task.outputs.files
}
artifactsRemovedDiagnosticFlag = true
}
fun Project.noDefaultJar() {
tasks.findByName("jar")?.let { defaultJarTask ->
defaultJarTask.enabled = false
defaultJarTask.actions = emptyList()
configurations.forEach { cfg ->
cfg.artifacts.removeAll { artifact ->
artifact.file in defaultJarTask.outputs.files
}
removeArtifacts(cfg, defaultJarTask)
}
}
}
@@ -58,8 +70,7 @@ fun Project.runtimeJarArtifactBy(task: Task, artifactRef: Any, body: Configurabl
fun <T : Jar> Project.runtimeJar(task: T, body: T.() -> Unit = {}): T {
extra["runtimeJarTask"] = task
tasks.findByName("jar")?.let { defaultJarTask ->
configurations.getOrCreate("archives")
.artifacts.removeAll { (it as? ArchivePublishArtifact)?.archiveTask?.let { it == defaultJarTask } ?: false }
removeArtifacts(configurations.getOrCreate("archives"), defaultJarTask)
}
return task.apply {
setupPublicJar(project.the<BasePluginConvention>().archivesBaseName)
@@ -109,6 +120,10 @@ fun Project.standardPublicJars() {
fun Project.publish(body: Upload.() -> Unit = {}): Upload {
apply<plugins.PublishedKotlinModule>()
if (artifactsRemovedDiagnosticFlag) {
error("`publish()` should be called before removing artifacts typically done in `noDefaultJar()` of `runtimeJar()` calls")
}
afterEvaluate {
if (configurations.findByName("classes-dirs") != null)
throw GradleException("classesDirsArtifact() is incompatible with publish(), see sources comments for details")

View File

@@ -100,7 +100,8 @@ import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.*;
import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.*;
import static org.jetbrains.kotlin.codegen.inline.InlineCodegenUtilsKt.*;
import static org.jetbrains.kotlin.resolve.BindingContext.*;
import static org.jetbrains.kotlin.resolve.BindingContextUtils.*;
import static org.jetbrains.kotlin.resolve.BindingContextUtils.getDelegationConstructorCall;
import static org.jetbrains.kotlin.resolve.BindingContextUtils.isBoxedLocalCapturedInClosure;
import static org.jetbrains.kotlin.resolve.DescriptorUtils.*;
import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.*;
import static org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils.isFunctionExpression;
@@ -2900,7 +2901,9 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
while (cur != null) {
ClassDescriptor thisDescriptor = cur.getThisDescriptor();
if (!isSuper && thisDescriptor == thisOrOuterClass) {
// We use equals on type constructors (instead of reference equality on classes) to support the case where default parameter
// values of actual functions loaded from the expected function refer to the expected class.
if (!isSuper && thisDescriptor.getTypeConstructor().equals(thisOrOuterClass.getTypeConstructor())) {
return result;
}

View File

@@ -21,10 +21,9 @@ import com.intellij.openapi.util.Trinity
import gnu.trove.TObjectIntHashMap
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.org.objectweb.asm.Type
import java.util.*
import java.util.ArrayList
class FrameMap : FrameMapBase<DeclarationDescriptor>()
open class FrameMap : FrameMapBase<DeclarationDescriptor>()
open class FrameMapBase<T : Any> {
private val myVarIndex = TObjectIntHashMap<T>()
@@ -61,7 +60,7 @@ open class FrameMapBase<T : Any> {
currentSize -= type.size
}
fun getIndex(descriptor: T): Int {
open fun getIndex(descriptor: T): Int {
return if (myVarIndex.contains(descriptor)) myVarIndex.get(descriptor) else -1
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. 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.codegen
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.resolve.multiplatform.ExpectedActualResolver
import org.jetbrains.kotlin.resolve.scopes.receivers.ExtensionReceiver
/**
* This [FrameMap] subclass substitutes values declared in the expected declaration with the corresponding value in the actual declaration,
* which is needed for the case when expected function declares parameters with default values, which refer to other parameters.
*/
class FrameMapWithExpectActualSupport(private val module: ModuleDescriptor) : FrameMap() {
override fun getIndex(descriptor: DeclarationDescriptor): Int {
val tmp = if (descriptor is ParameterDescriptor) findActualParameter(descriptor) ?: descriptor else descriptor
return super.getIndex(tmp)
}
private fun findActualParameter(parameter: ParameterDescriptor): ParameterDescriptor? {
val container = parameter.containingDeclaration
if (container !is CallableMemberDescriptor || !container.isExpect) return null
// Generation of value parameters is supported by the fact that FunctionCodegen.generateDefaultImplBody substitutes value parameters
// of the generated actual function with the parameters of the expected declaration in the first place.
// Generation of dispatch receiver parameters (this and outer receiver values) is supported
// in ExpressionCodegen.generateThisOrOuterFromContext by comparing classes by type constructor equality.
if (parameter !is ReceiverParameterDescriptor || parameter.value !is ExtensionReceiver) return null
val actual = with(ExpectedActualResolver) {
container.findCompatibleActualForExpected(module).firstOrNull()
}
return (actual as? CallableDescriptor)?.extensionReceiverParameter
}
}

View File

@@ -1360,7 +1360,7 @@ public class FunctionCodegen {
@NotNull List<ValueParameterDescriptor> valueParameters,
boolean isStatic
) {
FrameMap frameMap = new FrameMap();
FrameMap frameMap = new FrameMapWithExpectActualSupport(state.getModule());
if (!isStatic) {
frameMap.enterTemp(OBJECT_TYPE);
}

View File

@@ -6,11 +6,11 @@
package org.jetbrains.kotlin.codegen.state
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.load.kotlin.getRepresentativeUpperBound
import org.jetbrains.kotlin.resolve.InlineClassDescriptorResolver
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
import org.jetbrains.kotlin.resolve.jvm.*
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.typeUtil.representativeUpperBound
import java.security.MessageDigest
import java.util.*
@@ -44,7 +44,7 @@ private fun getSignatureElementForMangling(type: KotlinType): String = buildStri
}
is TypeParameterDescriptor -> {
append(getSignatureElementForMangling(getRepresentativeUpperBound(descriptor)))
append(getSignatureElementForMangling(descriptor.representativeUpperBound))
}
}
}

View File

@@ -25,10 +25,10 @@ sourceSets {
"test" {}
}
publish()
val jar: Jar by tasks
runtimeJar(rewriteDepsToShadedCompiler(jar))
sourcesJar()
javadocJar()
publish()

View File

@@ -41,6 +41,8 @@ sourceSets {
"test" {}
}
publish()
noDefaultJar()
runtimeJar(task<ShadowJar>("shadowJar")) {
@@ -55,5 +57,3 @@ javadocJar()
dist()
ideaPlugin()
publish()

View File

@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.diagnostics.Errors.*
import org.jetbrains.kotlin.idea.MainFunctionDetector
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject
import org.jetbrains.kotlin.resolve.*
import org.jetbrains.kotlin.resolve.BindingContext.*
import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsExpression
@@ -736,7 +737,9 @@ class ControlFlowInformationProvider private constructor(
return
}
!languageVersionSettings.supportsFeature(LanguageFeature.WarningOnMainUnusedParameter) -> {
trace.record(UNUSED_MAIN_PARAMETER, element)
if (owner.containingClassOrObject == null) {
trace.record(UNUSED_MAIN_PARAMETER, element)
}
return
}
}

View File

@@ -231,6 +231,8 @@ public interface Errors {
DiagnosticFactory0<KtExpression> ANNOTATION_ARGUMENT_MUST_BE_CONST = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtExpression> ANNOTATION_ARGUMENT_MUST_BE_KCLASS_LITERAL = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtExpression> ANNOTATION_ARGUMENT_MUST_BE_ENUM_CONST = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtExpression> ANNOTATION_ARGUMENT_KCLASS_LITERAL_OF_TYPE_PARAMETER = DiagnosticFactory0.create(WARNING);
DiagnosticFactory0<KtExpression> ANNOTATION_ARGUMENT_KCLASS_LITERAL_OF_TYPE_PARAMETER_ERROR = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtExpression> ANNOTATION_PARAMETER_DEFAULT_VALUE_MUST_BE_CONSTANT = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtAnnotatedExpression> ANNOTATIONS_ON_BLOCK_LEVEL_EXPRESSION_ON_THE_SAME_LINE = DiagnosticFactory0.create(WARNING);
DiagnosticFactory0<KtAnnotationEntry> ANNOTATION_USED_AS_ANNOTATION_ARGUMENT = DiagnosticFactory0.create(ERROR);
@@ -798,6 +800,8 @@ public interface Errors {
DiagnosticFactory2<KtElement, KotlinType, KotlinType> INCOMPATIBLE_ENUM_COMPARISON =
DiagnosticFactory2.create(WARNING);
DiagnosticFactory2<KtElement, KotlinType, KotlinType> INCOMPATIBLE_ENUM_COMPARISON_ERROR =
DiagnosticFactory2.create(ERROR);
DiagnosticFactory1<KtExpression, KotlinType> HAS_NEXT_MISSING = DiagnosticFactory1.create(ERROR);
DiagnosticFactory1<KtExpression, KotlinType> HAS_NEXT_FUNCTION_AMBIGUITY = DiagnosticFactory1.create(ERROR);

View File

@@ -741,6 +741,7 @@ public class DefaultErrorMessages {
}, RENDER_TYPE, RENDER_TYPE);
MAP.put(INCOMPATIBLE_ENUM_COMPARISON, "Comparison of incompatible enums ''{0}'' and ''{1}'' is always unsuccessful", RENDER_TYPE, RENDER_TYPE);
MAP.put(INCOMPATIBLE_ENUM_COMPARISON_ERROR, "Comparison of incompatible enums ''{0}'' and ''{1}'' is always unsuccessful", RENDER_TYPE, RENDER_TYPE);
MAP.put(SENSELESS_COMPARISON, "Condition ''{0}'' is always ''{1}''", ELEMENT_TEXT, TO_STRING);
MAP.put(SENSELESS_NULL_IN_WHEN, "Expression under 'when' is never equal to null");
@@ -866,6 +867,8 @@ public class DefaultErrorMessages {
MAP.put(ANNOTATION_ARGUMENT_MUST_BE_CONST, "An annotation argument must be a compile-time constant");
MAP.put(ANNOTATION_ARGUMENT_MUST_BE_ENUM_CONST, "An enum annotation argument must be a enum constant");
MAP.put(ANNOTATION_ARGUMENT_MUST_BE_KCLASS_LITERAL, "An annotation argument must be a class literal (T::class)");
MAP.put(ANNOTATION_ARGUMENT_KCLASS_LITERAL_OF_TYPE_PARAMETER, "Type parameter in a class literal is not allowed in an annotation argument");
MAP.put(ANNOTATION_ARGUMENT_KCLASS_LITERAL_OF_TYPE_PARAMETER_ERROR, "Type parameter in a class literal is deprecated in an annotation argument");
MAP.put(ANNOTATION_PARAMETER_DEFAULT_VALUE_MUST_BE_CONSTANT, "Default value of annotation parameter must be a compile-time constant");
MAP.put(ANNOTATIONS_ON_BLOCK_LEVEL_EXPRESSION_ON_THE_SAME_LINE,

View File

@@ -127,7 +127,13 @@ class ConstantExpressionEvaluator(
val descriptor = expressionType.constructor.declarationDescriptor
val diagnosticFactory = when {
DescriptorUtils.isEnumClass(descriptor) -> Errors.ANNOTATION_ARGUMENT_MUST_BE_ENUM_CONST
descriptor is ClassDescriptor && KotlinBuiltIns.isKClass(descriptor) -> Errors.ANNOTATION_ARGUMENT_MUST_BE_KCLASS_LITERAL
descriptor is ClassDescriptor && KotlinBuiltIns.isKClass(descriptor) -> {
if (isTypeParameterOrArrayOfTypeParameter(expressionType.arguments.singleOrNull()?.type)) {
Errors.ANNOTATION_ARGUMENT_KCLASS_LITERAL_OF_TYPE_PARAMETER_ERROR
} else {
Errors.ANNOTATION_ARGUMENT_MUST_BE_KCLASS_LITERAL
}
}
else -> Errors.ANNOTATION_ARGUMENT_MUST_BE_CONST
}
@@ -177,6 +183,8 @@ class ConstantExpressionEvaluator(
} else {
trace.report(Errors.ANNOTATION_ARGUMENT_MUST_BE_KCLASS_LITERAL.on(argumentExpression))
}
} else if (doubleColonLhs is DoubleColonLHS.Type && isTypeParameterOrArrayOfTypeParameter(doubleColonLhs.type)) {
trace.report(Errors.ANNOTATION_ARGUMENT_KCLASS_LITERAL_OF_TYPE_PARAMETER.on(argumentExpression))
}
}
}
@@ -324,6 +332,13 @@ class ConstantExpressionEvaluator(
fun getPossiblyErrorConstant(expression: KtExpression, bindingContext: BindingContext): CompileTimeConstant<*>? {
return bindingContext.get(BindingContext.COMPILE_TIME_VALUE, expression)
}
internal fun isTypeParameterOrArrayOfTypeParameter(type: KotlinType?): Boolean =
when {
type == null -> false
KotlinBuiltIns.isArray(type) -> isTypeParameterOrArrayOfTypeParameter(type.arguments.singleOrNull()?.type)
else -> type.constructor.declarationDescriptor is TypeParameterDescriptor
}
}
}
@@ -336,6 +351,7 @@ private class ConstantExpressionEvaluatorVisitor(
private val constantExpressionEvaluator: ConstantExpressionEvaluator,
private val trace: BindingTrace
) : KtVisitor<CompileTimeConstant<*>?, KotlinType>() {
private val languageVersionSettings = constantExpressionEvaluator.languageVersionSettings
private val builtIns = constantExpressionEvaluator.module.builtIns
fun evaluate(expression: KtExpression, expectedType: KotlinType?): CompileTimeConstant<*>? {
@@ -613,7 +629,8 @@ private class ConstantExpressionEvaluatorVisitor(
trace.report(Errors.DIVISION_BY_ZERO.on(parentExpression))
if ((isIntegerType(argumentForReceiver.value) && isIntegerType(argumentForParameter.value)) ||
!constantExpressionEvaluator.languageVersionSettings.supportsFeature(LanguageFeature.DivisionByZeroInConstantExpressions)) {
!languageVersionSettings.supportsFeature(LanguageFeature.DivisionByZeroInConstantExpressions)
) {
return ErrorValue.create("Division by zero").wrap()
}
}
@@ -883,11 +900,19 @@ private class ConstantExpressionEvaluatorVisitor(
}
override fun visitClassLiteralExpression(expression: KtClassLiteralExpression, expectedType: KotlinType?): CompileTimeConstant<*>? {
val type = trace.getType(expression)!!
if (type.isError) return null
val descriptor = type.constructor.declarationDescriptor
val kClassType = trace.getType(expression)!!
if (kClassType.isError) return null
val descriptor = kClassType.constructor.declarationDescriptor
if (descriptor !is ClassDescriptor || !KotlinBuiltIns.isKClass(descriptor)) return null
return KClassValue.create(type.arguments.first().type)?.wrap()
val type = kClassType.arguments.singleOrNull()?.type ?: return null
if (languageVersionSettings.supportsFeature(LanguageFeature.ProhibitTypeParametersInClassLiteralsInAnnotationArguments) &&
ConstantExpressionEvaluator.isTypeParameterOrArrayOfTypeParameter(type)
) {
return null
}
return KClassValue.create(type)?.wrap()
}
private fun resolveArguments(valueArguments: List<ValueArgument>, expectedType: KotlinType): List<CompileTimeConstant<*>?> {
@@ -983,12 +1008,7 @@ private class ConstantExpressionEvaluatorVisitor(
parameters: CompileTimeConstant.Parameters,
expectedType: KotlinType
): CompileTimeConstant<*>? {
if (parameters.isUnsignedNumberLiteral &&
!checkAccessibilityOfUnsignedTypes(
constantExpressionEvaluator.module,
constantExpressionEvaluator.languageVersionSettings
)
) {
if (parameters.isUnsignedNumberLiteral && !checkAccessibilityOfUnsignedTypes()) {
return UnsignedErrorValueTypeConstant(value, parameters)
}
@@ -1019,8 +1039,8 @@ private class ConstantExpressionEvaluatorVisitor(
}.wrap(parameters)
}
private fun checkAccessibilityOfUnsignedTypes(module: ModuleDescriptor, languageVersionSettings: LanguageVersionSettings): Boolean {
val uInt = module.findClassAcrossModuleDependencies(KotlinBuiltIns.FQ_NAMES.uInt) ?: return false
private fun checkAccessibilityOfUnsignedTypes(): Boolean {
val uInt = constantExpressionEvaluator.module.findClassAcrossModuleDependencies(KotlinBuiltIns.FQ_NAMES.uInt) ?: return false
val accessibility = uInt.checkSinceKotlinVersionAccessibility(languageVersionSettings)
// Case `NotAccessibleButWasExperimental` will be checked later in `checkExperimentalityOfConstantLiteral`
return accessibility is SinceKotlinAccessibility.Accessible

View File

@@ -28,7 +28,6 @@ import org.jetbrains.kotlin.resolve.calls.inference.CallHandle;
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystem;
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilderImpl;
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
import org.jetbrains.kotlin.types.typeUtil.TypeUtilsKt;
import java.util.*;
@@ -41,11 +40,6 @@ public class TypeIntersector {
return intersectTypes(new LinkedHashSet<>(Arrays.asList(typeA, typeB))) == null;
}
public static boolean isIncompatibleEnums(@NotNull KotlinType typeA, @NotNull KotlinType typeB) {
if (!TypeUtilsKt.isEnum(typeA) || !TypeUtilsKt.isEnum(typeB)) return false;
return !typeA.getConstructor().equals(typeB.getConstructor());
}
@Nullable
public static KotlinType intersectTypes(@NotNull Collection<KotlinType> types) {
assert !types.isEmpty() : "Attempting to intersect empty collection of types, this case should be dealt with on the call site.";

View File

@@ -0,0 +1,49 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. 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.types
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext
import org.jetbrains.kotlin.types.typeUtil.*
fun checkEnumsForCompatibility(context: ExpressionTypingContext, reportOn: KtElement, typeA: KotlinType, typeB: KotlinType) {
if (isIncompatibleEnums(typeA, typeB)) {
val diagnostic = if (context.languageVersionSettings.supportsFeature(LanguageFeature.ProhibitComparisonOfIncompatibleEnums)) {
Errors.INCOMPATIBLE_ENUM_COMPARISON_ERROR
} else {
Errors.INCOMPATIBLE_ENUM_COMPARISON
}
context.trace.report(diagnostic.on(reportOn, typeA, typeB))
}
}
private fun isIncompatibleEnums(typeA: KotlinType, typeB: KotlinType): Boolean {
if (!typeA.isEnum() && !typeB.isEnum()) return false
if (TypeUtils.isNullableType(typeA) && TypeUtils.isNullableType(typeB)) return false
// TODO: remove this line once KT-30266 will be fixed
// For now, this check is needed as isSubClass contains bug wrt Nothing
if (typeA.isNothingOrNullableNothing() || typeB.isNothingOrNullableNothing()) return false
val representativeTypeA = typeA.representativeTypeForTypeParameter()
val representativeTypeB = typeB.representativeTypeForTypeParameter()
val classA = representativeTypeA.constructor.declarationDescriptor as? ClassDescriptor ?: return false
val classB = representativeTypeB.constructor.declarationDescriptor as? ClassDescriptor ?: return false
return !DescriptorUtils.isSubclass(classA, classB) && !DescriptorUtils.isSubclass(classB, classA)
}
private fun KotlinType.representativeTypeForTypeParameter(): KotlinType {
val descriptor = constructor.declarationDescriptor
return if (descriptor is TypeParameterDescriptor) descriptor.representativeUpperBound else this
}

View File

@@ -1430,10 +1430,10 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
if (rightType != null) {
if (TypeIntersector.isIntersectionEmpty(leftType, rightType)) {
context.trace.report(EQUALITY_NOT_APPLICABLE.on(expression, expression.getOperationReference(), leftType, rightType));
} else {
EnumCompatibilityCheckerKt.checkEnumsForCompatibility(context, expression, leftType, rightType);
}
else if (TypeIntersector.isIncompatibleEnums(leftType, rightType)) {
context.trace.report(INCOMPATIBLE_ENUM_COMPARISON.on(expression, leftType, rightType));
}
SenselessComparisonChecker.checkSenselessComparisonWithNull(
expression, left, right, context,

View File

@@ -684,9 +684,7 @@ class PatternMatchingTypingVisitor internal constructor(facade: ExpressionTyping
return
}
if (TypeIntersector.isIncompatibleEnums(type, subjectType)) {
context.trace.report(INCOMPATIBLE_ENUM_COMPARISON.on(reportErrorOn, subjectType, type))
}
checkEnumsForCompatibility(context, reportErrorOn, subjectType, type)
// check if the pattern is essentially a 'null' expression
if (KotlinBuiltIns.isNullableNothing(type) && !TypeUtils.isNullableType(subjectType)) {

View File

@@ -6,18 +6,18 @@
package org.jetbrains.kotlin.backend.common.descriptors
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptorImpl
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.descriptors.impl.ReceiverParameterDescriptorImpl
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.declarations.impl.IrClassImpl
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.symbols.impl.IrClassSymbolImpl
import org.jetbrains.kotlin.ir.types.classifierOrFail
import org.jetbrains.kotlin.ir.types.toKotlinType
import org.jetbrains.kotlin.ir.util.defaultType
import org.jetbrains.kotlin.ir.util.dump
import org.jetbrains.kotlin.ir.util.isAnnotationClass
import org.jetbrains.kotlin.ir.util.parentAsClass
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.constants.*
@@ -41,13 +41,18 @@ abstract class WrappedDeclarationDescriptor<T : IrDeclaration>(annotations: Anno
private val annotationsFromOwner by lazy {
val ownerAnnotations = (owner as? IrAnnotationContainer)?.annotations ?: return@lazy Annotations.EMPTY
Annotations.create(ownerAnnotations.map { call ->
AnnotationDescriptorImpl(
call.symbol.owner.parentAsClass.defaultType.toKotlinType(),
call.symbol.owner.valueParameters.associate { it.name to call.getValueArgument(it.index)!!.toConstantValue() },
Annotations.create(ownerAnnotations.map { it.toAnnotationDescriptor() })
}
private fun IrCall.toAnnotationDescriptor(): AnnotationDescriptor {
assert(symbol.owner is IrConstructor && symbol.owner.parentAsClass.isAnnotationClass) {
"Expected call to constructor of annotation class but was: ${this.dump()}"
}
return AnnotationDescriptorImpl(
symbol.owner.parentAsClass.defaultType.toKotlinType(),
symbol.owner.valueParameters.associate { it.name to getValueArgument(it.index)!!.toConstantValue() },
/*TODO*/ SourceElement.NO_SOURCE
)
})
)
}
private fun IrElement.toConstantValue(): ConstantValue<*> {
@@ -77,7 +82,9 @@ abstract class WrappedDeclarationDescriptor<T : IrDeclaration>(annotations: Anno
this is IrClassReference -> KClassValue(classType.classifierOrFail.descriptor.classId!!, /*TODO*/0)
else -> error("$this is not expected")
this is IrCall -> AnnotationValue(this.toAnnotationDescriptor())
else -> error("$this is not expected: ${this.dump()}")
}
}
@@ -583,7 +590,7 @@ open class WrappedClassDescriptor(
private val _typeConstructor: TypeConstructor by lazy {
LazyTypeConstructor(
this,
{ emptyList() },
{ owner.typeParameters.map { it.descriptor } },
{ owner.superTypes.map { it.toKotlinType() } },
LockBasedStorageManager.NO_LOCKS
)

View File

@@ -431,6 +431,9 @@ fun PsiElement.before(element: PsiElement) = textRange.endOffset <= element.text
inline fun <reified T : PsiElement> PsiElement.getLastParentOfTypeInRow() = parents.takeWhile { it is T }.lastOrNull() as? T
inline fun <reified T : PsiElement> PsiElement.getLastParentOfTypeInRowWithSelf() = parentsWithSelf
.takeWhile { it is T }.lastOrNull() as? T
fun KtModifierListOwner.hasExpectModifier() = hasModifier(KtTokens.HEADER_KEYWORD) || hasModifier(KtTokens.EXPECT_KEYWORD)
fun KtModifierList.hasExpectModifier() = hasModifier(KtTokens.HEADER_KEYWORD) || hasModifier(KtTokens.EXPECT_KEYWORD)

View File

@@ -0,0 +1,18 @@
// !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND: JVM_IR
// FILE: common.kt
expect class C {
val value: String
fun test(result: String = value): String
}
// FILE: platform.kt
actual class C(actual val value: String) {
actual fun test(result: String): String = result
}
fun box() = C("Fail").test("OK")

View File

@@ -0,0 +1,16 @@
// !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND: JVM_IR
// FILE: common.kt
class Receiver(val value: String)
expect fun Receiver.test(result: String = value): String
// FILE: platform.kt
actual fun Receiver.test(result: String): String {
return result
}
fun box() = Receiver("Fail").test("OK")

View File

@@ -0,0 +1,17 @@
// !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND: JVM_IR
// FILE: common.kt
class B(val value: Int)
expect fun test(a: Int = 2, b: Int = B(a * 2).value, c: String = "${b}$a"): String
// FILE: platform.kt
actual fun test(a: Int, b: Int, c: String): String = c
fun box(): String {
val result = test()
return if (result == "42") "OK" else "Fail: $result"
}

View File

@@ -0,0 +1,31 @@
// !LANGUAGE: +MultiPlatformProjects
// NO_CHECK_LAMBDA_INLINING
// IGNORE_BACKEND: JVM_IR
// FILE: 1.kt
class C(val s1: String, val s2: String)
expect fun C.test(r1: () -> String = { s1 }, r2: () -> String = this::s2): String
actual inline fun C.test(r1: () -> String, r2: () -> String): String = r1() + r2()
expect class D {
val s1: String
val s2: String
fun test(r1: () -> String = { s1 }, r2: () -> String = this::s2): String
}
actual class D(actual val s1: String, actual val s2: String) {
actual inline fun test(r1: () -> String, r2: () -> String): String = r1() + r2()
}
// FILE: 2.kt
fun box(): String {
if (C("O", "K").test() != "OK") return "Fail extension receiver"
if (D("O", "K").test() != "OK") return "Fail dispatch receiver"
return "OK"
}

View File

@@ -1,4 +1,4 @@
// WITH_REFLECT
// !LANGUAGE: +ProhibitTypeParametersInClassLiteralsInAnnotationArguments
import kotlin.reflect.KClass
@@ -35,4 +35,11 @@ fun test7() {}
fun test8() {}
inline val <reified T> T.test9
get() = @Ann(T::class) object {}
get() = @AnnArray(<!NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION!>arrayOf(
<!ANNOTATION_ARGUMENT_KCLASS_LITERAL_OF_TYPE_PARAMETER_ERROR!>T::class<!>,
<!ANNOTATION_ARGUMENT_KCLASS_LITERAL_OF_TYPE_PARAMETER_ERROR!>Array<T>::class<!>,
<!ANNOTATION_ARGUMENT_KCLASS_LITERAL_OF_TYPE_PARAMETER_ERROR!>Array<Array<Array<T>>>::class<!>
)<!>) object {}
inline val <reified T> T.test10
get() = @AnnArray(<!NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION!>[<!ANNOTATION_ARGUMENT_KCLASS_LITERAL_OF_TYPE_PARAMETER_ERROR!>T::class<!>]<!>) object {}

View File

@@ -1,5 +1,6 @@
package
public val </*0*/ reified T> T.test10: kotlin.Any
public val </*0*/ reified T> T.test9: kotlin.Any
public fun foo(): kotlin.String
@Ann(k = kotlin.String::class) public fun test1(): kotlin.Unit

View File

@@ -0,0 +1,12 @@
// !LANGUAGE: -ProhibitTypeParametersInClassLiteralsInAnnotationArguments
import kotlin.reflect.KClass
annotation class Ann(vararg val k: KClass<*>)
inline val <reified T> T.test
get() = @Ann(
<!ANNOTATION_ARGUMENT_KCLASS_LITERAL_OF_TYPE_PARAMETER!>T::class<!>,
<!ANNOTATION_ARGUMENT_KCLASS_LITERAL_OF_TYPE_PARAMETER!>Array<T>::class<!>,
<!ANNOTATION_ARGUMENT_KCLASS_LITERAL_OF_TYPE_PARAMETER!>Array<Array<Array<T>>>::class<!>
) object {}

View File

@@ -0,0 +1,11 @@
package
public val </*0*/ reified T> T.test: kotlin.Any
public final annotation class Ann : kotlin.Annotation {
public constructor Ann(/*0*/ vararg k: kotlin.reflect.KClass<*> /*kotlin.Array<out kotlin.reflect.KClass<*>>*/)
public final val k: kotlin.Array<out kotlin.reflect.KClass<*>>
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

@@ -1,3 +1,5 @@
// !LANGUAGE: -ProhibitComparisonOfIncompatibleEnums
enum class E1 {
A, B
}
@@ -56,3 +58,88 @@ fun foo3(e1: Enum<E1>, e2: Enum<E2>, e: Enum<*>) {
else -> {}
}
}
interface MyInterface
open class MyOpenClass
fun foo4(e1: E1, i: MyInterface, c: MyOpenClass) {
<!INCOMPATIBLE_ENUM_COMPARISON!>e1 == i<!>
<!INCOMPATIBLE_ENUM_COMPARISON!>i == e1<!>
<!INCOMPATIBLE_ENUM_COMPARISON!>e1 == c<!>
<!INCOMPATIBLE_ENUM_COMPARISON!>c == e1<!>
when (e1) {
<!INCOMPATIBLE_ENUM_COMPARISON!>i<!> -> {}
<!INCOMPATIBLE_ENUM_COMPARISON!>c<!> -> {}
else -> {}
}
}
enum class E3 : MyInterface { X, Y }
fun foo5(i: MyInterface, a: Any) {
E3.X == E3.Y
E3.X == i
E3.X == a
}
fun foo6(e1: E1?, e2: E2) {
<!SENSELESS_COMPARISON!>E1.A == null<!>
<!SENSELESS_COMPARISON!>null == E1.A<!>
e1 == null
null == e1
<!INCOMPATIBLE_ENUM_COMPARISON!>e1 == E2.A<!>
<!INCOMPATIBLE_ENUM_COMPARISON!>E2.A == e1<!>
<!INCOMPATIBLE_ENUM_COMPARISON!>e1 == e2<!>
<!INCOMPATIBLE_ENUM_COMPARISON!>e2 == e1<!>
<!SENSELESS_COMPARISON!>e2 == null<!>
<!SENSELESS_COMPARISON!>null == e2<!>
<!SENSELESS_COMPARISON!>E1.A == null<!>
<!SENSELESS_COMPARISON!>null == E1.A<!>
}
fun foo7(e1: E1?, e2: E2?) {
e1 == e2 // There should be an IDE-inspection for such cases
}
fun <T> foo8(e1: E1?, e2: E2, t: T) {
e1 == t
t == e1
e2 == t
t == e2
E1.A == t
t == E1.A
}
fun <T, K> foo9(e1: E1?, e2: E2, t: T, k: K) where T : MyInterface, T : MyOpenClass, K : MyInterface {
<!INCOMPATIBLE_ENUM_COMPARISON!>e1 == t<!>
<!INCOMPATIBLE_ENUM_COMPARISON!>t == e1<!>
<!INCOMPATIBLE_ENUM_COMPARISON!>e2 == t<!>
<!INCOMPATIBLE_ENUM_COMPARISON!>t == e2<!>
<!INCOMPATIBLE_ENUM_COMPARISON!>E1.A == t<!>
<!INCOMPATIBLE_ENUM_COMPARISON!>t == E1.A<!>
<!INCOMPATIBLE_ENUM_COMPARISON!>E3.X == t<!>
E3.X == k
k == E3.X
}
interface Inv<T>
enum class E4 : Inv<Int> { A }
fun foo10(e4: E4, invString: Inv<String>) {
e4 == invString
invString == e4
E4.A == invString
invString == E4.A
}

View File

@@ -1,8 +1,15 @@
package
public fun foo1(/*0*/ e1: E1, /*1*/ e2: E2): kotlin.Unit
public fun foo10(/*0*/ e4: E4, /*1*/ invString: Inv<kotlin.String>): kotlin.Unit
public fun foo2(/*0*/ e1: E1, /*1*/ e2: E2): kotlin.Unit
public fun foo3(/*0*/ e1: kotlin.Enum<E1>, /*1*/ e2: kotlin.Enum<E2>, /*2*/ e: kotlin.Enum<*>): kotlin.Unit
public fun foo4(/*0*/ e1: E1, /*1*/ i: MyInterface, /*2*/ c: MyOpenClass): kotlin.Unit
public fun foo5(/*0*/ i: MyInterface, /*1*/ a: kotlin.Any): kotlin.Unit
public fun foo6(/*0*/ e1: E1?, /*1*/ e2: E2): kotlin.Unit
public fun foo7(/*0*/ e1: E1?, /*1*/ e2: E2?): kotlin.Unit
public fun </*0*/ T> foo8(/*0*/ e1: E1?, /*1*/ e2: E2, /*2*/ t: T): kotlin.Unit
public fun </*0*/ T : MyInterface, /*1*/ K : MyInterface> foo9(/*0*/ e1: E1?, /*1*/ e2: E2, /*2*/ t: T, /*3*/ k: K): kotlin.Unit where T : MyOpenClass
public final enum class E1 : kotlin.Enum<E1> {
enum entry A
@@ -45,3 +52,62 @@ public final enum class E2 : kotlin.Enum<E2> {
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): E2
public final /*synthesized*/ fun values(): kotlin.Array<E2>
}
public final enum class E3 : kotlin.Enum<E3>, MyInterface {
enum entry X
enum entry Y
private constructor E3()
public final override /*1*/ /*fake_override*/ val name: kotlin.String
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: E3): kotlin.Int
public final override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<E3!>!
public final override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): E3
public final /*synthesized*/ fun values(): kotlin.Array<E3>
}
public final enum class E4 : kotlin.Enum<E4>, Inv<kotlin.Int> {
enum entry A
private constructor E4()
public final override /*1*/ /*fake_override*/ val name: kotlin.String
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: E4): kotlin.Int
public final override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<E4!>!
public final override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): E4
public final /*synthesized*/ fun values(): kotlin.Array<E4>
}
public interface Inv</*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 MyInterface {
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 open class MyOpenClass {
public constructor MyOpenClass()
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

@@ -0,0 +1,145 @@
// !LANGUAGE: +ProhibitComparisonOfIncompatibleEnums
enum class E1 {
A, B
}
enum class E2 {
A, B
}
fun foo1(e1: E1, e2: E2) {
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>e1 == e2<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>e1 != e2<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>e1 == E2.A<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>E1.B == e2<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>E1.A == E2.B<!>
e1 == E1.A
E1.A == e1
e2 == E2.B
E2.B == e2
}
fun foo2(e1: E1, e2: E2) {
when (e1) {
E1.A -> {}
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>E2.A<!> -> {}
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>E2.B<!> -> {}
e1 -> {}
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>e2<!> -> {}
else -> {}
}
}
fun foo3(e1: Enum<E1>, e2: Enum<E2>, e: Enum<*>) {
e1 == e
e1 == e2
e1 == E1.A
e1 == E2.A
when (e1) {
e1 -> {}
e2 -> {}
e -> {}
E1.A -> {}
E2.A -> {}
else -> {}
}
when (e) {
e -> {}
e2 -> {}
E1.A -> {}
E2.A -> {}
else -> {}
}
}
interface MyInterface
open class MyOpenClass
fun foo4(e1: E1, i: MyInterface, c: MyOpenClass) {
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>e1 == i<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>i == e1<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>e1 == c<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>c == e1<!>
when (e1) {
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>i<!> -> {}
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>c<!> -> {}
else -> {}
}
}
enum class E3 : MyInterface { X, Y }
fun foo5(i: MyInterface, a: Any) {
E3.X == E3.Y
E3.X == i
E3.X == a
}
fun foo6(e1: E1?, e2: E2) {
<!SENSELESS_COMPARISON!>E1.A == null<!>
<!SENSELESS_COMPARISON!>null == E1.A<!>
e1 == null
null == e1
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>e1 == E2.A<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>E2.A == e1<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>e1 == e2<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>e2 == e1<!>
<!SENSELESS_COMPARISON!>e2 == null<!>
<!SENSELESS_COMPARISON!>null == e2<!>
<!SENSELESS_COMPARISON!>E1.A == null<!>
<!SENSELESS_COMPARISON!>null == E1.A<!>
}
fun foo7(e1: E1?, e2: E2?) {
e1 == e2 // There should be an IDE-inspection for such cases
}
fun <T> foo8(e1: E1?, e2: E2, t: T) {
e1 == t
t == e1
e2 == t
t == e2
E1.A == t
t == E1.A
}
fun <T, K> foo9(e1: E1?, e2: E2, t: T, k: K) where T : MyInterface, T : MyOpenClass, K : MyInterface {
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>e1 == t<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>t == e1<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>e2 == t<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>t == e2<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>E1.A == t<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>t == E1.A<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>E3.X == t<!>
E3.X == k
k == E3.X
}
interface Inv<T>
enum class E4 : Inv<Int> { A }
fun foo10(e4: E4, invString: Inv<String>) {
e4 == invString
invString == e4
E4.A == invString
invString == E4.A
}

View File

@@ -0,0 +1,113 @@
package
public fun foo1(/*0*/ e1: E1, /*1*/ e2: E2): kotlin.Unit
public fun foo10(/*0*/ e4: E4, /*1*/ invString: Inv<kotlin.String>): kotlin.Unit
public fun foo2(/*0*/ e1: E1, /*1*/ e2: E2): kotlin.Unit
public fun foo3(/*0*/ e1: kotlin.Enum<E1>, /*1*/ e2: kotlin.Enum<E2>, /*2*/ e: kotlin.Enum<*>): kotlin.Unit
public fun foo4(/*0*/ e1: E1, /*1*/ i: MyInterface, /*2*/ c: MyOpenClass): kotlin.Unit
public fun foo5(/*0*/ i: MyInterface, /*1*/ a: kotlin.Any): kotlin.Unit
public fun foo6(/*0*/ e1: E1?, /*1*/ e2: E2): kotlin.Unit
public fun foo7(/*0*/ e1: E1?, /*1*/ e2: E2?): kotlin.Unit
public fun </*0*/ T> foo8(/*0*/ e1: E1?, /*1*/ e2: E2, /*2*/ t: T): kotlin.Unit
public fun </*0*/ T : MyInterface, /*1*/ K : MyInterface> foo9(/*0*/ e1: E1?, /*1*/ e2: E2, /*2*/ t: T, /*3*/ k: K): kotlin.Unit where T : MyOpenClass
public final enum class E1 : kotlin.Enum<E1> {
enum entry A
enum entry B
private constructor E1()
public final override /*1*/ /*fake_override*/ val name: kotlin.String
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: E1): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<E1!>!
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): E1
public final /*synthesized*/ fun values(): kotlin.Array<E1>
}
public final enum class E2 : kotlin.Enum<E2> {
enum entry A
enum entry B
private constructor E2()
public final override /*1*/ /*fake_override*/ val name: kotlin.String
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: E2): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<E2!>!
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): E2
public final /*synthesized*/ fun values(): kotlin.Array<E2>
}
public final enum class E3 : kotlin.Enum<E3>, MyInterface {
enum entry X
enum entry Y
private constructor E3()
public final override /*1*/ /*fake_override*/ val name: kotlin.String
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: E3): kotlin.Int
public final override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<E3!>!
public final override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): E3
public final /*synthesized*/ fun values(): kotlin.Array<E3>
}
public final enum class E4 : kotlin.Enum<E4>, Inv<kotlin.Int> {
enum entry A
private constructor E4()
public final override /*1*/ /*fake_override*/ val name: kotlin.String
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: E4): kotlin.Int
public final override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<E4!>!
public final override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): E4
public final /*synthesized*/ fun values(): kotlin.Array<E4>
}
public interface Inv</*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 MyInterface {
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 open class MyOpenClass {
public constructor MyOpenClass()
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

@@ -2991,6 +2991,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
runTest("compiler/testData/diagnostics/tests/classLiteral/inAnnotationArguments.kt");
}
@TestMetadata("inAnnotationArguments_noTypeParams.kt")
public void testInAnnotationArguments_noTypeParams() throws Exception {
runTest("compiler/testData/diagnostics/tests/classLiteral/inAnnotationArguments_noTypeParams.kt");
}
@TestMetadata("integerValueType.kt")
public void testIntegerValueType() throws Exception {
runTest("compiler/testData/diagnostics/tests/classLiteral/integerValueType.kt");
@@ -6928,6 +6933,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
runTest("compiler/testData/diagnostics/tests/enum/incompatibleEnums.kt");
}
@TestMetadata("incompatibleEnums_1_4.kt")
public void testIncompatibleEnums_1_4() throws Exception {
runTest("compiler/testData/diagnostics/tests/enum/incompatibleEnums_1_4.kt");
}
@TestMetadata("inheritFromEnumEntry.kt")
public void testInheritFromEnumEntry() throws Exception {
runTest("compiler/testData/diagnostics/tests/enum/inheritFromEnumEntry.kt");

View File

@@ -2986,6 +2986,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
runTest("compiler/testData/diagnostics/tests/classLiteral/inAnnotationArguments.kt");
}
@TestMetadata("inAnnotationArguments_noTypeParams.kt")
public void testInAnnotationArguments_noTypeParams() throws Exception {
runTest("compiler/testData/diagnostics/tests/classLiteral/inAnnotationArguments_noTypeParams.kt");
}
@TestMetadata("integerValueType.kt")
public void testIntegerValueType() throws Exception {
runTest("compiler/testData/diagnostics/tests/classLiteral/integerValueType.kt");
@@ -6923,6 +6928,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
runTest("compiler/testData/diagnostics/tests/enum/incompatibleEnums.kt");
}
@TestMetadata("incompatibleEnums_1_4.kt")
public void testIncompatibleEnums_1_4() throws Exception {
runTest("compiler/testData/diagnostics/tests/enum/incompatibleEnums_1_4.kt");
}
@TestMetadata("inheritFromEnumEntry.kt")
public void testInheritFromEnumEntry() throws Exception {
runTest("compiler/testData/diagnostics/tests/enum/inheritFromEnumEntry.kt");

View File

@@ -15875,6 +15875,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/delegatedExpectedInterface.kt");
}
@TestMetadata("dispatchReceiverValue.kt")
public void testDispatchReceiverValue() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/dispatchReceiverValue.kt");
}
@TestMetadata("extensionReceiverValue.kt")
public void testExtensionReceiverValue() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/extensionReceiverValue.kt");
}
@TestMetadata("function.kt")
public void testFunction() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/function.kt");
@@ -15930,6 +15940,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/kt23739.kt");
}
@TestMetadata("parametersInArgumentValues.kt")
public void testParametersInArgumentValues() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/parametersInArgumentValues.kt");
}
@TestMetadata("superCall.kt")
public void testSuperCall() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/superCall.kt");

View File

@@ -1890,6 +1890,37 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
}
}
@TestMetadata("compiler/testData/codegen/boxInline/multiplatform")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Multiplatform extends AbstractBlackBoxInlineCodegenTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInMultiplatform() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/multiplatform"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("compiler/testData/codegen/boxInline/multiplatform/defaultArguments")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class DefaultArguments extends AbstractBlackBoxInlineCodegenTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInDefaultArguments() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/multiplatform/defaultArguments"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("receiversAndParametersInLambda.kt")
public void testReceiversAndParametersInLambda() throws Exception {
runTest("compiler/testData/codegen/boxInline/multiplatform/defaultArguments/receiversAndParametersInLambda.kt");
}
}
}
@TestMetadata("compiler/testData/codegen/boxInline/noInline")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)

View File

@@ -1890,6 +1890,37 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
}
}
@TestMetadata("compiler/testData/codegen/boxInline/multiplatform")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Multiplatform extends AbstractCompileKotlinAgainstInlineKotlinTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInMultiplatform() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/multiplatform"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("compiler/testData/codegen/boxInline/multiplatform/defaultArguments")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class DefaultArguments extends AbstractCompileKotlinAgainstInlineKotlinTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInDefaultArguments() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/multiplatform/defaultArguments"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("receiversAndParametersInLambda.kt")
public void testReceiversAndParametersInLambda() throws Exception {
runTest("compiler/testData/codegen/boxInline/multiplatform/defaultArguments/receiversAndParametersInLambda.kt");
}
}
}
@TestMetadata("compiler/testData/codegen/boxInline/noInline")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)

View File

@@ -15880,6 +15880,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/constructor.kt");
}
@TestMetadata("dispatchReceiverValue.kt")
public void testDispatchReceiverValue() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/dispatchReceiverValue.kt");
}
@TestMetadata("extensionReceiverValue.kt")
public void testExtensionReceiverValue() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/extensionReceiverValue.kt");
}
@TestMetadata("function.kt")
public void testFunction() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/function.kt");
@@ -15934,6 +15944,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
public void testKt23739() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/kt23739.kt");
}
@TestMetadata("parametersInArgumentValues.kt")
public void testParametersInArgumentValues() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/parametersInArgumentValues.kt");
}
}
}

View File

@@ -15880,6 +15880,16 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/delegatedExpectedInterface.kt");
}
@TestMetadata("dispatchReceiverValue.kt")
public void testDispatchReceiverValue() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/dispatchReceiverValue.kt");
}
@TestMetadata("extensionReceiverValue.kt")
public void testExtensionReceiverValue() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/extensionReceiverValue.kt");
}
@TestMetadata("function.kt")
public void testFunction() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/function.kt");
@@ -15935,6 +15945,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/kt23739.kt");
}
@TestMetadata("parametersInArgumentValues.kt")
public void testParametersInArgumentValues() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/parametersInArgumentValues.kt");
}
@TestMetadata("superCall.kt")
public void testSuperCall() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/superCall.kt");

View File

@@ -1890,6 +1890,37 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli
}
}
@TestMetadata("compiler/testData/codegen/boxInline/multiplatform")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Multiplatform extends AbstractIrBlackBoxInlineCodegenTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
}
public void testAllFilesPresentInMultiplatform() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/multiplatform"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
}
@TestMetadata("compiler/testData/codegen/boxInline/multiplatform/defaultArguments")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class DefaultArguments extends AbstractIrBlackBoxInlineCodegenTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
}
public void testAllFilesPresentInDefaultArguments() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/multiplatform/defaultArguments"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
}
@TestMetadata("receiversAndParametersInLambda.kt")
public void testReceiversAndParametersInLambda() throws Exception {
runTest("compiler/testData/codegen/boxInline/multiplatform/defaultArguments/receiversAndParametersInLambda.kt");
}
}
}
@TestMetadata("compiler/testData/codegen/boxInline/noInline")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)

View File

@@ -100,6 +100,8 @@ enum class LanguageFeature(
ProperInlineFromHigherPlatformDiagnostic(KOTLIN_1_4, kind = BUG_FIX),
ProhibitRepeatedUseSiteTargetAnnotations(KOTLIN_1_4, kind = BUG_FIX),
ProhibitUseSiteTargetAnnotationsOnSuperTypes(KOTLIN_1_4, kind = BUG_FIX),
ProhibitTypeParametersInClassLiteralsInAnnotationArguments(KOTLIN_1_4, kind = BUG_FIX),
ProhibitComparisonOfIncompatibleEnums(KOTLIN_1_4, kind = BUG_FIX),
ProperVisibilityForCompanionObjectInstanceField(sinceVersion = null, kind = BUG_FIX),
// Temporarily disabled, see KT-27084/KT-22379

View File

@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.resolve.unsubstitutedUnderlyingType
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.typeUtil.makeNullable
import org.jetbrains.kotlin.types.typeUtil.replaceArgumentsWithStarProjections
import org.jetbrains.kotlin.types.typeUtil.representativeUpperBound
import org.jetbrains.kotlin.utils.DO_NOTHING_3
interface JvmTypeFactory<T : Any> {
@@ -181,7 +182,7 @@ fun <T : Any> mapType(
descriptor is TypeParameterDescriptor -> {
val type = mapType(
getRepresentativeUpperBound(descriptor),
descriptor.representativeUpperBound,
factory,
mode,
typeMappingConfiguration,
@@ -255,7 +256,7 @@ internal fun computeUnderlyingType(inlineClassType: KotlinType): KotlinType? {
val descriptor = inlineClassType.unsubstitutedUnderlyingType()?.constructor?.declarationDescriptor ?: return null
return if (descriptor is TypeParameterDescriptor)
getRepresentativeUpperBound(descriptor)
descriptor.representativeUpperBound
else
inlineClassType.substitutedUnderlyingType()
}
@@ -270,7 +271,7 @@ internal fun computeExpandedTypeInner(kotlinType: KotlinType, visitedClassifiers
return when {
classifier is TypeParameterDescriptor ->
computeExpandedTypeInner(getRepresentativeUpperBound(classifier), visitedClassifiers)
computeExpandedTypeInner(classifier.representativeUpperBound, visitedClassifiers)
?.let { expandedUpperBound ->
if (expandedUpperBound.isNullable() || !kotlinType.isMarkedNullable)
expandedUpperBound
@@ -338,16 +339,6 @@ fun computeInternalName(
private fun getContainer(container: DeclarationDescriptor?): DeclarationDescriptor? =
container as? ClassDescriptor ?: container as? PackageFragmentDescriptor ?: container?.let { getContainer(it.containingDeclaration) }
fun getRepresentativeUpperBound(descriptor: TypeParameterDescriptor): KotlinType {
val upperBounds = descriptor.upperBounds
assert(!upperBounds.isEmpty()) { "Upper bounds should not be empty: $descriptor" }
return upperBounds.firstOrNull {
val classDescriptor = it.constructor.declarationDescriptor as? ClassDescriptor ?: return@firstOrNull false
classDescriptor.kind != ClassKind.INTERFACE && classDescriptor.kind != ClassKind.ANNOTATION_CLASS
} ?: upperBounds.first()
}
open class JvmDescriptorTypeWriter<T : Any>(private val jvmTypeFactory: JvmTypeFactory<T>) {
private var jvmCurrentTypeArrayLevel: Int = 0
protected var jvmCurrentType: T? = null

View File

@@ -6,15 +6,11 @@
package org.jetbrains.kotlin.resolve.jvm
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.load.kotlin.getRepresentativeUpperBound
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
import org.jetbrains.kotlin.resolve.isInlineClass
import org.jetbrains.kotlin.resolve.isInlineClassType
import org.jetbrains.kotlin.types.KotlinType
import java.security.MessageDigest
import java.util.*
import org.jetbrains.kotlin.types.typeUtil.representativeUpperBound
fun shouldHideConstructorDueToInlineClassTypeValueParameters(descriptor: CallableMemberDescriptor): Boolean {
val constructorDescriptor = descriptor as? ClassConstructorDescriptor ?: return false
@@ -45,5 +41,5 @@ private fun isDontMangleClass(classDescriptor: ClassDescriptor) =
private fun KotlinType.isTypeParameterWithUpperBoundThatRequiresMangling(): Boolean {
val descriptor = constructor.declarationDescriptor as? TypeParameterDescriptor ?: return false
return getRepresentativeUpperBound(descriptor).requiresFunctionNameMangling()
return descriptor.representativeUpperBound.requiresFunctionNameMangling()
}

View File

@@ -214,10 +214,10 @@ class KClassValue(value: Value) : ConstantValue<KClassValue.Value>(value) {
KClassValue(classId, arrayDimensions)
}
is TypeParameterDescriptor -> {
// This is possible if a reified type parameter is used in annotation on a local class / anonymous object.
// This is possible before 1.4 if a reified type parameter is used in annotation on a local class / anonymous object.
// In JVM class file, we can't represent such literal properly, so we're writing java.lang.Object instead.
// This has no effect on the compiler front-end or other back-ends, so we use kotlin.Any for simplicity here.
// Overall, it looks like such code should be disallowed: https://youtrack.jetbrains.com/issue/KT-27799
// See LanguageFeature.ProhibitTypeParametersInClassLiteralsInAnnotationArguments
KClassValue(ClassId.topLevel(KotlinBuiltIns.FQ_NAMES.any.toSafe()), 0)
}
else -> null

View File

@@ -384,20 +384,30 @@ public class TypeUtils {
public static boolean contains(
@Nullable KotlinType type,
@NotNull Function1<UnwrappedType, Boolean> isSpecialType
) {
return contains(type, isSpecialType, new HashSet<KotlinType>());
}
private static boolean contains(
@Nullable KotlinType type,
@NotNull Function1<UnwrappedType, Boolean> isSpecialType,
HashSet<KotlinType> visited
) {
if (type == null) return false;
if (visited.contains(type)) return false;
visited.add(type);
UnwrappedType unwrappedType = type.unwrap();
if (isSpecialType.invoke(unwrappedType)) return true;
FlexibleType flexibleType = unwrappedType instanceof FlexibleType ? (FlexibleType) unwrappedType : null;
if (flexibleType != null
&& (contains(flexibleType.getLowerBound(), isSpecialType) || contains(flexibleType.getUpperBound(), isSpecialType))) {
&& (contains(flexibleType.getLowerBound(), isSpecialType, visited) || contains(flexibleType.getUpperBound(), isSpecialType, visited))) {
return true;
}
if (unwrappedType instanceof DefinitelyNotNullType &&
contains(((DefinitelyNotNullType) unwrappedType).getOriginal(), isSpecialType)) {
contains(((DefinitelyNotNullType) unwrappedType).getOriginal(), isSpecialType, visited)) {
return true;
}
@@ -405,13 +415,13 @@ public class TypeUtils {
if (typeConstructor instanceof IntersectionTypeConstructor) {
IntersectionTypeConstructor intersectionTypeConstructor = (IntersectionTypeConstructor) typeConstructor;
for (KotlinType supertype : intersectionTypeConstructor.getSupertypes()) {
if (contains(supertype, isSpecialType)) return true;
if (contains(supertype, isSpecialType, visited)) return true;
}
return false;
}
for (TypeProjection projection : type.getArguments()) {
if (!projection.isStarProjection() && contains(projection.getType(), isSpecialType)) return true;
if (!projection.isStarProjection() && contains(projection.getType(), isSpecialType, visited)) return true;
}
return false;
}

View File

@@ -54,6 +54,7 @@ fun KotlinType.supertypes(): Collection<KotlinType> = TypeUtils.getAllSupertypes
fun KotlinType.isNothing(): Boolean = KotlinBuiltIns.isNothing(this)
fun KotlinType.isNullableNothing(): Boolean = KotlinBuiltIns.isNullableNothing(this)
fun KotlinType.isNothingOrNullableNothing(): Boolean = KotlinBuiltIns.isNothingOrNullableNothing(this)
fun KotlinType.isUnit(): Boolean = KotlinBuiltIns.isUnit(this)
fun KotlinType.isAnyOrNullableAny(): Boolean = KotlinBuiltIns.isAnyOrNullableAny(this)
fun KotlinType.isNullableAny(): Boolean = KotlinBuiltIns.isNullableAny(this)
@@ -228,3 +229,14 @@ fun UnwrappedType.canHaveUndefinedNullability(): Boolean =
constructor is NewTypeVariableConstructor ||
constructor.declarationDescriptor is TypeParameterDescriptor ||
this is NewCapturedType
val TypeParameterDescriptor.representativeUpperBound: KotlinType
get() {
assert(upperBounds.isNotEmpty()) { "Upper bounds should not be empty: $this" }
return upperBounds.firstOrNull {
val classDescriptor = it.constructor.declarationDescriptor as? ClassDescriptor ?: return@firstOrNull false
classDescriptor.kind != ClassKind.INTERFACE && classDescriptor.kind != ClassKind.ANNOTATION_CLASS
} ?: upperBounds.first()
}

View File

@@ -25,6 +25,7 @@ class TypeDeserializer(
private val parent: TypeDeserializer?,
typeParameterProtos: List<ProtoBuf.TypeParameter>,
private val debugName: String,
private val containerPresentableName: String,
var experimentalSuspendFunctionTypeEncountered: Boolean = false
) {
private val classDescriptors: (Int) -> ClassDescriptor? = c.storageManager.createMemoizedFunctionWithNullableValues { fqNameIndex ->
@@ -112,7 +113,9 @@ class TypeDeserializer(
proto.hasClassName() -> (classDescriptors(proto.className) ?: notFoundClass(proto.className)).typeConstructor
proto.hasTypeParameter() ->
typeParameterTypeConstructor(proto.typeParameter)
?: ErrorUtils.createErrorTypeConstructor("Unknown type parameter ${proto.typeParameter}")
?: ErrorUtils.createErrorTypeConstructor(
"Unknown type parameter ${proto.typeParameter}. Please try recompiling module containing \"$containerPresentableName\""
)
proto.hasTypeParameterName() -> {
val container = c.containingDeclaration
val name = c.nameResolver.getString(proto.typeParameterName)

View File

@@ -80,7 +80,8 @@ class DeserializationContext(
) {
val typeDeserializer: TypeDeserializer = TypeDeserializer(
this, parentTypeDeserializer, typeParameters,
"Deserializer for ${containingDeclaration.name}"
"Deserializer for \"${containingDeclaration.name}\"",
containerSource?.presentableString ?: "[container not found]"
)
val memberDeserializer: MemberDeserializer = MemberDeserializer(this)

View File

@@ -27,7 +27,7 @@ class JvmMetadataVersion(versionArray: IntArray, val isStrictSemantics: Boolean)
companion object {
@JvmField
val INSTANCE = JvmMetadataVersion(1, 1, 13)
val INSTANCE = JvmMetadataVersion(1, 1, 14)
@JvmField
val INVALID_VERSION = JvmMetadataVersion()

View File

@@ -527,7 +527,7 @@ fun main(args: Array<String>) {
}
testClass<AbstractOutOfBlockModificationTest> {
model("codeInsight/outOfBlock")
model("codeInsight/outOfBlock", pattern = KT_OR_KTS)
}
testClass<AbstractDataFlowValueRenderingTest> {

View File

@@ -518,7 +518,7 @@ fun main(args: Array<String>) {
}
testClass<AbstractOutOfBlockModificationTest> {
model("codeInsight/outOfBlock")
model("codeInsight/outOfBlock", pattern = KT_OR_KTS)
}
testClass<AbstractDataFlowValueRenderingTest> {
@@ -627,10 +627,6 @@ fun main(args: Array<String>) {
model("debugger/smartStepInto")
}
testClass<AbstractBeforeExtractFunctionInsertionTest> {
model("debugger/insertBeforeExtractFunction", extension = "kt")
}
testClass<AbstractKotlinSteppingTest> {
model("debugger/tinyApp/src/stepping/stepIntoAndSmartStepInto", pattern = KT_WITHOUT_DOTS_IN_NAME, testMethod = "doStepIntoTest", testClassName = "StepInto")
model("debugger/tinyApp/src/stepping/stepIntoAndSmartStepInto", pattern = KT_WITHOUT_DOTS_IN_NAME, testMethod = "doSmartStepIntoTest", testClassName = "SmartStepInto")

View File

@@ -515,7 +515,7 @@ fun main(args: Array<String>) {
}
testClass<AbstractOutOfBlockModificationTest> {
model("codeInsight/outOfBlock")
model("codeInsight/outOfBlock", pattern = KT_OR_KTS)
}
testClass<AbstractDataFlowValueRenderingTest> {

View File

@@ -507,7 +507,7 @@ fun main(args: Array<String>) {
}
testClass<AbstractOutOfBlockModificationTest> {
model("codeInsight/outOfBlock")
model("codeInsight/outOfBlock", pattern = KT_OR_KTS)
}
testClass<AbstractDataFlowValueRenderingTest> {

View File

@@ -507,7 +507,7 @@ fun main(args: Array<String>) {
}
testClass<AbstractOutOfBlockModificationTest> {
model("codeInsight/outOfBlock")
model("codeInsight/outOfBlock", pattern = KT_OR_KTS)
}
testClass<AbstractDataFlowValueRenderingTest> {

View File

@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.analyzer.ModuleInfo
import org.jetbrains.kotlin.analyzer.TrackableModuleInfo
import org.jetbrains.kotlin.caches.project.LibraryModuleInfo
import org.jetbrains.kotlin.caches.resolve.resolution
import org.jetbrains.kotlin.config.KotlinSourceRootType
import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.util.enlargedSearchScope
import org.jetbrains.kotlin.idea.configuration.BuildSystemType
@@ -210,8 +210,8 @@ fun Module.testSourceInfo(): ModuleTestSourceInfo? = if (hasTestRoots()) ModuleT
internal fun Module.correspondingModuleInfos(): List<ModuleSourceInfo> = listOf(testSourceInfo(), productionSourceInfo()).filterNotNull()
private fun Module.hasProductionRoots() = hasRootsOfType(JavaSourceRootType.SOURCE) || hasRootsOfType(KotlinSourceRootType.Source) || (isNewMPPModule && sourceType == SourceType.PRODUCTION)
private fun Module.hasTestRoots() = hasRootsOfType(JavaSourceRootType.TEST_SOURCE) || hasRootsOfType(KotlinSourceRootType.TestSource) || (isNewMPPModule && sourceType == SourceType.TEST)
private fun Module.hasProductionRoots() = hasRootsOfType(JavaSourceRootType.SOURCE) || hasRootsOfType(SourceKotlinRootType) || (isNewMPPModule && sourceType == SourceType.PRODUCTION)
private fun Module.hasTestRoots() = hasRootsOfType(JavaSourceRootType.TEST_SOURCE) || hasRootsOfType(TestSourceKotlinRootType) || (isNewMPPModule && sourceType == SourceType.TEST)
private fun Module.hasRootsOfType(sourceRootType: JpsModuleSourceRootType<*>): Boolean =
rootManager.contentEntries.any { it.getSourceFolders(sourceRootType).isNotEmpty() }

View File

@@ -39,7 +39,6 @@ import org.jetbrains.kotlin.idea.caches.project.cached
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getTopmostParentOfType
import org.jetbrains.kotlin.psi.psiUtil.isAncestor
import org.jetbrains.kotlin.psi.psiUtil.parents
val KOTLIN_CONSOLE_KEY = Key.create<Boolean>("kotlin.console")
@@ -128,8 +127,8 @@ class KotlinCodeBlockModificationListener(
?.let { return it }
}
val blockDeclaration = KtPsiUtil.getTopmostParentOfTypes(element, *BLOCK_DECLARATION_TYPES) ?: return null
if (blockDeclaration.parents.any { it !is KtClassBody && it !is KtClassOrObject && it !is KtFile }) return null // should not be local declaration
val blockDeclaration = KtPsiUtil.getTopmostParentOfTypes(element, *BLOCK_DECLARATION_TYPES) as? KtDeclaration ?: return null
if (KtPsiUtil.isLocal(blockDeclaration)) return null // should not be local declaration
when (blockDeclaration) {
is KtNamedFunction -> {
@@ -151,6 +150,13 @@ class KotlinCodeBlockModificationListener(
}
}
is KtScriptInitializer -> {
return (blockDeclaration.body as? KtCallExpression)
?.lambdaArguments?.last()
?.getLambdaExpression()
?.takeIf { it.isAncestor(element) }
}
else -> throw IllegalStateException()
}
@@ -163,7 +169,8 @@ class KotlinCodeBlockModificationListener(
private val BLOCK_DECLARATION_TYPES = arrayOf<Class<out KtDeclaration>>(
KtProperty::class.java,
KtNamedFunction::class.java
KtNamedFunction::class.java,
KtScriptInitializer::class.java
)
fun getInstance(project: Project) = project.getComponent(KotlinCodeBlockModificationListener::class.java)

View File

@@ -22,7 +22,10 @@ import org.jetbrains.kotlin.idea.util.ShadowedDeclarationsFilter
import org.jetbrains.kotlin.idea.util.getResolutionScope
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.*
import org.jetbrains.kotlin.psi.psiUtil.createSmartPointer
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForReceiver
import org.jetbrains.kotlin.psi.psiUtil.parents
import org.jetbrains.kotlin.renderer.DescriptorRenderer
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.calls.callUtil.getCall
@@ -36,7 +39,6 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
import org.jetbrains.kotlin.resolve.scopes.utils.findFirstClassifierWithDeprecationStatus
import org.jetbrains.kotlin.resolve.scopes.utils.findPackage
import org.jetbrains.kotlin.resolve.source.getPsi
import java.lang.IllegalStateException
import java.util.*
class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT }) {
@@ -49,7 +51,7 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
) {
companion object {
val DEFAULT = Options()
val ALL_ENABLED = Options(true, true)
val ALL_ENABLED = Options(removeThisLabels = true, removeThis = true)
}
}
@@ -59,6 +61,30 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
val RETAIN_COMPANION = ShortenReferences { Options(removeExplicitCompanion = false) }
fun canBePossibleToDropReceiver(element: KtDotQualifiedExpression, bindingContext: BindingContext): Boolean {
val receiver = element.receiverExpression
val nameRef = when (receiver) {
is KtThisExpression -> return true
is KtNameReferenceExpression -> receiver
is KtDotQualifiedExpression -> receiver.selectorExpression as? KtNameReferenceExpression ?: return false
else -> return false
}
val targetDescriptor = bindingContext[BindingContext.REFERENCE_TARGET, nameRef]
when (targetDescriptor) {
is ClassDescriptor -> {
if (targetDescriptor.kind != ClassKind.OBJECT) return true
// for object receiver we should additionally check that it's dispatch receiver (that is the member is inside the object) or not a receiver at all
val resolvedCall = element.getResolvedCall(bindingContext) ?: return false
val receiverKind = resolvedCall.explicitReceiverKind
return receiverKind == ExplicitReceiverKind.DISPATCH_RECEIVER || receiverKind == ExplicitReceiverKind.NO_EXPLICIT_RECEIVER
}
is PackageViewDescriptor -> return true
else -> return false
}
}
private fun DeclarationDescriptor.asString() = DescriptorRenderer.FQ_NAMES_IN_TYPES.render(this)
private fun KtReferenceExpression.targets(context: BindingContext) = getImportableTargets(context)
@@ -85,7 +111,7 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
rangeMarker.isGreedyToLeft = true
rangeMarker.isGreedyToRight = true
try {
process(listOf(file), { element ->
process(listOf(file)) { element ->
if (rangeMarker.isValid) {
val range = TextRange(rangeMarker.startOffset, rangeMarker.endOffset)
@@ -111,7 +137,7 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
} else {
FilterResult.SKIP
}
})
}
} finally {
rangeMarker.dispose()
}
@@ -172,7 +198,7 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
}
// step 2: analyze collected elements with resolve and decide which can be shortened now and which need descriptors to be imported before shortening
val allElementsToAnalyze = visitors.flatMap { it.getElementsToAnalyze().map { it.element } }
val allElementsToAnalyze = visitors.flatMap { visitor -> visitor.getElementsToAnalyze().map { it.element } }
val bindingContext = file.getResolutionFacade().analyze(allElementsToAnalyze, BodyResolveMode.PARTIAL_WITH_CFA)
processors.forEach { it.analyzeCollectedElements(bindingContext) }
@@ -363,7 +389,7 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
val referenceExpression = element.referenceExpression ?: return AnalyzeQualifiedElementResult.Skip
val target = referenceExpression.targets(bindingContext).singleOrNull()
?: return AnalyzeQualifiedElementResult.Skip
?: return AnalyzeQualifiedElementResult.Skip
val scope = element.getResolutionScope(bindingContext, resolutionFacade)
val name = target.name
@@ -449,7 +475,8 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
if (PsiTreeUtil.getParentOfType(
element,
KtImportDirective::class.java, KtPackageDirective::class.java
) != null) return AnalyzeQualifiedElementResult.Skip
) != null
) return AnalyzeQualifiedElementResult.Skip
val selector = element.selectorExpression ?: return AnalyzeQualifiedElementResult.Skip
val callee = selector.getCalleeExpressionIfAny() as? KtReferenceExpression ?: return AnalyzeQualifiedElementResult.Skip
@@ -536,30 +563,6 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
}
}
private fun canBePossibleToDropReceiver(element: KtDotQualifiedExpression, bindingContext: BindingContext): Boolean {
val receiver = element.receiverExpression
val nameRef = when (receiver) {
is KtThisExpression -> return true
is KtNameReferenceExpression -> receiver
is KtDotQualifiedExpression -> receiver.selectorExpression as? KtNameReferenceExpression ?: return false
else -> return false
}
val targetDescriptor = bindingContext[BindingContext.REFERENCE_TARGET, nameRef]
when (targetDescriptor) {
is ClassDescriptor -> {
if (targetDescriptor.kind != ClassKind.OBJECT) return true
// for object receiver we should additionally check that it's dispatch receiver (that is the member is inside the object) or not a receiver at all
val resolvedCall = element.getResolvedCall(bindingContext) ?: return false
val receiverKind = resolvedCall.explicitReceiverKind
return receiverKind == ExplicitReceiverKind.DISPATCH_RECEIVER || receiverKind == ExplicitReceiverKind.NO_EXPLICIT_RECEIVER
}
is PackageViewDescriptor -> return true
else -> return false
}
}
private fun copyShortenAndAnalyze(
element: KtDotQualifiedExpression,
bindingContext: BindingContext
@@ -673,7 +676,8 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
if (PsiTreeUtil.getParentOfType(
element,
KtImportDirective::class.java, KtPackageDirective::class.java
) != null) return AnalyzeQualifiedElementResult.Skip
) != null
) return AnalyzeQualifiedElementResult.Skip
val receiverTarget = receiver.singleTarget(bindingContext) as? ClassDescriptor ?: return AnalyzeQualifiedElementResult.Skip
@@ -683,7 +687,7 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
if (receiverTarget.companionObjectDescriptor != selectorTarget) return AnalyzeQualifiedElementResult.Skip
val selectorsSelector = (parent as? KtDotQualifiedExpression)?.selectorExpression
?: return AnalyzeQualifiedElementResult.ShortenNow
?: return AnalyzeQualifiedElementResult.ShortenNow
val selectorsSelectorTarget = selectorsSelector.singleTarget(bindingContext) ?: return AnalyzeQualifiedElementResult.Skip
if (selectorsSelectorTarget is ClassDescriptor) return AnalyzeQualifiedElementResult.Skip
@@ -693,7 +697,8 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
if (source != null && isEnumCompanionPropertyWithEntryConflict(
source,
source.name ?: ""
)) return AnalyzeQualifiedElementResult.Skip
)
) return AnalyzeQualifiedElementResult.Skip
}
return AnalyzeQualifiedElementResult.ShortenNow

View File

@@ -10,23 +10,22 @@ import com.intellij.openapi.vfs.VirtualFile
import org.jetbrains.jps.model.java.JavaResourceRootType
import org.jetbrains.jps.model.java.JavaSourceRootType
import org.jetbrains.jps.model.module.JpsModuleSourceRootType
import org.jetbrains.kotlin.config.KotlinResourceRootType
import org.jetbrains.kotlin.config.KotlinSourceRootType
import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.idea.caches.project.SourceType
import org.jetbrains.kotlin.idea.util.isInSourceContentWithoutInjected
private val testRootTypes: Set<JpsModuleSourceRootType<*>> = setOf(
JavaSourceRootType.TEST_SOURCE,
JavaResourceRootType.TEST_RESOURCE,
KotlinSourceRootType.TestSource,
KotlinResourceRootType.TestResource
TestSourceKotlinRootType,
TestResourceKotlinRootType
)
private val sourceRootTypes = setOf<JpsModuleSourceRootType<*>>(
JavaSourceRootType.SOURCE,
JavaResourceRootType.RESOURCE,
KotlinSourceRootType.Source,
KotlinResourceRootType.Resource
SourceKotlinRootType,
ResourceKotlinRootType
)
fun JpsModuleSourceRootType<*>.getSourceType(): SourceType? = when(this) {

View File

@@ -19,7 +19,8 @@ import com.intellij.util.Query
import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes
import org.jetbrains.jps.model.java.JavaSourceRootProperties
import org.jetbrains.jps.model.module.JpsModuleSourceRootType
import org.jetbrains.kotlin.config.KotlinSourceRootType
import org.jetbrains.kotlin.config.SourceKotlinRootType
import org.jetbrains.kotlin.config.TestSourceKotlinRootType
import org.jetbrains.kotlin.idea.caches.PerModulePackageCacheService
import org.jetbrains.kotlin.idea.roots.invalidateProjectRoots
import org.jetbrains.kotlin.idea.util.rootManager
@@ -79,7 +80,7 @@ private fun findLongestExistingPackage(module: Module, packageName: String): Psi
}
private val kotlinSourceRootTypes: Set<JpsModuleSourceRootType<JavaSourceRootProperties>> =
setOf(KotlinSourceRootType.Source, KotlinSourceRootType.TestSource) + JavaModuleSourceRootTypes.SOURCES
setOf(SourceKotlinRootType, TestSourceKotlinRootType) + JavaModuleSourceRootTypes.SOURCES
private fun Module.getNonGeneratedKotlinSourceRoots(): List<VirtualFile> {
val result = mutableListOf<VirtualFile>()

View File

@@ -230,6 +230,10 @@ fun KtClass.getOrCreateCompanionObject(): KtObjectDeclaration {
}
fun KtDeclaration.toDescriptor(): DeclarationDescriptor? {
if (this is KtScriptInitializer) {
return null
}
val bindingContext = analyze()
// TODO: temporary code
if (this is KtPrimaryConstructor) {

View File

@@ -103,22 +103,28 @@ class KotlinScriptingSettings : PersistentStateComponent<Element> {
KotlinScriptDefinitionKey(this.name, this::class.qualifiedName ?: "unknown")
private fun Element.addScriptDefinitionContentElement(definition: KotlinScriptDefinitionKey, settings: KotlinScriptDefinitionValue) {
Element(SCRIPT_DEFINITION_TAG).apply {
addElement(SCRIPT_DEFINITION_TAG).apply {
attribute(KotlinScriptDefinitionKey::className.name, definition.className)
attribute(KotlinScriptDefinitionKey::definitionName.name, definition.definitionName)
Element(KotlinScriptDefinitionValue::order.name).apply {
addElement(KotlinScriptDefinitionValue::order.name).apply {
text = settings.order.toString()
}
if (!settings.isEnabled) {
Element(KotlinScriptDefinitionValue::isEnabled.name).apply {
addElement(KotlinScriptDefinitionValue::isEnabled.name).apply {
text = settings.isEnabled.toString()
}
}
}
}
private fun Element.addElement(name: String): Element {
val element = Element(name)
addContent(element)
return element
}
private fun Element.toValue(): KotlinScriptDefinitionValue {
val order = getChildText(KotlinScriptDefinitionValue::order.name)?.toInt() ?: Integer.MAX_VALUE
val isEnabled = getChildText(KotlinScriptDefinitionValue::isEnabled.name)?.toBoolean() ?: true

View File

@@ -29,10 +29,7 @@ import com.intellij.openapi.util.Key
import com.intellij.openapi.util.io.FileUtil
import org.gradle.api.artifacts.Dependency
import org.gradle.tooling.model.idea.IdeaModule
import org.jetbrains.kotlin.gradle.CompilerArgumentsBySourceSet
import org.jetbrains.kotlin.gradle.KotlinGradleModel
import org.jetbrains.kotlin.gradle.KotlinGradleModelBuilder
import org.jetbrains.kotlin.gradle.KotlinMPPGradleModel
import org.jetbrains.kotlin.gradle.*
import org.jetbrains.kotlin.idea.inspections.gradle.getDependencyModules
import org.jetbrains.kotlin.idea.util.CopyableDataNodeUserDataProperty
import org.jetbrains.kotlin.idea.util.DataNodeUserDataProperty
@@ -181,7 +178,10 @@ class KotlinGradleProjectResolverExtension : AbstractProjectResolverExtension()
}
}
val dependencies = if (useModulePerSourceSet()) moduleNode.getDependencies(ideProject) else getDependencyModules(ideModule, gradleModule.project)
val dependencies = if (useModulePerSourceSet()) moduleNode.getDependencies(ideProject) else getDependencyModules(
ideModule,
gradleModule.project
)
// queue only those dependencies that haven't been discovered earlier
dependencies.filterTo(toProcess, discovered::add)
}
@@ -200,8 +200,8 @@ class KotlinGradleProjectResolverExtension : AbstractProjectResolverExtension()
if (mppModel != null) {
mppModel.targets.forEach { target ->
KotlinStatisticsTrigger.trigger(
KotlinEventTrigger.KotlinGradleTargetTrigger,
"MPP.${target.platform.id + (target.presetName?.let { ".$it"} ?: "")}"
KotlinEventTrigger.KotlinGradleTargetTrigger,
"MPP.${target.platform.id + (target.presetName?.let { ".$it" } ?: "")}"
)
}
return super.populateModuleDependencies(gradleModule, ideModule, ideProject)
@@ -219,13 +219,13 @@ class KotlinGradleProjectResolverExtension : AbstractProjectResolverExtension()
ideModule.isResolved = true
ideModule.hasKotlinPlugin = gradleModel.hasKotlinPlugin
ideModule.compilerArgumentsBySourceSet = gradleModel.compilerArgumentsBySourceSet
ideModule.compilerArgumentsBySourceSet = gradleModel.compilerArgumentsBySourceSet.deepCopy()
ideModule.coroutines = gradleModel.coroutines
ideModule.platformPluginId = gradleModel.platformPluginId
KotlinStatisticsTrigger.trigger(
KotlinEventTrigger.KotlinGradleTargetTrigger,
gradleModel.kotlinTarget ?: "unknown"
KotlinEventTrigger.KotlinGradleTargetTrigger,
gradleModel.kotlinTarget ?: "unknown"
)
addImplementedModuleNames(gradleModule, ideModule, ideProject, gradleModel)

View File

@@ -232,7 +232,7 @@ class KotlinGradleWebMultiplatformModuleBuilder : KotlinGradleAbstractMultiplatf
override fun buildMultiPlatformPart(): String {
return """
def ktor_version = '1.0.1'
def ktor_version = '1.1.3'
def logback_version = '1.2.3'
kotlin {

View File

@@ -613,7 +613,7 @@ open class KotlinMPPGradleProjectResolver : AbstractProjectResolverExtension() {
resolverCtx: ProjectResolverContext
): KotlinSourceSetInfo? {
if (sourceSet.platform.isNotSupported()) return null
return KotlinSourceSetInfo(sourceSet).also { info ->
return KotlinSourceSetInfo(KotlinSourceSetImpl(sourceSet)).also { info ->
val languageSettings = sourceSet.languageSettings
info.moduleId = getKotlinModuleId(gradleModule, sourceSet, resolverCtx)
info.gradleModuleId = getModuleId(resolverCtx, gradleModule)
@@ -643,16 +643,18 @@ open class KotlinMPPGradleProjectResolver : AbstractProjectResolverExtension() {
resolverCtx: ProjectResolverContext
): KotlinSourceSetInfo? {
if (compilation.platform.isNotSupported()) return null
return KotlinSourceSetInfo(compilation).also { sourceSetInfo ->
return KotlinSourceSetInfo(KotlinCompilationImpl(compilation)).also { sourceSetInfo ->
sourceSetInfo.moduleId = getKotlinModuleId(gradleModule, compilation, resolverCtx)
sourceSetInfo.gradleModuleId = getModuleId(resolverCtx, gradleModule)
sourceSetInfo.platform = compilation.platform
sourceSetInfo.isTestModule = compilation.isTestModule
sourceSetInfo.compilerArguments = createCompilerArguments(compilation.arguments.currentArguments, compilation.platform).also {
it.multiPlatform = true
}
sourceSetInfo.compilerArguments =
createCompilerArguments(compilation.arguments.currentArguments, compilation.platform).also {
it.multiPlatform = true
}
sourceSetInfo.dependencyClasspath = compilation.dependencyClasspath
sourceSetInfo.defaultCompilerArguments = createCompilerArguments(compilation.arguments.defaultArguments, compilation.platform)
sourceSetInfo.defaultCompilerArguments =
createCompilerArguments(compilation.arguments.defaultArguments, compilation.platform)
sourceSetInfo.addSourceSets(compilation.sourceSets, compilation.fullName(), gradleModule, resolverCtx)
}
}
@@ -679,7 +681,7 @@ open class KotlinMPPGradleProjectResolver : AbstractProjectResolverExtension() {
}
private fun KotlinModule.fullName(simpleName: String = name) = when (this) {
is KotlinCompilation -> compilationFullName(simpleName, target.disambiguationClassifier)
is KotlinCompilation -> compilationFullName(simpleName, disambiguationClassifier)
else -> simpleName
}
@@ -687,6 +689,9 @@ open class KotlinMPPGradleProjectResolver : AbstractProjectResolverExtension() {
getModuleId(resolverCtx, gradleModule) + ":" + kotlinModule.fullName()
private fun ExternalProject.notImportedCommonSourceSets() =
GradlePropertiesFileFacade.forExternalProject(this).readProperty(KOTLIN_NOT_IMPORTED_COMMON_SOURCE_SETS_SETTING)?.equals("true", ignoreCase = true) ?: false
GradlePropertiesFileFacade.forExternalProject(this).readProperty(KOTLIN_NOT_IMPORTED_COMMON_SOURCE_SETS_SETTING)?.equals(
"true",
ignoreCase = true
) ?: false
}
}

View File

@@ -7,9 +7,23 @@ package org.jetbrains.kotlin.gradle
import org.jetbrains.kotlin.idea.configuration.KotlinGradleSharedMultiplatformModuleBuilder
import org.jetbrains.kotlin.idea.configuration.KotlinGradleWebMultiplatformModuleBuilder
import org.jetbrains.kotlin.idea.test.KotlinSdkCreationChecker
import org.junit.Test
class GradleMultiplatformWizardTest : AbstractGradleMultiplatformWizardTest() {
lateinit var sdkCreationChecker: KotlinSdkCreationChecker
override fun setUp() {
super.setUp()
sdkCreationChecker = KotlinSdkCreationChecker()
}
override fun tearDown() {
sdkCreationChecker.removeNewKotlinSdk()
super.tearDown()
}
@Test
fun testWeb() {
testImportFromBuilder(KotlinGradleWebMultiplatformModuleBuilder(), "SampleTests", "SampleTestsJVM")

View File

@@ -8,9 +8,7 @@ package org.jetbrains.kotlin.gradle
import com.intellij.openapi.roots.*
import org.jetbrains.jps.model.java.JavaResourceRootType
import org.jetbrains.jps.model.java.JavaSourceRootType
import org.jetbrains.kotlin.config.JvmTarget
import org.jetbrains.kotlin.config.KotlinResourceRootType
import org.jetbrains.kotlin.config.KotlinSourceRootType
import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.idea.codeInsight.gradle.ExternalSystemImportingTestCase
import org.jetbrains.kotlin.idea.codeInsight.gradle.MultiplePluginVersionGradleImportingTestCase
import org.jetbrains.kotlin.platform.impl.CommonIdePlatformKind
@@ -65,8 +63,8 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
platform(CommonIdePlatformKind.Platform)
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:${kotlinVersion()}", DependencyScope.COMPILE)
moduleDependency("lib_commonMain", DependencyScope.COMPILE)
sourceFolder("app/src/commonMain/kotlin", KotlinSourceRootType.Source)
sourceFolder("app/src/commonMain/resources", KotlinResourceRootType.Resource)
sourceFolder("app/src/commonMain/kotlin", SourceKotlinRootType)
sourceFolder("app/src/commonMain/resources", ResourceKotlinRootType)
inheritProjectOutput()
}
module("app_commonTest") {
@@ -74,8 +72,8 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:${kotlinVersion()}", DependencyScope.TEST)
moduleDependency("lib_commonMain", DependencyScope.TEST)
moduleDependency("app_commonMain", DependencyScope.TEST)
sourceFolder("app/src/commonTest/kotlin", KotlinSourceRootType.TestSource)
sourceFolder("app/src/commonTest/resources", KotlinResourceRootType.TestResource)
sourceFolder("app/src/commonTest/kotlin", TestSourceKotlinRootType)
sourceFolder("app/src/commonTest/resources", TestResourceKotlinRootType)
inheritProjectOutput()
}
module("app_jsMain") {
@@ -85,8 +83,8 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
moduleDependency("lib_jsMain", DependencyScope.COMPILE)
moduleDependency("lib_commonMain", DependencyScope.COMPILE)
moduleDependency("app_commonMain", DependencyScope.COMPILE)
sourceFolder("app/src/jsMain/kotlin", KotlinSourceRootType.Source)
sourceFolder("app/src/jsMain/resources", KotlinResourceRootType.Resource)
sourceFolder("app/src/jsMain/kotlin", SourceKotlinRootType)
sourceFolder("app/src/jsMain/resources", ResourceKotlinRootType)
outputPath("app/build/classes/kotlin/js/main", true)
}
module("app_jsTest") {
@@ -98,8 +96,8 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
moduleDependency("app_commonMain", DependencyScope.TEST)
moduleDependency("app_commonTest", DependencyScope.TEST)
moduleDependency("app_jsMain", DependencyScope.TEST)
sourceFolder("app/src/jsTest/kotlin", KotlinSourceRootType.TestSource)
sourceFolder("app/src/jsTest/resources", KotlinResourceRootType.TestResource)
sourceFolder("app/src/jsTest/kotlin", TestSourceKotlinRootType)
sourceFolder("app/src/jsTest/resources", TestResourceKotlinRootType)
outputPath("app/build/classes/kotlin/js/test", false)
}
module("app_jvmMain") {
@@ -157,16 +155,16 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
module("lib_commonMain") {
platform(CommonIdePlatformKind.Platform)
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:${kotlinVersion()}", DependencyScope.COMPILE)
sourceFolder("lib/src/commonMain/kotlin", KotlinSourceRootType.Source)
sourceFolder("lib/src/commonMain/resources", KotlinResourceRootType.Resource)
sourceFolder("lib/src/commonMain/kotlin", SourceKotlinRootType)
sourceFolder("lib/src/commonMain/resources", ResourceKotlinRootType)
inheritProjectOutput()
}
module("lib_commonTest") {
platform(CommonIdePlatformKind.Platform)
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:${kotlinVersion()}", DependencyScope.TEST)
moduleDependency("lib_commonMain", DependencyScope.TEST)
sourceFolder("lib/src/commonTest/kotlin", KotlinSourceRootType.TestSource)
sourceFolder("lib/src/commonTest/resources", KotlinResourceRootType.TestResource)
sourceFolder("lib/src/commonTest/kotlin", TestSourceKotlinRootType)
sourceFolder("lib/src/commonTest/resources", TestResourceKotlinRootType)
inheritProjectOutput()
}
module("lib_jsMain") {
@@ -174,8 +172,8 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-stdlib-js:${kotlinVersion()}", DependencyScope.COMPILE)
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:${kotlinVersion()}", DependencyScope.COMPILE)
moduleDependency("lib_commonMain", DependencyScope.COMPILE)
sourceFolder("lib/src/jsMain/kotlin", KotlinSourceRootType.Source)
sourceFolder("lib/src/jsMain/resources", KotlinResourceRootType.Resource)
sourceFolder("lib/src/jsMain/kotlin", SourceKotlinRootType)
sourceFolder("lib/src/jsMain/resources", ResourceKotlinRootType)
outputPath("lib/build/classes/kotlin/js/main", true)
}
module("lib_jsTest") {
@@ -185,8 +183,8 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
moduleDependency("lib_commonMain", DependencyScope.TEST)
moduleDependency("lib_commonTest", DependencyScope.TEST)
moduleDependency("lib_jsMain", DependencyScope.TEST)
sourceFolder("lib/src/jsTest/kotlin", KotlinSourceRootType.TestSource)
sourceFolder("lib/src/jsTest/resources", KotlinResourceRootType.TestResource)
sourceFolder("lib/src/jsTest/kotlin", TestSourceKotlinRootType)
sourceFolder("lib/src/jsTest/resources", TestResourceKotlinRootType)
outputPath("lib/build/classes/kotlin/js/test", false)
}
module("lib_jvmMain") {
@@ -305,14 +303,14 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
module("shared")
module("shared_commonMain") {
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:${kotlinVersion()}", DependencyScope.COMPILE)
sourceFolder("shared/src/commonMain/kotlin", KotlinSourceRootType.Source)
sourceFolder("shared/src/commonMain/resources", KotlinResourceRootType.Resource)
sourceFolder("shared/src/commonMain/kotlin", SourceKotlinRootType)
sourceFolder("shared/src/commonMain/resources", ResourceKotlinRootType)
}
module("shared_commonTest") {
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:${kotlinVersion()}", DependencyScope.TEST)
moduleDependency("shared_commonMain", DependencyScope.TEST)
sourceFolder("shared/src/commonTest/kotlin", KotlinSourceRootType.TestSource)
sourceFolder("shared/src/commonTest/resources", KotlinResourceRootType.TestResource)
sourceFolder("shared/src/commonTest/kotlin", TestSourceKotlinRootType)
sourceFolder("shared/src/commonTest/resources", TestResourceKotlinRootType)
}
module("shared_androidMain") {
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:${kotlinVersion()}", DependencyScope.COMPILE)
@@ -340,8 +338,8 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
libraryDependency("Kotlin/Native $nativeVersion - stdlib", DependencyScope.PROVIDED)
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:${kotlinVersion()}", DependencyScope.COMPILE)
moduleDependency("shared_commonMain", DependencyScope.COMPILE)
sourceFolder("shared/src/iOSMain/kotlin", KotlinSourceRootType.Source)
sourceFolder("shared/src/iOSMain/resources", KotlinResourceRootType.Resource)
sourceFolder("shared/src/iOSMain/kotlin", SourceKotlinRootType)
sourceFolder("shared/src/iOSMain/resources", ResourceKotlinRootType)
}
module("shared_iOSTest") {
libraryDependency("Kotlin/Native $nativeVersion - stdlib", DependencyScope.PROVIDED)
@@ -349,8 +347,8 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
moduleDependency("shared_iOSMain", DependencyScope.TEST)
moduleDependency("shared_commonMain", DependencyScope.TEST)
moduleDependency("shared_commonTest", DependencyScope.TEST)
sourceFolder("shared/src/iOSTest/kotlin", KotlinSourceRootType.TestSource)
sourceFolder("shared/src/iOSTest/resources", KotlinResourceRootType.TestResource)
sourceFolder("shared/src/iOSTest/kotlin", TestSourceKotlinRootType)
sourceFolder("shared/src/iOSTest/resources", TestResourceKotlinRootType)
}
}
}

View File

@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.idea.codeInsight.gradle;
import com.intellij.openapi.application.AccessToken;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.externalSystem.importing.ImportSpecBuilder;
import com.intellij.openapi.externalSystem.model.DataNode;
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
@@ -49,9 +50,13 @@ import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.Proxy;
import java.util.*;
import org.apache.log4j.Level;
// part of com.intellij.openapi.externalSystem.test.ExternalSystemImportingTestCase
public abstract class ExternalSystemImportingTestCase extends ExternalSystemTestCase {
private Logger logger;
@Override
protected Module getModule(String name) {
AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock();
@@ -74,16 +79,26 @@ public abstract class ExternalSystemImportingTestCase extends ExternalSystemTest
doImportProject();
}
public void ensureIsNotGradleProxyObject(Object o, Map<Object, Object> referencingObjects) {
if (o instanceof Proxy) {
StringBuilder errMessage = new StringBuilder();
errMessage.append(String.format("Object [%s] seems to be a referenced gradle tooling api object. (it may lead to memory leaks during import) Referencing path: ", o));
while (o != null) {
errMessage.append(String.format("[%s] type: %s <-\r\n", o, o.getClass().toString()));
o = referencingObjects.get(o);
}
//TODO fail(errMessage.toString());
public boolean ensureIsNotGradleProxyObject(
Object o,
Map<Object, Object> referencingObjects,
Map<Object, String> referencingFieldNames
) {
if (!(o instanceof Proxy)) {
return true;
}
StringBuilder errMessage = new StringBuilder();
errMessage.append(String.format(
"Object [%s] seems to be a referenced gradle tooling api object. (it may lead to memory leaks during import) Referencing path: ",
o));
while (o != null) {
errMessage.append(String.format("[%s].[%s] type: %s <-\r\n", o, referencingFieldNames.get(o), o.getClass().toString()));
o = referencingObjects.get(o);
}
System.err.println(errMessage.toString());
//TODO uncomment after fixing IDEA-207782
//fail(errMessage.toString());
return false;
}
private boolean shouldBeProcessed(Object toProcess, Set<Object> processed) {
@@ -91,56 +106,83 @@ public abstract class ExternalSystemImportingTestCase extends ExternalSystemTest
}
public void inspectForGradleMemoryLeaks(DataNode<ProjectData> externalProject) {
// Static logger initialisation should not be used because logger factory may be changed on test.setUp
if (logger == null) {
logger = Logger.getInstance(this.getClass().getName());
logger.setLevel(Level.INFO);//not required
}
long start = System.currentTimeMillis();
Set<Object> processed = new HashSet<>();
Queue<Object> toProcess = new LinkedList<>();
Map<Object, Object> referencingObjects = new HashMap<>();
Map<Object, String> referencingFieldNames = new HashMap<>();
Set<Field> modifiedFields = new HashSet<>();
toProcess.add(externalProject);
try {
while (! toProcess.isEmpty()) {
while (!toProcess.isEmpty()) {
Object nextObject = toProcess.poll();
processed.add(nextObject);
ensureIsNotGradleProxyObject(nextObject, referencingObjects);
if (!ensureIsNotGradleProxyObject(nextObject, referencingObjects, referencingFieldNames)) {
break;
}
for (Field field : nextObject.getClass().getDeclaredFields()) {
try {
final Object fieldValue;
boolean isAccessible = field.isAccessible();
try {
if (!field.isAccessible()) {
field.setAccessible(true);
fieldValue = field.get(nextObject);
} finally {
field.setAccessible(isAccessible);
modifiedFields.add(field);
}
if (fieldValue == null) {
final Object fieldValue = field.get(nextObject);
if (fieldValue == null || fieldValue.getClass().isPrimitive()) {
continue;
}
if (fieldValue instanceof Collection) {
for (Object o : (Collection)fieldValue) {
saveToProcessIfRequired(processed, toProcess, referencingObjects, nextObject, o);
for (Object o : (Collection) fieldValue) {
saveToProcessIfRequired(processed, toProcess, referencingObjects, referencingFieldNames, nextObject, o,
field.getName());
}
} else if (fieldValue.getClass().isArray()) {
}
else if (fieldValue.getClass().isArray()) {
for (int i = 0; i < Array.getLength(fieldValue); i++) {
Object o = Array.get(fieldValue, i);
saveToProcessIfRequired(processed, toProcess, referencingObjects, nextObject, o);
saveToProcessIfRequired(processed, toProcess, referencingObjects, referencingFieldNames, nextObject, o,
field.getName());
}
} else {
saveToProcessIfRequired(processed, toProcess, referencingObjects, nextObject, fieldValue);
}
} catch (IllegalAccessException e) {
else {
saveToProcessIfRequired(processed, toProcess, referencingObjects, referencingFieldNames, nextObject, fieldValue,
field.getName());
}
}
catch (IllegalAccessException e) {
fail(e.getMessage());
}
}
}
} finally {
System.out.println("Processed size = " + processed.size() + " Duration: " + (System.currentTimeMillis() - start));
}
finally {
for (Field f : modifiedFields) {
f.setAccessible(false);
}
logger.info(
String.format("Memory leak tracker has finished. Number of processed objects = %s. Duration = %s ms.", processed.size(),
(System.currentTimeMillis() - start)));
}
}
private void saveToProcessIfRequired(Set<Object> processed, Queue<Object> toProcess, Map<Object, Object> referrers, Object referringObject, Object o) {
private void saveToProcessIfRequired(
Set<Object> processed,
Queue<Object> toProcess,
Map<Object, Object> referrers,
Map<Object, String> referencingFieldNames,
Object referringObject,
Object o,
String fieldName
) {
if (shouldBeProcessed(o, processed)) {
toProcess.add(o);
referencingFieldNames.put(o, fieldName);
referrers.put(o, referringObject);
}
}

View File

@@ -86,7 +86,7 @@ class GradleFacetImportTest : GradleImportingTestCase() {
super.tearDown()
}
private fun assertKotlinSdk(vararg moduleNames: String) {
private fun assertSameKotlinSdks(vararg moduleNames: String) {
val sdks = moduleNames.map { getModule(it).sdk!! }
val refSdk = sdks.firstOrNull() ?: return
Assert.assertTrue(refSdk.sdkType is KotlinSdkType)
@@ -629,19 +629,19 @@ compileTestKotlin {
assertEquals(JSLibraryKind, (stdlib as LibraryEx).kind)
assertTrue(stdlib.getFiles(OrderRootType.CLASSES).isNotEmpty())
assertKotlinSdk("project_main", "project_test")
assertSameKotlinSdks("project_main", "project_test")
Assert.assertEquals(
listOf("file:///src/main/java" to KotlinSourceRootType.Source,
"file:///src/main/kotlin" to KotlinSourceRootType.Source,
"file:///src/main/resources" to KotlinResourceRootType.Resource),
listOf("file:///src/main/java" to SourceKotlinRootType,
"file:///src/main/kotlin" to SourceKotlinRootType,
"file:///src/main/resources" to ResourceKotlinRootType),
getSourceRootInfos("project_main")
)
Assert.assertEquals(
listOf("file:///src/test/java" to KotlinSourceRootType.TestSource,
"file:///src/test/kotlin" to KotlinSourceRootType.TestSource,
"file:///src/test/resources" to KotlinResourceRootType.TestResource),
getSourceRootInfos("project_test")
listOf("file:///src/test/java" to TestSourceKotlinRootType,
"file:///src/test/kotlin" to TestSourceKotlinRootType,
"file:///src/test/resources" to TestResourceKotlinRootType),
getSourceRootInfos("project_test")
)
assertAllModulesConfigured()
@@ -696,16 +696,16 @@ compileTestKotlin {
assertAllModulesConfigured()
Assert.assertEquals(
listOf("file:///src/main/java" to KotlinSourceRootType.Source,
"file:///src/main/kotlin" to KotlinSourceRootType.Source,
"file:///src/main/resources" to KotlinResourceRootType.Resource),
listOf("file:///src/main/java" to SourceKotlinRootType,
"file:///src/main/kotlin" to SourceKotlinRootType,
"file:///src/main/resources" to ResourceKotlinRootType),
getSourceRootInfos("project_main")
)
Assert.assertEquals(
listOf("file:///src/test/java" to KotlinSourceRootType.TestSource,
"file:///src/test/kotlin" to KotlinSourceRootType.TestSource,
"file:///src/test/resources" to KotlinResourceRootType.TestResource),
getSourceRootInfos("project_test")
listOf("file:///src/test/java" to TestSourceKotlinRootType,
"file:///src/test/kotlin" to TestSourceKotlinRootType,
"file:///src/test/resources" to TestResourceKotlinRootType),
getSourceRootInfos("project_test")
)
}
@@ -792,16 +792,16 @@ compileTestKotlin {
assertAllModulesConfigured()
Assert.assertEquals(
listOf("file:///src/main/java" to KotlinSourceRootType.Source,
"file:///src/main/kotlin" to KotlinSourceRootType.Source,
"file:///src/main/resources" to KotlinResourceRootType.Resource),
listOf("file:///src/main/java" to SourceKotlinRootType,
"file:///src/main/kotlin" to SourceKotlinRootType,
"file:///src/main/resources" to ResourceKotlinRootType),
getSourceRootInfos("project_main")
)
Assert.assertEquals(
listOf("file:///src/test/java" to KotlinSourceRootType.TestSource,
"file:///src/test/kotlin" to KotlinSourceRootType.TestSource,
"file:///src/test/resources" to KotlinResourceRootType.TestResource),
getSourceRootInfos("project_test")
listOf("file:///src/test/java" to TestSourceKotlinRootType,
"file:///src/test/kotlin" to TestSourceKotlinRootType,
"file:///src/test/resources" to TestResourceKotlinRootType),
getSourceRootInfos("project_test")
)
}
@@ -927,16 +927,16 @@ compileTestKotlin {
assertEquals(CommonLibraryKind, libraries.single { it.name?.contains("kotlin-stdlib-common") == true }.kind)
Assert.assertEquals(
listOf("file:///src/main/java" to KotlinSourceRootType.Source,
"file:///src/main/kotlin" to KotlinSourceRootType.Source,
"file:///src/main/resources" to KotlinResourceRootType.Resource),
listOf("file:///src/main/java" to SourceKotlinRootType,
"file:///src/main/kotlin" to SourceKotlinRootType,
"file:///src/main/resources" to ResourceKotlinRootType),
getSourceRootInfos("project_main")
)
Assert.assertEquals(
listOf("file:///src/test/java" to KotlinSourceRootType.TestSource,
"file:///src/test/kotlin" to KotlinSourceRootType.TestSource,
"file:///src/test/resources" to KotlinResourceRootType.TestResource),
getSourceRootInfos("project_test")
listOf("file:///src/test/java" to TestSourceKotlinRootType,
"file:///src/test/kotlin" to TestSourceKotlinRootType,
"file:///src/test/resources" to TestResourceKotlinRootType),
getSourceRootInfos("project_test")
)
}
@@ -985,16 +985,16 @@ compileTestKotlin {
assertEquals(CommonLibraryKind, (stdlib as LibraryEx).kind)
Assert.assertEquals(
listOf("file:///src/main/java" to KotlinSourceRootType.Source,
"file:///src/main/kotlin" to KotlinSourceRootType.Source,
"file:///src/main/resources" to KotlinResourceRootType.Resource),
listOf("file:///src/main/java" to SourceKotlinRootType,
"file:///src/main/kotlin" to SourceKotlinRootType,
"file:///src/main/resources" to ResourceKotlinRootType),
getSourceRootInfos("project_main")
)
Assert.assertEquals(
listOf("file:///src/test/java" to KotlinSourceRootType.TestSource,
"file:///src/test/kotlin" to KotlinSourceRootType.TestSource,
"file:///src/test/resources" to KotlinResourceRootType.TestResource),
getSourceRootInfos("project_test")
listOf("file:///src/test/java" to TestSourceKotlinRootType,
"file:///src/test/kotlin" to TestSourceKotlinRootType,
"file:///src/test/resources" to TestResourceKotlinRootType),
getSourceRootInfos("project_test")
)
}
@@ -1042,13 +1042,13 @@ compileTestKotlin {
assertEquals(CommonLibraryKind, (stdlib as LibraryEx).kind)
Assert.assertEquals(
listOf("file:///src/main/java" to KotlinSourceRootType.Source,
"file:///src/main/kotlin" to KotlinSourceRootType.Source,
"file:///src/test/java" to KotlinSourceRootType.TestSource,
"file:///src/test/kotlin" to KotlinSourceRootType.TestSource,
"file:///src/main/resources" to KotlinResourceRootType.Resource,
"file:///src/test/resources" to KotlinResourceRootType.TestResource),
getSourceRootInfos("project")
listOf("file:///src/main/java" to SourceKotlinRootType,
"file:///src/main/kotlin" to SourceKotlinRootType,
"file:///src/test/java" to TestSourceKotlinRootType,
"file:///src/test/kotlin" to TestSourceKotlinRootType,
"file:///src/main/resources" to ResourceKotlinRootType,
"file:///src/test/resources" to TestResourceKotlinRootType),
getSourceRootInfos("project")
)
}
@@ -1129,16 +1129,16 @@ compileTestKotlin {
}
Assert.assertEquals(
listOf("file:///src/main/java" to KotlinSourceRootType.Source,
"file:///src/main/kotlin" to KotlinSourceRootType.Source,
"file:///src/main/resources" to KotlinResourceRootType.Resource),
listOf("file:///src/main/java" to SourceKotlinRootType,
"file:///src/main/kotlin" to SourceKotlinRootType,
"file:///src/main/resources" to ResourceKotlinRootType),
getSourceRootInfos("project_main")
)
Assert.assertEquals(
listOf("file:///src/test/java" to KotlinSourceRootType.TestSource,
"file:///src/test/kotlin" to KotlinSourceRootType.TestSource,
"file:///src/test/resources" to KotlinResourceRootType.TestResource),
getSourceRootInfos("project_test")
listOf("file:///src/test/java" to TestSourceKotlinRootType,
"file:///src/test/kotlin" to TestSourceKotlinRootType,
"file:///src/test/resources" to TestResourceKotlinRootType),
getSourceRootInfos("project_test")
)
}
@@ -1339,7 +1339,7 @@ compileTestKotlin {
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-eap-44")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.40")
}
}
@@ -2040,7 +2040,7 @@ compileTestKotlin {
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.0-rc-39")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.40")
}
}
@@ -2054,7 +2054,7 @@ compileTestKotlin {
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-common:1.2.0-rc-39"
compile "org.jetbrains.kotlin:kotlin-stdlib-common:1.2.40"
}
compileKotlinCommon{
@@ -2103,17 +2103,17 @@ compileTestKotlin {
val stdlib = rootManager.orderEntries.filterIsInstance<LibraryOrderEntry>().single().library
assertEquals(CommonLibraryKind, (stdlib as LibraryEx).kind)
assertKotlinSdk("project_main", "project_test")
assertSameKotlinSdks("project_main", "project_test")
Assert.assertEquals(
listOf("file:///src/main/kotlin" to KotlinSourceRootType.Source,
"file:///src/main/resources" to KotlinResourceRootType.Resource),
listOf("file:///src/main/kotlin" to SourceKotlinRootType,
"file:///src/main/resources" to ResourceKotlinRootType),
getSourceRootInfos("project_main")
)
Assert.assertEquals(
listOf("file:///src/test/kotlin" to KotlinSourceRootType.TestSource,
"file:///src/test/resources" to KotlinResourceRootType.TestResource),
getSourceRootInfos("project_test")
listOf("file:///src/test/kotlin" to TestSourceKotlinRootType,
"file:///src/test/resources" to TestResourceKotlinRootType),
getSourceRootInfos("project_test")
)
}

View File

@@ -86,7 +86,7 @@ class GradleFacetImportTest : GradleImportingTestCase() {
super.tearDown()
}
private fun assertKotlinSdk(vararg moduleNames: String) {
private fun assertSameKotlinSdks(vararg moduleNames: String) {
val sdks = moduleNames.map { getModule(it).sdk!! }
val refSdk = sdks.firstOrNull() ?: return
Assert.assertTrue(refSdk.sdkType is KotlinSdkType)
@@ -629,19 +629,19 @@ compileTestKotlin {
assertEquals(JSLibraryKind, (stdlib as LibraryEx).kind)
assertTrue(stdlib.getFiles(OrderRootType.CLASSES).isNotEmpty())
assertKotlinSdk("project_main", "project_test")
assertSameKotlinSdks("project_main", "project_test")
Assert.assertEquals(
listOf("file:///src/main/java" to KotlinSourceRootType.Source,
"file:///src/main/kotlin" to KotlinSourceRootType.Source,
"file:///src/main/resources" to KotlinResourceRootType.Resource),
listOf("file:///src/main/java" to SourceKotlinRootType,
"file:///src/main/kotlin" to SourceKotlinRootType,
"file:///src/main/resources" to ResourceKotlinRootType),
getSourceRootInfos("project_main")
)
Assert.assertEquals(
listOf("file:///src/test/java" to KotlinSourceRootType.TestSource,
"file:///src/test/kotlin" to KotlinSourceRootType.TestSource,
"file:///src/test/resources" to KotlinResourceRootType.TestResource),
getSourceRootInfos("project_test")
listOf("file:///src/test/java" to TestSourceKotlinRootType,
"file:///src/test/kotlin" to TestSourceKotlinRootType,
"file:///src/test/resources" to TestResourceKotlinRootType),
getSourceRootInfos("project_test")
)
assertAllModulesConfigured()
@@ -696,16 +696,16 @@ compileTestKotlin {
assertAllModulesConfigured()
Assert.assertEquals(
listOf("file:///src/main/java" to KotlinSourceRootType.Source,
"file:///src/main/kotlin" to KotlinSourceRootType.Source,
"file:///src/main/resources" to KotlinResourceRootType.Resource),
listOf("file:///src/main/java" to SourceKotlinRootType,
"file:///src/main/kotlin" to SourceKotlinRootType,
"file:///src/main/resources" to ResourceKotlinRootType),
getSourceRootInfos("project_main")
)
Assert.assertEquals(
listOf("file:///src/test/java" to KotlinSourceRootType.TestSource,
"file:///src/test/kotlin" to KotlinSourceRootType.TestSource,
"file:///src/test/resources" to KotlinResourceRootType.TestResource),
getSourceRootInfos("project_test")
listOf("file:///src/test/java" to TestSourceKotlinRootType,
"file:///src/test/kotlin" to TestSourceKotlinRootType,
"file:///src/test/resources" to TestResourceKotlinRootType),
getSourceRootInfos("project_test")
)
}
@@ -792,16 +792,16 @@ compileTestKotlin {
assertAllModulesConfigured()
Assert.assertEquals(
listOf("file:///src/main/java" to KotlinSourceRootType.Source,
"file:///src/main/kotlin" to KotlinSourceRootType.Source,
"file:///src/main/resources" to KotlinResourceRootType.Resource),
listOf("file:///src/main/java" to SourceKotlinRootType,
"file:///src/main/kotlin" to SourceKotlinRootType,
"file:///src/main/resources" to ResourceKotlinRootType),
getSourceRootInfos("project_main")
)
Assert.assertEquals(
listOf("file:///src/test/java" to KotlinSourceRootType.TestSource,
"file:///src/test/kotlin" to KotlinSourceRootType.TestSource,
"file:///src/test/resources" to KotlinResourceRootType.TestResource),
getSourceRootInfos("project_test")
listOf("file:///src/test/java" to TestSourceKotlinRootType,
"file:///src/test/kotlin" to TestSourceKotlinRootType,
"file:///src/test/resources" to TestResourceKotlinRootType),
getSourceRootInfos("project_test")
)
}
@@ -927,16 +927,16 @@ compileTestKotlin {
assertEquals(CommonLibraryKind, libraries.single { it.name?.contains("kotlin-stdlib-common") == true }.kind)
Assert.assertEquals(
listOf("file:///src/main/java" to KotlinSourceRootType.Source,
"file:///src/main/kotlin" to KotlinSourceRootType.Source,
"file:///src/main/resources" to KotlinResourceRootType.Resource),
listOf("file:///src/main/java" to SourceKotlinRootType,
"file:///src/main/kotlin" to SourceKotlinRootType,
"file:///src/main/resources" to ResourceKotlinRootType),
getSourceRootInfos("project_main")
)
Assert.assertEquals(
listOf("file:///src/test/java" to KotlinSourceRootType.TestSource,
"file:///src/test/kotlin" to KotlinSourceRootType.TestSource,
"file:///src/test/resources" to KotlinResourceRootType.TestResource),
getSourceRootInfos("project_test")
listOf("file:///src/test/java" to TestSourceKotlinRootType,
"file:///src/test/kotlin" to TestSourceKotlinRootType,
"file:///src/test/resources" to TestResourceKotlinRootType),
getSourceRootInfos("project_test")
)
}
@@ -987,16 +987,16 @@ compileTestKotlin {
assertEquals(CommonLibraryKind, (stdlib as LibraryEx).kind)
Assert.assertEquals(
listOf("file:///src/main/java" to KotlinSourceRootType.Source,
"file:///src/main/kotlin" to KotlinSourceRootType.Source,
"file:///src/main/resources" to KotlinResourceRootType.Resource),
listOf("file:///src/main/java" to SourceKotlinRootType,
"file:///src/main/kotlin" to SourceKotlinRootType,
"file:///src/main/resources" to ResourceKotlinRootType),
getSourceRootInfos("project_main")
)
Assert.assertEquals(
listOf("file:///src/test/java" to KotlinSourceRootType.TestSource,
"file:///src/test/kotlin" to KotlinSourceRootType.TestSource,
"file:///src/test/resources" to KotlinResourceRootType.TestResource),
getSourceRootInfos("project_test")
listOf("file:///src/test/java" to TestSourceKotlinRootType,
"file:///src/test/kotlin" to TestSourceKotlinRootType,
"file:///src/test/resources" to TestResourceKotlinRootType),
getSourceRootInfos("project_test")
)
}
@@ -1044,13 +1044,13 @@ compileTestKotlin {
assertEquals(CommonLibraryKind, (stdlib as LibraryEx).kind)
Assert.assertEquals(
listOf("file:///src/main/java" to KotlinSourceRootType.Source,
"file:///src/main/kotlin" to KotlinSourceRootType.Source,
"file:///src/test/java" to KotlinSourceRootType.TestSource,
"file:///src/test/kotlin" to KotlinSourceRootType.TestSource,
"file:///src/main/resources" to KotlinResourceRootType.Resource,
"file:///src/test/resources" to KotlinResourceRootType.TestResource),
getSourceRootInfos("project")
listOf("file:///src/main/java" to SourceKotlinRootType,
"file:///src/main/kotlin" to SourceKotlinRootType,
"file:///src/test/java" to TestSourceKotlinRootType,
"file:///src/test/kotlin" to TestSourceKotlinRootType,
"file:///src/main/resources" to ResourceKotlinRootType,
"file:///src/test/resources" to TestResourceKotlinRootType),
getSourceRootInfos("project")
)
}
@@ -1131,16 +1131,16 @@ compileTestKotlin {
}
Assert.assertEquals(
listOf("file:///src/main/java" to KotlinSourceRootType.Source,
"file:///src/main/kotlin" to KotlinSourceRootType.Source,
"file:///src/main/resources" to KotlinResourceRootType.Resource),
listOf("file:///src/main/java" to SourceKotlinRootType,
"file:///src/main/kotlin" to SourceKotlinRootType,
"file:///src/main/resources" to ResourceKotlinRootType),
getSourceRootInfos("project_main")
)
Assert.assertEquals(
listOf("file:///src/test/java" to KotlinSourceRootType.TestSource,
"file:///src/test/kotlin" to KotlinSourceRootType.TestSource,
"file:///src/test/resources" to KotlinResourceRootType.TestResource),
getSourceRootInfos("project_test")
listOf("file:///src/test/java" to TestSourceKotlinRootType,
"file:///src/test/kotlin" to TestSourceKotlinRootType,
"file:///src/test/resources" to TestResourceKotlinRootType),
getSourceRootInfos("project_test")
)
}
@@ -1341,7 +1341,7 @@ compileTestKotlin {
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-eap-44")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.40")
}
}
@@ -2048,7 +2048,7 @@ compileTestKotlin {
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.0-rc-39")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.40")
}
}
@@ -2062,7 +2062,7 @@ compileTestKotlin {
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-common:1.2.0-rc-39"
compile "org.jetbrains.kotlin:kotlin-stdlib-common:1.2.40"
}
compileKotlinCommon{
@@ -2111,17 +2111,17 @@ compileTestKotlin {
val stdlib = rootManager.orderEntries.filterIsInstance<LibraryOrderEntry>().single().library
assertEquals(CommonLibraryKind, (stdlib as LibraryEx).kind)
assertKotlinSdk("project_main", "project_test")
assertSameKotlinSdks("project_main", "project_test")
Assert.assertEquals(
listOf("file:///src/main/kotlin" to KotlinSourceRootType.Source,
"file:///src/main/resources" to KotlinResourceRootType.Resource),
listOf("file:///src/main/kotlin" to SourceKotlinRootType,
"file:///src/main/resources" to ResourceKotlinRootType),
getSourceRootInfos("project_main")
)
Assert.assertEquals(
listOf("file:///src/test/kotlin" to KotlinSourceRootType.TestSource,
"file:///src/test/resources" to KotlinResourceRootType.TestResource),
getSourceRootInfos("project_test")
listOf("file:///src/test/kotlin" to TestSourceKotlinRootType,
"file:///src/test/resources" to TestResourceKotlinRootType),
getSourceRootInfos("project_test")
)
}

View File

@@ -1149,7 +1149,7 @@ compileTestKotlin {
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-eap-44")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.40")
}
}

View File

@@ -13,8 +13,6 @@ import org.jetbrains.jps.model.module.JpsModuleSourceRootType
sealed class KotlinResourceRootType(val isTest: Boolean) : JpsElementTypeBase<JavaResourceRootProperties>(),
JpsModuleSourceRootType<JavaResourceRootProperties>, KotlinRootType {
object Resource : KotlinResourceRootType(false)
object TestResource : KotlinResourceRootType(true)
override fun createDefaultProperties() =
JpsJavaExtensionService.getInstance().createResourceRootProperties("", false)
@@ -24,4 +22,7 @@ sealed class KotlinResourceRootType(val isTest: Boolean) : JpsElementTypeBase<Ja
override fun isForTests() = isTest
override fun equals(other: Any?) = if (super.equals(other)) true else isSameRootType(this, other)
}
}
object ResourceKotlinRootType : KotlinResourceRootType(false)
object TestResourceKotlinRootType : KotlinResourceRootType(true)

View File

@@ -13,8 +13,6 @@ import org.jetbrains.jps.model.module.JpsModuleSourceRootType
sealed class KotlinResourceRootType(val isTest: Boolean) : JpsElementTypeBase<JavaResourceRootProperties>(),
JpsModuleSourceRootType<JavaResourceRootProperties>, KotlinRootType {
object Resource : KotlinResourceRootType(false)
object TestResource : KotlinResourceRootType(true)
override fun createDefaultProperties() =
JpsJavaExtensionService.getInstance().createResourceRootProperties("", false)
@@ -22,4 +20,7 @@ sealed class KotlinResourceRootType(val isTest: Boolean) : JpsElementTypeBase<Ja
override fun isTestRoot() = isTest
override fun equals(other: Any?) = if (super.equals(other)) true else isSameRootType(this, other)
}
}
object ResourceKotlinRootType : KotlinResourceRootType(false)
object TestResourceKotlinRootType : KotlinResourceRootType(true)

View File

@@ -13,12 +13,13 @@ import org.jetbrains.jps.model.module.JpsModuleSourceRootType
sealed class KotlinResourceRootType() : JpsElementTypeBase<JavaResourceRootProperties>(),
JpsModuleSourceRootType<JavaResourceRootProperties> {
object Resource : KotlinResourceRootType()
object TestResource : KotlinResourceRootType() {
override fun isForTests() = true
}
override fun createDefaultProperties() =
JpsJavaExtensionService.getInstance().createResourceRootProperties("", false)
}
object ResourceKotlinRootType : KotlinResourceRootType()
object TestResourceKotlinRootType : KotlinResourceRootType() {
override fun isForTests() = true
}

View File

@@ -13,8 +13,6 @@ import org.jetbrains.jps.model.module.JpsModuleSourceRootType
sealed class KotlinResourceRootType(val isTest: Boolean) : JpsElementTypeBase<JavaResourceRootProperties>(),
JpsModuleSourceRootType<JavaResourceRootProperties>, KotlinRootType {
object Resource : KotlinResourceRootType(false)
object TestResource : KotlinResourceRootType(true)
override fun createDefaultProperties() =
JpsJavaExtensionService.getInstance().createResourceRootProperties("", false)
@@ -22,4 +20,7 @@ sealed class KotlinResourceRootType(val isTest: Boolean) : JpsElementTypeBase<Ja
override fun isTestRoot() = isTest
override fun equals(other: Any?) = if (super.equals(other)) true else isSameRootType(this, other)
}
}
object ResourceKotlinRootType : KotlinResourceRootType(false)
object TestResourceKotlinRootType : KotlinResourceRootType(true)

View File

@@ -12,14 +12,10 @@ import org.jetbrains.jps.model.java.JpsJavaExtensionService
import org.jetbrains.jps.model.module.JpsModuleSourceRootType
sealed class KotlinSourceRootType(val isTest: Boolean) : JpsElementTypeBase<JavaSourceRootProperties>(), JpsModuleSourceRootType<JavaSourceRootProperties>, KotlinRootType {
object Source : KotlinSourceRootType(false)
object TestSource : KotlinSourceRootType(true)
override fun createDefaultProperties() = JpsJavaExtensionService.getInstance().createSourceRootProperties("")
companion object {
val ALL_SOURCES = setOf(Source, TestSource)
}
override fun isTestRoot() = isTest
@@ -28,3 +24,8 @@ sealed class KotlinSourceRootType(val isTest: Boolean) : JpsElementTypeBase<Java
override fun equals(other: Any?) = if (super.equals(other)) true else isSameRootType(this, other)
}
object SourceKotlinRootType : KotlinSourceRootType(false)
object TestSourceKotlinRootType : KotlinSourceRootType(true)
val ALL_KOTLIN_SOURCE_ROOT_TYPES = setOf(SourceKotlinRootType, TestSourceKotlinRootType)

View File

@@ -12,17 +12,18 @@ import org.jetbrains.jps.model.java.JpsJavaExtensionService
import org.jetbrains.jps.model.module.JpsModuleSourceRootType
sealed class KotlinSourceRootType(val isTest: Boolean) : JpsElementTypeBase<JavaSourceRootProperties>(), JpsModuleSourceRootType<JavaSourceRootProperties>, KotlinRootType {
object Source : KotlinSourceRootType(false)
object TestSource : KotlinSourceRootType(true)
override fun createDefaultProperties() = JpsJavaExtensionService.getInstance().createSourceRootProperties("")
companion object {
val ALL_SOURCES = setOf(Source, TestSource)
}
override fun isTestRoot() = isTest
override fun equals(other: Any?) = if (super.equals(other)) true else isSameRootType(this, other)
}
object SourceKotlinRootType : KotlinSourceRootType(false)
object TestSourceKotlinRootType : KotlinSourceRootType(true)
val ALL_KOTLIN_SOURCE_ROOT_TYPES = setOf(SourceKotlinRootType, TestSourceKotlinRootType)

View File

@@ -12,16 +12,15 @@ import org.jetbrains.jps.model.java.JpsJavaExtensionService
import org.jetbrains.jps.model.module.JpsModuleSourceRootType
sealed class KotlinSourceRootType() : JpsElementTypeBase<JavaSourceRootProperties>(), JpsModuleSourceRootType<JavaSourceRootProperties> {
object Source : KotlinSourceRootType()
object TestSource : KotlinSourceRootType() {
override fun isForTests() = true
}
override fun createDefaultProperties() = JpsJavaExtensionService.getInstance().createSourceRootProperties("")
companion object {
val ALL_SOURCES = setOf(Source, TestSource)
}
}
object SourceKotlinRootType : KotlinSourceRootType()
object TestSourceKotlinRootType : KotlinSourceRootType() {
override fun isForTests() = true
}
val ALL_KOTLIN_SOURCE_ROOT_TYPES = setOf(SourceKotlinRootType, TestSourceKotlinRootType)

View File

@@ -12,17 +12,20 @@ import org.jetbrains.jps.model.java.JpsJavaExtensionService
import org.jetbrains.jps.model.module.JpsModuleSourceRootType
sealed class KotlinSourceRootType(val isTest: Boolean) : JpsElementTypeBase<JavaSourceRootProperties>(), JpsModuleSourceRootType<JavaSourceRootProperties>, KotlinRootType {
object Source : KotlinSourceRootType(false)
object TestSource : KotlinSourceRootType(true)
override fun createDefaultProperties() = JpsJavaExtensionService.getInstance().createSourceRootProperties("")
companion object {
val ALL_SOURCES = setOf(Source, TestSource)
}
override fun isTestRoot() = isTest
fun isForTests() = isTest
override fun equals(other: Any?) = if (super.equals(other)) true else isSameRootType(this, other)
}
object SourceKotlinRootType : KotlinSourceRootType(false)
object TestSourceKotlinRootType : KotlinSourceRootType(true)
val ALL_KOTLIN_SOURCE_ROOT_TYPES = setOf(SourceKotlinRootType, TestSourceKotlinRootType)

View File

@@ -0,0 +1,31 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. 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.config
import org.jetbrains.jps.model.ex.JpsElementTypeBase
import org.jetbrains.jps.model.java.JavaSourceRootProperties
import org.jetbrains.jps.model.java.JavaSourceRootType
import org.jetbrains.jps.model.java.JpsJavaExtensionService
import org.jetbrains.jps.model.module.JpsModuleSourceRootType
sealed class KotlinSourceRootType(val isTest: Boolean) : JpsElementTypeBase<JavaSourceRootProperties>(), JpsModuleSourceRootType<JavaSourceRootProperties>, KotlinRootType {
override fun createDefaultProperties() = JpsJavaExtensionService.getInstance().createSourceRootProperties("")
override fun isTestRoot() = isTest
fun isForTests() = isTest
override fun equals(other: Any?) = if (super.equals(other)) true else isSameRootType(this, other)
}
object SourceKotlinRootType : KotlinSourceRootType(false)
object TestSourceKotlinRootType : KotlinSourceRootType(true)
val ALL_KOTLIN_SOURCE_ROOT_TYPES = setOf(SourceKotlinRootType, TestSourceKotlinRootType)

View File

@@ -27,12 +27,12 @@ sealed class KotlinSourceRootPropertiesSerializer(
typeId: String
) : JpsModuleSourceRootPropertiesSerializer<JavaSourceRootProperties>(type, typeId) {
object Source : KotlinSourceRootPropertiesSerializer(
KotlinSourceRootType.Source,
SourceKotlinRootType,
KOTLIN_SOURCE_ROOT_TYPE_ID
)
object TestSource : KotlinSourceRootPropertiesSerializer(
KotlinSourceRootType.TestSource,
TestSourceKotlinRootType,
KOTLIN_TEST_ROOT_TYPE_ID
)
@@ -59,12 +59,12 @@ sealed class KotlinResourceRootPropertiesSerializer(
typeId: String
) : JpsModuleSourceRootPropertiesSerializer<JavaResourceRootProperties>(type, typeId) {
object Resource : KotlinResourceRootPropertiesSerializer(
KotlinResourceRootType.Resource,
ResourceKotlinRootType,
KOTLIN_RESOURCE_ROOT_TYPE_ID
)
object TestResource : KotlinResourceRootPropertiesSerializer(
KotlinResourceRootType.TestResource,
KOTLIN_TEST_RESOURCE_ROOT_TYPE_ID
TestResourceKotlinRootType,
KOTLIN_TEST_RESOURCE_ROOT_TYPE_ID
)
override fun loadProperties(sourceRootTag: Element): JavaResourceRootProperties {

View File

@@ -331,8 +331,8 @@ class KotlinMavenImporter : MavenImporter(KOTLIN_PLUGIN_GROUP_ID, KOTLIN_PLUGIN_
.flatMap { it.goals.asSequence() }
.any { it in PomFile.KotlinGoals.CompileGoals && it !in PomFile.KotlinGoals.JvmGoals }
val prodSourceRootType: JpsModuleSourceRootType<*> = if (isNonJvmModule) KotlinSourceRootType.Source else JavaSourceRootType.SOURCE
val testSourceRootType: JpsModuleSourceRootType<*> = if (isNonJvmModule) KotlinSourceRootType.TestSource else JavaSourceRootType.TEST_SOURCE
val prodSourceRootType: JpsModuleSourceRootType<*> = if (isNonJvmModule) SourceKotlinRootType else JavaSourceRootType.SOURCE
val testSourceRootType: JpsModuleSourceRootType<*> = if (isNonJvmModule) TestSourceKotlinRootType else JavaSourceRootType.TEST_SOURCE
for ((type, dir) in directories) {
if (rootModel.getSourceFolder(File(dir)) == null) {
@@ -346,10 +346,10 @@ class KotlinMavenImporter : MavenImporter(KOTLIN_PLUGIN_GROUP_ID, KOTLIN_PLUGIN_
}
if (isNonJvmModule) {
mavenProject.sources.forEach { rootModel.addSourceFolder(it, KotlinSourceRootType.Source) }
mavenProject.testSources.forEach { rootModel.addSourceFolder(it, KotlinSourceRootType.TestSource) }
mavenProject.resources.forEach { rootModel.addSourceFolder(it.directory, KotlinResourceRootType.Resource) }
mavenProject.testResources.forEach { rootModel.addSourceFolder(it.directory, KotlinResourceRootType.TestResource) }
mavenProject.sources.forEach { rootModel.addSourceFolder(it, SourceKotlinRootType) }
mavenProject.testSources.forEach { rootModel.addSourceFolder(it, TestSourceKotlinRootType) }
mavenProject.resources.forEach { rootModel.addSourceFolder(it.directory, ResourceKotlinRootType) }
mavenProject.testResources.forEach { rootModel.addSourceFolder(it.directory, TestResourceKotlinRootType) }
KotlinSdkType.setUpIfNeeded()
}

View File

@@ -40,8 +40,9 @@ import org.jetbrains.idea.maven.project.MavenProjectsManager
import org.jetbrains.idea.maven.utils.MavenArtifactScope
import org.jetbrains.jps.model.java.JavaSourceRootType
import org.jetbrains.kotlin.cli.common.arguments.CliArgumentStringBuilder.buildArgumentString
import org.jetbrains.kotlin.config.KotlinSourceRootType
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.config.SourceKotlinRootType
import org.jetbrains.kotlin.config.TestSourceKotlinRootType
import org.jetbrains.kotlin.idea.configuration.RepositoryDescription
import org.jetbrains.kotlin.idea.maven.configuration.KotlinMavenConfigurator
import org.jetbrains.kotlin.psi.psiUtil.getChildrenOfType
@@ -500,9 +501,9 @@ class PomFile private constructor(private val xmlFile: XmlFile, val domModel: Ma
private fun SourceFolder.isRelatedSourceRoot(isTest: Boolean): Boolean {
return if (isTest) {
rootType == JavaSourceRootType.TEST_SOURCE || rootType == KotlinSourceRootType.TestSource
rootType == JavaSourceRootType.TEST_SOURCE || rootType == TestSourceKotlinRootType
} else {
rootType == JavaSourceRootType.SOURCE || rootType == KotlinSourceRootType.Source
rootType == JavaSourceRootType.SOURCE || rootType == SourceKotlinRootType
}
}

View File

@@ -30,7 +30,7 @@ import com.intellij.psi.PsiDocumentManager
import com.intellij.psi.PsiManager
import com.intellij.psi.search.FileTypeIndex
import org.jetbrains.jps.model.java.JavaSourceRootType
import org.jetbrains.kotlin.config.KotlinSourceRootType
import org.jetbrains.kotlin.config.SourceKotlinRootType
import org.jetbrains.kotlin.idea.inspections.runInspection
import org.jetbrains.kotlin.idea.maven.inspections.KotlinMavenPluginPhaseInspection
import org.jetbrains.kotlin.idea.refactoring.toPsiDirectory
@@ -181,7 +181,7 @@ abstract class AbstractKotlinMavenInspectionTest : MavenImportingTestCase() {
val contentEntry = getContentRoots(myProject.allModules().single().name).single()
val sourceFolder =
contentEntry.getSourceFolders(JavaSourceRootType.SOURCE).singleOrNull() ?:
contentEntry.getSourceFolders(KotlinSourceRootType.Source).singleOrNull()
contentEntry.getSourceFolders(SourceKotlinRootType).singleOrNull()
ApplicationManager.getApplication().runWriteAction {
val javaFile = sourceFolder?.file?.toPsiDirectory(myProject)?.createFile("Test.java") ?: throw IllegalStateException()
javaFile.viewProvider.document!!.setText("class Test {}\n")

View File

@@ -843,10 +843,10 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
Assert.assertTrue(ModuleRootManager.getInstance(getModule("project")).sdk!!.sdkType is KotlinSdkType)
assertContentFolders("project", KotlinSourceRootType.Source, "src/main/kotlin")
assertContentFolders("project", KotlinSourceRootType.TestSource, "src/test/java")
assertContentFolders("project", KotlinResourceRootType.Resource, "src/main/resources")
assertContentFolders("project", KotlinResourceRootType.TestResource, "src/test/resources")
assertContentFolders("project", SourceKotlinRootType, "src/main/kotlin")
assertContentFolders("project", TestSourceKotlinRootType, "src/test/java")
assertContentFolders("project", ResourceKotlinRootType, "src/main/resources")
assertContentFolders("project", TestResourceKotlinRootType, "src/test/resources")
}
fun testJsCustomOutputPaths() {
@@ -1315,10 +1315,10 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
Assert.assertTrue(ModuleRootManager.getInstance(getModule("project")).sdk!!.sdkType is KotlinSdkType)
assertContentFolders("project", KotlinSourceRootType.Source, "src/main/kotlin")
assertContentFolders("project", KotlinSourceRootType.TestSource, "src/test/java")
assertContentFolders("project", KotlinResourceRootType.Resource, "src/main/resources")
assertContentFolders("project", KotlinResourceRootType.TestResource, "src/test/resources")
assertContentFolders("project", SourceKotlinRootType, "src/main/kotlin")
assertContentFolders("project", TestSourceKotlinRootType, "src/test/java")
assertContentFolders("project", ResourceKotlinRootType, "src/main/resources")
assertContentFolders("project", TestResourceKotlinRootType, "src/test/resources")
}
fun testJsDetectionByGoalWithJsStdlib() {
@@ -1372,10 +1372,10 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
Assert.assertTrue(ModuleRootManager.getInstance(getModule("project")).sdk!!.sdkType is KotlinSdkType)
assertContentFolders("project", KotlinSourceRootType.Source, "src/main/kotlin")
assertContentFolders("project", KotlinSourceRootType.TestSource, "src/test/java")
assertContentFolders("project", KotlinResourceRootType.Resource, "src/main/resources")
assertContentFolders("project", KotlinResourceRootType.TestResource, "src/test/resources")
assertContentFolders("project", SourceKotlinRootType, "src/main/kotlin")
assertContentFolders("project", TestSourceKotlinRootType, "src/test/java")
assertContentFolders("project", ResourceKotlinRootType, "src/main/resources")
assertContentFolders("project", TestResourceKotlinRootType, "src/test/resources")
}
fun testJsDetectionByGoalWithCommonStdlib() {
@@ -1429,10 +1429,10 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
Assert.assertTrue(ModuleRootManager.getInstance(getModule("project")).sdk!!.sdkType is KotlinSdkType)
assertContentFolders("project", KotlinSourceRootType.Source, "src/main/kotlin")
assertContentFolders("project", KotlinSourceRootType.TestSource, "src/test/java")
assertContentFolders("project", KotlinResourceRootType.Resource, "src/main/resources")
assertContentFolders("project", KotlinResourceRootType.TestResource, "src/test/resources")
assertContentFolders("project", SourceKotlinRootType, "src/main/kotlin")
assertContentFolders("project", TestSourceKotlinRootType, "src/test/java")
assertContentFolders("project", ResourceKotlinRootType, "src/main/resources")
assertContentFolders("project", TestResourceKotlinRootType, "src/test/resources")
}
fun testJsAndCommonStdlibKinds() {
@@ -1494,10 +1494,10 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
assertEquals(JSLibraryKind, libraries.single { it.name?.contains("kotlin-stdlib-js") == true }.kind)
assertEquals(CommonLibraryKind, libraries.single { it.name?.contains("kotlin-stdlib-common") == true }.kind)
assertContentFolders("project", KotlinSourceRootType.Source, "src/main/kotlin")
assertContentFolders("project", KotlinSourceRootType.TestSource, "src/test/java")
assertContentFolders("project", KotlinResourceRootType.Resource, "src/main/resources")
assertContentFolders("project", KotlinResourceRootType.TestResource, "src/test/resources")
assertContentFolders("project", SourceKotlinRootType, "src/main/kotlin")
assertContentFolders("project", TestSourceKotlinRootType, "src/test/java")
assertContentFolders("project", ResourceKotlinRootType, "src/main/resources")
assertContentFolders("project", TestResourceKotlinRootType, "src/test/resources")
}
fun testCommonDetectionByGoalWithJvmStdlib() {
@@ -1545,10 +1545,10 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
Assert.assertTrue(ModuleRootManager.getInstance(getModule("project")).sdk!!.sdkType is KotlinSdkType)
assertContentFolders("project", KotlinSourceRootType.Source, "src/main/kotlin")
assertContentFolders("project", KotlinSourceRootType.TestSource, "src/test/java")
assertContentFolders("project", KotlinResourceRootType.Resource, "src/main/resources")
assertContentFolders("project", KotlinResourceRootType.TestResource, "src/test/resources")
assertContentFolders("project", SourceKotlinRootType, "src/main/kotlin")
assertContentFolders("project", TestSourceKotlinRootType, "src/test/java")
assertContentFolders("project", ResourceKotlinRootType, "src/main/resources")
assertContentFolders("project", TestResourceKotlinRootType, "src/test/resources")
}
fun testCommonDetectionByGoalWithJsStdlib() {
@@ -1596,10 +1596,10 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
Assert.assertTrue(ModuleRootManager.getInstance(getModule("project")).sdk!!.sdkType is KotlinSdkType)
assertContentFolders("project", KotlinSourceRootType.Source, "src/main/kotlin")
assertContentFolders("project", KotlinSourceRootType.TestSource, "src/test/java")
assertContentFolders("project", KotlinResourceRootType.Resource, "src/main/resources")
assertContentFolders("project", KotlinResourceRootType.TestResource, "src/test/resources")
assertContentFolders("project", SourceKotlinRootType, "src/main/kotlin")
assertContentFolders("project", TestSourceKotlinRootType, "src/test/java")
assertContentFolders("project", ResourceKotlinRootType, "src/main/resources")
assertContentFolders("project", TestResourceKotlinRootType, "src/test/resources")
}
fun testCommonDetectionByGoalWithCommonStdlib() {
@@ -1651,10 +1651,10 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
Assert.assertTrue(ModuleRootManager.getInstance(getModule("project")).sdk!!.sdkType is KotlinSdkType)
assertContentFolders("project", KotlinSourceRootType.Source, "src/main/kotlin")
assertContentFolders("project", KotlinSourceRootType.TestSource, "src/test/java")
assertContentFolders("project", KotlinResourceRootType.Resource, "src/main/resources")
assertContentFolders("project", KotlinResourceRootType.TestResource, "src/test/resources")
assertContentFolders("project", SourceKotlinRootType, "src/main/kotlin")
assertContentFolders("project", TestSourceKotlinRootType, "src/test/java")
assertContentFolders("project", ResourceKotlinRootType, "src/main/resources")
assertContentFolders("project", TestResourceKotlinRootType, "src/test/resources")
}
fun testJvmDetectionByConflictingGoalsAndJvmStdlib() {
@@ -1706,10 +1706,10 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
Assert.assertEquals(JvmIdePlatformKind.Platform(JvmTarget.JVM_1_6), facetSettings.platform)
assertContentFolders("project", KotlinSourceRootType.Source, "src/main/kotlin")
assertContentFolders("project", KotlinSourceRootType.TestSource, "src/test/java")
assertContentFolders("project", KotlinResourceRootType.Resource, "src/main/resources")
assertContentFolders("project", KotlinResourceRootType.TestResource, "src/test/resources")
assertContentFolders("project", SourceKotlinRootType, "src/main/kotlin")
assertContentFolders("project", TestSourceKotlinRootType, "src/test/java")
assertContentFolders("project", ResourceKotlinRootType, "src/main/resources")
assertContentFolders("project", TestResourceKotlinRootType, "src/test/resources")
}
fun testJsDetectionByConflictingGoalsAndJsStdlib() {
@@ -1761,10 +1761,10 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
Assert.assertTrue(facetSettings.platform.isJavaScript)
assertContentFolders("project", KotlinSourceRootType.Source, "src/main/kotlin")
assertContentFolders("project", KotlinSourceRootType.TestSource, "src/test/java")
assertContentFolders("project", KotlinResourceRootType.Resource, "src/main/resources")
assertContentFolders("project", KotlinResourceRootType.TestResource, "src/test/resources")
assertContentFolders("project", SourceKotlinRootType, "src/main/kotlin")
assertContentFolders("project", TestSourceKotlinRootType, "src/test/java")
assertContentFolders("project", ResourceKotlinRootType, "src/main/resources")
assertContentFolders("project", TestResourceKotlinRootType, "src/test/resources")
}
fun testCommonDetectionByConflictingGoalsAndCommonStdlib() {
@@ -1816,10 +1816,10 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
Assert.assertTrue(facetSettings.platform.isCommon)
assertContentFolders("project", KotlinSourceRootType.Source, "src/main/kotlin")
assertContentFolders("project", KotlinSourceRootType.TestSource, "src/test/java")
assertContentFolders("project", KotlinResourceRootType.Resource, "src/main/resources")
assertContentFolders("project", KotlinResourceRootType.TestResource, "src/test/resources")
assertContentFolders("project", SourceKotlinRootType, "src/main/kotlin")
assertContentFolders("project", TestSourceKotlinRootType, "src/test/java")
assertContentFolders("project", ResourceKotlinRootType, "src/main/resources")
assertContentFolders("project", TestResourceKotlinRootType, "src/test/resources")
}
fun testNoPluginsInAdditionalArgs() {

View File

@@ -34,14 +34,30 @@ interface ArgsInfo : Serializable {
val dependencyClasspath: List<String>
}
class ArgsInfoImpl(
override val currentArguments: List<String>,
override val defaultArguments: List<String>,
override val dependencyClasspath: List<String>
) : ArgsInfo
data class ArgsInfoImpl(
override val currentArguments: List<String>,
override val defaultArguments: List<String>,
override val dependencyClasspath: List<String>
) : ArgsInfo {
constructor(argsInfo: ArgsInfo) : this(
ArrayList(argsInfo.currentArguments),
ArrayList(argsInfo.defaultArguments),
ArrayList(argsInfo.dependencyClasspath)
)
}
typealias CompilerArgumentsBySourceSet = Map<String, ArgsInfo>
/**
* Creates deep copy in order to avoid holding links to Proxy objects created by gradle tooling api
*/
fun CompilerArgumentsBySourceSet.deepCopy(): CompilerArgumentsBySourceSet {
val result = HashMap<String, ArgsInfo>()
this.forEach { key, value -> result[key] = ArgsInfoImpl(value) }
return result
}
interface KotlinGradleModel : Serializable {
val hasKotlinPlugin: Boolean
val compilerArgumentsBySourceSet: CompilerArgumentsBySourceSet
@@ -51,13 +67,13 @@ interface KotlinGradleModel : Serializable {
val kotlinTarget: String?
}
class KotlinGradleModelImpl(
override val hasKotlinPlugin: Boolean,
override val compilerArgumentsBySourceSet: CompilerArgumentsBySourceSet,
override val coroutines: String?,
override val platformPluginId: String?,
override val implements: List<String>,
override val kotlinTarget: String? = null
data class KotlinGradleModelImpl(
override val hasKotlinPlugin: Boolean,
override val compilerArgumentsBySourceSet: CompilerArgumentsBySourceSet,
override val coroutines: String?,
override val platformPluginId: String?,
override val implements: List<String>,
override val kotlinTarget: String? = null
) : KotlinGradleModel
abstract class AbstractKotlinGradleModelBuilder : ModelBuilderService {
@@ -72,8 +88,8 @@ abstract class AbstractKotlinGradleModelBuilder : ModelBuilderService {
)
val platformPluginIds = listOf("kotlin-platform-jvm", "kotlin-platform-js", "kotlin-platform-common")
val pluginToPlatform = linkedMapOf(
"kotlin" to "kotlin-platform-jvm",
"kotlin2js" to "kotlin-platform-js"
"kotlin" to "kotlin-platform-jvm",
"kotlin2js" to "kotlin-platform-js"
)
val kotlinPluginIds = listOf("kotlin", "kotlin2js", "kotlin-android")
val ABSTRACT_KOTLIN_COMPILE_CLASS = "org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile"
@@ -81,7 +97,7 @@ abstract class AbstractKotlinGradleModelBuilder : ModelBuilderService {
fun Task.getSourceSetName(): String {
return try {
javaClass.methods.firstOrNull { it.name.startsWith("getSourceSetName") && it.parameterTypes.isEmpty() }?.invoke(this) as? String
} catch (e : InvocationTargetException) {
} catch (e: InvocationTargetException) {
null // can be thrown if property is not initialized yet
} ?: "main"
}
@@ -90,16 +106,17 @@ abstract class AbstractKotlinGradleModelBuilder : ModelBuilderService {
class KotlinGradleModelBuilder : AbstractKotlinGradleModelBuilder() {
override fun getErrorMessageBuilder(project: Project, e: Exception): ErrorMessageBuilder {
return ErrorMessageBuilder.create(project, e, "Gradle import errors").withDescription("Unable to build Kotlin project configuration")
return ErrorMessageBuilder.create(project, e, "Gradle import errors")
.withDescription("Unable to build Kotlin project configuration")
}
override fun canBuild(modelName: String?): Boolean = modelName == KotlinGradleModel::class.java.name
private fun getImplementedProjects(project: Project): List<Project> {
return listOf("expectedBy", "implement")
.flatMap { project.configurations.findByName(it)?.dependencies ?: emptySet<Dependency>() }
.filterIsInstance<ProjectDependency>()
.mapNotNull { it.dependencyProject }
.flatMap { project.configurations.findByName(it)?.dependencies ?: emptySet<Dependency>() }
.filterIsInstance<ProjectDependency>()
.mapNotNull { it.dependencyProject }
}
// see GradleProjectResolverUtil.getModuleId() in IDEA codebase
@@ -109,8 +126,7 @@ class KotlinGradleModelBuilder : AbstractKotlinGradleModelBuilder() {
private fun Task.getCompilerArguments(methodName: String): List<String> {
return try {
javaClass.getDeclaredMethod(methodName).invoke(this) as List<String>
}
catch (e : Exception) {
} catch (e: Exception) {
// No argument accessor method is available
emptyList()
}
@@ -122,14 +138,11 @@ class KotlinGradleModelBuilder : AbstractKotlinGradleModelBuilder() {
val getCompileClasspath = abstractKotlinCompileClass.getDeclaredMethod("getCompileClasspath").apply { isAccessible = true }
@Suppress("UNCHECKED_CAST")
return (getCompileClasspath.invoke(this) as Collection<File>).map { it.path }
}
catch(e: ClassNotFoundException) {
} catch (e: ClassNotFoundException) {
// Leave arguments unchanged
}
catch (e: NoSuchMethodException) {
} catch (e: NoSuchMethodException) {
// Leave arguments unchanged
}
catch (e: InvocationTargetException) {
} catch (e: InvocationTargetException) {
// We can safely ignore this exception here as getCompileClasspath() gets called again at a later time
// Leave arguments unchanged
}
@@ -140,15 +153,13 @@ class KotlinGradleModelBuilder : AbstractKotlinGradleModelBuilder() {
val kotlinExtension = project.extensions.findByName("kotlin") ?: return null
val experimentalExtension = try {
kotlinExtension::class.java.getMethod("getExperimental").invoke(kotlinExtension)
}
catch(e: NoSuchMethodException) {
} catch (e: NoSuchMethodException) {
return null
}
return try {
experimentalExtension::class.java.getMethod("getCoroutines").invoke(experimentalExtension)?.toString()
}
catch(e: NoSuchMethodException) {
} catch (e: NoSuchMethodException) {
null
}
}
@@ -173,12 +184,12 @@ class KotlinGradleModelBuilder : AbstractKotlinGradleModelBuilder() {
val implementedProjects = getImplementedProjects(project)
return KotlinGradleModelImpl(
kotlinPluginId != null || platformPluginId != null,
compilerArgumentsBySourceSet,
getCoroutines(project),
platform,
implementedProjects.map { it.pathOrName() },
platform ?: kotlinPluginId
kotlinPluginId != null || platformPluginId != null,
compilerArgumentsBySourceSet,
getCoroutines(project),
platform,
implementedProjects.map { it.pathOrName() },
platform ?: kotlinPluginId
)
}
}

View File

@@ -6,11 +6,14 @@
package org.jetbrains.kotlin.gradle
import org.jetbrains.plugins.gradle.model.ExternalDependency
import org.jetbrains.plugins.gradle.model.ModelFactory
import java.io.File
import java.io.Serializable
typealias KotlinDependency = ExternalDependency
fun KotlinDependency.deepCopy(): KotlinDependency = ModelFactory.createCopy(this)
interface KotlinModule : Serializable {
val name: String
val platform: KotlinPlatform
@@ -55,10 +58,10 @@ interface KotlinCompilationArguments : Serializable {
interface KotlinCompilation : KotlinModule {
val sourceSets: Collection<KotlinSourceSet>
val target: KotlinTarget
val output: KotlinCompilationOutput
val arguments: KotlinCompilationArguments
val dependencyClasspath: List<String>
val disambiguationClassifier: String?
companion object {
const val MAIN_COMPILATION_NAME = "main"

View File

@@ -194,7 +194,10 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
}
val jar = buildTargetJar(gradleTarget, project)
val target = KotlinTargetImpl(gradleTarget.name, targetPresetName, disambiguationClassifier, platform, compilations, jar)
compilations.forEach { it.target = target }
compilations.forEach {
it.disambiguationClassifier = target.disambiguationClassifier
it.platform = target.platform
}
return target
}

View File

@@ -185,7 +185,10 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
}
val jar = buildTargetJar(gradleTarget, project)
val target = KotlinTargetImpl(gradleTarget.name, null, disambiguationClassifier, platform, compilations, jar)
compilations.forEach { it.target = target }
compilations.forEach {
it.disambiguationClassifier = target.disambiguationClassifier
it.platform = target.platform
}
return target
}

View File

@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.gradle
import java.io.File
class KotlinSourceSetImpl(
data class KotlinSourceSetImpl(
override val name: String,
override val languageSettings: KotlinLanguageSettings,
override val sourceDirs: Set<File>,
@@ -15,6 +15,16 @@ class KotlinSourceSetImpl(
override val dependencies: Set<KotlinDependency>,
override val dependsOnSourceSets: Set<String>
) : KotlinSourceSet {
constructor(kotlinSourceSet: KotlinSourceSet) : this(
kotlinSourceSet.name,
KotlinLanguageSettingsImpl(kotlinSourceSet.languageSettings),
HashSet(kotlinSourceSet.sourceDirs),
HashSet(kotlinSourceSet.resourceDirs),
kotlinSourceSet.dependencies.map { it.deepCopy() }.toSet(),
HashSet(kotlinSourceSet.dependsOnSourceSets)
)
override var platform: KotlinPlatform = KotlinPlatform.COMMON
internal set
@@ -24,7 +34,7 @@ class KotlinSourceSetImpl(
override fun toString() = name
}
class KotlinLanguageSettingsImpl(
data class KotlinLanguageSettingsImpl(
override val languageVersion: String?,
override val apiVersion: String?,
override val isProgressiveMode: Boolean,
@@ -32,20 +42,38 @@ class KotlinLanguageSettingsImpl(
override val experimentalAnnotationsInUse: Set<String>,
override val compilerPluginArguments: List<String>,
override val compilerPluginClasspath: Set<File>
) : KotlinLanguageSettings
) : KotlinLanguageSettings {
constructor(settings: KotlinLanguageSettings) : this(
settings.languageVersion,
settings.apiVersion,
settings.isProgressiveMode,
settings.enabledLanguageFeatures,
settings.experimentalAnnotationsInUse,
settings.compilerPluginArguments,
settings.compilerPluginClasspath
)
}
class KotlinCompilationOutputImpl(
data class KotlinCompilationOutputImpl(
override val classesDirs: Set<File>,
override val effectiveClassesDir: File?,
override val resourcesDir: File?
) : KotlinCompilationOutput
) : KotlinCompilationOutput {
constructor(output: KotlinCompilationOutput) : this(
HashSet(output.classesDirs),
output.effectiveClassesDir,
output.resourcesDir
)
}
class KotlinCompilationArgumentsImpl(
data class KotlinCompilationArgumentsImpl(
override val defaultArguments: List<String>,
override val currentArguments: List<String>
) : KotlinCompilationArguments
) : KotlinCompilationArguments {
constructor(arguments: KotlinCompilationArguments) : this(ArrayList(arguments.defaultArguments), ArrayList(arguments.currentArguments))
}
class KotlinCompilationImpl(
data class KotlinCompilationImpl(
override val name: String,
override val sourceSets: Collection<KotlinSourceSet>,
override val dependencies: Set<KotlinDependency>,
@@ -53,11 +81,25 @@ class KotlinCompilationImpl(
override val arguments: KotlinCompilationArguments,
override val dependencyClasspath: List<String>
) : KotlinCompilation {
override lateinit var target: KotlinTarget
// create deep copy
constructor(kotlinCompilation: KotlinCompilation) : this(
kotlinCompilation.name,
kotlinCompilation.sourceSets.map { KotlinSourceSetImpl(it) }.toList(),
kotlinCompilation.dependencies.map { it.deepCopy() }.toSet(),
KotlinCompilationOutputImpl(kotlinCompilation.output),
KotlinCompilationArgumentsImpl(kotlinCompilation.arguments),
ArrayList(kotlinCompilation.dependencyClasspath)
) {
disambiguationClassifier = kotlinCompilation.disambiguationClassifier
platform = kotlinCompilation.platform
}
override var disambiguationClassifier: String? = null
internal set
override lateinit var platform: KotlinPlatform
internal set
override val platform: KotlinPlatform
get() = target.platform
override val isTestModule: Boolean
get() = name == KotlinCompilation.TEST_COMPILATION_NAME
@@ -66,11 +108,11 @@ class KotlinCompilationImpl(
override fun toString() = name
}
class KotlinTargetJarImpl(
data class KotlinTargetJarImpl(
override val archiveFile: File?
) : KotlinTargetJar
class KotlinTargetImpl(
data class KotlinTargetImpl(
override val name: String,
override val presetName: String?,
override val disambiguationClassifier: String?,
@@ -81,11 +123,11 @@ class KotlinTargetImpl(
override fun toString() = name
}
class ExtraFeaturesImpl(
data class ExtraFeaturesImpl(
override val coroutinesState: String?
) : ExtraFeatures
class KotlinMPPGradleModelImpl(
data class KotlinMPPGradleModelImpl(
override val sourceSets: Map<String, KotlinSourceSet>,
override val targets: Collection<KotlinTarget>,
override val extraFeatures: ExtraFeatures,

View File

@@ -163,8 +163,7 @@
restartRequired="false"/>
<registryKey key="kotlin.uast.multiresolve.enabled"
description="Whether to use muiti resolve for UAST in Kotlin provided by `Call.resolveCandidates`,
otherwise PsiPolyVariantReference-based multiResolve will be performed"
description="Whether to use multi resolve for UAST in Kotlin provided by `Call.resolveCandidates`, otherwise PsiPolyVariantReference-based multiResolve will be performed"
defaultValue="true"
restartRequired="false"/>
</extensions>

View File

@@ -162,8 +162,7 @@
restartRequired="false"/>
<registryKey key="kotlin.uast.multiresolve.enabled"
description="Whether to use muiti resolve for UAST in Kotlin provided by `Call.resolveCandidates`,
otherwise PsiPolyVariantReference-based multiResolve will be performed"
description="Whether to use multi resolve for UAST in Kotlin provided by `Call.resolveCandidates`, otherwise PsiPolyVariantReference-based multiResolve will be performed"
defaultValue="true"
restartRequired="false"/>
</extensions>

View File

@@ -163,8 +163,7 @@
restartRequired="false"/>
<registryKey key="kotlin.uast.multiresolve.enabled"
description="Whether to use muiti resolve for UAST in Kotlin provided by `Call.resolveCandidates`,
otherwise PsiPolyVariantReference-based multiResolve will be performed"
description="Whether to use multi resolve for UAST in Kotlin provided by `Call.resolveCandidates`, otherwise PsiPolyVariantReference-based multiResolve will be performed"
defaultValue="true"
restartRequired="false"/>

View File

@@ -1754,6 +1754,15 @@
language="kotlin"
/>
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.ReplaceCollectionCountWithSizeInspection"
displayName="Collection count can be converted to size"
groupPath="Kotlin"
groupName="Style issues"
enabledByDefault="false"
level="WEAK WARNING"
language="kotlin"
/>
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.DeprecatedCallableAddReplaceWithInspection"
displayName="@Deprecated annotation without 'replaceWith' argument"
groupPath="Kotlin"
@@ -2699,6 +2708,14 @@
level="WARNING"
language="kotlin"/>
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.RemoveRedundantQualifierNameInspection"
displayName="Remove redundant qualifier name"
groupPath="Kotlin"
groupName="Redundant constructs"
enabledByDefault="true"
level="WARNING"
language="kotlin"/>
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.RedundantSetterInspection"
displayName="Redundant property setter"
groupPath="Kotlin"
@@ -3271,6 +3288,15 @@
language="kotlin"
/>
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.JavaMapForEachInspection"
displayName="Java Map.forEach method call should be replaced with Kotlin's forEach"
groupPath="Kotlin"
groupName="Style issues"
enabledByDefault="true"
level="WEAK WARNING"
language="kotlin"
/>
<referenceImporter implementation="org.jetbrains.kotlin.idea.quickfix.KotlinReferenceImporter"/>
<fileType.fileViewProviderFactory filetype="KJSM" implementationClass="com.intellij.psi.ClassFileViewProviderFactory"/>

View File

@@ -28,5 +28,7 @@
<idePlatformKind implementation="org.jetbrains.kotlin.platform.impl.CommonIdePlatformKind"/>
<idePlatformKindTooling implementation="org.jetbrains.kotlin.idea.core.platform.impl.CommonIdePlatformKindTooling"/>
<syntheticResolveExtension implementation="org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingResolveExtension"/>
</extensions>
</idea-plugin>

View File

@@ -64,10 +64,6 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
<xi:include href="plugin-kotlin-extensions.xml" xpointer="xpointer(/idea-plugin/*)"/>
<extensions defaultExtensionNs="org.jetbrains.kotlin">
<syntheticResolveExtension implementation="org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingResolveExtension"/>
</extensions>
<extensions defaultExtensionNs="com.intellij.jvm">
<declarationSearcher language="kotlin" implementationClass="org.jetbrains.kotlin.idea.jvm.KotlinDeclarationSearcher"/>
</extensions>

View File

@@ -71,10 +71,6 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
<xi:include href="plugin-kotlin-extensions.xml" xpointer="xpointer(/idea-plugin/*)"/>
<extensions defaultExtensionNs="org.jetbrains.kotlin">
<syntheticResolveExtension implementation="org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingResolveExtension"/>
</extensions>
<extensions defaultExtensionNs="com.intellij.jvm">
<declarationSearcher language="kotlin" implementationClass="org.jetbrains.kotlin.idea.jvm.KotlinDeclarationSearcher"/>
</extensions>

View File

@@ -63,10 +63,6 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
<xi:include href="plugin-kotlin-extensions.xml" xpointer="xpointer(/idea-plugin/*)"/>
<extensions defaultExtensionNs="org.jetbrains.kotlin">
<syntheticResolveExtension implementation="org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingResolveExtension"/>
</extensions>
<extensions defaultExtensionNs="com.intellij.jvm">
<declarationSearcher language="kotlin" implementationClass="org.jetbrains.kotlin.idea.jvm.KotlinDeclarationSearcher"/>
</extensions>

View File

@@ -70,10 +70,6 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
<xi:include href="plugin-kotlin-extensions.xml" xpointer="xpointer(/idea-plugin/*)"/>
<extensions defaultExtensionNs="org.jetbrains.kotlin">
<syntheticResolveExtension implementation="org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingResolveExtension"/>
</extensions>
<extensions defaultExtensionNs="org.jetbrains.kotlin">
<pluginUpdateVerifier implementation="org.jetbrains.kotlin.idea.update.GooglePluginUpdateVerifier"/>
</extensions>

View File

@@ -71,10 +71,6 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
<xi:include href="plugin-kotlin-extensions.xml" xpointer="xpointer(/idea-plugin/*)"/>
<extensions defaultExtensionNs="org.jetbrains.kotlin">
<syntheticResolveExtension implementation="org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingResolveExtension"/>
</extensions>
<extensions defaultExtensionNs="org.jetbrains.kotlin">
<pluginUpdateVerifier implementation="org.jetbrains.kotlin.idea.update.GooglePluginUpdateVerifier"/>
</extensions>

View File

@@ -64,10 +64,6 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
<xi:include href="plugin-kotlin-extensions.xml" xpointer="xpointer(/idea-plugin/*)"/>
<extensions defaultExtensionNs="org.jetbrains.kotlin">
<syntheticResolveExtension implementation="org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingResolveExtension"/>
</extensions>
<extensions defaultExtensionNs="org.jetbrains.kotlin">
<pluginUpdateVerifier implementation="org.jetbrains.kotlin.idea.update.GooglePluginUpdateVerifier"/>
</extensions>

Some files were not shown because too many files have changed in this diff Show More