Compare commits

..

43 Commits

Author SHA1 Message Date
Mikhail Glukhikh
ede11fbdd0 Fix compilation in 161 branch (KtLightClassForLocalDeclaration) 2017-03-16 13:38:10 +03:00
Mikhail Glukhikh
823a371fa9 Fix compilation (AbstractAndroidFoldingTest) 2017-03-16 13:29:29 +03:00
Mikhail Glukhikh
ec68471f82 Revert startInWriteAction in quick-fix for EqualsOrHashCodeInspection (no such thing in 161) 2017-03-16 13:29:22 +03:00
mglukhikh
9f5e6f5f9c Quick doc provider test fix (2016.1 platform specific) 2017-03-16 13:29:16 +03:00
mglukhikh
6b9c4c1526 Debugger test fix (161 branch specific) 2017-03-16 13:29:09 +03:00
Mikhail Glukhikh
198fa9733a Revert commit d13c342 to fix KotlinConsoleKeeper in 161 / AS22 2017-03-16 13:29:03 +03:00
Mikhail Glukhikh
34de3283f7 Fix 161 branch IDE tests by removing "compatible build" 2017-03-16 13:28:56 +03:00
mglukhikh
28a2abea4e Fix compilation (KotlinLineMarkerProvider) 2017-03-16 13:28:50 +03:00
mglukhikh
61cb263af6 Fix compilation (KotlinSuspendCallLineMarkerProvider) 2017-03-16 13:28:43 +03:00
Ilya Chernikov
745665dfe7 Fix compilation 2017-03-16 13:28:37 +03:00
Yan Zhulanow
119f81cda3 Revert "Rename: Fix exceptions on moving file with facade class to another package"
This reverts commit f8513abfa1.

(cherry picked from commit e53914d)
2017-03-16 13:28:30 +03:00
Ilya Chernikov
622e8ceb8f Fix test code after KotlinTestUtils api changes 2017-03-16 13:28:23 +03:00
Ilya Chernikov
b862999394 Fix missing api problem by copying functions from newer IOUtil 2017-03-16 13:28:17 +03:00
Dmitry Jemerov
df76ad533e revert Snappy version 2017-03-16 13:28:10 +03:00
Dmitry Jemerov
97fd653235 Revert: Get rid of deprecated (as of IDEA 2016.2) method calls 2017-03-16 13:28:04 +03:00
Dmitry Jemerov
4a32239a88 Fix compilation of AS 2.2 linters against IJ 2016.1 2017-03-16 13:27:58 +03:00
Dmitry Jemerov
b7c35d4545 fix compilation under 161 2017-03-16 13:27:51 +03:00
Dmitry Jemerov
e24a20360a delete postfix template test from 161 branch 2017-03-16 13:27:44 +03:00
Dmitry Jemerov
8291f07464 compilation fix 2017-03-16 13:27:38 +03:00
Dmitry Jemerov
6bee3f8aff set plugins compatible build to a version which is compatible with the Kotlin plugin 2017-03-16 13:27:31 +03:00
Dmitry Jemerov
127e2cba50 Revert: Problem: fix thread leaking check fail on teamcity for ultimate rename tests 2017-03-16 13:27:25 +03:00
Dmitry Jemerov
e6130042a7 fix compilation against 161 (KotlinSteppingCommandProvider) 2017-03-16 13:27:18 +03:00
Dmitry Jemerov
bd49deef41 Revert "Add TransactionGuard application service to KotlinCoreEnvironment"
This reverts commit 3e0b79e40a.
2017-03-16 13:27:11 +03:00
Dmitry Jemerov
581ae0fd86 Revert "Push Down: Support moving members from Java to Kotlin class"
This reverts commit f9e877ce96.
2017-03-16 13:27:05 +03:00
Dmitry Jemerov
2bb965607c until build for 2016.1 version of the plugin 2017-03-16 13:26:58 +03:00
Dmitry Jemerov
a23fe719c8 do not register Kotlin postfix template provider 2017-03-16 13:26:51 +03:00
Dmitry Jemerov
6b74b8cf0b Revert: Fix goto implementation tests - deffered task should be executed 2017-03-16 13:26:45 +03:00
Dmitry Jemerov
a3fd53b843 Revert: Fix goto implementation tests - deffered task should be executed 2017-03-16 13:26:39 +03:00
Dmitry Jemerov
e1afe868e8 Revert: Test only: method signature changed 2017-03-16 13:26:32 +03:00
Dmitry Jemerov
97bb1a92e3 Revert: Problem: workaround thread leaking problem 2017-03-16 13:26:25 +03:00
Dmitry Jemerov
12d7461cdd Revert: Register TypeAnnotationModifier EP in environment for web demo converter 2017-03-16 13:26:19 +03:00
Dmitry Jemerov
233cbf1069 Revert: Tests only: codeCleanup() method signature was changed 2017-03-16 13:26:12 +03:00
Dmitry Jemerov
5988728417 Revert: Tests only: Constructor for XWatchesViewImpl was changed 2017-03-16 13:26:06 +03:00
Dmitry Jemerov
89c2b98629 Revert: Tests only: add new method in MockPsiManager.java 2017-03-16 13:25:59 +03:00
Dmitry Jemerov
d0dff3638c Revert: Tests only: reparseRange parameters changed 2017-03-16 13:25:52 +03:00
Dmitry Jemerov
cb3804c7e4 Revert: Tests only: implement new method 2017-03-16 13:25:46 +03:00
Dmitry Jemerov
97187fa5d2 Revert: Register TypeAnnotationModifier as extension point 2017-03-16 13:25:39 +03:00
Dmitry Jemerov
b336ad43c5 Revert: More write action requirement remove 2017-03-16 13:25:32 +03:00
Dmitry Jemerov
8c75426545 Revert: API Change: Implement new method isSuppressAll() 2017-03-16 13:25:26 +03:00
Dmitry Jemerov
06dbc029d8 Revert startInWriteAction() methods 2017-03-16 13:25:19 +03:00
Dmitry Jemerov
cf9369264e Revert: registerUnresolvedError is in base class in idea from br146 2017-03-16 13:25:13 +03:00
Dmitry Jemerov
7def1618a8 Revert: Patch ThreadTracker during Kotlin plugin init 2017-03-16 13:25:05 +03:00
Dmitry Jemerov
c0d6987a3a revert IDEA version to 2016.1.2 2017-03-16 13:24:59 +03:00
15592 changed files with 156093 additions and 344824 deletions

21
.gitignore vendored
View File

@@ -7,18 +7,17 @@
/gh-pages
/ideaSDK
/android-studio/sdk
/out
/tmp
out
tmp
workspace.xml
*.versionsBackup
/idea/testData/debugger/tinyApp/classes*
/jps-plugin/testData/kannotator
/ultimate/dependencies
/ultimate/ideaSDK
/ultimate/out
/ultimate/tmp
/js/js.translator/testData/**/out/
.gradle/
build/
!**/src/**/build
ultimate/.DS_Store
ultimate/.idea/shelf
ultimate/dependencies
ultimate/ideaSDK
ultimate/out
ultimate/tmp
ultimate/workspace.xml
ultimate/*.versionsBackup

2
.idea/ant.xml generated
View File

@@ -3,7 +3,7 @@
<component name="AntConfiguration">
<buildFile url="file://$PROJECT_DIR$/compiler/frontend/buildLexer.xml" />
<buildFile url="file://$PROJECT_DIR$/build.xml">
<antCommandLine value="-J-ea" />
<antCommandLine value="-J-XX:MaxPermSize=100m -J-ea" />
<maximumHeapSize value="1024" />
</buildFile>
<buildFile url="file://$PROJECT_DIR$/update_dependencies.xml" />

View File

@@ -60,19 +60,17 @@
<element id="module-output" name="backend.jvm" />
<element id="module-output" name="ir.psi2ir" />
<element id="module-output" name="annotation-based-compiler-plugins-ide-support" />
<element id="module-output" name="frontend.script" />
</element>
<element id="library" level="project" name="javax.inject" />
<element id="directory" name="jps">
<element id="artifact" artifact-name="KotlinJpsPlugin" />
</element>
<element id="library" level="project" name="markdown" />
<element id="archive" name="android-extensions-ide.jar">
<element id="archive" name="kotlin-android-extensions-plugin.jar">
<element id="module-output" name="android-extensions-idea" />
</element>
<element id="archive" name="android-extensions-compiler.jar">
<element id="archive" name="kotlin-android-extensions-compiler-plugin.jar">
<element id="module-output" name="android-extensions-compiler" />
<element id="module-output" name="android-extensions-runtime" />
</element>
<element id="archive" name="android-lint.jar">
<element id="module-output" name="uast-kotlin" />
@@ -93,7 +91,8 @@
<element id="archive" name="noarg-ide-plugin.jar">
<element id="module-output" name="noarg-ide" />
</element>
<element id="file-copy" path="$PROJECT_DIR$/dependencies/bootstrap-compiler/Kotlin/kotlinc/lib/kotlin-script-runtime.jar" />
<element id="file-copy" path="$PROJECT_DIR$/dist/kotlinc/lib/kotlin-daemon-client.jar" />
<element id="file-copy" path="$PROJECT_DIR$/dist/kotlinc/lib/kotlin-script-runtime.jar" />
<element id="archive" name="sam-with-receiver-compiler-plugin.jar">
<element id="module-output" name="sam-with-receiver-cli" />
</element>
@@ -104,9 +103,6 @@
<element id="module-output" name="kotlin-gradle-tooling" />
</element>
<element id="library" level="project" name="uast-java" />
<element id="library" level="project" name="kotlinx-coroutines-core" />
<element id="library" level="project" name="javaslang" />
<element id="library" level="project" name="kotlinx-coroutines-jdk8" />
</element>
<element id="directory" name="kotlinc">
<element id="dir-copy" path="$PROJECT_DIR$/dist/kotlinc" />

View File

@@ -1,6 +1,7 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<profile version="1.0" is_locked="false">
<option name="myName" value="idea.default" />
<option name="myLocal" value="false" />
<inspection_tool class="AbstractMethodCallInConstructor" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ArchaicSystemPropertyAccess" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AssignmentToForLoopParameter" enabled="true" level="WARNING" enabled_by_default="true">
@@ -235,6 +236,10 @@
<scope name="idea openapi" level="WARNING" enabled="true" />
<scope name="runtime.classes" level="ERROR" enabled="true" />
</inspection_tool>
<inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false">
<option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" />
<option name="loggerFactoryMethodName" value="getLogger,getLogger,getLog,getLogger" />
</inspection_tool>
<inspection_tool class="LoopToCallChain" enabled="false" level="INFO" enabled_by_default="false" />
<inspection_tool class="MethodMayBeStatic" enabled="true" level="WARNING" enabled_by_default="true">
<option name="m_onlyPrivateOrFinal" value="false" />
@@ -342,12 +347,11 @@
<constraint name="__context__" script="&quot;&quot;" within="" contains="" />
</searchConfiguration>
</inspection_tool>
<inspection_tool class="SameParameterValue" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="SetReplaceableByEnumSet" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="SetupCallsSuperSetup" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="SetupIsPublicVoidNoArg" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="SimplifiableIfStatement" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="Since15" enabled="false" level="ERROR" enabled_by_default="false">
<inspection_tool class="Since15" enabled="true" level="ERROR" enabled_by_default="true">
<scope name="IDEA Test Sources" level="ERROR" enabled="false" />
</inspection_tool>
<inspection_tool class="SocketResource" enabled="true" level="WARNING" enabled_by_default="true">

14
.idea/libraries/Rhino.xml generated Normal file
View File

@@ -0,0 +1,14 @@
<component name="libraryTable">
<library name="Rhino">
<ANNOTATIONS>
<root url="file://$PROJECT_DIR$/annotations" />
</ANNOTATIONS>
<CLASSES>
<root url="jar://$PROJECT_DIR$/dependencies/rhino-1.7.6.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/dependencies/rhino-1.7.6-sources.jar!/rhino1.7.6/src" />
</SOURCES>
</library>
</component>

View File

@@ -1,9 +0,0 @@
<component name="libraryTable">
<library name="android-layoutlib">
<CLASSES>
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/android/lib/layoutlib.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@@ -6,6 +6,7 @@
<CLASSES>
<root url="file://$PROJECT_DIR$/ideaSDK/plugins/android/lib" />
<root url="file://$PROJECT_DIR$/ideaSDK/plugins/android/lib/jps" />
<root url="jar://$PROJECT_DIR$/ideaSDK/lib/android-common.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>

View File

@@ -8,7 +8,7 @@
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/dependencies/asm-src.zip!/" />
<root url="jar://$PROJECT_DIR$/dependencies/asm5-src.zip!/" />
</SOURCES>
</library>
</component>

View File

@@ -3,6 +3,7 @@
<CLASSES>
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/coverage/lib/coverage.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/coverage/lib/jacocoant.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/coverage/lib/coverage-agent.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>

View File

@@ -4,11 +4,11 @@
<root url="file://$PROJECT_DIR$/annotations" />
</ANNOTATIONS>
<CLASSES>
<root url="jar://$PROJECT_DIR$/ideaSDK/lib/guava-19.0.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/lib/guava-17.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/dependencies/guava-19.0-sources.jar!/" />
<root url="jar://$PROJECT_DIR$/dependencies/guava-17.0-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@@ -9,9 +9,9 @@
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/dependencies/guava-19.0-sources.jar!/" />
<root url="jar://$PROJECT_DIR$/dependencies/guava-17.0-sources.jar!/" />
<root url="jar://$PROJECT_DIR$/dependencies/asm5-src.zip!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.jar!/" />
<root url="jar://$PROJECT_DIR$/dependencies/asm-src.zip!/" />
</SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/ideaSDK/lib" recursive="false" />
</library>

View File

@@ -5,27 +5,14 @@
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.jar!/" />
</ANNOTATIONS>
<CLASSES>
<root url="jar://$PROJECT_DIR$/ideaSDK/core/annotations.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/core/asm-all.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/core/guava-19.0.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/core/intellij-core.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/core/jdom.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/core/jna.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/core/log4j.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/core/picocontainer.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/core/snappy-in-java-0.5.1.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/core/trove4j.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/core/util.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/core/xpp3-1.1.4-min.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/core/xstream-1.4.8.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/lib/jsr305.jar!/" />
<root url="file://$PROJECT_DIR$/ideaSDK/core" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/dependencies/guava-19.0-sources.jar!/" />
<root url="jar://$PROJECT_DIR$/dependencies/guava-17.0-sources.jar!/" />
<root url="jar://$PROJECT_DIR$/dependencies/asm5-src.zip!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.jar!/" />
<root url="jar://$PROJECT_DIR$/dependencies/asm-src.zip!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/lib/jsr305.jar!/" />
</SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/ideaSDK/core" recursive="false" />
</library>
</component>

View File

@@ -0,0 +1,17 @@
<component name="libraryTable">
<library name="intellij-core-analysis">
<ANNOTATIONS>
<root url="file://$PROJECT_DIR$/annotations" />
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.jar!/" />
</ANNOTATIONS>
<CLASSES>
<root url="jar://$PROJECT_DIR$/ideaSDK/core-analysis/intellij-core-analysis.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/dependencies/asm5-src.zip!/" />
<root url="jar://$PROJECT_DIR$/dependencies/guava-17.0-sources.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@@ -1,11 +0,0 @@
<component name="libraryTable">
<library name="javaslang">
<CLASSES>
<root url="jar://$PROJECT_DIR$/dependencies/javaslang-2.0.6.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/dependencies/javaslang-2.0.6-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@@ -9,6 +9,17 @@
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.jar!/jps/antLayout/src" />
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.jar!/jps/jps-builders/src" />
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.jar!/jps/jps-builders/testSrc" />
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.jar!/jps/jps-launcher/src" />
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.jar!/jps/model-api/src" />
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.jar!/jps/model-impl/src" />
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.jar!/jps/model-impl/testSrc" />
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.jar!/jps/model-serialization/src" />
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.jar!/jps/model-serialization/testSrc" />
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.jar!/jps/plugin-system/src" />
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.jar!/jps/standalone-builder/src" />
</SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/ideaSDK/jps" recursive="false" />
</library>

View File

@@ -1,9 +0,0 @@
<component name="libraryTable">
<library name="json-org">
<CLASSES>
<root url="jar://$PROJECT_DIR$/dependencies/json-org.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@@ -4,9 +4,6 @@
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-reflect.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://$PROJECT_DIR$/core/reflection.jvm/src" />
<root url="file://$PROJECT_DIR$/core/descriptors.runtime/src" />
</SOURCES>
<SOURCES />
</library>
</component>

View File

@@ -1,13 +1,13 @@
<component name="libraryTable">
<library name="kotlin-test">
<CLASSES>
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-test.jar!/" />
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-test.jar!/"/>
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://$PROJECT_DIR$/libraries/kotlin.test/shared/src/main/kotlin" />
<root url="file://$PROJECT_DIR$/libraries/kotlin.test/shared/src/main/kotlin.jvm" />
<root url="file://$PROJECT_DIR$/libraries/kotlin.test/junit/src/main/kotlin" />
<root url="file://$PROJECT_DIR$/libraries/kotlin.test/common/src/main/kotlin" />
<root url="file://$PROJECT_DIR$/libraries/kotlin.test/jvm/src/main/kotlin" />
</SOURCES>
</library>
</component>

View File

@@ -1,11 +0,0 @@
<component name="libraryTable">
<library name="kotlinx-coroutines-core">
<CLASSES>
<root url="jar://$PROJECT_DIR$/dependencies/kotlinx-coroutines-core.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/dependencies/kotlinx-coroutines-core-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@@ -1,11 +0,0 @@
<component name="libraryTable">
<library name="kotlinx-coroutines-jdk8">
<CLASSES>
<root url="jar://$PROJECT_DIR$/dependencies/kotlinx-coroutines-jdk8.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/dependencies/kotlinx-coroutines-jdk8-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@@ -5,7 +5,6 @@
</ANNOTATIONS>
<CLASSES>
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/properties/lib/properties.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/properties/lib/resources_en.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>

View File

@@ -7,6 +7,11 @@
<root url="jar://$PROJECT_DIR$/ideaSDK/lib/trove4j.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
<SOURCES>
<root url="jar://$PROJECT_DIR$/ideaSDK/lib/src/trove4j_src.jar!/core/src" />
<root url="jar://$PROJECT_DIR$/ideaSDK/lib/src/trove4j_src.jar!/generated/src" />
<root url="jar://$PROJECT_DIR$/ideaSDK/lib/src/trove4j_src.jar!/test/src" />
<root url="jar://$PROJECT_DIR$/ideaSDK/lib/src/trove4j_src.jar!/util/src" />
</SOURCES>
</library>
</component>

3
.idea/misc.xml generated
View File

@@ -6,6 +6,7 @@
</properties>
</component>
<component name="EntryPointsManager">
<entry_points version="2.0" />
<list size="1">
<item index="0" class="java.lang.String" itemvalue="javax.inject.Inject" />
</list>
@@ -48,7 +49,7 @@
<component name="ProjectResources">
<default-html-doctype>http://www.w3.org/1999/xhtml</default-html-doctype>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" default="false" assert-keyword="true" jdk-15="true" project-jdk-name="1.6" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="SuppressABINotification">

17
.idea/modules.xml generated
View File

@@ -9,11 +9,11 @@
<module fileurl="file://$PROJECT_DIR$/plugins/android-extensions/android-extensions-compiler/android-extensions-compiler.iml" filepath="$PROJECT_DIR$/plugins/android-extensions/android-extensions-compiler/android-extensions-compiler.iml" group="plugins/android-extensions" />
<module fileurl="file://$PROJECT_DIR$/plugins/android-extensions/android-extensions-idea/android-extensions-idea.iml" filepath="$PROJECT_DIR$/plugins/android-extensions/android-extensions-idea/android-extensions-idea.iml" group="plugins/android-extensions" />
<module fileurl="file://$PROJECT_DIR$/plugins/android-extensions/android-extensions-jps/android-extensions-jps.iml" filepath="$PROJECT_DIR$/plugins/android-extensions/android-extensions-jps/android-extensions-jps.iml" group="plugins/android-extensions" />
<module fileurl="file://$PROJECT_DIR$/plugins/android-extensions/android-extensions-runtime/android-extensions-runtime.iml" filepath="$PROJECT_DIR$/plugins/android-extensions/android-extensions-runtime/android-extensions-runtime.iml" group="plugins/android-extensions" />
<module fileurl="file://$PROJECT_DIR$/android-studio/android-studio.iml" filepath="$PROJECT_DIR$/android-studio/android-studio.iml" group="ide" />
<module fileurl="file://$PROJECT_DIR$/compiler/android-tests/android-tests.iml" filepath="$PROJECT_DIR$/compiler/android-tests/android-tests.iml" group="compiler" />
<module fileurl="file://$PROJECT_DIR$/plugins/annotation-based-compiler-plugins-ide-support/annotation-based-compiler-plugins-ide-support.iml" filepath="$PROJECT_DIR$/plugins/annotation-based-compiler-plugins-ide-support/annotation-based-compiler-plugins-ide-support.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/plugins/annotation-collector/annotation-collector.iml" filepath="$PROJECT_DIR$/plugins/annotation-collector/annotation-collector.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/plugins/annotation-processing/annotation-processing.iml" filepath="$PROJECT_DIR$/plugins/annotation-processing/annotation-processing.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/ant/ant.iml" filepath="$PROJECT_DIR$/ant/ant.iml" />
<module fileurl="file://$PROJECT_DIR$/compiler/backend/backend.iml" filepath="$PROJECT_DIR$/compiler/backend/backend.iml" group="compiler/java" />
<module fileurl="file://$PROJECT_DIR$/compiler/backend-common/backend-common.iml" filepath="$PROJECT_DIR$/compiler/backend-common/backend-common.iml" group="compiler" />
@@ -41,7 +41,6 @@
<module fileurl="file://$PROJECT_DIR$/idea/formatter/formatter.iml" filepath="$PROJECT_DIR$/idea/formatter/formatter.iml" group="ide" />
<module fileurl="file://$PROJECT_DIR$/compiler/frontend/frontend.iml" filepath="$PROJECT_DIR$/compiler/frontend/frontend.iml" group="compiler" />
<module fileurl="file://$PROJECT_DIR$/compiler/frontend.java/frontend.java.iml" filepath="$PROJECT_DIR$/compiler/frontend.java/frontend.java.iml" group="compiler/java" />
<module fileurl="file://$PROJECT_DIR$/compiler/frontend.script/frontend.script.iml" filepath="$PROJECT_DIR$/compiler/frontend.script/frontend.script.iml" group="compiler" />
<module fileurl="file://$PROJECT_DIR$/generators/generators.iml" filepath="$PROJECT_DIR$/generators/generators.iml" group="infrastructure" />
<module fileurl="file://$PROJECT_DIR$/grammar/grammar.iml" filepath="$PROJECT_DIR$/grammar/grammar.iml" group="compiler" />
<module fileurl="file://$PROJECT_DIR$/idea/ide-common/ide-common.iml" filepath="$PROJECT_DIR$/idea/ide-common/ide-common.iml" group="ide" />
@@ -63,11 +62,10 @@
<module fileurl="file://$PROJECT_DIR$/compiler/ir/ir.psi2ir/ir.psi2ir.iml" filepath="$PROJECT_DIR$/compiler/ir/ir.psi2ir/ir.psi2ir.iml" group="compiler/ir" />
<module fileurl="file://$PROJECT_DIR$/compiler/ir/ir.tree/ir.tree.iml" filepath="$PROJECT_DIR$/compiler/ir/ir.tree/ir.tree.iml" group="compiler/ir" />
<module fileurl="file://$PROJECT_DIR$/j2k/j2k.iml" filepath="$PROJECT_DIR$/j2k/j2k.iml" group="j2k" />
<module fileurl="file://$PROJECT_DIR$/compiler/javac-wrapper/javac-wrapper.iml" filepath="$PROJECT_DIR$/compiler/javac-wrapper/javac-wrapper.iml" group="compiler" />
<module fileurl="file://$PROJECT_DIR$/plugins/java-model-wrappers/java-model-wrappers.iml" filepath="$PROJECT_DIR$/plugins/java-model-wrappers/java-model-wrappers.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/jps-plugin/jps-plugin.iml" filepath="$PROJECT_DIR$/jps-plugin/jps-plugin.iml" group="ide/jps" />
<module fileurl="file://$PROJECT_DIR$/jps-plugin/jps-tests/jps-tests.iml" filepath="$PROJECT_DIR$/jps-plugin/jps-tests/jps-tests.iml" group="ide/jps" />
<module fileurl="file://$PROJECT_DIR$/js/js.ast/js.ast.iml" filepath="$PROJECT_DIR$/js/js.ast/js.ast.iml" group="compiler/js" />
<module fileurl="file://$PROJECT_DIR$/js/js.dce/js.dce.iml" filepath="$PROJECT_DIR$/js/js.dce/js.dce.iml" group="compiler/js" />
<module fileurl="file://$PROJECT_DIR$/js/js.frontend/js.frontend.iml" filepath="$PROJECT_DIR$/js/js.frontend/js.frontend.iml" group="compiler/js" />
<module fileurl="file://$PROJECT_DIR$/js/js.inliner/js.inliner.iml" filepath="$PROJECT_DIR$/js/js.inliner/js.inliner.iml" group="compiler/js" />
<module fileurl="file://$PROJECT_DIR$/js/js.parser/js.parser.iml" filepath="$PROJECT_DIR$/js/js.parser/js.parser.iml" group="compiler/js" />
@@ -75,14 +73,14 @@
<module fileurl="file://$PROJECT_DIR$/js/js.tests/js.tests.iml" filepath="$PROJECT_DIR$/js/js.tests/js.tests.iml" group="compiler/js" />
<module fileurl="file://$PROJECT_DIR$/js/js.translator/js.translator.iml" filepath="$PROJECT_DIR$/js/js.translator/js.translator.iml" group="compiler/js" />
<module fileurl="file://$PROJECT_DIR$/jps-plugin/kannotator-jps-plugin-test/kannotator-jps-plugin-test.iml" filepath="$PROJECT_DIR$/jps-plugin/kannotator-jps-plugin-test/kannotator-jps-plugin-test.iml" group="ide/jps" />
<module fileurl="file://$PROJECT_DIR$/plugins/kapt3/kapt3.iml" filepath="$PROJECT_DIR$/plugins/kapt3/kapt3.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/plugins/kapt3/kapt3.iml" filepath="$PROJECT_DIR$/plugins/kapt3/kapt3.iml" />
<module fileurl="file://$PROJECT_DIR$/idea/kotlin-gradle-tooling/kotlin-gradle-tooling.iml" filepath="$PROJECT_DIR$/idea/kotlin-gradle-tooling/kotlin-gradle-tooling.iml" />
<module fileurl="file://$PROJECT_DIR$/compiler/light-classes/light-classes.iml" filepath="$PROJECT_DIR$/compiler/light-classes/light-classes.iml" group="compiler/java" />
<module fileurl="file://$PROJECT_DIR$/plugins/lint/lint-api/lint-api.iml" filepath="$PROJECT_DIR$/plugins/lint/lint-api/lint-api.iml" group="plugins/lint" />
<module fileurl="file://$PROJECT_DIR$/plugins/lint/lint-checks/lint-checks.iml" filepath="$PROJECT_DIR$/plugins/lint/lint-checks/lint-checks.iml" group="plugins/lint" />
<module fileurl="file://$PROJECT_DIR$/plugins/lint/lint-idea/lint-idea.iml" filepath="$PROJECT_DIR$/plugins/lint/lint-idea/lint-idea.iml" group="plugins/lint" />
<module fileurl="file://$PROJECT_DIR$/plugins/noarg/noarg-cli/noarg-cli.iml" filepath="$PROJECT_DIR$/plugins/noarg/noarg-cli/noarg-cli.iml" group="plugins/noarg" />
<module fileurl="file://$PROJECT_DIR$/plugins/noarg/noarg-ide/noarg-ide.iml" filepath="$PROJECT_DIR$/plugins/noarg/noarg-ide/noarg-ide.iml" group="plugins/noarg" />
<module fileurl="file://$PROJECT_DIR$/plugins/noarg/noarg-cli/noarg-cli.iml" filepath="$PROJECT_DIR$/plugins/noarg/noarg-cli/noarg-cli.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/noarg/noarg-ide/noarg-ide.iml" filepath="$PROJECT_DIR$/plugins/noarg/noarg-ide/noarg-ide.iml" />
<module fileurl="file://$PROJECT_DIR$/non-compiler-tests/non-compiler-tests.iml" filepath="$PROJECT_DIR$/non-compiler-tests/non-compiler-tests.iml" />
<module fileurl="file://$PROJECT_DIR$/compiler/plugin-api/plugin-api.iml" filepath="$PROJECT_DIR$/compiler/plugin-api/plugin-api.iml" group="compiler" />
<module fileurl="file://$PROJECT_DIR$/plugins/plugins-tests/plugins-tests.iml" filepath="$PROJECT_DIR$/plugins/plugins-tests/plugins-tests.iml" group="plugins" />
@@ -90,11 +88,10 @@
<module fileurl="file://$PROJECT_DIR$/core/reflection.jvm/reflection.jvm.iml" filepath="$PROJECT_DIR$/core/reflection.jvm/reflection.jvm.iml" group="core" />
<module fileurl="file://$PROJECT_DIR$/compiler/resolution/resolution.iml" filepath="$PROJECT_DIR$/compiler/resolution/resolution.iml" group="compiler" />
<module fileurl="file://$PROJECT_DIR$/core/runtime.jvm/runtime.jvm.iml" filepath="$PROJECT_DIR$/core/runtime.jvm/runtime.jvm.iml" group="core" />
<module fileurl="file://$PROJECT_DIR$/plugins/sam-with-receiver/sam-with-receiver-cli/sam-with-receiver-cli.iml" filepath="$PROJECT_DIR$/plugins/sam-with-receiver/sam-with-receiver-cli/sam-with-receiver-cli.iml" group="plugins/sam-with-receiver" />
<module fileurl="file://$PROJECT_DIR$/plugins/sam-with-receiver/sam-with-receiver-ide/sam-with-receiver-ide.iml" filepath="$PROJECT_DIR$/plugins/sam-with-receiver/sam-with-receiver-ide/sam-with-receiver-ide.iml" group="plugins/sam-with-receiver" />
<module fileurl="file://$PROJECT_DIR$/plugins/sam-with-receiver/sam-with-receiver-cli/sam-with-receiver-cli.iml" filepath="$PROJECT_DIR$/plugins/sam-with-receiver/sam-with-receiver-cli/sam-with-receiver-cli.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/sam-with-receiver/sam-with-receiver-ide/sam-with-receiver-ide.iml" filepath="$PROJECT_DIR$/plugins/sam-with-receiver/sam-with-receiver-ide/sam-with-receiver-ide.iml" />
<module fileurl="file://$PROJECT_DIR$/core/script.runtime/script.runtime.iml" filepath="$PROJECT_DIR$/core/script.runtime/script.runtime.iml" group="core" />
<module fileurl="file://$PROJECT_DIR$/compiler/serialization/serialization.iml" filepath="$PROJECT_DIR$/compiler/serialization/serialization.iml" group="compiler" />
<module fileurl="file://$PROJECT_DIR$/plugins/source-sections/source-sections-compiler/source-sections-compiler.iml" filepath="$PROJECT_DIR$/plugins/source-sections/source-sections-compiler/source-sections-compiler.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/compiler/tests-common/tests-common.iml" filepath="$PROJECT_DIR$/compiler/tests-common/tests-common.iml" group="compiler" />
<module fileurl="file://$PROJECT_DIR$/compiler/tests-ir-jvm/tests-ir-jvm.iml" filepath="$PROJECT_DIR$/compiler/tests-ir-jvm/tests-ir-jvm.iml" group="compiler/ir" />
<module fileurl="file://$PROJECT_DIR$/plugins/uast-kotlin/uast-kotlin.iml" filepath="$PROJECT_DIR$/plugins/uast-kotlin/uast-kotlin.iml" group="plugins/lint" />

View File

@@ -13,7 +13,7 @@
<option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="package" />
<option name="VM_PARAMETERS" value="-ea -XX:+HeapDumpOnOutOfMemoryError -Xmx1250m -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=128m -Djna.nosys=true" />
<option name="VM_PARAMETERS" value="-ea -XX:+HeapDumpOnOutOfMemoryError -Xmx1250m -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=64m -Djna.nosys=true" />
<option name="PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ENV_VARIABLES" />

View File

@@ -13,7 +13,7 @@
<option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="package" />
<option name="VM_PARAMETERS" value="-ea -XX:+HeapDumpOnOutOfMemoryError -Xmx1024m -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=128m -Djna.nosys=true" />
<option name="VM_PARAMETERS" value="-ea -XX:+HeapDumpOnOutOfMemoryError -Xmx900m -XX:MaxPermSize=320m -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=64m -Djna.nosys=true" />
<option name="PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ENV_VARIABLES" />

View File

@@ -13,7 +13,7 @@
<option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="package" />
<option name="VM_PARAMETERS" value="-ea -XX:+HeapDumpOnOutOfMemoryError -Xmx900m -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=128m -Djna.nosys=true -Dkotlin.colors.enabled=false" />
<option name="VM_PARAMETERS" value="-ea -XX:+HeapDumpOnOutOfMemoryError -Xmx1100m -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=128m -Djna.nosys=true" />
<option name="PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ENV_VARIABLES" />

View File

@@ -8,7 +8,7 @@
<option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="package" />
<option name="VM_PARAMETERS" value="-Xmx1250m -XX:ReservedCodeCacheSize=128m -XX:+HeapDumpOnOutOfMemoryError -ea -Didea.is.internal=true -Didea.debug.mode=true -Dapple.laf.useScreenMenuBar=true -Dapple.awt.graphics.UseQuartz=true -Dsun.io.useCanonCaches=false -Dplugin.path=$PROJECT_DIR$/out/artifacts/Kotlin -Djna.nosys=true" />
<option name="VM_PARAMETERS" value="-Xmx1250m -XX:ReservedCodeCacheSize=64m -XX:+HeapDumpOnOutOfMemoryError -ea -Didea.is.internal=true -Didea.debug.mode=true -Dapple.laf.useScreenMenuBar=true -Dapple.awt.graphics.UseQuartz=true -Dsun.io.useCanonCaches=false -Dplugin.path=$PROJECT_DIR$/out/artifacts/Kotlin -Djna.nosys=true" />
<option name="PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ENV_VARIABLES" />

View File

@@ -3,7 +3,7 @@
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="android-tests" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<option name="ALTERNATIVE_JRE_PATH" value="1.8" />
<option name="ALTERNATIVE_JRE_PATH" value="1.6" />
<option name="PACKAGE_NAME" value="org.jetbrains.kotlin.android.tests" />
<option name="MAIN_CLASS_NAME" value="org.jetbrains.kotlin.android.tests.AndroidRunner" />
<option name="METHOD_NAME" value="" />

View File

@@ -1,28 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Codegen Tests with JVM target 1.6 on JDK 1.6" type="JUnit" factoryName="JUnit">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea">
<pattern>
<option name="PATTERN" value="org.jetbrains.kotlin.codegen.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<module name="compiler-tests" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<option name="ALTERNATIVE_JRE_PATH" value="1.8" />
<option name="PACKAGE_NAME" value="org.jetbrains.kotlin.codegen" />
<option name="MAIN_CLASS_NAME" value="org.jetbrains.kotlin.codegen.CodegenJdkCommonTestSuite" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="class" />
<option name="VM_PARAMETERS" value="-Dkotlin.test.default.jvm.target=1.6 -Dkotlin.test.box.in.separate.process.port=5100 -Dkotlin.test.java.compilation.target=1.6 -ea -XX:+HeapDumpOnOutOfMemoryError -Xmx1024m -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=128m -Djna.nosys=true" />
<option name="PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<envs />
<patterns />
<method />
</configuration>
</component>

View File

@@ -1,28 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Codegen Tests with JVM target 1.6 on JDK 9" type="JUnit" factoryName="JUnit">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea">
<pattern>
<option name="PATTERN" value="org.jetbrains.kotlin.codegen.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<module name="compiler-tests" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<option name="ALTERNATIVE_JRE_PATH" value="9-ea" />
<option name="PACKAGE_NAME" value="org.jetbrains.kotlin.codegen" />
<option name="MAIN_CLASS_NAME" value="org.jetbrains.kotlin.codegen.CodegenJdkCommonTestSuite" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="class" />
<option name="VM_PARAMETERS" value="-Dkotlin.test.default.jvm.target=1.6 -ea -XX:+HeapDumpOnOutOfMemoryError -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=128m -Djna.nosys=true --add-opens java.desktop/javax.swing=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED" />
<option name="PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<envs />
<patterns />
<method />
</configuration>
</component>

View File

@@ -1,28 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Codegen Tests with JVM target 1.8 on JDK 1.8" type="JUnit" factoryName="JUnit">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea">
<pattern>
<option name="PATTERN" value="org.jetbrains.kotlin.codegen.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<module name="compiler-tests" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<option name="ALTERNATIVE_JRE_PATH" value="1.8" />
<option name="PACKAGE_NAME" value="org.jetbrains.kotlin.codegen" />
<option name="MAIN_CLASS_NAME" value="org.jetbrains.kotlin.codegen.CodegenJdkCommonTestSuite" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="class" />
<option name="VM_PARAMETERS" value="-Dkotlin.test.default.jvm.target=1.8 -ea -XX:+HeapDumpOnOutOfMemoryError -Xmx1024m -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=128m -Djna.nosys=true" />
<option name="PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<envs />
<patterns />
<method />
</configuration>
</component>

View File

@@ -1,28 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Codegen Tests with JVM target 1.8 on JDK 9" type="JUnit" factoryName="JUnit">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea">
<pattern>
<option name="PATTERN" value="org.jetbrains.kotlin.codegen.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<module name="compiler-tests" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<option name="ALTERNATIVE_JRE_PATH" value="9-ea" />
<option name="PACKAGE_NAME" value="org.jetbrains.kotlin.codegen" />
<option name="MAIN_CLASS_NAME" value="org.jetbrains.kotlin.codegen.CodegenJdkCommonTestSuite" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="class" />
<option name="VM_PARAMETERS" value="-Dkotlin.test.default.jvm.target=1.8 -ea -XX:+HeapDumpOnOutOfMemoryError -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=128m -Djna.nosys=true --add-opens java.desktop/javax.swing=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED" />
<option name="PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<envs />
<patterns />
<method />
</configuration>
</component>

View File

@@ -1,28 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Codegen Tests with JVM target 9 on JDK 9 " type="JUnit" factoryName="JUnit">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea">
<pattern>
<option name="PATTERN" value="org.jetbrains.kotlin.codegen.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<module name="compiler-tests" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<option name="ALTERNATIVE_JRE_PATH" value="9-ea" />
<option name="PACKAGE_NAME" value="org.jetbrains.kotlin.codegen" />
<option name="MAIN_CLASS_NAME" value="org.jetbrains.kotlin.codegen.CodegenJdkCommonTestSuite" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="class" />
<option name="VM_PARAMETERS" value="-Dkotlin.test.default.jvm.target=1.8 -Dkotlin.test.substitute.bytecode.1.8.to.1.9=true -ea -XX:+HeapDumpOnOutOfMemoryError -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=128m -Djna.nosys=true --add-opens java.desktop/javax.swing=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED" />
<option name="PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<envs />
<patterns />
<method />
</configuration>
</component>

View File

@@ -13,7 +13,7 @@
<option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="package" />
<option name="VM_PARAMETERS" value="-ea -XX:+HeapDumpOnOutOfMemoryError -Xmx1024m -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=128m -Djna.nosys=true -Dkotlin.colors.enabled=false" />
<option name="VM_PARAMETERS" value="-ea -XX:+HeapDumpOnOutOfMemoryError -Xmx700m -XX:MaxPermSize=300m -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=64m -Djna.nosys=true" />
<option name="PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ENV_VARIABLES" />

View File

@@ -1,9 +1,8 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="IDEA" type="Application" factoryName="Application" singleton="true">
<log_file path="$PROJECT_DIR$/ideaSDK/system-idea/log/idea.log" checked="true" skipped="true" show_all="false" alias="idea.log" />
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" value="com.intellij.idea.Main" />
<option name="VM_PARAMETERS" value="-Xmx1250m -XX:ReservedCodeCacheSize=128m -XX:+HeapDumpOnOutOfMemoryError -ea -Didea.is.internal=true -Didea.debug.mode=true -Didea.system.path=../system-idea -Didea.config.path=../config-idea -Dapple.laf.useScreenMenuBar=true -Dapple.awt.graphics.UseQuartz=true -Dsun.io.useCanonCaches=false -Dplugin.path=$PROJECT_DIR$/out/artifacts/Kotlin -Dkotlin.internal.mode.enabled=true -Didea.additional.classpath=../idea-kotlin-runtime/kotlin-runtime.jar,../idea-kotlin-runtime/kotlin-reflect.jar" />
<option name="VM_PARAMETERS" value="-Xmx1250m -XX:ReservedCodeCacheSize=64m -XX:+HeapDumpOnOutOfMemoryError -ea -Didea.is.internal=true -Didea.debug.mode=true -Didea.system.path=../system-idea -Didea.config.path=../config-idea -Dapple.laf.useScreenMenuBar=true -Dapple.awt.graphics.UseQuartz=true -Dsun.io.useCanonCaches=false -Dplugin.path=$PROJECT_DIR$/out/artifacts/Kotlin -Dkotlin.internal.mode.enabled=true -Didea.additional.classpath=../idea-kotlin-runtime/kotlin-runtime.jar,../idea-kotlin-runtime/kotlin-reflect.jar" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/ideaSDK/bin" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />

View File

@@ -1,9 +1,8 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="IDEA (No ProcessCanceledException)" type="Application" factoryName="Application" singleton="true">
<log_file path="$PROJECT_DIR$/ideaSDK/system-idea/log/idea.log" checked="true" skipped="true" show_all="false" alias="idea.log" />
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" value="com.intellij.idea.Main" />
<option name="VM_PARAMETERS" value="-Xmx1250m -XX:ReservedCodeCacheSize=128m -XX:+HeapDumpOnOutOfMemoryError -ea -Didea.is.internal=true -Didea.debug.mode=true -Didea.system.path=../system-idea -Didea.config.path=../config-idea -Dapple.laf.useScreenMenuBar=true -Dapple.awt.graphics.UseQuartz=true -Dsun.io.useCanonCaches=false -Dplugin.path=$PROJECT_DIR$/out/artifacts/Kotlin -Didea.ProcessCanceledException=disabled -Dkotlin.internal.mode.enabled=true -Didea.additional.classpath=../idea-kotlin-runtime/kotlin-runtime.jar,../idea-kotlin-runtime/kotlin-reflect.jar" />
<option name="VM_PARAMETERS" value="-Xmx1250m -XX:ReservedCodeCacheSize=64m -XX:+HeapDumpOnOutOfMemoryError -ea -Didea.is.internal=true -Didea.debug.mode=true -Didea.system.path=../system-idea -Didea.config.path=../config-idea -Dapple.laf.useScreenMenuBar=true -Dapple.awt.graphics.UseQuartz=true -Dsun.io.useCanonCaches=false -Dplugin.path=$PROJECT_DIR$/out/artifacts/Kotlin -Didea.ProcessCanceledException=disabled -Dkotlin.internal.mode.enabled=true -Didea.additional.classpath=../idea-kotlin-runtime/kotlin-runtime.jar,../idea-kotlin-runtime/kotlin-reflect.jar" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/ideaSDK/bin" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />

View File

@@ -13,7 +13,7 @@
<option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="package" />
<option name="VM_PARAMETERS" value="-ea -XX:+HeapDumpOnOutOfMemoryError -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=128m -Djna.nosys=true -Dkotlin.colors.enabled=false" />
<option name="VM_PARAMETERS" value="-ea -XX:+HeapDumpOnOutOfMemoryError -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=64m -Djna.nosys=true" />
<option name="PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ENV_VARIABLES" />

View File

@@ -13,7 +13,7 @@
<option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="package" />
<option name="VM_PARAMETERS" value="-ea -XX:+HeapDumpOnOutOfMemoryError -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=128m -Djna.nosys=true --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.desktop/javax.swing=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED" />
<option name="VM_PARAMETERS" value="-ea -XX:+HeapDumpOnOutOfMemoryError -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=64m -Djna.nosys=true --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.desktop/javax.swing=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED" />
<option name="PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ENV_VARIABLES" />

View File

@@ -8,7 +8,7 @@
<option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="package" />
<option name="VM_PARAMETERS" value="-ea -XX:+HeapDumpOnOutOfMemoryError -Xmx1250m -XX:+UseCodeCacheFlushing -Djna.nosys=true -Dkotlin.js.skipMinificationTest=false" />
<option name="VM_PARAMETERS" value="-ea -XX:+HeapDumpOnOutOfMemoryError -Xmx1250m -XX:+UseCodeCacheFlushing -Djna.nosys=true" />
<option name="PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ENV_VARIABLES" />

File diff suppressed because it is too large Load Diff

View File

@@ -14,73 +14,37 @@
<excludeFolder url="file://$MODULE_DIR$/ideaSDK/system" />
<excludeFolder url="file://$MODULE_DIR$/ideaSDK/system-idea" />
<excludeFolder url="file://$MODULE_DIR$/libraries/.idea" />
<excludeFolder url="file://$MODULE_DIR$/libraries/build" />
<excludeFolder url="file://$MODULE_DIR$/libraries/examples/annotation-processor-example/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/examples/browser-example-with-library/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/docs/apidoc/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/docs/website/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/examples/browser-example/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/examples/js-example/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/examples/kotlin-gradle-subplugin-example/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/examples/kotlin-java-example/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/examples/kotlin-js-library-example/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/examples/kotlin-jsr223-daemon-local-eval-example/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/examples/kotlin-jsr223-local-example/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/kotlin.test/common/build" />
<excludeFolder url="file://$MODULE_DIR$/libraries/kotlin.test/js/build" />
<excludeFolder url="file://$MODULE_DIR$/libraries/kotlin.test/js/it/build" />
<excludeFolder url="file://$MODULE_DIR$/libraries/kotlin.test/js/it/node_modules" />
<excludeFolder url="file://$MODULE_DIR$/libraries/kotlin.test/junit/build" />
<excludeFolder url="file://$MODULE_DIR$/libraries/kotlin.test/jvm/build" />
<excludeFolder url="file://$MODULE_DIR$/libraries/stdlib/build" />
<excludeFolder url="file://$MODULE_DIR$/libraries/stdlib/common/build" />
<excludeFolder url="file://$MODULE_DIR$/libraries/stdlib/jre7/build" />
<excludeFolder url="file://$MODULE_DIR$/libraries/stdlib/jre8/build" />
<excludeFolder url="file://$MODULE_DIR$/libraries/stdlib/js/build" />
<excludeFolder url="file://$MODULE_DIR$/libraries/stdlib/js/node_modules" />
<excludeFolder url="file://$MODULE_DIR$/libraries/kotlin-jdbc/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/kotlin-swing/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/kunit/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/stdlib/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/stdlib/validator/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/.idea" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/binary-compatibility-validator/build" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/gradle-tools/build" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/idl2k/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-allopen/build" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-allopen/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-android-extensions/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-annotation-processing-maven/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-annotation-processing/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-build-common-test/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-compiler-client-embeddable-test/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-compiler-client-embeddable/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-compiler-embeddable/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-compiler-runner/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kdoc-maven-plugin/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kdoc/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-compiler/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-daemon-client/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-gradle-plugin-api/build" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-gradle-plugin-api/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-gradle-plugin-integration-tests/build" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-gradle-plugin-integration-tests/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-gradle-plugin/build" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-gradle-plugin-core/local-repo" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-gradle-plugin-core/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-gradle-plugin-test/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-gradle-plugin/local-repo" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-gradle-plugin/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-maven-allopen/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-maven-noarg/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-js-library/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-js-tests-junit/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-js-tests/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-maven-plugin-test/local-repo" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-maven-plugin-test/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-maven-plugin/local-repo" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-maven-plugin/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-noarg/build" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-noarg/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-osgi-bundle/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-reflect/build" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-sam-with-receiver-compiler-plugin/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-script-util/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-source-sections-compiler-plugin/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-stdlib-gen/build" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/maven-archetypes/kotlin-archetype-js/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/maven-archetypes/kotlin-archetype-jvm/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/native-platform/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/protobuf-lite/build" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/runtime/build" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/script-runtime/build" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-reflect/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/kotlin-stdlib-gen/target" />
<excludeFolder url="file://$MODULE_DIR$/libraries/tools/runtime/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
</module>

106
ReadMe.md
View File

@@ -1,4 +1,4 @@
<a href="http://slack.kotlinlang.org/"><img src="http://slack.kotlinlang.org/badge.svg" height="20"></a>
<a href="https://kotlinslackin.herokuapp.com"><img src="https://kotlinslackin.herokuapp.com/badge.svg" height="20"></a>
[![TeamCity (simple build status)](https://img.shields.io/teamcity/http/teamcity.jetbrains.com/s/bt345.svg)](https://teamcity.jetbrains.com/viewType.html?buildTypeId=bt345&branch_Kotlin=%3Cdefault%3E&tab=buildTypeStatusDiv)
[![Maven Central](https://img.shields.io/maven-central/v/org.jetbrains.kotlin/kotlin-maven-plugin.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.jetbrains.kotlin%22)
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0)
@@ -9,13 +9,13 @@ Welcome to [Kotlin](https://kotlinlang.org/)! Some handy links:
* [Kotlin Site](https://kotlinlang.org/)
* [Getting Started Guide](https://kotlinlang.org/docs/tutorials/getting-started.html)
* [Try Kotlin](https://try.kotlinlang.org/)
* [Try Kotlin](http://try.kotlinlang.org/)
* [Kotlin Standard Library](https://kotlinlang.org/api/latest/jvm/stdlib/index.html)
* [Issue Tracker](https://youtrack.jetbrains.com/issues/KT)
* [Forum](https://discuss.kotlinlang.org/)
* [Kotlin Blog](https://blog.jetbrains.com/kotlin/)
* [Follow Kotlin on Twitter](https://twitter.com/kotlin)
* [Public Slack channel](http://slack.kotlinlang.org/)
* [Public Slack channel](https://kotlinslackin.herokuapp.com/)
* [TeamCity CI build](https://teamcity.jetbrains.com/project.html?tab=projectOverview&projectId=Kotlin)
## Editing Kotlin
@@ -32,7 +32,7 @@ In order to build Kotlin distribution you need to have:
- JDK 1.6, 1.7 and 1.8
- Setup environment variables as following:
JAVA_HOME="path to JDK 1.8"
JAVA_HOME="path to JDK 1.6"
JDK_16="path to JDK 1.6"
JDK_17="path to JDK 1.7"
JDK_18="path to JDK 1.8"
@@ -45,49 +45,65 @@ To build this project, first time you try to build you need to run this:
which will setup the dependencies on
* `intellij-core` is a part of command line compiler and contains only necessary APIs.
* `idea-full` is a full blown IntelliJ IDEA Community Edition to be used in the plugin module.
* intellij-core: is a part of command line compiler and contains only necessary APIs.
* idea-full: is a full blown IntelliJ IDEA Community Edition to be used in former plugin module.
Then, you need to run
ant -f build.xml
which will build the binaries of the compiler and put them into the `dist` directory. You may need to increase the **heap size** for Ant using
which will build the binaries of the compiler and put them into the 'dist' directory. You may need to increase the **heap size** for Ant using
[ANT_OPTS](https://web.liferay.com/community/wiki/-/wiki/Main/Ant+opts).
**OPTIONAL:** Maven artifact distribution is built separately, go into `libraries` directory after building the compiler and run:
**OPTIONAL:** Maven distribution is built separately, run
./gradlew build install
mvn install
mvn package
> Note: on Windows type `gradlew` without the leading `./`
Refer to [libraries/ReadMe.md](libraries/ReadMe.md) for details.
from 'libraries' directory after building the compiler. Refer to [libraries/ReadMe.md](libraries/ReadMe.md) for details.
## Working with the project in IntelliJ IDEA
The [root kotlin project](https://github.com/JetBrains/kotlin) already has an IntelliJ IDEA project, you can just open it in IntelliJ IDEA.
You may need to set the Project SDK (`File -> Project Structure -> Project`).
You may also need to add `tools.jar` to your SDK:
File -> Project Structure -> SDKs -> <Your JDK> -> Classpath
You may need to set the Project SDK (File -> Project Structure -> Project).
You may also need to add `tools.jar` to your SDK: File -> Project Structure -> SDKs -> <Your JDK> -> Classpath,
then choose the `tools.jar` in the JDK's `lib` directory.
If you are not dealing with Android, you may need to disable the Android Plugin in order to compile the project.
### <a name="installing-plugin"></a> Installing the latest Kotlin plugin
Since Kotlin project contains code written in Kotlin itself, you will also need a Kotlin plugin to build the project in IntelliJ IDEA.
To keep the plugin version in sync with the rest of the team and our [Continuous Integration server](https://teamcity.jetbrains.com/project.html?projectId=Kotlin&tab=projectOverview)
you should install the according to the [instructions below](#plugin-for-contributors).
You probably want to have locally the same version of plugin that build server is using for building.
If you want to have an IntelliJ IDEA installation without the Kotlin plugin which is separate to your default IntelliJ IDEA installation which has the Kotlin
plugin [see this document](https://devnet.jetbrains.com/docs/DOC-181) which describes how to have multiple IntelliJ IDEA installations using different configurations and plugin directories.
From this root project there are Run/Debug Configurations for running IDEA or the Compiler Tests for example; so if you want to try out the latest and greatest IDEA plugin
* VCS -> Git -> Pull
* Run IntelliJ IDEA
* a child IntelliJ IDEA with the Kotlin plugin will then startup
* you can now open the [kotlin libraries project](https://github.com/JetBrains/kotlin/tree/master/libraries) to then work with the various kotlin libraries etc.
### <a name="pre-built-plugin"></a>Using a pre-built Kotlin IntelliJ IDEA plugin
There are several options for getting Kotlin plugin. A stable version can be obtained as any other plugin for IntelliJ IDEA:
Preferences -> Plugins -> Install JetBrains plugin... -> Search with "Kotlin" string
The most recent version of the plugin can be downloaded from the
[IDEA Plugin and Tests CI build](https://teamcity.jetbrains.com/project.html?projectId=project67&tab=projectOverview). When downloading is
finished you can install it with "Install plugin from disk...":
Preferences -> Plugins -> Install plugin from disk...
You can now open any Kotlin based projects.
<a name="plugin-for-contributors"></a>
**Note for contributors**: If you are planning to contribute to Kotlin project you probably want to have locally the same version of plugin that build server is using for building.
As this version is constantly moving, the best way to always be updated is to let IntelliJ IDEA notify you when it is time to renew your plugin.
To keep the plugin version in sync with the rest of the team and our [Continuous Integration server](https://teamcity.jetbrains.com/project.html?projectId=Kotlin&tab=projectOverview)
you should setup IDEA to update the plugin directly from the build server.
Open:
Open
Preferences -> Plugins -> Browse Repositories -> Manage Repositories...
@@ -97,22 +113,10 @@ and add the following URL to your repositories:
Then update the list of plugins in "Browse Repositories", you'll see two versions of Kotlin there, install the one with the higher version number.
If you want to keep an IntelliJ IDEA installation with that bleeding edge Kotlin plugin for working Kotlin project sources only separate to your default IntelliJ IDEA installation with the stable Kotlin
plugin [see this document](https://intellij-support.jetbrains.com/hc/en-us/articles/207240985-Changing-IDE-default-directories-used-for-config-plugins-and-caches-storage), which describes how to have multiple IntelliJ IDEA installations using different configurations and plugin directories.
### Compiling and running
From this root project there are Run/Debug Configurations for running IDEA or the Compiler Tests for example; so if you want to try out the latest and greatest IDEA plugin
* VCS -> Git -> Pull
* Run IntelliJ IDEA
* a child IntelliJ IDEA with the Kotlin plugin will then startup
* you can now open the [kotlin libraries project](https://github.com/JetBrains/kotlin/tree/master/libraries) to then work with the various kotlin libraries etc.
# Contributing
We love contributions! There's [lots to do on Kotlin](https://youtrack.jetbrains.com/issues/KT) and on the
[standard library](https://youtrack.jetbrains.com/issues/KT?q=%23Kotlin%20%23Unresolved%20and%20(links:%20KT-2554,%20KT-4089%20or%20%23Libraries)) so why not chat with us
[standard library](https://youtrack.jetbrains.com/issues/KT?q=Subtask+of%3A+KT-2554+%23Unresolved) so why not chat with us
about what you're interested in doing? Please join the #kontributors channel in [our Slack chat](http://kotlinslackin.herokuapp.com/)
and let us know about your plans.
@@ -124,8 +128,8 @@ A nice gentle way to contribute would be to review the [standard library docs](h
and find classes or functions which are not documented very well and submit a patch.
In particular it'd be great if all functions included a nice example of how to use it such as for the
[`hashMapOf()`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/hash-map-of.html) function.
This is implemented using the [`@sample`](https://github.com/JetBrains/kotlin/blob/1.1.0/libraries/stdlib/src/kotlin/collections/Maps.kt#L91)
[`hashMapOf()`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/hash-map-of.html) function.
This is implemented using the [`@sample`](https://github.com/JetBrains/kotlin/blob/master/libraries/stdlib/src/kotlin/collections/Maps.kt#L64)
macro to include code from a test function. The benefits of this approach are twofold; First, the API's documentation is improved via beneficial examples that help new users and second, the code coverage is increased.
Also the [JavaScript translation](https://github.com/JetBrains/kotlin/blob/master/js/ReadMe.md) could really use your help. See the [JavaScript contribution section](https://github.com/JetBrains/kotlin/blob/master/js/ReadMe.md) for more details.
@@ -135,8 +139,8 @@ Also the [JavaScript translation](https://github.com/JetBrains/kotlin/blob/maste
The Kotlin compiler is written in Java and Kotlin (we gradually migrate more and more of it to pure Kotlin). So the easiest way to work on the compiler or IntelliJ IDEA plugin is
* download a recent [IntelliJ IDEA](https://www.jetbrains.com/idea/?fromMenu#chooseYourEdition), Community edition is enough
* [install the Kotlin plugin](#installing-plugin)
* download a clean [IDEA 15 EAP build](https://confluence.jetbrains.com/display/IDEADEV/IDEA+15+EAP)
* [install the Kotlin plugin](#pre-built-plugin)
* open the [root kotlin project](https://github.com/JetBrains/kotlin) in IDEA (opening the kotlin directory)
You can now run the various Run/Debug Configurations such as
@@ -148,19 +152,16 @@ You can now run the various Run/Debug Configurations such as
## If you want to work on the Kotlin libraries
* download a recent [IntelliJ IDEA](https://www.jetbrains.com/idea/?fromMenu#chooseYourEdition), Community edition is enough
* [install the Kotlin plugin](#installing-plugin)
* download a clean [IDEA 15 EAP build](https://confluence.jetbrains.com/display/IDEADEV/IDEA+15+EAP)
* [install the Kotlin plugin](#pre-built-plugin)
* open the [kotlin libraries project](https://github.com/JetBrains/kotlin/tree/master/libraries)
Then build via
cd libraries
./gradlew build install
mvn install
> Note: on Windows type `gradlew` without the leading `./`
Some of the code in the standard library is created by generating code from templates. See the [README](libraries/stdlib/ReadMe.md) in the stdlib section for how run the code generator. The existing templates can be used as examples for creating new ones.
Some of the code in the standard library is created by generating code from templates. See the [README](https://github.com/JetBrains/kotlin/blob/master/libraries/stdlib/ReadMe.md) in the stdlib section for how run the code generator. The existing templates can be used as examples for creating new ones.
## Submitting patches
@@ -168,15 +169,12 @@ The best way to submit a patch is to [fork the project on github](https://help.g
[pull request](https://help.github.com/articles/creating-a-pull-request/) via [github](https://github.com).
If you create your own fork, it might help to enable rebase by default
when you pull by executing
``` bash
git config --global pull.rebase true
```
This will avoid your local repo having too many merge commits
when you pull by executing `git config --global pull.rebase
true`. This will avoid your local repo having too many merge commits
which will help keep your pull request simple and easy to apply.
## Commit comments
If you include in your comment this text (where KT-1234 is the Issue ID in the [Issue Tracker](https://youtrack.jetbrains.com/issues/KT)), the issue will get automatically marked as fixed.
If you include in your comment this text (where KT-1234 is the Issue ID in the [Issue Tracker](https://youtrack.jetbrains.com/issues/KT), the issue will get automatically marked as fixed.
#KT-1234 Fixed

View File

@@ -17,7 +17,6 @@
<property name="compiler.version.java.bk" value="${version_substitute_dir}/KotlinCompilerVersion.java.bk"/>
<property name="compiler.version.java.versioned" value="${compiler.version.java}.versioned"/>
<property name="compiler.version.number" value="${build.number}"/>
<property name="compiler.ant.fork.jvmargs" value="-Xmx1024m"/>
<property name="plugin.zip" value="${artifact.output.path}/kotlin-plugin-${build.number}.zip"/>
@@ -151,8 +150,8 @@
<print-file-size-statistic path="${kotlin-home}/lib" file-name="kotlin-stdlib-js.jar"/>
<print-file-size-statistic path="${js.stdlib.output.dir}" file-name="kotlin.js"/>
<print-file-size-statistic path="${js.stdlib.output.dir}" file-name="kotlin-test.js"/>
<print-file-size-statistic path="${basedir}/libraries/stdlib/js/build/classes/main" file-name="kotlin.meta.js"/>
<print-file-size-statistic path="${js.stdlib.output.dir}" file-name="${compiled.stdlib.meta.js}"/>
<print-file-size-statistic path="${js.stdlib.output.dir}" file-name="${compiled.stdlib.js}"/>
</target>
<target name="post_build" depends="zipArtifacts, revertTemplateFiles, printStatistics, remove_internal_artifacts, dont_remove_internal_artifacts"/>

View File

@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.ant
import org.apache.tools.ant.BuildException
import org.apache.tools.ant.MagicNames
import org.apache.tools.ant.Project.MSG_ERR
import org.apache.tools.ant.Project.MSG_WARN
import org.apache.tools.ant.taskdefs.compilers.Javac13
import org.apache.tools.ant.taskdefs.condition.AntVersion
@@ -45,11 +44,6 @@ class KotlinCompilerAdapter : Javac13() {
@Throws(BuildException::class)
override fun execute(): Boolean {
if (javac.isForkedJavac) {
javac.log("<withKotlin> task does not yet support the fork mode", MSG_ERR)
return false
}
val javac = javac
checkAntVersion()

View File

@@ -14,6 +14,5 @@
<orderEntry type="module" module-name="util" />
<orderEntry type="module" module-name="tests-common" scope="TEST" />
<orderEntry type="library" scope="TEST" name="idea-full" level="project" />
<orderEntry type="library" name="kotlin-reflect" level="project" />
</component>
</module>

View File

@@ -61,11 +61,11 @@ data class JvmBuildMetaInfo(
fun JvmBuildMetaInfo(args: CommonCompilerArguments): JvmBuildMetaInfo =
JvmBuildMetaInfo(isEAP = KotlinCompilerVersion.isPreRelease(),
compilerBuildVersion = KotlinCompilerVersion.VERSION,
languageVersionString = args.languageVersion ?: LanguageVersion.LATEST_STABLE.versionString,
apiVersionString = args.apiVersion ?: ApiVersion.LATEST_STABLE.versionString,
coroutinesEnable = args.coroutinesState == CommonCompilerArguments.ENABLE,
coroutinesWarn = args.coroutinesState == CommonCompilerArguments.WARN,
coroutinesError = args.coroutinesState == CommonCompilerArguments.ERROR,
languageVersionString = args.languageVersion ?: LanguageVersion.LATEST.versionString,
apiVersionString = args.apiVersion ?: ApiVersion.LATEST.versionString,
coroutinesEnable = args.coroutinesEnable,
coroutinesWarn = args.coroutinesWarn,
coroutinesError = args.coroutinesError,
multiplatformEnable = args.multiPlatform,
metadataVersionMajor = JvmMetadataVersion.INSTANCE.major,
metadataVersionMinor = JvmMetadataVersion.INSTANCE.minor,

View File

@@ -16,33 +16,32 @@
package org.jetbrains.kotlin.compilerRunner;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.Function;
import com.intellij.util.containers.ComparatorUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.cli.common.arguments.Argument;
import org.jetbrains.kotlin.cli.common.arguments.CommonToolArguments;
import org.jetbrains.kotlin.cli.common.arguments.ParseCommandLineArgumentsKt;
import org.jetbrains.kotlin.utils.StringsKt;
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments;
import org.jetbrains.kotlin.cli.common.parser.com.sampullara.cli.Argument;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
public class ArgumentUtils {
private ArgumentUtils() {}
@NotNull
public static List<String> convertArgumentsToStringList(@NotNull CommonToolArguments arguments)
public static List<String> convertArgumentsToStringList(@NotNull CommonCompilerArguments arguments)
throws InstantiationException, IllegalAccessException {
List<String> result = new ArrayList<>();
List<String> result = new ArrayList<String>();
convertArgumentsToStringList(arguments, arguments.getClass().newInstance(), arguments.getClass(), result);
result.addAll(arguments.freeArgs);
return result;
}
private static void convertArgumentsToStringList(
@NotNull CommonToolArguments arguments,
@NotNull CommonToolArguments defaultArguments,
@NotNull CommonCompilerArguments arguments,
@NotNull CommonCompilerArguments defaultArguments,
@NotNull Class<?> clazz,
@NotNull List<String> result
) throws IllegalAccessException, InstantiationException {
@@ -61,26 +60,27 @@ public class ArgumentUtils {
continue;
}
if (value == null || Objects.equals(value, defaultValue)) continue;
if (ComparatorUtil.equalsNullable(value, defaultValue)) continue;
String name = getAlias(argument);
if (name == null) {
name = getName(argument, field);
}
Class<?> fieldType = field.getType();
if (fieldType.isArray()) {
Object[] values = (Object[]) value;
if (values.length == 0) continue;
value = StringsKt.join(Arrays.asList(values), ",");
//noinspection unchecked
value = StringUtil.join(values, Function.TO_STRING, argument.delimiter());
}
result.add(argument.value());
result.add(argument.prefix() + name);
if (fieldType == boolean.class || fieldType == Boolean.class) continue;
if (ParseCommandLineArgumentsKt.isAdvanced(argument)) {
result.set(result.size() - 1, argument.value() + "=" + value.toString());
}
else {
result.add(value.toString());
}
result.add(value.toString());
}
Class<?> superClazz = clazz.getSuperclass();
@@ -88,4 +88,14 @@ public class ArgumentUtils {
convertArgumentsToStringList(arguments, defaultArguments, superClazz, result);
}
}
private static String getAlias(Argument argument) {
String alias = argument.alias();
return alias.isEmpty() ? null : alias;
}
private static String getName(Argument argument, Field field) {
String name = argument.value();
return name.isEmpty() ? field.getName() : name;
}
}

View File

@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.config.IncrementalCompilation
import org.jetbrains.kotlin.load.java.JvmBytecodeBinaryVersion
import org.jetbrains.kotlin.load.kotlin.JvmMetadataVersion
import java.io.File
import java.io.IOException
private val NORMAL_VERSION = 8
private val EXPERIMENTAL_VERSION = 4
@@ -41,16 +40,8 @@ class CacheVersion(
) {
private val isEnabled by lazy(isEnabled)
private val actualVersion: Int?
get() = try {
versionFile.readText().toInt()
}
catch (e: NumberFormatException) {
null
}
catch (e: IOException) {
null
}
private val actualVersion: Int
get() = versionFile.readText().toInt()
private val expectedVersion: Int
get() {

View File

@@ -27,7 +27,7 @@ interface ICReporter {
fun reportCompileIteration(sourceFiles: Collection<File>, exitCode: ExitCode) {}
fun pathsAsString(files: Iterable<File>): String =
files.joinToString { it.canonicalPath }
files.map { it.canonicalPath }.joinToString()
fun pathsAsString(vararg files: File): String =
pathsAsString(files.toList())

View File

@@ -197,7 +197,7 @@ open class LookupStorage(private val targetDataDir: File) : BasicMapsOwner() {
}
class LookupTrackerImpl(private val delegate: LookupTracker) : LookupTracker {
val lookups = MultiMap.createSet<LookupSymbol, String>()
val lookups = MultiMap<LookupSymbol, String>()
val pathInterner = StringInterner()
private val interner = StringInterner()

View File

@@ -56,12 +56,6 @@ open class ProtoCompareGenerated(val oldNameResolver: NameResolver, val newNameR
if (!checkStringEquals(old.getExtension(JvmProtoBuf.packageModuleName), new.getExtension(JvmProtoBuf.packageModuleName))) return false
}
if (old.getExtensionCount(JvmProtoBuf.packageLocalVariable) != new.getExtensionCount(JvmProtoBuf.packageLocalVariable)) return false
for(i in 0..old.getExtensionCount(JvmProtoBuf.packageLocalVariable) - 1) {
if (!checkEquals(old.getExtension(JvmProtoBuf.packageLocalVariable, i), new.getExtension(JvmProtoBuf.packageLocalVariable, i))) return false
}
return true
}
enum class ProtoBufPackageKind {
@@ -70,8 +64,7 @@ open class ProtoCompareGenerated(val oldNameResolver: NameResolver, val newNameR
TYPE_ALIAS_LIST,
TYPE_TABLE,
SINCE_KOTLIN_INFO_TABLE,
PACKAGE_MODULE_NAME,
PACKAGE_LOCAL_VARIABLE_LIST
PACKAGE_MODULE_NAME
}
fun difference(old: ProtoBuf.Package, new: ProtoBuf.Package): EnumSet<ProtoBufPackageKind> {
@@ -98,12 +91,6 @@ open class ProtoCompareGenerated(val oldNameResolver: NameResolver, val newNameR
if (!checkStringEquals(old.getExtension(JvmProtoBuf.packageModuleName), new.getExtension(JvmProtoBuf.packageModuleName))) result.add(ProtoBufPackageKind.PACKAGE_MODULE_NAME)
}
if (old.getExtensionCount(JvmProtoBuf.packageLocalVariable) != new.getExtensionCount(JvmProtoBuf.packageLocalVariable)) result.add(ProtoBufPackageKind.PACKAGE_LOCAL_VARIABLE_LIST)
for(i in 0..old.getExtensionCount(JvmProtoBuf.packageLocalVariable) - 1) {
if (!checkEquals(old.getExtension(JvmProtoBuf.packageLocalVariable, i), new.getExtension(JvmProtoBuf.packageLocalVariable, i))) result.add(ProtoBufPackageKind.PACKAGE_LOCAL_VARIABLE_LIST)
}
return result
}
@@ -160,12 +147,6 @@ open class ProtoCompareGenerated(val oldNameResolver: NameResolver, val newNameR
if (!checkStringEquals(old.getExtension(JvmProtoBuf.classModuleName), new.getExtension(JvmProtoBuf.classModuleName))) return false
}
if (old.getExtensionCount(JvmProtoBuf.classLocalVariable) != new.getExtensionCount(JvmProtoBuf.classLocalVariable)) return false
for(i in 0..old.getExtensionCount(JvmProtoBuf.classLocalVariable) - 1) {
if (!checkEquals(old.getExtension(JvmProtoBuf.classLocalVariable, i), new.getExtension(JvmProtoBuf.classLocalVariable, i))) return false
}
return true
}
enum class ProtoBufClassKind {
@@ -185,8 +166,7 @@ open class ProtoCompareGenerated(val oldNameResolver: NameResolver, val newNameR
TYPE_TABLE,
SINCE_KOTLIN_INFO,
SINCE_KOTLIN_INFO_TABLE,
CLASS_MODULE_NAME,
CLASS_LOCAL_VARIABLE_LIST
CLASS_MODULE_NAME
}
fun difference(old: ProtoBuf.Class, new: ProtoBuf.Class): EnumSet<ProtoBufClassKind> {
@@ -244,12 +224,6 @@ open class ProtoCompareGenerated(val oldNameResolver: NameResolver, val newNameR
if (!checkStringEquals(old.getExtension(JvmProtoBuf.classModuleName), new.getExtension(JvmProtoBuf.classModuleName))) result.add(ProtoBufClassKind.CLASS_MODULE_NAME)
}
if (old.getExtensionCount(JvmProtoBuf.classLocalVariable) != new.getExtensionCount(JvmProtoBuf.classLocalVariable)) result.add(ProtoBufClassKind.CLASS_LOCAL_VARIABLE_LIST)
for(i in 0..old.getExtensionCount(JvmProtoBuf.classLocalVariable) - 1) {
if (!checkEquals(old.getExtension(JvmProtoBuf.classLocalVariable, i), new.getExtension(JvmProtoBuf.classLocalVariable, i))) result.add(ProtoBufClassKind.CLASS_LOCAL_VARIABLE_LIST)
}
return result
}
@@ -1079,10 +1053,6 @@ fun ProtoBuf.Package.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int)
hashCode = 31 * hashCode + stringIndexes(getExtension(JvmProtoBuf.packageModuleName))
}
for(i in 0..getExtensionCount(JvmProtoBuf.packageLocalVariable) - 1) {
hashCode = 31 * hashCode + getExtension(JvmProtoBuf.packageLocalVariable, i).hashCode(stringIndexes, fqNameIndexes)
}
return hashCode
}
@@ -1155,10 +1125,6 @@ fun ProtoBuf.Class.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) ->
hashCode = 31 * hashCode + stringIndexes(getExtension(JvmProtoBuf.classModuleName))
}
for(i in 0..getExtensionCount(JvmProtoBuf.classLocalVariable) - 1) {
hashCode = 31 * hashCode + getExtension(JvmProtoBuf.classLocalVariable, i).hashCode(stringIndexes, fqNameIndexes)
}
return hashCode
}

View File

@@ -19,6 +19,7 @@
package org.jetbrains.kotlin.incremental
import com.intellij.ide.highlighter.JavaFileType
import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.util.text.StringUtil
import org.jetbrains.kotlin.build.GeneratedFile
@@ -41,7 +42,9 @@ import java.util.*
fun Iterable<File>.javaSourceRoots(roots: Iterable<File>): Iterable<File> =
filter(File::isJavaFile).mapNotNull { findSrcDirRoot(it, roots) }
filter(File::isJavaFile)
.map { findSrcDirRoot(it, roots) }
.filterNotNull()
fun makeModuleFile(name: String, isTest: Boolean, outputDir: File, sourcesToCompile: Iterable<File>, javaSourceRoots: Iterable<File>, classpath: Iterable<File>, friendDirs: Iterable<File>): File {
val builder = KotlinModuleXmlBuilder()
@@ -51,7 +54,6 @@ fun makeModuleFile(name: String, isTest: Boolean, outputDir: File, sourcesToComp
sourcesToCompile,
javaSourceRoots.map { JvmSourceRoot(it) },
classpath,
null,
"java-production",
isTest,
// this excludes the output directories from the class path, to be removed for true incremental compilation
@@ -164,13 +166,12 @@ fun<Target> OutputItemsCollectorImpl.generatedFiles(
return outputs.map { outputItem ->
val target =
outputItem.sourceFiles.firstOrNull()?.let { sourceToTarget[it] } ?:
targets.singleOrNull { getOutputDir(it)?.let { outputItem.outputFile.startsWith(it) } ?: false } ?:
targets.filter { getOutputDir(it)?.let { outputItem.outputFile.startsWith(it) } ?: false }.singleOrNull() ?:
representativeTarget
when (outputItem.outputFile.extension) {
"class" -> GeneratedJvmClass(target, outputItem.sourceFiles, outputItem.outputFile)
else -> GeneratedFile(target, outputItem.sourceFiles, outputItem.outputFile)
}
if (outputItem.outputFile.name.endsWith(".class"))
GeneratedJvmClass(target, outputItem.sourceFiles, outputItem.outputFile)
else
GeneratedFile(target, outputItem.sourceFiles, outputItem.outputFile)
}
}

View File

@@ -186,8 +186,7 @@ private class DifferenceCalculatorForClass(oldData: ProtoMapValue, newData: Prot
}
for (kind in diff) {
@Suppress("UNUSED_VARIABLE") // To make this 'when' exhaustive
val unused: Any = when (kind!!) {
when (kind!!) {
ProtoBufClassKind.COMPANION_OBJECT_NAME -> {
if (oldProto.hasCompanionObjectName()) oldProto.companionObjectName.oldToNames()
if (newProto.hasCompanionObjectName()) newProto.companionObjectName.newToNames()
@@ -204,7 +203,10 @@ private class DifferenceCalculatorForClass(oldData: ProtoMapValue, newData: Prot
}
ProtoBufClassKind.CONSTRUCTOR_LIST -> {
val differentNonPrivateConstructors = calcDifferenceForNonPrivateMembers(ProtoBuf.Class::getConstructorList)
isClassAffected = isClassAffected || differentNonPrivateConstructors.isNotEmpty()
if (differentNonPrivateConstructors.isNotEmpty()) {
isClassAffected = true
}
}
ProtoBufClassKind.FUNCTION_LIST ->
names.addAll(calcDifferenceForNonPrivateMembers(ProtoBuf.Class::getFunctionList))
@@ -236,9 +238,6 @@ private class DifferenceCalculatorForClass(oldData: ProtoMapValue, newData: Prot
ProtoBufClassKind.CLASS_MODULE_NAME -> {
// TODO
}
ProtoBufClassKind.CLASS_LOCAL_VARIABLE_LIST -> {
// Not affected, local variables are not accessible outside of a file
}
}
}
@@ -268,8 +267,7 @@ private class DifferenceCalculatorForPackageFacade(oldData: ProtoMapValue, newDa
}
for (kind in diff) {
@Suppress("UNUSED_VARIABLE") // To make this 'when' exhaustive
val unused: Any = when (kind!!) {
when (kind!!) {
ProtoBufPackageKind.FUNCTION_LIST ->
names.addAll(calcDifferenceForNonPrivateMembers(ProtoBuf.Package::getFunctionList))
ProtoBufPackageKind.PROPERTY_LIST ->
@@ -281,9 +279,7 @@ private class DifferenceCalculatorForPackageFacade(oldData: ProtoMapValue, newDa
ProtoBufPackageKind.PACKAGE_MODULE_NAME -> {
// TODO
}
ProtoBufPackageKind.PACKAGE_LOCAL_VARIABLE_LIST -> {
// Not affected, local variables are not accessible outside of a file
}
else -> throw IllegalArgumentException("Unsupported kind: $kind")
}
}

View File

@@ -42,5 +42,5 @@ open class BasicMapsOwner {
maps.forEach { it.flush(memoryCachesOnly) }
}
@TestOnly fun dump(): String = maps.joinToString("\n\n") { it.dump() }
@TestOnly fun dump(): String = maps.map { it.dump() }.joinToString("\n\n")
}

View File

@@ -39,7 +39,6 @@ class KotlinModuleXmlBuilder {
sourceFiles: Iterable<File>,
javaSourceRoots: Iterable<JvmSourceRoot>,
classpathRoots: Iterable<File>,
modularJdkRoot: File?,
targetTypeId: String,
isTests: Boolean,
directoriesToFilterOut: Set<File>,
@@ -65,10 +64,6 @@ class KotlinModuleXmlBuilder {
processJavaSourceRoots(javaSourceRoots)
processClasspath(classpathRoots, directoriesToFilterOut)
if (modularJdkRoot != null) {
p.println("<", MODULAR_JDK_ROOT, " ", PATH, "=\"", getEscapedPath(modularJdkRoot), "\"/>")
}
closeTag(p, MODULE)
return this
}

View File

@@ -17,8 +17,10 @@
package org.jetbrains.kotlin.build
import junit.framework.TestCase
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
import org.jetbrains.kotlin.config.KotlinCompilerVersion
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.load.kotlin.JvmMetadataVersion
import org.junit.Assert.assertNotEquals
import org.junit.Test
@@ -62,14 +64,14 @@ class JvmBuildMetaInfoTest : TestCase() {
@Test
fun testEquals() {
val args1 = K2JVMCompilerArguments()
args1.coroutinesState = CommonCompilerArguments.ENABLE
args1.coroutinesEnable = true
val info1 = JvmBuildMetaInfo(args1)
val args2 = K2JVMCompilerArguments()
args2.coroutinesState = CommonCompilerArguments.WARN
args2.coroutinesEnable = false
val info2 = JvmBuildMetaInfo(args2)
assertNotEquals(info1, info2)
assertEquals(info1, info2.copy(coroutinesEnable = true, coroutinesWarn = false))
assertEquals(info1, info2.copy(coroutinesEnable = true))
}
}
}

View File

@@ -9743,7 +9743,6 @@ public final class DebugProtoBuf {
*ClassKind
*isInner
*isData
*isHeader
* </pre>
*/
boolean hasFlags();
@@ -9757,7 +9756,6 @@ public final class DebugProtoBuf {
*ClassKind
*isInner
*isData
*isHeader
* </pre>
*/
int getFlags();
@@ -10465,7 +10463,6 @@ public final class DebugProtoBuf {
*ClassKind
*isInner
*isData
*isHeader
* </pre>
*/
public boolean hasFlags() {
@@ -10481,7 +10478,6 @@ public final class DebugProtoBuf {
*ClassKind
*isInner
*isData
*isHeader
* </pre>
*/
public int getFlags() {
@@ -11826,7 +11822,6 @@ public final class DebugProtoBuf {
*ClassKind
*isInner
*isData
*isHeader
* </pre>
*/
public boolean hasFlags() {
@@ -11842,7 +11837,6 @@ public final class DebugProtoBuf {
*ClassKind
*isInner
*isData
*isHeader
* </pre>
*/
public int getFlags() {
@@ -11858,7 +11852,6 @@ public final class DebugProtoBuf {
*ClassKind
*isInner
*isData
*isHeader
* </pre>
*/
public Builder setFlags(int value) {
@@ -11877,7 +11870,6 @@ public final class DebugProtoBuf {
*ClassKind
*isInner
*isData
*isHeader
* </pre>
*/
public Builder clearFlags() {
@@ -17733,8 +17725,6 @@ public final class DebugProtoBuf {
*isInline
*isTailrec
*isExternal
*isSuspend
*isHeader
* </pre>
*/
boolean hasFlags();
@@ -17751,8 +17741,6 @@ public final class DebugProtoBuf {
*isInline
*isTailrec
*isExternal
*isSuspend
*isHeader
* </pre>
*/
int getFlags();
@@ -18096,8 +18084,6 @@ public final class DebugProtoBuf {
*isInline
*isTailrec
*isExternal
*isSuspend
*isHeader
* </pre>
*/
public boolean hasFlags() {
@@ -18116,8 +18102,6 @@ public final class DebugProtoBuf {
*isInline
*isTailrec
*isExternal
*isSuspend
*isHeader
* </pre>
*/
public int getFlags() {
@@ -18929,8 +18913,6 @@ public final class DebugProtoBuf {
*isInline
*isTailrec
*isExternal
*isSuspend
*isHeader
* </pre>
*/
public boolean hasFlags() {
@@ -18949,8 +18931,6 @@ public final class DebugProtoBuf {
*isInline
*isTailrec
*isExternal
*isSuspend
*isHeader
* </pre>
*/
public int getFlags() {
@@ -18969,8 +18949,6 @@ public final class DebugProtoBuf {
*isInline
*isTailrec
*isExternal
*isSuspend
*isHeader
* </pre>
*/
public Builder setFlags(int value) {
@@ -18992,8 +18970,6 @@ public final class DebugProtoBuf {
*isInline
*isTailrec
*isExternal
*isSuspend
*isHeader
* </pre>
*/
public Builder clearFlags() {
@@ -20039,7 +20015,6 @@ public final class DebugProtoBuf {
*hasConstant
*isExternal
*isDelegated
*isHeader
* </pre>
*/
boolean hasFlags();
@@ -20059,7 +20034,6 @@ public final class DebugProtoBuf {
*hasConstant
*isExternal
*isDelegated
*isHeader
* </pre>
*/
int getFlags();
@@ -20417,7 +20391,6 @@ public final class DebugProtoBuf {
*hasConstant
*isExternal
*isDelegated
*isHeader
* </pre>
*/
public boolean hasFlags() {
@@ -20439,7 +20412,6 @@ public final class DebugProtoBuf {
*hasConstant
*isExternal
*isDelegated
*isHeader
* </pre>
*/
public int getFlags() {
@@ -21239,7 +21211,6 @@ public final class DebugProtoBuf {
*hasConstant
*isExternal
*isDelegated
*isHeader
* </pre>
*/
public boolean hasFlags() {
@@ -21261,7 +21232,6 @@ public final class DebugProtoBuf {
*hasConstant
*isExternal
*isDelegated
*isHeader
* </pre>
*/
public int getFlags() {
@@ -21283,7 +21253,6 @@ public final class DebugProtoBuf {
*hasConstant
*isExternal
*isDelegated
*isHeader
* </pre>
*/
public Builder setFlags(int value) {
@@ -21308,7 +21277,6 @@ public final class DebugProtoBuf {
*hasConstant
*isExternal
*isDelegated
*isHeader
* </pre>
*/
public Builder clearFlags() {
@@ -22202,8 +22170,8 @@ public final class DebugProtoBuf {
* <code>optional int32 flags = 1 [default = 0];</code>
*
* <pre>
*hasAnnotations
*declaresDefault
*hasAnnotations
*isCrossinline
*isNoinline
* </pre>
@@ -22213,8 +22181,8 @@ public final class DebugProtoBuf {
* <code>optional int32 flags = 1 [default = 0];</code>
*
* <pre>
*hasAnnotations
*declaresDefault
*hasAnnotations
*isCrossinline
*isNoinline
* </pre>
@@ -22419,8 +22387,8 @@ public final class DebugProtoBuf {
* <code>optional int32 flags = 1 [default = 0];</code>
*
* <pre>
*hasAnnotations
*declaresDefault
*hasAnnotations
*isCrossinline
*isNoinline
* </pre>
@@ -22432,8 +22400,8 @@ public final class DebugProtoBuf {
* <code>optional int32 flags = 1 [default = 0];</code>
*
* <pre>
*hasAnnotations
*declaresDefault
*hasAnnotations
*isCrossinline
*isNoinline
* </pre>
@@ -22913,8 +22881,8 @@ public final class DebugProtoBuf {
* <code>optional int32 flags = 1 [default = 0];</code>
*
* <pre>
*hasAnnotations
*declaresDefault
*hasAnnotations
*isCrossinline
*isNoinline
* </pre>
@@ -22926,8 +22894,8 @@ public final class DebugProtoBuf {
* <code>optional int32 flags = 1 [default = 0];</code>
*
* <pre>
*hasAnnotations
*declaresDefault
*hasAnnotations
*isCrossinline
*isNoinline
* </pre>
@@ -22939,8 +22907,8 @@ public final class DebugProtoBuf {
* <code>optional int32 flags = 1 [default = 0];</code>
*
* <pre>
*hasAnnotations
*declaresDefault
*hasAnnotations
*isCrossinline
*isNoinline
* </pre>
@@ -22955,8 +22923,8 @@ public final class DebugProtoBuf {
* <code>optional int32 flags = 1 [default = 0];</code>
*
* <pre>
*hasAnnotations
*declaresDefault
*hasAnnotations
*isCrossinline
*isNoinline
* </pre>

View File

@@ -14,9 +14,7 @@ public final class DebugJvmProtoBuf {
registry.add(org.jetbrains.kotlin.serialization.jvm.DebugJvmProtoBuf.isRaw);
registry.add(org.jetbrains.kotlin.serialization.jvm.DebugJvmProtoBuf.typeParameterAnnotation);
registry.add(org.jetbrains.kotlin.serialization.jvm.DebugJvmProtoBuf.classModuleName);
registry.add(org.jetbrains.kotlin.serialization.jvm.DebugJvmProtoBuf.classLocalVariable);
registry.add(org.jetbrains.kotlin.serialization.jvm.DebugJvmProtoBuf.packageModuleName);
registry.add(org.jetbrains.kotlin.serialization.jvm.DebugJvmProtoBuf.packageLocalVariable);
}
public interface StringTableTypesOrBuilder extends
// @@protoc_insertion_point(interface_extends:org.jetbrains.kotlin.serialization.jvm.StringTableTypes)
@@ -4588,17 +4586,6 @@ public final class DebugJvmProtoBuf {
.newFileScopedGeneratedExtension(
java.lang.Integer.class,
null);
public static final int CLASS_LOCAL_VARIABLE_FIELD_NUMBER = 102;
/**
* <code>extend .org.jetbrains.kotlin.serialization.Class { ... }</code>
*/
public static final
org.jetbrains.kotlin.protobuf.GeneratedMessage.GeneratedExtension<
org.jetbrains.kotlin.serialization.DebugProtoBuf.Class,
java.util.List<org.jetbrains.kotlin.serialization.DebugProtoBuf.Property>> classLocalVariable = org.jetbrains.kotlin.protobuf.GeneratedMessage
.newFileScopedGeneratedExtension(
org.jetbrains.kotlin.serialization.DebugProtoBuf.Property.class,
org.jetbrains.kotlin.serialization.DebugProtoBuf.Property.getDefaultInstance());
public static final int PACKAGE_MODULE_NAME_FIELD_NUMBER = 101;
/**
* <code>extend .org.jetbrains.kotlin.serialization.Package { ... }</code>
@@ -4610,17 +4597,6 @@ public final class DebugJvmProtoBuf {
.newFileScopedGeneratedExtension(
java.lang.Integer.class,
null);
public static final int PACKAGE_LOCAL_VARIABLE_FIELD_NUMBER = 102;
/**
* <code>extend .org.jetbrains.kotlin.serialization.Package { ... }</code>
*/
public static final
org.jetbrains.kotlin.protobuf.GeneratedMessage.GeneratedExtension<
org.jetbrains.kotlin.serialization.DebugProtoBuf.Package,
java.util.List<org.jetbrains.kotlin.serialization.DebugProtoBuf.Property>> packageLocalVariable = org.jetbrains.kotlin.protobuf.GeneratedMessage
.newFileScopedGeneratedExtension(
org.jetbrains.kotlin.serialization.DebugProtoBuf.Property.class,
org.jetbrains.kotlin.serialization.DebugProtoBuf.Property.getDefaultInstance());
private static final org.jetbrains.kotlin.protobuf.Descriptors.Descriptor
internal_static_org_jetbrains_kotlin_serialization_jvm_StringTableTypes_descriptor;
private static
@@ -4702,15 +4678,9 @@ public final class DebugJvmProtoBuf {
"g.jetbrains.kotlin.serialization.Annotat" +
"ion:J\n\021class_module_name\022).org.jetbrains" +
".kotlin.serialization.Class\030e \001(\005B\004\230\265\030\001:" +
"u\n\024class_local_variable\022).org.jetbrains." +
"kotlin.serialization.Class\030f \003(\0132,.org.j" +
"etbrains.kotlin.serialization.Property:N",
"\n\023package_module_name\022+.org.jetbrains.ko" +
"tlin.serialization.Package\030e \001(\005B\004\230\265\030\001:y" +
"\n\026package_local_variable\022+.org.jetbrains" +
".kotlin.serialization.Package\030f \003(\0132,.or" +
"g.jetbrains.kotlin.serialization.Propert" +
"yB\022B\020DebugJvmProtoBuf"
"N\n\023package_module_name\022+.org.jetbrains.k" +
"otlin.serialization.Package\030e \001(\005B\004\230\265\030\001B" +
"\022B\020DebugJvmProtoBuf"
};
org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
@@ -4763,9 +4733,7 @@ public final class DebugJvmProtoBuf {
isRaw.internalInit(descriptor.getExtensions().get(4));
typeParameterAnnotation.internalInit(descriptor.getExtensions().get(5));
classModuleName.internalInit(descriptor.getExtensions().get(6));
classLocalVariable.internalInit(descriptor.getExtensions().get(7));
packageModuleName.internalInit(descriptor.getExtensions().get(8));
packageLocalVariable.internalInit(descriptor.getExtensions().get(9));
packageModuleName.internalInit(descriptor.getExtensions().get(7));
org.jetbrains.kotlin.protobuf.ExtensionRegistry registry =
org.jetbrains.kotlin.protobuf.ExtensionRegistry.newInstance();
registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.stringIdInTable);

744
build.xml

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,18 @@
# This file is used to override default values used by the Ant build system.
#
# This file must be checked into Version Control Systems, as it is
# integral to the build system of your project.
# This file is only used by the Ant script.
# You can use this to override default values such as
# 'source.dir' for the location of your java source folder and
# 'out.dir' for the location of your output folder.
# You can also use it define how the release builds are signed by declaring
# the following properties:
# 'key.store' for the location of your keystore and
# 'key.alias' for the name of the key to use.
# The password will be asked during the build when you use the 'release' target.
tested.project.dir=tested-module

View File

@@ -64,27 +64,12 @@ android {
dexOptions {
dexInProcess false
javaMaxHeapSize "300m"
javaMaxHeapSize "700m"
//default is 4 and Total Memory = maxProcessCount * javaMaxHeapSize
maxProcessCount 1
additionalParameters "--debug"
maxProcessCount 2
}
}
task jarTestFolders() {
println "Jar folders..."
new File("${projectDir}/libs/").listFiles().each { File file ->
if (file.isDirectory()) {
println "Jar '${file.name}' folder..."
ant.jar(basedir: "libs/${file.name}/", destfile: "libs/" + file.name + ".jar")
}
}
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn jarTestFolders
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile 'junit:junit:4.12'

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="testsForAndroid" default="help" basedir="">
<property file="local.properties"/>
<property file="ant.properties"/>
<loadproperties srcFile="project.properties"/>
<import file="custom_rules.xml" optional="true"/>
<import file="${sdk.dir}/tools/ant/build.xml"/>
<target name="pack_libraries">
<jar basedir="libs/codegen-test-output" destfile="libs/test.jar"/>
<delete dir="libs/codegen-test-output"/>
</target>
</project>

View File

@@ -1,2 +0,0 @@
#don't try to download android specific tools within gradle: licence acceptance will be required
android.builder.sdkDownload=false

View File

@@ -20,6 +20,7 @@ import com.intellij.util.PlatformUtils;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.android.tests.ant.AntRunner;
import org.jetbrains.kotlin.android.tests.download.SDKDownloader;
import org.jetbrains.kotlin.android.tests.emulator.Emulator;
import org.jetbrains.kotlin.android.tests.gradle.GradleRunner;
@@ -82,6 +83,8 @@ public class CodegenTestsOnAndroidRunner {
downloader.unzipAll();
PermissionManager.setPermissions(pathManager);
AntRunner antRunner = new AntRunner(pathManager);
antRunner.packLibraries();
Emulator emulator = new Emulator(pathManager, Emulator.ARM);
GradleRunner gradleRunner = new GradleRunner(pathManager);
gradleRunner.clean();
@@ -148,7 +151,7 @@ public class CodegenTestsOnAndroidRunner {
for (int i = 0; i < testCases.getLength(); i++) {
Element item = (Element) testCases.item(i);
NodeList failure = item.getElementsByTagName("failure");
final NodeList failure = item.getElementsByTagName("failure");
String name = item.getAttribute("name");
String clazz = item.getAttribute("classname");

View File

@@ -52,8 +52,8 @@ public class PathManager {
return getAndroidSdkRoot() + "/build-tools";
}
public String getOutputForCompiledFiles(int index) {
return tmpFolder + "/libs/libtest" + index;
public String getOutputForCompiledFiles() {
return tmpFolder + "/libs/codegen-test-output";
}
public String getLibsFolderInAndroidTestedModuleTmpFolder() {
@@ -84,6 +84,10 @@ public class PathManager {
return getDependenciesRoot() + "/download";
}
public String getAntBinDirectory() {
return rootFolder + "/dependencies/ant-1.8/bin";
}
public String getAndroidModuleRoot() {
return rootFolder + "/compiler/android-tests/android-module";
}

View File

@@ -0,0 +1,105 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.android.tests.ant;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.openapi.util.SystemInfo;
import org.jetbrains.kotlin.android.tests.OutputUtils;
import org.jetbrains.kotlin.android.tests.PathManager;
import org.jetbrains.kotlin.android.tests.run.RunResult;
import org.jetbrains.kotlin.android.tests.run.RunUtils;
import org.jetbrains.kotlin.utils.ExceptionUtilsKt;
import java.util.ArrayList;
import java.util.List;
public class AntRunner {
private final List<String> listOfAntCommands;
public AntRunner(PathManager pathManager) {
listOfAntCommands = new ArrayList<String>();
String antCmdName = SystemInfo.isWindows ? "ant.bat" : "ant";
listOfAntCommands.add(pathManager.getAntBinDirectory() + "/" + antCmdName);
listOfAntCommands.add("-Dsdk.dir=" + pathManager.getAndroidSdkRoot());
listOfAntCommands.add("-buildfile");
listOfAntCommands.add(pathManager.getTmpFolder() + "/build.xml");
}
/* Pack compiled sources on first step to one jar file */
public void packLibraries() {
System.out.println("Pack libraries...");
RunResult result = RunUtils.execute(generateCommandLine("pack_libraries"));
OutputUtils.checkResult(result);
}
/* Clean output directory */
public void cleanOutput() {
System.out.println("Clearing output directory...");
RunResult result = RunUtils.execute(generateCommandLine("clean"));
OutputUtils.checkResult(result);
}
public void compileSources() {
System.out.println("Compiling sources...");
RunResult result = RunUtils.execute(generateCommandLine("debug"));
OutputUtils.checkResult(result);
}
public void installApplicationOnEmulator() {
System.out.println("Installing apk...");
RunResult result = RunUtils.execute(generateCommandLine("installt"));
String resultOutput = result.getOutput();
if (!isInstallSuccessful(resultOutput)) {
installApplicationOnEmulator();
return;
}
else {
if (result.getStatus()) {
System.out.println(resultOutput);
}
}
OutputUtils.checkResult(result);
}
public String runTestsOnEmulator() {
System.out.println("Running tests...");
RunResult result = RunUtils.execute(generateCommandLine("test"));
String resultOutput = result.getOutput();
OutputUtils.checkResult(result);
return resultOutput;
}
private static boolean isInstallSuccessful(String output) {
if (output.contains("Is the system running?")) {
System.out.println("Device not ready. Waiting for 20 sec.");
try {
Thread.sleep(20000);
}
catch (InterruptedException e) {
throw ExceptionUtilsKt.rethrow(e);
}
return false;
}
return true;
}
private GeneralCommandLine generateCommandLine(String taskName) {
GeneralCommandLine commandLine = new GeneralCommandLine(listOfAntCommands);
commandLine.addParameter(taskName);
return commandLine;
}
}

View File

@@ -54,7 +54,7 @@ public class SDKDownloader {
platformToolsZipPath = pathManager.getRootForDownload() + "/platform-tools.zip";
skdToolsZipPath = pathManager.getRootForDownload() + "/tools.zip";
buildToolsZipPath = pathManager.getRootForDownload() + "/build-tools.zip";
gradleZipPath = pathManager.getRootForDownload() + "/gradle" + GRADLE_VERSION + ".zip";
gradleZipPath = pathManager.getRootForDownload() + "/gradle.zip";
}
public void downloadPlatform() {
@@ -195,18 +195,21 @@ public class SDKDownloader {
}
try {
byte[] buf = new byte[1024];
ZipEntry zipEntry = null;
try (ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(pathToFile))) {
zipEntry = zipInputStream.getNextEntry();
while (zipEntry != null) {
String entryName = zipEntry.getName();
ZipInputStream zipinputstream;
ZipEntry zipentry;
zipinputstream = new ZipInputStream(new FileInputStream(pathToFile));
zipentry = zipinputstream.getNextEntry();
try {
while (zipentry != null) {
String entryName = zipentry.getName();
int n;
File outputFile = new File(outputFolder + "/" + entryName);
if (zipEntry.isDirectory()) {
if (zipentry.isDirectory()) {
outputFile.mkdirs();
zipInputStream.closeEntry();
zipEntry = zipInputStream.getNextEntry();
zipinputstream.closeEntry();
zipentry = zipinputstream.getNextEntry();
continue;
}
else {
@@ -217,19 +220,23 @@ public class SDKDownloader {
outputFile.createNewFile();
}
try (FileOutputStream fileOutputStream = new FileOutputStream(outputFile)) {
while ((n = zipInputStream.read(buf, 0, 1024)) > -1) {
fileOutputStream.write(buf, 0, n);
FileOutputStream fileoutputstream = new FileOutputStream(outputFile);
try {
while ((n = zipinputstream.read(buf, 0, 1024)) > -1) {
fileoutputstream.write(buf, 0, n);
}
}
zipInputStream.closeEntry();
zipEntry = zipInputStream.getNextEntry();
finally {
fileoutputstream.close();
}
zipinputstream.closeEntry();
zipentry = zipinputstream.getNextEntry();
}
zipinputstream.close();
}
catch (IOException e) {
if (zipEntry != null) {
System.err.println("Entry name: " + zipEntry.getName());
}
System.err.println("Entry name: " + zipentry.getName());
e.printStackTrace();
}
}

View File

@@ -30,7 +30,7 @@ public class GradleRunner {
private final List<String> listOfCommands;
public GradleRunner(PathManager pathManager) {
listOfCommands = new ArrayList<>();
listOfCommands = new ArrayList<String>();
String cmdName = SystemInfo.isWindows ? "gradle.bat" : "gradle";
listOfCommands.add(pathManager.getGradleBinFolder() + "/" + cmdName);
listOfCommands.add("--build-file");
@@ -46,9 +46,7 @@ public class GradleRunner {
public void build() {
System.out.println("Building gradle project...");
GeneralCommandLine build = generateCommandLine("build");
build.addParameter("--stacktrace");
RunResult result = RunUtils.execute(build);
RunResult result = RunUtils.execute(generateCommandLine("build"));
OutputUtils.checkResult(result);
}

View File

@@ -29,6 +29,7 @@ public class PermissionManager {
public static void setPermissions(PathManager pathManager) {
if (!SystemInfo.isWindows) {
RunUtils.execute(generateChmodCmd(pathManager.getAntBinDirectory() + "/ant"));
setExecPermissionForSimpleNamedFiles(new File(pathManager.getToolsFolderInAndroidSdk()));
setExecPermissionForSimpleNamedFiles(new File(pathManager.getToolsFolderInAndroidSdk() + "/bin64"));
setExecPermissionForSimpleNamedFiles(new File(pathManager.getBuildToolsFolderInAndroidSdk() + "/" + SDKDownloader.BUILD_TOOLS));

View File

@@ -86,15 +86,22 @@ public class RunUtils {
return run(settings);
}
public static void executeOnSeparateThread(@NotNull RunSettings settings) {
public static void executeOnSeparateThread(@NotNull final RunSettings settings) {
assert !settings.waitForEnd : "Use execute() instead";
new Thread(() -> run(settings)).start();
Thread t = new Thread(new Runnable() {
@Override
public void run() {
RunUtils.run(settings);
}
});
t.start();
}
private static RunResult run(RunSettings settings) {
private static RunResult run(final RunSettings settings) {
System.out.println("RUN COMMAND: " + settings);
StringBuilder stdOut = new StringBuilder();
StringBuilder stdErr = new StringBuilder();
final StringBuilder stdOut = new StringBuilder();
final StringBuilder stdErr = new StringBuilder();
OSProcessHandler handler;
try {
@@ -104,7 +111,10 @@ public class RunUtils {
}
close(handler.getProcessInput());
}
catch (ExecutionException | IOException e) {
catch (ExecutionException e) {
return new RunResult(false, getStackTrace(e));
}
catch (IOException e) {
return new RunResult(false, getStackTrace(e));
}

View File

@@ -29,8 +29,8 @@ public class AndroidJpsBuildTestCase extends BaseKotlinJpsBuildTestCase {
public void doTest() {
initProject();
rebuildAllModules();
buildAllModules().assertSuccessful();
rebuildAll();
makeAll().assertSuccessful();
}
@Override

View File

@@ -64,8 +64,11 @@ public class AndroidRunner extends TestSuite {
private static void writeAndroidSkdToLocalProperties() throws IOException {
System.out.println("Writing android sdk to local.properties: " + pathManager.getAndroidSdkRoot());
File file = new File(pathManager.getTmpFolder() + "/local.properties");
try (FileWriter fw = new FileWriter(file)) {
FileWriter fw = new FileWriter(file);
try {
fw.write("sdk.dir=" + pathManager.getAndroidSdkRoot());
} finally {
fw.close();
}
}
}

View File

@@ -55,7 +55,6 @@ public class CodegenTestsOnAndroidGenerator extends KtUsefulTestCase {
private static final String generatorName = "CodegenTestsOnAndroidGenerator";
private static int MODULE_INDEX = 1;
private int WRITED_FILES_COUNT = 0;
private final List<String> generatedTestNames = Lists.newArrayList();
@@ -143,7 +142,7 @@ public class CodegenTestsOnAndroidGenerator extends KtUsefulTestCase {
private final boolean isFullJdkAndRuntime;
private final boolean inheritMultifileParts;
public List<KtFile> files = new ArrayList<>();
public List<KtFile> files = new ArrayList<KtFile>();
private KotlinCoreEnvironment environment;
private FilesWriter(boolean isFullJdkAndRuntime, boolean inheritMultifileParts) {
@@ -176,7 +175,7 @@ public class CodegenTestsOnAndroidGenerator extends KtUsefulTestCase {
public void writeFilesOnDisk() {
writeFiles(files);
files = new ArrayList<>();
files = new ArrayList<KtFile>();
environment = createEnvironment(isFullJdkAndRuntime);
}
@@ -192,15 +191,10 @@ public class CodegenTestsOnAndroidGenerator extends KtUsefulTestCase {
private void writeFiles(List<KtFile> filesToCompile) {
if (filesToCompile.isEmpty()) return;
//1000 files per folder, each folder would be jared by build.gradle script
// We can't create one big jar with all test cause dex has problem with memory on teamcity
WRITED_FILES_COUNT += filesToCompile.size();
File outputDir = new File(pathManager.getOutputForCompiledFiles(WRITED_FILES_COUNT / 1000));
System.out.println("Generating " + filesToCompile.size() + " files" +
(inheritMultifileParts
? " (JVM.INHERIT_MULTIFILE_PARTS)"
: isFullJdkAndRuntime ? " (full jdk and runtime)" : "") + " into " + outputDir.getName() + "...");
: isFullJdkAndRuntime ? " (full jdk and runtime)" : "") + "...");
OutputFileCollection outputFiles;
try {
outputFiles = GenerationUtils.compileFiles(filesToCompile, environment).getFactory();
@@ -209,6 +203,7 @@ public class CodegenTestsOnAndroidGenerator extends KtUsefulTestCase {
throw new RuntimeException(e);
}
File outputDir = new File(pathManager.getOutputForCompiledFiles());
if (!outputDir.exists()) {
outputDir.mkdirs();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,7 +47,6 @@ public class SpecialFiles {
excludedFiles.add("arrayOfKClasses.kt");
excludedFiles.add("enumKClassAnnotation.kt");
excludedFiles.add("primitivesAndArrays.kt");
excludedFiles.add("getDelegateWithoutReflection.kt");
// Reflection is used to check full class name
excludedFiles.add("native");
@@ -97,14 +96,6 @@ public class SpecialFiles {
excludedFiles.add("kt11121.kt");
excludedFiles.add("kt5112.kt");
// Different format of inner signature on Android and JVM
excludedFiles.add("signatureOfDeepGenericInner.kt");
excludedFiles.add("signatureOfDeepInner.kt");
excludedFiles.add("signatureOfDeepInnerLastGeneric.kt");
excludedFiles.add("signatureOfGenericInnerGenericOuter.kt");
excludedFiles.add("signatureOfGenericInnerSimpleOuter.kt");
excludedFiles.add("signatureOfSimpleInnerSimpleOuter.kt");
// Some classes are not visible on android
excludedFiles.add("classpath.kt");

View File

@@ -7,6 +7,7 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="intellij-core" level="project" />
<orderEntry type="module" module-name="frontend" />
<orderEntry type="module" module-name="util" />
</component>

View File

@@ -101,11 +101,12 @@ object CodegenUtil {
}
@JvmStatic
fun getSuperClassBySuperTypeListEntry(specifier: KtSuperTypeListEntry, bindingContext: BindingContext): ClassDescriptor? {
fun getSuperClassBySuperTypeListEntry(specifier: KtSuperTypeListEntry, bindingContext: BindingContext): ClassDescriptor {
val superType = bindingContext.get(BindingContext.TYPE, specifier.typeReference!!)
?: error("superType should not be null: ${specifier.text}")
return superType.constructor.declarationDescriptor as? ClassDescriptor
?: error("ClassDescriptor of superType should not be null: ${specifier.text}")
}
@JvmStatic
@@ -158,8 +159,8 @@ object CodegenUtil {
@JvmStatic
fun constructFakeFunctionCall(project: Project, referencedFunction: FunctionDescriptor): KtCallExpression {
val fakeFunctionCall = StringBuilder("callableReferenceFakeCall(")
fakeFunctionCall.append(referencedFunction.valueParameters.joinToString(", ") { "p${it.index}" })
fakeFunctionCall.append(referencedFunction.valueParameters.map { "p${it.index}" }.joinToString(", "))
fakeFunctionCall.append(")")
return KtPsiFactory(project, markGenerated = false).createExpression(fakeFunctionCall.toString()) as KtCallExpression
return KtPsiFactory(project).createExpression(fakeFunctionCall.toString()) as KtCallExpression
}
}

View File

@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.resolve.BindingContextUtils
* TODO: data class with zero components gets no toString/equals/hashCode methods. This is inconsistent and should be
* changed here with the platform backends adopted.
*/
abstract class DataClassMethodGenerator(protected val declaration: KtClassOrObject, private val bindingContext: BindingContext) {
abstract class DataClassMethodGenerator(private val declaration: KtClassOrObject, private val bindingContext: BindingContext) {
protected val classDescriptor: ClassDescriptor = BindingContextUtils.getNotNull(bindingContext, BindingContext.CLASS, declaration)
fun generate() {

View File

@@ -9,8 +9,11 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="frontend" />
<orderEntry type="module" module-name="frontend.java" />
<orderEntry type="library" scope="PROVIDED" name="intellij-core" level="project" />
<orderEntry type="module" module-name="serialization" />
<orderEntry type="module" module-name="backend-common" exported="" />
<orderEntry type="module" module-name="util" />
<orderEntry type="module" module-name="backend.jvm" />
<orderEntry type="module" module-name="ir.tree" />
</component>
</module>

View File

@@ -20,6 +20,7 @@ import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.codegen.inline.FileMapping;
import org.jetbrains.kotlin.codegen.inline.InlineCodegenUtil;
import org.jetbrains.kotlin.codegen.inline.SMAPBuilder;
import org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings;
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
@@ -28,8 +29,6 @@ import org.jetbrains.org.objectweb.asm.*;
import java.util.ArrayList;
import java.util.List;
import static org.jetbrains.kotlin.codegen.inline.InlineCodegenUtilsKt.GENERATE_SMAP;
public abstract class AbstractClassBuilder implements ClassBuilder {
protected static final MethodVisitor EMPTY_METHOD_VISITOR = new MethodVisitor(Opcodes.ASM5) {};
protected static final FieldVisitor EMPTY_FIELD_VISITOR = new FieldVisitor(Opcodes.ASM5) {};
@@ -38,7 +37,7 @@ public abstract class AbstractClassBuilder implements ClassBuilder {
private final JvmSerializationBindings serializationBindings = new JvmSerializationBindings();
private final List<FileMapping> fileMappings = new ArrayList<>();
private final List<FileMapping> fileMappings = new ArrayList<FileMapping>();
private String sourceName;
@@ -106,7 +105,7 @@ public abstract class AbstractClassBuilder implements ClassBuilder {
@Override
public void done() {
if (!fileMappings.isEmpty() && GENERATE_SMAP) {
if (!fileMappings.isEmpty() && InlineCodegenUtil.GENERATE_SMAP) {
FileMapping origin = fileMappings.get(0);
assert sourceName == null || origin.getName().equals(sourceName) : "Error " + origin.getName() + " != " + sourceName;
getVisitor().visitSource(origin.getName(), new SMAPBuilder(origin.getName(), origin.getPath(), fileMappings).build());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -56,7 +56,7 @@ public class AccessorForFunctionDescriptor extends AbstractAccessorForFunctionDe
setSuspend(descriptor.isSuspend());
if (descriptor.getUserData(CoroutineCodegenUtilKt.INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION) != null) {
userDataMap = new LinkedHashMap<>();
userDataMap = new LinkedHashMap<UserDataKey<?>, Object>();
userDataMap.put(
CoroutineCodegenUtilKt.INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION,
descriptor.getUserData(CoroutineCodegenUtilKt.INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION)

View File

@@ -16,7 +16,6 @@
package org.jetbrains.kotlin.codegen;
import kotlin.collections.CollectionsKt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.codegen.annotation.WrappedAnnotated;
@@ -26,21 +25,16 @@ import org.jetbrains.kotlin.descriptors.annotations.*;
import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor;
import org.jetbrains.kotlin.load.java.JvmAnnotationNames;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.resolve.AnnotationChecker;
import org.jetbrains.kotlin.resolve.constants.*;
import org.jetbrains.kotlin.resolve.constants.StringValue;
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
import org.jetbrains.kotlin.types.FlexibleType;
import org.jetbrains.kotlin.types.FlexibleTypesKt;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.types.TypeUtils;
import org.jetbrains.kotlin.types.*;
import org.jetbrains.org.objectweb.asm.*;
import java.lang.annotation.*;
import java.util.*;
import static org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt.getAnnotationClass;
public abstract class AnnotationCodegen {
public static final class JvmFlagAnnotation {
@@ -71,17 +65,7 @@ public abstract class AnnotationCodegen {
new JvmFlagAnnotation("kotlin.jvm.Synchronized", Opcodes.ACC_SYNCHRONIZED)
);
private static final AnnotationVisitor NO_ANNOTATION_VISITOR = new AnnotationVisitor(Opcodes.ASM5) {
@Override
public AnnotationVisitor visitAnnotation(String name, @NotNull String desc) {
return safe(super.visitAnnotation(name, desc));
}
@Override
public AnnotationVisitor visitArray(String name) {
return safe(super.visitArray(name));
}
};
private static final AnnotationVisitor NO_ANNOTATION_VISITOR = new AnnotationVisitor(Opcodes.ASM5) {};
private final InnerClassConsumer innerClassConsumer;
private final KotlinTypeMapper typeMapper;
@@ -103,7 +87,7 @@ public abstract class AnnotationCodegen {
return;
}
Set<String> annotationDescriptorsAlreadyPresent = new HashSet<>();
Set<String> annotationDescriptorsAlreadyPresent = new HashSet<String>();
Annotations annotations = annotated.getAnnotations();
@@ -216,7 +200,8 @@ public abstract class AnnotationCodegen {
generateAnnotationIfNotPresent(annotationDescriptorsAlreadyPresent, annotationClass);
}
private static final Map<KotlinTarget, ElementType> annotationTargetMap = new EnumMap<>(KotlinTarget.class);
private static final Map<KotlinTarget, ElementType> annotationTargetMap =
new EnumMap<KotlinTarget, ElementType>(KotlinTarget.class);
static {
annotationTargetMap.put(KotlinTarget.CLASS, ElementType.TYPE);
@@ -293,34 +278,39 @@ public abstract class AnnotationCodegen {
@Nullable
private String genAnnotation(@NotNull AnnotationDescriptor annotationDescriptor) {
ClassDescriptor classDescriptor = getAnnotationClass(annotationDescriptor);
assert classDescriptor != null : "Annotation descriptor has no class: " + annotationDescriptor;
RetentionPolicy rp = getRetentionPolicy(classDescriptor);
ClassifierDescriptor classifierDescriptor = annotationDescriptor.getType().getConstructor().getDeclarationDescriptor();
assert classifierDescriptor != null : "Annotation descriptor has no class: " + annotationDescriptor;
RetentionPolicy rp = getRetentionPolicy(classifierDescriptor);
if (rp == RetentionPolicy.SOURCE && !typeMapper.getClassBuilderMode().generateSourceRetentionAnnotations) {
return null;
}
innerClassConsumer.addInnerClassInfoFromAnnotation(classDescriptor);
String descriptor = typeMapper.mapType(annotationDescriptor.getType()).getDescriptor();
String asmTypeDescriptor = typeMapper.mapType(annotationDescriptor.getType()).getDescriptor();
AnnotationVisitor annotationVisitor = visitAnnotation(asmTypeDescriptor, rp == RetentionPolicy.RUNTIME);
if (classifierDescriptor instanceof ClassDescriptor) {
innerClassConsumer.addInnerClassInfoFromAnnotation(((ClassDescriptor) classifierDescriptor));
}
AnnotationVisitor annotationVisitor = visitAnnotation(descriptor, rp == RetentionPolicy.RUNTIME);
genAnnotationArguments(annotationDescriptor, annotationVisitor);
annotationVisitor.visitEnd();
return asmTypeDescriptor;
return descriptor;
}
private void genAnnotationArguments(AnnotationDescriptor annotationDescriptor, AnnotationVisitor annotationVisitor) {
for (Map.Entry<Name, ConstantValue<?>> entry : annotationDescriptor.getAllValueArguments().entrySet()) {
genCompileTimeValue(entry.getKey().asString(), entry.getValue(), annotationVisitor);
for (Map.Entry<ValueParameterDescriptor, ConstantValue<?>> entry : annotationDescriptor.getAllValueArguments().entrySet()) {
ValueParameterDescriptor descriptor = entry.getKey();
String name = descriptor.getName().asString();
genCompileTimeValue(name, entry.getValue(), annotationVisitor);
}
}
private void genCompileTimeValue(
@Nullable String name,
@Nullable final String name,
@NotNull ConstantValue<?> value,
@NotNull AnnotationVisitor annotationVisitor
@NotNull final AnnotationVisitor annotationVisitor
) {
AnnotationArgumentVisitor argumentVisitor = new AnnotationArgumentVisitor<Void, Void>() {
@Override
@@ -428,7 +418,8 @@ public abstract class AnnotationCodegen {
value.accept(argumentVisitor, null);
}
private static final Map<KotlinRetention, RetentionPolicy> annotationRetentionMap = new EnumMap<>(KotlinRetention.class);
private static final Map<KotlinRetention, RetentionPolicy> annotationRetentionMap =
new EnumMap<KotlinRetention, RetentionPolicy>(KotlinRetention.class);
static {
annotationRetentionMap.put(KotlinRetention.SOURCE, RetentionPolicy.SOURCE);
@@ -472,13 +463,16 @@ public abstract class AnnotationCodegen {
}
AnnotationDescriptor retentionAnnotation = descriptor.getAnnotations().findAnnotation(new FqName(Retention.class.getName()));
if (retentionAnnotation != null) {
ConstantValue<?> compileTimeConstant = CollectionsKt.firstOrNull(retentionAnnotation.getAllValueArguments().values());
if (compileTimeConstant instanceof EnumValue) {
ClassDescriptor enumEntry = ((EnumValue) compileTimeConstant).getValue();
KotlinType classObjectType = DescriptorUtilsKt.getClassValueType(enumEntry);
if (classObjectType != null) {
if ("java/lang/annotation/RetentionPolicy".equals(typeMapper.mapType(classObjectType).getInternalName())) {
return RetentionPolicy.valueOf(enumEntry.getName().asString());
Collection<ConstantValue<?>> valueArguments = retentionAnnotation.getAllValueArguments().values();
if (!valueArguments.isEmpty()) {
ConstantValue<?> compileTimeConstant = valueArguments.iterator().next();
if (compileTimeConstant instanceof EnumValue) {
ClassDescriptor enumEntry = ((EnumValue) compileTimeConstant).getValue();
KotlinType classObjectType = DescriptorUtilsKt.getClassValueType(enumEntry);
if (classObjectType != null) {
if ("java/lang/annotation/RetentionPolicy".equals(typeMapper.mapType(classObjectType).getInternalName())) {
return RetentionPolicy.valueOf(enumEntry.getName().asString());
}
}
}
}
@@ -491,7 +485,7 @@ public abstract class AnnotationCodegen {
abstract AnnotationVisitor visitAnnotation(String descr, boolean visible);
public static AnnotationCodegen forClass(
@NotNull ClassVisitor cv,
final @NotNull ClassVisitor cv,
@NotNull InnerClassConsumer innerClassConsumer,
@NotNull KotlinTypeMapper mapper
) {
@@ -505,7 +499,7 @@ public abstract class AnnotationCodegen {
}
public static AnnotationCodegen forMethod(
@NotNull MethodVisitor mv,
final @NotNull MethodVisitor mv,
@NotNull InnerClassConsumer innerClassConsumer,
@NotNull KotlinTypeMapper mapper
) {
@@ -519,7 +513,7 @@ public abstract class AnnotationCodegen {
}
public static AnnotationCodegen forField(
@NotNull FieldVisitor fv,
final @NotNull FieldVisitor fv,
@NotNull InnerClassConsumer innerClassConsumer,
@NotNull KotlinTypeMapper mapper
) {
@@ -533,8 +527,8 @@ public abstract class AnnotationCodegen {
}
public static AnnotationCodegen forParameter(
int parameter,
@NotNull MethodVisitor mv,
final int parameter,
final @NotNull MethodVisitor mv,
@NotNull InnerClassConsumer innerClassConsumer,
@NotNull KotlinTypeMapper mapper
) {
@@ -548,7 +542,7 @@ public abstract class AnnotationCodegen {
}
public static AnnotationCodegen forAnnotationDefaultValue(
@NotNull MethodVisitor mv,
final @NotNull MethodVisitor mv,
@NotNull InnerClassConsumer innerClassConsumer,
@NotNull KotlinTypeMapper mapper
) {

View File

@@ -21,24 +21,22 @@ import com.google.common.collect.Sets;
import com.intellij.openapi.util.Pair;
import com.intellij.psi.tree.IElementType;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
import org.jetbrains.kotlin.builtins.PrimitiveType;
import org.jetbrains.kotlin.codegen.binding.CalculatedClosure;
import org.jetbrains.kotlin.codegen.context.CodegenContext;
import org.jetbrains.kotlin.codegen.intrinsics.HashCode;
import org.jetbrains.kotlin.codegen.intrinsics.IntrinsicMethods;
import org.jetbrains.kotlin.codegen.serialization.JvmStringTable;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper;
import org.jetbrains.kotlin.config.JvmTarget;
import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.lexer.KtTokens;
import org.jetbrains.kotlin.load.java.JavaVisibilities;
import org.jetbrains.kotlin.load.java.JvmAnnotationNames;
import org.jetbrains.kotlin.name.ClassId;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.protobuf.MessageLite;
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
@@ -68,7 +66,7 @@ import static org.jetbrains.kotlin.builtins.KotlinBuiltIns.isPrimitiveClass;
import static org.jetbrains.kotlin.codegen.CodegenUtilKt.isToArrayFromCollection;
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isConstOrHasJvmFieldAnnotation;
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isJvmInterface;
import static org.jetbrains.kotlin.descriptors.annotations.AnnotationUtilKt.isEffectivelyInlineOnly;
import static org.jetbrains.kotlin.descriptors.annotations.AnnotationUtilKt.isInlineOnlyOrReifiable;
import static org.jetbrains.kotlin.resolve.DescriptorUtils.*;
import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.*;
import static org.jetbrains.kotlin.types.TypeUtils.isNullableType;
@@ -140,18 +138,10 @@ public class AsmUtil {
return primitiveTypeByBoxedType.get(boxedType);
}
public static boolean isBoxedTypeOf(@NotNull Type boxedType, @NotNull Type unboxedType) {
return unboxPrimitiveTypeOrNull(boxedType) == unboxedType;
}
public static boolean isIntPrimitive(Type type) {
return type == Type.INT_TYPE || type == Type.SHORT_TYPE || type == Type.BYTE_TYPE || type == Type.CHAR_TYPE;
}
public static boolean isIntOrLongPrimitive(Type type) {
return isIntPrimitive(type) || type == Type.LONG_TYPE;
}
public static boolean isNumberPrimitiveOrBoolean(Type type) {
return isNumberPrimitive(type) || type.getSort() == Type.BOOLEAN;
}
@@ -362,7 +352,7 @@ public class AsmUtil {
DeclarationDescriptor containingDeclaration = memberDescriptor.getContainingDeclaration();
Visibility memberVisibility = memberDescriptor.getVisibility();
if (isEffectivelyInlineOnly(memberDescriptor)) return ACC_PRIVATE;
if (isInlineOnlyOrReifiable(memberDescriptor)) return ACC_PRIVATE;
if (memberVisibility == Visibilities.LOCAL && memberDescriptor instanceof CallableMemberDescriptor) {
return ACC_PUBLIC;
@@ -406,10 +396,6 @@ public class AsmUtil {
return null;
}
if (memberDescriptor instanceof FunctionDescriptor && ((FunctionDescriptor) memberDescriptor).isSuspend()) {
return NO_FLAG_PACKAGE_PRIVATE;
}
// the following code is only for PRIVATE visibility of member
if (memberDescriptor instanceof ConstructorDescriptor) {
if (isEnumEntry(containingDeclaration)) {
@@ -460,7 +446,7 @@ public class AsmUtil {
}
public static void genClosureFields(@NotNull CalculatedClosure closure, ClassBuilder v, KotlinTypeMapper typeMapper) {
List<Pair<String, Type>> allFields = new ArrayList<>();
List<Pair<String, Type>> allFields = new ArrayList<Pair<String, Type>>();
ClassifierDescriptor captureThis = closure.getCaptureThis();
if (captureThis != null) {
@@ -514,16 +500,19 @@ public class AsmUtil {
v.invokevirtual("java/lang/StringBuilder", "append", "(" + type.getDescriptor() + ")Ljava/lang/StringBuilder;", false);
}
public static StackValue genToString(StackValue receiver, Type receiverType) {
return StackValue.operation(JAVA_STRING_TYPE, v -> {
Type type = stringValueOfType(receiverType);
receiver.put(type, v);
v.invokestatic("java/lang/String", "valueOf", "(" + type.getDescriptor() + ")Ljava/lang/String;", false);
return null;
public static StackValue genToString(final StackValue receiver, final Type receiverType) {
return StackValue.operation(JAVA_STRING_TYPE, new Function1<InstructionAdapter, Unit>() {
@Override
public Unit invoke(InstructionAdapter v) {
Type type = stringValueOfType(receiverType);
receiver.put(type, v);
v.invokestatic("java/lang/String", "valueOf", "(" + type.getDescriptor() + ")Ljava/lang/String;", false);
return null;
}
});
}
static void genHashCode(MethodVisitor mv, InstructionAdapter iv, Type type, JvmTarget jvmTarget) {
static void genHashCode(MethodVisitor mv, InstructionAdapter iv, Type type) {
if (type.getSort() == Type.ARRAY) {
Type elementType = correctElementType(type);
if (elementType.getSort() == Type.OBJECT || elementType.getSort() == Type.ARRAY) {
@@ -536,6 +525,16 @@ public class AsmUtil {
else if (type.getSort() == Type.OBJECT) {
iv.invokevirtual("java/lang/Object", "hashCode", "()I", false);
}
else if (type.getSort() == Type.LONG) {
genLongHashCode(mv, iv);
}
else if (type.getSort() == Type.DOUBLE) {
iv.invokestatic("java/lang/Double", "doubleToLongBits", "(D)J", false);
genLongHashCode(mv, iv);
}
else if (type.getSort() == Type.FLOAT) {
iv.invokestatic("java/lang/Float", "floatToIntBits", "(F)I", false);
}
else if (type.getSort() == Type.BOOLEAN) {
Label end = new Label();
iv.dup();
@@ -544,24 +543,8 @@ public class AsmUtil {
iv.iconst(1);
iv.mark(end);
}
else {
if (JvmTarget.JVM_1_6 == jvmTarget) {
if (type.getSort() == Type.LONG) {
genLongHashCode(mv, iv);
}
else if (type.getSort() == Type.DOUBLE) {
iv.invokestatic("java/lang/Double", "doubleToLongBits", "(D)J", false);
genLongHashCode(mv, iv);
}
else if (type.getSort() == Type.FLOAT) {
iv.invokestatic("java/lang/Float", "floatToIntBits", "(F)I", false);
}
else { // byte short char int
// do nothing
}
} else {
HashCode.Companion.invokeHashCode(iv, type);
}
else { // byte short char int
// do nothing
}
}
@@ -580,25 +563,28 @@ public class AsmUtil {
@NotNull
public static StackValue genEqualsForExpressionsOnStack(
@NotNull IElementType opToken,
@NotNull StackValue left,
@NotNull StackValue right
final @NotNull IElementType opToken,
final @NotNull StackValue left,
final @NotNull StackValue right
) {
Type leftType = left.type;
Type rightType = right.type;
final Type leftType = left.type;
final Type rightType = right.type;
if (isPrimitive(leftType) && leftType == rightType) {
return StackValue.cmp(opToken, leftType, left, right);
}
return StackValue.operation(Type.BOOLEAN_TYPE, v -> {
left.put(leftType, v);
right.put(rightType, v);
genAreEqualCall(v);
return StackValue.operation(Type.BOOLEAN_TYPE, new Function1<InstructionAdapter, Unit>() {
@Override
public Unit invoke(InstructionAdapter v) {
left.put(leftType, v);
right.put(rightType, v);
genAreEqualCall(v);
if (opToken == KtTokens.EXCLEQ || opToken == KtTokens.EXCLEQEQEQ) {
genInvertBoolean(v);
if (opToken == KtTokens.EXCLEQ || opToken == KtTokens.EXCLEQEQEQ) {
genInvertBoolean(v);
}
return Unit.INSTANCE;
}
return Unit.INSTANCE;
});
}
@@ -663,8 +649,6 @@ public class AsmUtil {
@NotNull FrameMap frameMap
) {
if (state.isParamAssertionsDisabled()) return;
// currently when resuming a suspend function we pass default values instead of real arguments (i.e. nulls for references)
if (descriptor.isSuspend()) return;
// Private method is not accessible from other classes, no assertions needed
if (getVisibilityAccessFlag(descriptor) == ACC_PRIVATE) return;
@@ -702,8 +686,8 @@ public class AsmUtil {
@NotNull
public static StackValue genNotNullAssertions(
@NotNull GenerationState state,
@NotNull StackValue stackValue,
@Nullable RuntimeAssertionInfo runtimeAssertionInfo
@NotNull final StackValue stackValue,
@Nullable final RuntimeAssertionInfo runtimeAssertionInfo
) {
if (state.isCallAssertionsDisabled()) return stackValue;
if (runtimeAssertionInfo == null || !runtimeAssertionInfo.getNeedNotNullAssertion()) return stackValue;
@@ -717,7 +701,7 @@ public class AsmUtil {
if (innerType.getSort() == Type.OBJECT || innerType.getSort() == Type.ARRAY) {
v.dup();
v.visitLdcInsn(runtimeAssertionInfo.getMessage());
v.invokestatic(IntrinsicMethods.INTRINSICS_CLASS_NAME, "checkExpressionValueIsNotNull",
v.invokestatic("kotlin/jvm/internal/Intrinsics", "checkExpressionValueIsNotNull",
"(Ljava/lang/Object;Ljava/lang/String;)V", false);
}
StackValue.coerce(innerType, type, v);
@@ -807,16 +791,6 @@ public class AsmUtil {
}
}
public static void pop2(@NotNull MethodVisitor v, @NotNull Type type) {
if (type.getSize() == 2) {
v.visitInsn(Opcodes.POP2);
v.visitInsn(Opcodes.POP2);
}
else {
v.visitInsn(Opcodes.POP2);
}
}
public static void dup(@NotNull InstructionAdapter v, @NotNull Type type) {
dup(v, type.getSize());
}
@@ -833,22 +807,6 @@ public class AsmUtil {
}
}
public static void dupx(@NotNull InstructionAdapter v, @NotNull Type type) {
dupx(v, type.getSize());
}
private static void dupx(@NotNull InstructionAdapter v, int size) {
if (size == 2) {
v.dup2X2();
}
else if (size == 1) {
v.dupX1();
}
else {
throw new UnsupportedOperationException();
}
}
public static void dup(@NotNull InstructionAdapter v, @NotNull Type topOfStack, @NotNull Type afterTop) {
if (topOfStack.getSize() == 0 && afterTop.getSize() == 0) {
return;
@@ -904,11 +862,6 @@ public class AsmUtil {
return Type.getObjectType(internalNameByFqNameWithoutInnerClasses(fqName));
}
@NotNull
public static Type asmTypeByClassId(@NotNull ClassId classId) {
return Type.getObjectType(classId.asString().replace('.', '$'));
}
@NotNull
public static String internalNameByFqNameWithoutInnerClasses(@NotNull FqName fqName) {
return JvmClassName.byFqNameWithoutInnerClasses(fqName).getInternalName();

View File

@@ -1,48 +0,0 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.codegen
import org.jetbrains.kotlin.codegen.inline.NameGenerator
import org.jetbrains.kotlin.codegen.inline.ReifiedTypeParametersUsages
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
interface BaseExpressionCodegen {
val frameMap: FrameMap
val visitor: InstructionAdapter
val inlineNameGenerator: NameGenerator
val lastLineNumber: Int
fun consumeReifiedOperationMarker(typeParameterDescriptor: TypeParameterDescriptor)
fun propagateChildReifiedTypeParametersUsages(reifiedTypeParametersUsages: ReifiedTypeParametersUsages)
fun pushClosureOnStack(
classDescriptor: ClassDescriptor,
putThis: Boolean,
callGenerator: CallGenerator,
functionReferenceReceiver: StackValue?
)
fun markLineNumberAfterInlineIfNeeded()
}

View File

@@ -1,308 +0,0 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.codegen
import com.intellij.psi.tree.IElementType
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.org.objectweb.asm.Label
import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
abstract class NumberLikeCompare(
left: StackValue,
right: StackValue,
operandType: Type,
private val opToken: IElementType
) : BranchedValue(left, right, operandType, NumberCompare.getNumberCompareOpcode(opToken)) {
override fun patchOpcode(opcode: Int, v: InstructionAdapter): Int =
NumberCompare.patchOpcode(opcode, v, opToken, operandType)
}
abstract class SafeCallFusedWithPrimitiveEqualityBase(
opToken: IElementType,
operandType: Type,
left: StackValue,
right: StackValue
) : NumberLikeCompare(left, right, operandType, opToken) {
private val trueIfEqual = opToken == KtTokens.EQEQ || opToken == KtTokens.EQEQEQ
protected abstract fun cleanupOnNullReceiver(v: InstructionAdapter)
override fun condJump(jumpLabel: Label, v: InstructionAdapter, jumpIfFalse: Boolean) {
val endLabel = Label()
arg1.put(operandType, v)
arg2!!.put(operandType, v)
v.visitJumpInsn(patchOpcode(if (jumpIfFalse) opcode else negatedOperations[opcode]!!, v), jumpLabel)
v.goTo(endLabel)
cleanupOnNullReceiver(v)
if (jumpIfFalse == trueIfEqual) {
v.goTo(jumpLabel)
}
v.mark(endLabel)
}
override fun putSelector(type: Type, v: InstructionAdapter) {
val falseLabel = Label()
val endLabel = Label()
arg1.put(operandType, v)
arg2!!.put(operandType, v)
v.visitJumpInsn(patchOpcode(opcode, v), falseLabel)
if (!trueIfEqual) {
val trueLabel = Label()
v.goTo(trueLabel)
cleanupOnNullReceiver(v)
v.mark(trueLabel)
}
v.iconst(1)
v.goTo(endLabel)
if (trueIfEqual) {
cleanupOnNullReceiver(v)
}
v.mark(falseLabel)
v.iconst(0)
v.mark(endLabel)
coerceTo(type, v)
}
}
class SafeCallToPrimitiveEquality(
opToken: IElementType,
operandType: Type,
left: StackValue,
right: StackValue,
private val safeReceiverType: Type,
private val safeReceiverIsNull: Label
) : SafeCallFusedWithPrimitiveEqualityBase(opToken, operandType, left, right) {
override fun cleanupOnNullReceiver(v: InstructionAdapter) {
v.mark(safeReceiverIsNull)
AsmUtil.pop(v, safeReceiverType)
}
}
class PrimitiveToSafeCallEquality(
opToken: IElementType,
operandType: Type,
left: StackValue,
right: StackValue,
private val safeReceiverType: Type,
private val safeReceiverIsNull: Label
) : SafeCallFusedWithPrimitiveEqualityBase(opToken, operandType, left, right) {
override fun cleanupOnNullReceiver(v: InstructionAdapter) {
v.mark(safeReceiverIsNull)
AsmUtil.pop(v, safeReceiverType)
AsmUtil.pop(v, arg1.type)
}
}
class BoxedToPrimitiveEquality private constructor(
leftBoxed: StackValue,
rightPrimitive: StackValue,
primitiveType: Type,
private val frameMap: FrameMap
) : NumberLikeCompare(leftBoxed, rightPrimitive, primitiveType, KtTokens.EQEQ) {
private val boxedType = arg1.type
override fun condJump(jumpLabel: Label, v: InstructionAdapter, jumpIfFalse: Boolean) {
if (arg2!!.canHaveSideEffects()) {
val tmp = frameMap.enterTemp(operandType)
doJump(
v, jumpLabel, jumpIfFalse,
{
arg1.put(boxedType, v)
arg2.put(operandType, v)
v.store(tmp, operandType)
},
{ v.load(tmp, operandType) }
)
frameMap.leaveTemp(operandType)
}
else {
doJump(
v, jumpLabel, jumpIfFalse,
{ arg1.put(boxedType, v) },
{ arg2.put(operandType, v) }
)
}
}
private inline fun doJump(
v: InstructionAdapter,
jumpLabel: Label,
jumpIfFalse: Boolean,
putArg1: () -> Unit,
putArg2: () -> Unit
) {
val notNullLabel = Label()
val endLabel = Label()
putArg1()
AsmUtil.dup(v, boxedType)
v.ifnonnull(notNullLabel)
AsmUtil.pop(v, boxedType)
if (jumpIfFalse) v.goTo(jumpLabel) else v.goTo(endLabel)
v.mark(notNullLabel)
coerce(boxedType, operandType, v)
putArg2()
v.visitJumpInsn(patchOpcode(if (jumpIfFalse) opcode else negatedOperations[opcode]!!, v), jumpLabel)
v.mark(endLabel)
}
companion object {
@JvmStatic
fun create(
opToken: IElementType,
left: StackValue,
leftType: Type,
right: StackValue,
rightType: Type,
frameMap: FrameMap
): BranchedValue =
if (!isApplicable(opToken, leftType, rightType))
throw IllegalArgumentException("Not applicable for $opToken, $leftType, $rightType")
else when (opToken) {
KtTokens.EQEQ -> BoxedToPrimitiveEquality(left, right, rightType, frameMap)
KtTokens.EXCLEQ -> Invert(BoxedToPrimitiveEquality(left, right, rightType, frameMap))
else -> throw AssertionError("Unexpected opToken: $opToken")
}
@JvmStatic
fun isApplicable(opToken: IElementType, leftType: Type, rightType: Type) =
(opToken == KtTokens.EQEQ || opToken == KtTokens.EXCLEQ) &&
AsmUtil.isIntOrLongPrimitive(rightType) &&
AsmUtil.isBoxedTypeOf(leftType, rightType)
}
}
abstract class PrimitiveToSomethingEquality
protected constructor(
leftPrimitive: StackValue,
right: StackValue,
primitiveType: Type
) : NumberLikeCompare(leftPrimitive, right, primitiveType, KtTokens.EQEQ) {
protected val primitiveType = leftPrimitive.type
protected val rightType = right.type
override fun condJump(jumpLabel: Label, v: InstructionAdapter, jumpIfFalse: Boolean) {
val notNullLabel = Label()
val endLabel = Label()
arg1.put(primitiveType, v)
arg2!!.put(rightType, v)
AsmUtil.dup(v, rightType)
jumpIfCanCompareTopWithPrimitive(v, notNullLabel)
AsmUtil.pop(v, rightType)
AsmUtil.pop(v, primitiveType)
if (jumpIfFalse) v.goTo(jumpLabel) else v.goTo(endLabel)
v.mark(notNullLabel)
coerceRightToPrimitive(v)
v.visitJumpInsn(patchOpcode(if (jumpIfFalse) opcode else negatedOperations[opcode]!!, v), jumpLabel)
v.mark(endLabel)
}
protected abstract fun jumpIfCanCompareTopWithPrimitive(v: InstructionAdapter, label: Label)
protected abstract fun coerceRightToPrimitive(v: InstructionAdapter)
}
class PrimitiveToBoxedEquality private constructor(
leftPrimitive: StackValue,
rightBoxed: StackValue,
primitiveType: Type
) : PrimitiveToSomethingEquality(leftPrimitive, rightBoxed, primitiveType) {
private val boxedType = rightBoxed.type
override fun jumpIfCanCompareTopWithPrimitive(v: InstructionAdapter, label: Label) {
v.ifnonnull(label)
}
override fun coerceRightToPrimitive(v: InstructionAdapter) {
coerce(boxedType, primitiveType, v)
}
companion object {
@JvmStatic
fun create(opToken: IElementType, left: StackValue, leftType: Type, right: StackValue, rightType: Type): BranchedValue =
if (!isApplicable(opToken, leftType, rightType))
throw IllegalArgumentException("Not applicable for $opToken, $leftType, $rightType")
else when (opToken) {
KtTokens.EQEQ -> PrimitiveToBoxedEquality(left, right, leftType)
KtTokens.EXCLEQ -> Invert(PrimitiveToBoxedEquality(left, right, leftType))
else -> throw AssertionError("Unexpected opToken: $opToken")
}
@JvmStatic
fun isApplicable(opToken: IElementType, leftType: Type, rightType: Type) =
(opToken == KtTokens.EQEQ || opToken == KtTokens.EXCLEQ) &&
AsmUtil.isIntOrLongPrimitive(leftType) &&
AsmUtil.isBoxedTypeOf(rightType, leftType)
}
}
class PrimitiveToObjectEquality private constructor(
leftPrimitive: StackValue,
rightObject: StackValue,
primitiveType: Type
) : PrimitiveToSomethingEquality(leftPrimitive, rightObject, primitiveType) {
private val boxedType = AsmUtil.boxType(primitiveType)
override fun jumpIfCanCompareTopWithPrimitive(v: InstructionAdapter, label: Label) {
v.instanceOf(boxedType)
v.ifne(label)
}
override fun coerceRightToPrimitive(v: InstructionAdapter) {
coerce(rightType, boxedType, v)
coerce(boxedType, primitiveType, v)
}
companion object {
@JvmStatic
fun create(opToken: IElementType, left: StackValue, leftType: Type, right: StackValue, rightType: Type): BranchedValue =
if (!isApplicable(opToken, leftType, rightType))
throw IllegalArgumentException("Not applicable for $opToken, $leftType, $rightType")
else when (opToken) {
KtTokens.EQEQ -> PrimitiveToObjectEquality(left, right, leftType)
KtTokens.EXCLEQ -> Invert(PrimitiveToObjectEquality(left, right, leftType))
else -> throw AssertionError("Unexpected opToken: $opToken")
}
@JvmStatic
fun isApplicable(opToken: IElementType, leftType: Type, rightType: Type) =
(opToken == KtTokens.EQEQ || opToken == KtTokens.EXCLEQ) &&
AsmUtil.isIntOrLongPrimitive(leftType) &&
rightType.sort == Type.OBJECT
}
}

View File

@@ -54,7 +54,9 @@ open class BranchedValue(
condJump(jumpLabel, v, jumpIfFalse)
}
protected open fun patchOpcode(opcode: Int, v: InstructionAdapter): Int = opcode
protected open fun patchOpcode(opcode: Int, v: InstructionAdapter): Int {
return opcode
}
companion object {
val negatedOperations = hashMapOf<Int, Int>()
@@ -118,9 +120,13 @@ open class BranchedValue(
negatedOperations.put(negatedOp, op)
}
fun booleanConstant(value: Boolean): BranchedValue = if (value) TRUE else FALSE
fun booleanConstant(value: Boolean): BranchedValue {
return if (value) TRUE else FALSE
}
fun createInvertValue(argument: StackValue): StackValue = Invert(condJump(argument))
fun createInvertValue(argument: StackValue): StackValue {
return Invert(condJump(argument))
}
fun condJump(condition: StackValue, label: Label, jumpIfFalse: Boolean, iv: InstructionAdapter) {
condJump(condition).condJump(label, iv, jumpIfFalse)
@@ -130,11 +136,14 @@ open class BranchedValue(
condJump(condition).loopJump(label, iv, jumpIfFalse)
}
fun condJump(condition: StackValue): CondJump =
CondJump(
condition as? BranchedValue ?: BranchedValue(condition, null, Type.BOOLEAN_TYPE, IFEQ),
IFEQ
)
fun condJump(condition: StackValue): CondJump {
return CondJump(if (condition is BranchedValue) {
condition
}
else {
BranchedValue(condition, null, Type.BOOLEAN_TYPE, IFEQ)
}, IFEQ)
}
fun cmp(opToken: IElementType, operandType: Type, left: StackValue, right: StackValue): StackValue =
if (operandType.sort == Type.OBJECT)
@@ -194,46 +203,51 @@ class CondJump(val condition: BranchedValue, op: Int) : BranchedValue(condition,
}
class NumberCompare(
private val opToken: IElementType,
val opToken: IElementType,
operandType: Type,
left: StackValue,
right: StackValue
) : BranchedValue(left, right, operandType, NumberCompare.getNumberCompareOpcode(opToken)) {
override fun patchOpcode(opcode: Int, v: InstructionAdapter): Int =
patchOpcode(opcode, v, opToken, operandType)
companion object {
fun getNumberCompareOpcode(opToken: IElementType): Int = when (opToken) {
KtTokens.EQEQ, KtTokens.EQEQEQ -> IFNE
KtTokens.EXCLEQ, KtTokens.EXCLEQEQEQ -> IFEQ
KtTokens.GT -> IFLE
KtTokens.GTEQ -> IFLT
KtTokens.LT -> IFGE
KtTokens.LTEQ -> IFGT
else -> {
throw UnsupportedOperationException("Don't know how to generate this condJump: " + opToken)
}
override fun patchOpcode(opcode: Int, v: InstructionAdapter): Int {
// Opcode takes one int operand from the stack
assert(opcode in IFEQ..IFLE) {
"Opcode for comparing must be in range ${IFEQ..IFLE}, but $opcode was found"
}
fun patchOpcode(opcode: Int, v: InstructionAdapter, opToken: IElementType, operandType: Type): Int {
assert(opcode in IFEQ..IFLE) {
"Opcode for comparing must be in range ${IFEQ..IFLE}, but $opcode was found"
return when (operandType) {
Type.FLOAT_TYPE, Type.DOUBLE_TYPE -> {
if (opToken == KtTokens.GT || opToken == KtTokens.GTEQ) {
v.cmpl(operandType)
}
else {
v.cmpg(operandType)
}
opcode
}
return when (operandType) {
Type.FLOAT_TYPE, Type.DOUBLE_TYPE -> {
if (opToken == KtTokens.GT || opToken == KtTokens.GTEQ)
v.cmpl(operandType)
else
v.cmpg(operandType)
opcode
Type.LONG_TYPE -> {
v.lcmp()
opcode
}
else -> {
opcode + (IF_ICMPEQ - IFEQ)
}
}
}
companion object {
fun getNumberCompareOpcode(opToken: IElementType): Int {
return when (opToken) {
KtTokens.EQEQ, KtTokens.EQEQEQ -> IFNE
KtTokens.EXCLEQ, KtTokens.EXCLEQEQEQ -> IFEQ
KtTokens.GT -> IFLE
KtTokens.GTEQ -> IFLT
KtTokens.LT -> IFGE
KtTokens.LTEQ -> IFGT
else -> {
throw UnsupportedOperationException("Don't know how to generate this condJump: " + opToken)
}
Type.LONG_TYPE -> {
v.lcmp()
opcode
}
else ->
opcode + (IF_ICMPEQ - IFEQ)
}
}
}
@@ -247,11 +261,12 @@ class ObjectCompare(
) : BranchedValue(left, right, operandType, ObjectCompare.getObjectCompareOpcode(opToken)) {
companion object {
fun getObjectCompareOpcode(opToken: IElementType): Int = when (opToken) {
KtTokens.EQEQEQ -> IF_ACMPNE
KtTokens.EXCLEQEQEQ -> IF_ACMPEQ
else -> throw UnsupportedOperationException("don't know how to generate this condjump")
fun getObjectCompareOpcode(opToken: IElementType): Int {
return when (opToken) {
KtTokens.EQEQEQ -> IF_ACMPNE
KtTokens.EXCLEQEQEQ -> IF_ACMPEQ
else -> throw UnsupportedOperationException("don't know how to generate this condjump")
}
}
}
}

View File

@@ -17,18 +17,18 @@
package org.jetbrains.kotlin.codegen;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.descriptors.CallableDescriptor;
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor;
import org.jetbrains.kotlin.psi.KtExpression;
import org.jetbrains.kotlin.psi.ValueArgument;
import org.jetbrains.kotlin.resolve.calls.model.DefaultValueArgument;
import org.jetbrains.kotlin.resolve.calls.model.ExpressionValueArgument;
import org.jetbrains.kotlin.resolve.calls.model.VarargValueArgument;
import org.jetbrains.kotlin.resolve.calls.model.*;
import org.jetbrains.kotlin.types.FlexibleTypesKt;
import org.jetbrains.org.objectweb.asm.Type;
import java.util.List;
import static org.jetbrains.kotlin.codegen.StackValue.createDefaulValue;
import static org.jetbrains.kotlin.codegen.AsmUtil.pushDefaultValueOnStack;
public class CallBasedArgumentGenerator extends ArgumentGenerator {
private final ExpressionCodegen codegen;
@@ -51,6 +51,21 @@ public class CallBasedArgumentGenerator extends ArgumentGenerator {
"Value parameters and their types mismatch in sizes: " + valueParameters.size() + " != " + valueParameterTypes.size();
}
@NotNull
@Override
public DefaultCallArgs generate(
@NotNull List<? extends ResolvedValueArgument> valueArgumentsByIndex,
@NotNull List<? extends ResolvedValueArgument> valueArgs,
@Nullable CallableDescriptor calleeDescriptor
) {
boolean shouldMarkLineNumbers = this.codegen.isShouldMarkLineNumbers();
this.codegen.setShouldMarkLineNumbers(false);
DefaultCallArgs defaultArgs = super.generate(valueArgumentsByIndex, valueArgs, calleeDescriptor);
this.codegen.setShouldMarkLineNumbers(shouldMarkLineNumbers);
return defaultArgs;
}
@Override
protected void generateExpression(int i, @NotNull ExpressionValueArgument argument) {
ValueParameterDescriptor parameter = valueParameters.get(i);
@@ -64,16 +79,19 @@ public class CallBasedArgumentGenerator extends ArgumentGenerator {
@Override
protected void generateDefault(int i, @NotNull DefaultValueArgument argument) {
callGenerator.putValueIfNeeded(valueParameterTypes.get(i), createDefaulValue(valueParameterTypes.get(i)), ValueKind.DEFAULT_PARAMETER, i);
Type type = valueParameterTypes.get(i);
pushDefaultValueOnStack(type, codegen.v);
callGenerator.afterParameterPut(type, null, i);
}
@Override
protected void generateVararg(int i, @NotNull VarargValueArgument argument) {
ValueParameterDescriptor parameter = valueParameters.get(i);
Type type = valueParameterTypes.get(i);
// Upper bound for type of vararg parameter should always have a form of 'Array<out T>',
// while its lower bound may be Nothing-typed after approximation
StackValue lazyVararg = codegen.genVarargs(argument, FlexibleTypesKt.upperIfFlexible(parameter.getType()));
callGenerator.putValueIfNeeded(valueParameterTypes.get(i), lazyVararg, ValueKind.GENERAL_VARARG, i);
codegen.genVarargs(argument, FlexibleTypesKt.upperIfFlexible(parameter.getType()));
callGenerator.afterParameterPut(type, null, i);
}
@Override

View File

@@ -21,19 +21,9 @@ import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.org.objectweb.asm.Type
enum class ValueKind {
GENERAL,
GENERAL_VARARG,
DEFAULT_PARAMETER,
DEFAULT_MASK,
METHOD_HANDLE_IN_DEFAULT,
CAPTURED,
DEFAULT_LAMBDA_CAPTURED_PARAMETER
}
abstract class CallGenerator {
interface CallGenerator {
class DefaultCallGenerator(private val codegen: ExpressionCodegen) : CallGenerator {
internal class DefaultCallGenerator(private val codegen: ExpressionCodegen) : CallGenerator() {
override fun genCallInner(
callableMethod: Callable,
@@ -48,6 +38,13 @@ interface CallGenerator {
}
}
override fun afterParameterPut(
type: Type,
stackValue: StackValue?,
parameterIndex: Int) {
}
override fun processAndPutHiddenParameters(justProcess: Boolean) {
}
@@ -70,7 +67,8 @@ interface CallGenerator {
stackValue.put(stackValue.type, codegen.v)
}
override fun putValueIfNeeded(parameterType: Type, value: StackValue, kind: ValueKind, parameterIndex: Int) {
override fun putValueIfNeeded(
parameterType: Type, value: StackValue) {
value.put(value.type, codegen.v)
}
@@ -106,34 +104,31 @@ interface CallGenerator {
genCallInner(callableMethod, resolvedCall, callDefault, codegen)
}
fun genCallInner(callableMethod: Callable, resolvedCall: ResolvedCall<*>?, callDefault: Boolean, codegen: ExpressionCodegen)
abstract fun genCallInner(callableMethod: Callable, resolvedCall: ResolvedCall<*>?, callDefault: Boolean, codegen: ExpressionCodegen)
fun genValueAndPut(
abstract fun afterParameterPut(
type: Type,
stackValue: StackValue?,
parameterIndex: Int)
abstract fun genValueAndPut(
valueParameterDescriptor: ValueParameterDescriptor,
argumentExpression: KtExpression,
parameterType: Type,
parameterIndex: Int)
fun putValueIfNeeded(
abstract fun putValueIfNeeded(
parameterType: Type,
value: StackValue) {
putValueIfNeeded(parameterType, value, ValueKind.GENERAL)
}
value: StackValue)
fun putValueIfNeeded(
parameterType: Type,
value: StackValue,
kind: ValueKind = ValueKind.GENERAL,
parameterIndex: Int = -1)
fun putCapturedValueOnStack(
abstract fun putCapturedValueOnStack(
stackValue: StackValue,
valueType: Type, paramIndex: Int)
fun processAndPutHiddenParameters(justProcess: Boolean)
abstract fun processAndPutHiddenParameters(justProcess: Boolean)
/*should be called if justProcess = true in processAndPutHiddenParameters*/
fun putHiddenParamsIntoLocals()
abstract fun putHiddenParamsIntoLocals()
fun reorderArgumentsIfNeeded(actualArgsWithDeclIndex: List<ArgumentAndDeclIndex>, valueParameterTypes: List<Type>)
abstract fun reorderArgumentsIfNeeded(actualArgsWithDeclIndex: List<ArgumentAndDeclIndex>, valueParameterTypes: List<Type>)
}

View File

@@ -1,168 +0,0 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.codegen;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.codegen.intrinsics.JavaClassProperty;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
public class CallReceiver extends StackValue {
private final StackValue dispatchReceiver;
private final StackValue extensionReceiver;
private final Type secondReceiverType;
private CallReceiver(
@NotNull StackValue dispatchReceiver,
@NotNull StackValue extensionReceiver,
@NotNull Type type,
@Nullable Type secondReceiverType
) {
super(type, dispatchReceiver.canHaveSideEffects() || extensionReceiver.canHaveSideEffects());
this.dispatchReceiver = dispatchReceiver;
this.extensionReceiver = extensionReceiver;
this.secondReceiverType = secondReceiverType;
}
public StackValue withoutReceiverArgument() {
return new CallReceiver(dispatchReceiver, none(), type, secondReceiverType);
}
public static StackValue generateCallReceiver(
@NotNull ResolvedCall<?> resolvedCall,
@NotNull ExpressionCodegen codegen,
@Nullable Callable callableMethod,
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
@NotNull StackValue dispatchReceiver,
@Nullable ReceiverParameterDescriptor extensionReceiverParameter,
@NotNull StackValue extensionReceiver
) {
KotlinTypeMapper typeMapper = codegen.typeMapper;
GenerationState state = codegen.getState();
Type type;
Type secondReceiverType = null;
if (extensionReceiverParameter != null) {
type = calcExtensionReceiverType(resolvedCall, extensionReceiverParameter, typeMapper, callableMethod, state);
if (dispatchReceiverParameter != null) {
secondReceiverType = calcDispatchReceiverType(resolvedCall, dispatchReceiverParameter, typeMapper, callableMethod);
}
}
else if (dispatchReceiverParameter != null) {
type = calcDispatchReceiverType(resolvedCall, dispatchReceiverParameter, typeMapper, callableMethod);
}
else if (isLocalFunCall(callableMethod)) {
type = callableMethod.getGenerateCalleeType();
}
else {
type = Type.VOID_TYPE;
}
assert type != null : "Could not map receiver type for " + resolvedCall;
return new CallReceiver(dispatchReceiver, extensionReceiver, type, secondReceiverType);
}
private static Type calcDispatchReceiverType(
@NotNull ResolvedCall<?> resolvedCall,
@Nullable ReceiverParameterDescriptor dispatchReceiver,
@NotNull KotlinTypeMapper typeMapper,
@Nullable Callable callableMethod
) {
if (dispatchReceiver == null) return null;
CallableDescriptor descriptor = resolvedCall.getResultingDescriptor();
if (CodegenUtilKt.isJvmStaticInObjectOrClass(descriptor)) {
return Type.VOID_TYPE;
}
if (callableMethod != null) {
return callableMethod.getDispatchReceiverType();
}
// Extract the receiver from the resolved call, workarounding the fact that ResolvedCall#dispatchReceiver doesn't have
// all the needed information, for example there's no way to find out whether or not a smart cast was applied to the receiver.
DeclarationDescriptor container = descriptor.getContainingDeclaration();
if (container instanceof ClassDescriptor) {
return typeMapper.mapClass((ClassDescriptor) container);
}
return typeMapper.mapType(dispatchReceiver);
}
private static Type calcExtensionReceiverType(
@NotNull ResolvedCall<?> resolvedCall,
@Nullable ReceiverParameterDescriptor extensionReceiver,
@NotNull KotlinTypeMapper typeMapper,
@Nullable Callable callableMethod,
@NotNull GenerationState state
) {
if (extensionReceiver == null) return null;
CallableDescriptor descriptor = resolvedCall.getCandidateDescriptor();
if (descriptor instanceof PropertyDescriptor &&
// hackaround: boxing changes behaviour of T.javaClass intrinsic
state.getIntrinsics().getIntrinsic((PropertyDescriptor) descriptor) != JavaClassProperty.INSTANCE
) {
ReceiverParameterDescriptor receiverCandidate = descriptor.getExtensionReceiverParameter();
assert receiverCandidate != null;
return typeMapper.mapType(receiverCandidate.getType());
}
return callableMethod != null ? callableMethod.getExtensionReceiverType() : typeMapper.mapType(extensionReceiver.getType());
}
@Override
public void putSelector(@NotNull Type type, @NotNull InstructionAdapter v) {
StackValue currentExtensionReceiver = extensionReceiver;
boolean hasExtensionReceiver = extensionReceiver != none();
if (extensionReceiver instanceof SafeCall) {
currentExtensionReceiver.put(currentExtensionReceiver.type, v);
currentExtensionReceiver = StackValue.onStack(currentExtensionReceiver.type);
}
Type dispatchReceiverType = secondReceiverType != null ? secondReceiverType :
hasExtensionReceiver ? dispatchReceiver.type :
type;
dispatchReceiver.put(dispatchReceiverType, v);
currentExtensionReceiver
.moveToTopOfStack(hasExtensionReceiver ? type : currentExtensionReceiver.type, v, dispatchReceiverType.getSize());
}
@Override
public void dup(@NotNull InstructionAdapter v, boolean withReceiver) {
AsmUtil.dup(v, extensionReceiver.type, dispatchReceiver.type);
}
@NotNull
public StackValue getDispatchReceiver() {
return dispatchReceiver;
}
@NotNull
public StackValue getExtensionReceiver() {
return extensionReceiver;
}
}

View File

@@ -45,7 +45,7 @@ interface Callable {
}
}
fun afterReceiverGeneration(v: InstructionAdapter, frameMap: FrameMap) {
fun afterReceiverGeneration(v: InstructionAdapter) {
}
}

View File

@@ -35,13 +35,8 @@ import java.util.List;
import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.enumEntryNeedSubclass;
public abstract class ClassBodyCodegen extends MemberCodegen<KtPureClassOrObject> {
@NotNull
public final KtPureClassOrObject myClass;
@NotNull
public final OwnerKind kind;
@NotNull
public final ClassDescriptor descriptor;
protected ClassBodyCodegen(
@@ -59,7 +54,7 @@ public abstract class ClassBodyCodegen extends MemberCodegen<KtPureClassOrObject
@Override
protected void generateBody() {
List<KtObjectDeclaration> companions = new ArrayList<>();
List<KtObjectDeclaration> companions = new ArrayList<KtObjectDeclaration>();
if (kind != OwnerKind.DEFAULT_IMPLS) {
//generate nested classes first and only then generate class body. It necessary to access to nested CodegenContexts
for (KtDeclaration declaration : myClass.getDeclarations()) {

View File

@@ -55,12 +55,20 @@ public class ClassBuilderFactories {
throw new IllegalStateException();
}
};
public static ClassBuilderFactory TEST_KAPT3 = new TestClassBuilderFactory(false) {
@NotNull
@Override
public ClassBuilderMode getClassBuilderMode() {
return ClassBuilderMode.KAPT3;
}
};
public static ClassBuilderFactory TEST = new TestClassBuilderFactory(false);
public static ClassBuilderFactory TEST_WITH_SOURCE_RETENTION_ANNOTATIONS = new TestClassBuilderFactory(true);
public static class TestClassBuilderFactory implements ClassBuilderFactory {
private static class TestClassBuilderFactory implements ClassBuilderFactory {
private final boolean generateSourceRetentionAnnotations;
public TestClassBuilderFactory(boolean generateSourceRetentionAnnotations) {
@@ -101,7 +109,7 @@ public class ClassBuilderFactories {
}
@NotNull
public static ClassBuilderFactory binaries(boolean generateSourceRetentionAnnotations) {
public static ClassBuilderFactory binaries(final boolean generateSourceRetentionAnnotations) {
return new ClassBuilderFactory() {
@NotNull
@Override

View File

@@ -16,8 +16,6 @@
package org.jetbrains.kotlin.codegen;
import org.jetbrains.annotations.TestOnly;
public class ClassBuilderMode {
public final boolean generateBodies;
public final boolean generateMetadata;
@@ -75,11 +73,4 @@ public class ClassBuilderMode {
/* metadata = */ true,
/* sourceRetention = */ true,
/* generateMultiFileFacadePartClasses = */ true);
@TestOnly
public final static ClassBuilderMode LIGHT_ANALYSIS_FOR_TESTS = new ClassBuilderMode(
/* bodies = */ false,
/* metadata = */ true,
/* sourceRetention = */ false,
/* generateMultiFileFacadePartClasses = */ true);
}

View File

@@ -18,6 +18,8 @@ package org.jetbrains.kotlin.codegen;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import kotlin.collections.CollectionsKt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -42,12 +44,12 @@ import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.getMappingFileName;
public class ClassFileFactory implements OutputFileCollection {
private final GenerationState state;
private final ClassBuilderFactory builderFactory;
private final Map<String, OutAndSourceFileList> generators = new LinkedHashMap<>();
private final Map<String, OutAndSourceFileList> generators = new LinkedHashMap<String, OutAndSourceFileList>();
private boolean isDone = false;
private final Set<File> packagePartSourceFiles = new HashSet<>();
private final Map<String, PackageParts> partsGroupedByPackage = new LinkedHashMap<>();
private final Set<File> packagePartSourceFiles = new HashSet<File>();
private final Map<String, PackageParts> partsGroupedByPackage = new LinkedHashMap<String, PackageParts>();
public ClassFileFactory(@NotNull GenerationState state, @NotNull ClassBuilderFactory builderFactory) {
this.state = state;
@@ -92,7 +94,7 @@ public class ClassFileFactory implements OutputFileCollection {
}
private void writeModuleMappings() {
JvmPackageTable.PackageTable.Builder builder = JvmPackageTable.PackageTable.newBuilder();
final JvmPackageTable.PackageTable.Builder builder = JvmPackageTable.PackageTable.newBuilder();
String outputFilePath = getMappingFileName(state.getModuleName());
for (PackageParts part : ClassFileUtilsKt.addCompiledPartsAndSort(partsGroupedByPackage.values(), state)) {
@@ -128,7 +130,12 @@ public class ClassFileFactory implements OutputFileCollection {
@NotNull
public List<OutputFile> getCurrentOutput() {
return CollectionsKt.map(generators.keySet(), OutputClassFile::new);
return ContainerUtil.map(generators.keySet(), new Function<String, OutputFile>() {
@Override
public OutputFile fun(String relativeClassFilePath) {
return new OutputClassFile(relativeClassFilePath);
}
});
}
@Override
@@ -153,7 +160,7 @@ public class ClassFileFactory implements OutputFileCollection {
@NotNull
@TestOnly
public Map<String, String> createTextForEachFile() {
Map<String, String> answer = new LinkedHashMap<>();
Map<String, String> answer = new LinkedHashMap<String, String>();
for (OutputFile file : asList()) {
answer.put(file.getRelativePath(), file.asText());
}
@@ -175,10 +182,17 @@ public class ClassFileFactory implements OutputFileCollection {
}
private PackagePartRegistry buildNewPackagePartRegistry(@NotNull FqName packageFqName) {
String packageFqNameAsString = packageFqName.asString();
return (partShortName, facadeShortName) -> {
PackageParts packageParts = partsGroupedByPackage.computeIfAbsent(packageFqNameAsString, PackageParts::new);
packageParts.addPart(partShortName, facadeShortName);
final String packageFqNameAsString = packageFqName.asString();
return new PackagePartRegistry() {
@Override
public void addPart(@NotNull String partShortName, @Nullable String facadeShortName) {
PackageParts packageParts = partsGroupedByPackage.get(packageFqNameAsString);
if (packageParts == null) {
packageParts = new PackageParts(packageFqNameAsString);
partsGroupedByPackage.put(packageFqNameAsString, packageParts);
}
packageParts.addPart(partShortName, facadeShortName);
}
};
}
@@ -188,7 +202,7 @@ public class ClassFileFactory implements OutputFileCollection {
@NotNull
private static List<File> toIoFilesIgnoringNonPhysical(@NotNull Collection<? extends PsiFile> psiFiles) {
List<File> result = new ArrayList<>(psiFiles.size());
List<File> result = new ArrayList<File>(psiFiles.size());
for (PsiFile psiFile : psiFiles) {
VirtualFile virtualFile = psiFile.getVirtualFile();
// We ignore non-physical files here, because this code is needed to tell the make what inputs affect which outputs

View File

@@ -21,20 +21,20 @@ import com.intellij.util.ArrayUtil;
import kotlin.Pair;
import kotlin.Unit;
import kotlin.collections.CollectionsKt;
import kotlin.jvm.functions.Function1;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.codegen.binding.CalculatedClosure;
import org.jetbrains.kotlin.codegen.binding.CodegenBinding;
import org.jetbrains.kotlin.codegen.context.ClosureContext;
import org.jetbrains.kotlin.codegen.context.EnclosedValueDescriptor;
import org.jetbrains.kotlin.codegen.coroutines.CoroutineCodegenUtilKt;
import org.jetbrains.kotlin.codegen.inline.InlineCodegenUtil;
import org.jetbrains.kotlin.codegen.serialization.JvmSerializerExtension;
import org.jetbrains.kotlin.codegen.signature.BothSignatureWriter;
import org.jetbrains.kotlin.codegen.signature.JvmSignatureWriter;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor;
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
import org.jetbrains.kotlin.load.java.JvmAbi;
@@ -49,6 +49,7 @@ import org.jetbrains.kotlin.serialization.ProtoBuf;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils;
import org.jetbrains.kotlin.util.OperatorNameConventions;
import org.jetbrains.org.objectweb.asm.AnnotationVisitor;
import org.jetbrains.org.objectweb.asm.MethodVisitor;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
@@ -61,7 +62,6 @@ import java.util.List;
import static org.jetbrains.kotlin.codegen.AsmUtil.*;
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isConst;
import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.CLOSURE;
import static org.jetbrains.kotlin.codegen.inline.InlineCodegenUtils2Kt.initDefaultSourceMappingIfNeeded;
import static org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings.METHOD_FOR_FUNCTION;
import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.*;
import static org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin.NO_ORIGIN;
@@ -102,7 +102,7 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
this.strategy = strategy;
if (samType == null) {
this.superInterfaceTypes = new ArrayList<>();
this.superInterfaceTypes = new ArrayList<KotlinType>();
KotlinType superClassType = null;
for (KotlinType supertype : classDescriptor.getTypeConstructor().getSupertypes()) {
@@ -160,7 +160,7 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
superInterfaceAsmTypes
);
initDefaultSourceMappingIfNeeded(context, this, state);
InlineCodegenUtil.initDefaultSourceMappingIfNeeded(context, this, state);
v.visitSource(element.getContainingFile().getName(), null);
}
@@ -231,23 +231,49 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
@Override
protected void generateKotlinMetadataAnnotation() {
FunctionDescriptor frontendFunDescriptor = CodegenUtilKt.unwrapFrontendVersion(funDescriptor);
FunctionDescriptor freeLambdaDescriptor = createFreeLambdaDescriptor(frontendFunDescriptor);
Method method = v.getSerializationBindings().get(METHOD_FOR_FUNCTION, frontendFunDescriptor);
assert method != null : "No method for " + frontendFunDescriptor;
FunctionDescriptor freeLambdaDescriptor = FakeDescriptorsForReferencesKt.createFreeFakeLambdaDescriptor(frontendFunDescriptor);
v.getSerializationBindings().put(METHOD_FOR_FUNCTION, freeLambdaDescriptor, method);
DescriptorSerializer serializer =
final DescriptorSerializer serializer =
DescriptorSerializer.createForLambda(new JvmSerializerExtension(v.getSerializationBindings(), state));
ProtoBuf.Function functionProto = serializer.functionProto(freeLambdaDescriptor).build();
final ProtoBuf.Function functionProto = serializer.functionProto(freeLambdaDescriptor).build();
WriteAnnotationUtilKt.writeKotlinMetadata(v, state, KotlinClassHeader.Kind.SYNTHETIC_CLASS, 0, av -> {
writeAnnotationData(av, serializer, functionProto);
return Unit.INSTANCE;
WriteAnnotationUtilKt.writeKotlinMetadata(v, state, KotlinClassHeader.Kind.SYNTHETIC_CLASS, 0, new Function1<AnnotationVisitor, Unit>() {
@Override
public Unit invoke(AnnotationVisitor av) {
writeAnnotationData(av, serializer, functionProto);
return Unit.INSTANCE;
}
});
}
/**
* Given a function descriptor, creates another function descriptor with type parameters copied from outer context(s).
* This is needed because once we're serializing this to a proto, there's no place to store information about external type parameters.
*/
@NotNull
private static FunctionDescriptor createFreeLambdaDescriptor(@NotNull FunctionDescriptor descriptor) {
FunctionDescriptor.CopyBuilder<? extends FunctionDescriptor> builder = descriptor.newCopyBuilder();
List<TypeParameterDescriptor> typeParameters = new ArrayList<TypeParameterDescriptor>(0);
builder.setTypeParameters(typeParameters);
DeclarationDescriptor container = descriptor.getContainingDeclaration();
while (container != null) {
if (container instanceof ClassDescriptor) {
typeParameters.addAll(((ClassDescriptor) container).getDeclaredTypeParameters());
}
else if (container instanceof CallableDescriptor && !(container instanceof ConstructorDescriptor)) {
typeParameters.addAll(((CallableDescriptor) container).getTypeParameters());
}
container = container.getContainingDeclaration();
}
return typeParameters.isEmpty() ? descriptor : builder.build();
}
@Override
protected void done() {
writeOuterClassAndEnclosingMethod();
@@ -255,22 +281,25 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
}
@NotNull
public StackValue putInstanceOnStack(@NotNull ExpressionCodegen codegen, @Nullable StackValue functionReferenceReceiver) {
public StackValue putInstanceOnStack(@NotNull final ExpressionCodegen codegen, @Nullable final StackValue functionReferenceReceiver) {
return StackValue.operation(
functionReferenceTarget != null ? K_FUNCTION : asmType,
v -> {
if (isConst(closure)) {
v.getstatic(asmType.getInternalName(), JvmAbi.INSTANCE_FIELD, asmType.getDescriptor());
}
else {
v.anew(asmType);
v.dup();
new Function1<InstructionAdapter, Unit>() {
@Override
public Unit invoke(InstructionAdapter v) {
if (isConst(closure)) {
v.getstatic(asmType.getInternalName(), JvmAbi.INSTANCE_FIELD, asmType.getDescriptor());
}
else {
v.anew(asmType);
v.dup();
codegen.pushClosureOnStack(classDescriptor, true, codegen.defaultCallGenerator, functionReferenceReceiver);
v.invokespecial(asmType.getInternalName(), "<init>", constructor.getDescriptor(), false);
}
codegen.pushClosureOnStack(classDescriptor, true, codegen.defaultCallGenerator, functionReferenceReceiver);
v.invokespecial(asmType.getInternalName(), "<init>", constructor.getDescriptor(), false);
}
return Unit.INSTANCE;
return Unit.INSTANCE;
}
}
);
}
@@ -294,7 +323,7 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
Type[] myParameterTypes = bridge.getArgumentTypes();
List<ParameterDescriptor> calleeParameters = CollectionsKt.plus(
CollectionsKt.listOfNotNull(funDescriptor.getExtensionReceiverParameter()),
org.jetbrains.kotlin.utils.CollectionsKt.<ParameterDescriptor>singletonOrEmptyList(funDescriptor.getExtensionReceiverParameter()),
funDescriptor.getValueParameters()
);
@@ -360,30 +389,13 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
@NotNull GenerationState state
) {
DeclarationDescriptor container = descriptor.getContainingDeclaration();
if (container instanceof ClassDescriptor) {
// TODO: getDefaultType() here is wrong and won't work for arrays
putJavaLangClassInstance(iv, state.getTypeMapper().mapType(((ClassDescriptor) container).getDefaultType()));
wrapJavaClassIntoKClass(iv);
}
else if (container instanceof PackageFragmentDescriptor) {
iv.aconst(state.getTypeMapper().mapOwner(descriptor));
}
else if (descriptor instanceof VariableDescriptorWithAccessors) {
iv.aconst(state.getBindingContext().get(
CodegenBinding.DELEGATED_PROPERTY_METADATA_OWNER, ((VariableDescriptorWithAccessors) descriptor)
));
}
else {
iv.aconst(null);
return;
}
boolean isContainerPackage =
descriptor instanceof LocalVariableDescriptor
? DescriptorUtils.getParentOfType(descriptor, ClassDescriptor.class) == null
: container instanceof PackageFragmentDescriptor;
if (isContainerPackage) {
// Note that this name is not used in reflection. There should be the name of the referenced declaration's module instead,
// but there's no nice API to obtain that name here yet
// TODO: write the referenced declaration's module name and use it in reflection
@@ -392,7 +404,7 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
Type.getMethodDescriptor(K_DECLARATION_CONTAINER_TYPE, getType(Class.class), getType(String.class)), false);
}
else {
wrapJavaClassIntoKClass(iv);
iv.aconst(null);
}
}

View File

@@ -36,7 +36,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
import org.jetbrains.kotlin.resolve.descriptorUtil.getAllSuperclassesWithoutAny
import org.jetbrains.kotlin.resolve.descriptorUtil.overriddenTreeUniqueAsSequence
import org.jetbrains.kotlin.resolve.jvm.diagnostics.CollectionStub
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodGenericSignature
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
@@ -337,7 +337,7 @@ class CollectionStubMethodGenerator(
val access = ACC_PUBLIC or (if (synthetic) ACC_SYNTHETIC else 0)
val asmMethod = signature.asmMethod
val genericSignature = if (synthetic) null else signature.genericsSignature
val mv = v.newMethod(CollectionStub, access, asmMethod.name, asmMethod.descriptor, genericSignature, null)
val mv = v.newMethod(JvmDeclarationOrigin.NO_ORIGIN, access, asmMethod.name, asmMethod.descriptor, genericSignature, null)
mv.visitCode()
AsmUtil.genThrow(
InstructionAdapter(mv),
@@ -351,7 +351,7 @@ private val READ_ONLY_ARE_EQUAL_TO_MUTABLE_TYPE_CHECKER = KotlinTypeCheckerImpl.
val firstClass = x.declarationDescriptor as? ClassDescriptor ?: return@withAxioms x == y
val secondClass = y.declarationDescriptor as? ClassDescriptor ?: return@withAxioms x == y
val j2k = JavaToKotlinClassMap
val j2k = JavaToKotlinClassMap.INSTANCE
val firstReadOnly = if (j2k.isMutable(firstClass)) j2k.convertMutableToReadOnly(firstClass) else firstClass
val secondReadOnly = if (j2k.isMutable(secondClass)) j2k.convertMutableToReadOnly(secondClass) else secondClass
firstReadOnly.typeConstructor == secondReadOnly.typeConstructor

View File

@@ -17,11 +17,15 @@
package org.jetbrains.kotlin.codegen;
public interface CompilationErrorHandler {
CompilationErrorHandler THROW_EXCEPTION = (exception, fileUrl) -> {
if (exception instanceof RuntimeException) {
throw (RuntimeException) exception;
CompilationErrorHandler THROW_EXCEPTION = new CompilationErrorHandler() {
@Override
public void reportException(Throwable exception, String fileUrl) {
if (exception instanceof RuntimeException) {
throw (RuntimeException) exception;
}
throw new IllegalStateException(exception);
}
throw new IllegalStateException(exception);
};
void reportException(Throwable exception, String fileUrl);

View File

@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.codegen
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
import java.util.*
class DefaultCallArgs(val size: Int) {
@@ -55,11 +56,24 @@ class DefaultCallArgs(val size: Int) {
val toInts = toInts()
if (!toInts.isEmpty()) {
for (mask in toInts) {
callGenerator.putValueIfNeeded(Type.INT_TYPE, StackValue.constant(mask, Type.INT_TYPE), ValueKind.DEFAULT_MASK)
callGenerator.putValueIfNeeded(Type.INT_TYPE, StackValue.constant(mask, Type.INT_TYPE))
}
val parameterType = if (isConstructor) AsmTypes.DEFAULT_CONSTRUCTOR_MARKER else AsmTypes.OBJECT_TYPE
callGenerator.putValueIfNeeded(parameterType, StackValue.constant(null, parameterType), ValueKind.METHOD_HANDLE_IN_DEFAULT)
callGenerator.putValueIfNeeded(parameterType, StackValue.constant(null, parameterType))
}
return toInts.isNotEmpty()
}
fun generateOnStackIfNeeded(iv: InstructionAdapter, isConstructor: Boolean): Boolean {
val toInts = toInts()
if (!toInts.isEmpty()) {
for (mask in toInts) {
iv.iconst(mask)
}
val parameterType = if (isConstructor) AsmTypes.DEFAULT_CONSTRUCTOR_MARKER else AsmTypes.OBJECT_TYPE
iv.aconst(null)
}
return toInts.isNotEmpty()
}

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