Use mutable lists before deserialization of project structure
The problem is that we perform xml deserialization using intellij mechanism which tries to clear target object if it isn't unmodifiable (see CollectionBinding.isMutableCollection). This check fails for kotlin.EmptyList (emptyList()) which then cause exception #KT-27321 Fixed
This commit is contained in:
+2
-1
@@ -105,7 +105,8 @@ abstract class BaseKotlinCompilerSettings<T : Freezable> protected constructor(p
|
||||
override fun loadState(state: Element) {
|
||||
_settings = ReflectionUtil.newInstance(_settings.javaClass).apply {
|
||||
if (this is CommonCompilerArguments) {
|
||||
freeArgs = ArrayList()
|
||||
freeArgs = mutableListOf()
|
||||
internalArguments = mutableListOf()
|
||||
}
|
||||
XmlSerializer.deserializeInto(this, state)
|
||||
}
|
||||
|
||||
+2
-1
@@ -107,7 +107,8 @@ abstract class BaseKotlinCompilerSettings<T : Freezable> protected constructor(p
|
||||
override fun loadState(state: Element) {
|
||||
_settings = ReflectionUtil.newInstance(_settings.javaClass).apply {
|
||||
if (this is CommonCompilerArguments) {
|
||||
freeArgs = ArrayList()
|
||||
freeArgs = mutableListOf()
|
||||
internalArguments = mutableListOf()
|
||||
}
|
||||
XmlSerializer.deserializeInto(this, state)
|
||||
}
|
||||
|
||||
@@ -138,7 +138,10 @@ private fun readV2AndLaterConfig(element: Element): KotlinFacetSettings {
|
||||
XmlSerializer.deserializeInto(compilerSettings!!, it)
|
||||
}
|
||||
element.getChild("compilerArguments")?.let {
|
||||
compilerArguments = targetPlatform.createArguments { freeArgs = ArrayList() }
|
||||
compilerArguments = targetPlatform.createArguments {
|
||||
freeArgs = mutableListOf()
|
||||
internalArguments = mutableListOf()
|
||||
}
|
||||
XmlSerializer.deserializeInto(compilerArguments!!, it)
|
||||
compilerArguments!!.detectVersionAutoAdvance()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="KotlinJavaRuntime (2)" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<resourceExtensions />
|
||||
<wildcardResourcePatterns>
|
||||
<entry name="!?*.java" />
|
||||
<entry name="!?*.form" />
|
||||
<entry name="!?*.class" />
|
||||
<entry name="!?*.groovy" />
|
||||
<entry name="!?*.scala" />
|
||||
<entry name="!?*.flex" />
|
||||
<entry name="!?*.kt" />
|
||||
<entry name="!?*.clj" />
|
||||
<entry name="!?*.aj" />
|
||||
</wildcardResourcePatterns>
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="false">
|
||||
<processorPath useClasspath="true" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
<component name="CopyrightManager" default="" />
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/module.iml" filepath="$PROJECT_DIR$/module.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="libraryTable">
|
||||
<library name="KotlinJavaRuntime (2)">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/../mockRuntime11/kotlin-runtime.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
<component name="KotlinCommonCompilerArguments">
|
||||
<option name="internalArguments">
|
||||
<list>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
@@ -32,6 +32,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiJavaModule;
|
||||
import com.intellij.psi.PsiRequiresStatement;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.kotlin.cli.common.arguments.InternalArgument;
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments;
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments;
|
||||
import org.jetbrains.kotlin.config.*;
|
||||
@@ -53,6 +54,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import static java.util.Collections.emptyList;
|
||||
@@ -308,6 +310,15 @@ public class ConfigureKotlinTest extends AbstractConfigureKotlinTest {
|
||||
);
|
||||
}
|
||||
|
||||
public void testProjectWithInternalArgs() {
|
||||
List<InternalArgument> internalArguments =
|
||||
KotlinCommonCompilerArgumentsHolder.Companion.getInstance(myProject).getSettings().getInternalArguments();
|
||||
assertEquals(
|
||||
0,
|
||||
internalArguments.size()
|
||||
);
|
||||
}
|
||||
|
||||
private void checkAddStdlibModule() {
|
||||
doTestOneJavaModule(KotlinWithLibraryConfigurator.FileState.COPY);
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiJavaModule;
|
||||
import com.intellij.psi.PsiRequiresStatement;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.kotlin.cli.common.arguments.InternalArgument;
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments;
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments;
|
||||
import org.jetbrains.kotlin.config.*;
|
||||
@@ -53,6 +54,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import static java.util.Collections.emptyList;
|
||||
@@ -308,6 +310,15 @@ public class ConfigureKotlinTest extends AbstractConfigureKotlinTest {
|
||||
);
|
||||
}
|
||||
|
||||
public void testProjectWithInternalArgs() {
|
||||
List<InternalArgument> internalArguments =
|
||||
KotlinCommonCompilerArgumentsHolder.Companion.getInstance(myProject).getSettings().getInternalArguments();
|
||||
assertEquals(
|
||||
0,
|
||||
internalArguments.size()
|
||||
);
|
||||
}
|
||||
|
||||
private void checkAddStdlibModule() {
|
||||
doTestOneJavaModule(KotlinWithLibraryConfigurator.FileState.COPY);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user