Compare commits

..

1380 Commits

Author SHA1 Message Date
Alexey Sedunov
11e9e7b552 Move: Fix ClassCastException on processing of callable references to Java methods
#KT-16809 Fixed
2017-03-22 00:07:17 +03:00
Alexey Sedunov
2f95131368 Move: Filter out ConflictUsageInfo instances before running the refactoring
#KT-16556 Fixed
2017-03-22 00:07:16 +03:00
Alexey Sedunov
d6599c8b83 Move: Fix NPE on moving directory where at least one Kotlin file contains package directive unmatched by the containing directory
#KT-8955 Fixed
2017-03-22 00:07:15 +03:00
Alexey Sedunov
048d1c0365 Move: Get element listener before original declaration is invalidated by the refactoring 2017-03-22 00:07:14 +03:00
Alexey Sedunov
cd1420f7c1 Move: Fix incorrect FqName when moving declaration to default package
#KT-15586 Fixed
2017-03-22 00:07:13 +03:00
Alexey Sedunov
4bcde41e8c Move: Avoid temporary file rename if the current name doesn't conflict with other files in the target directory. Improve protection against exceptions during the refactoring which may prevent final rename 2017-03-22 00:07:12 +03:00
Alexey Sedunov
6b6736fd55 Move: Do not report conflict on usages of inherited protected members
#KT-15190 Fixed
2017-03-22 00:07:11 +03:00
Alexey Sedunov
b67a77404e Move: Implement conflict checking for internal members
#KT-13190 Fixed
2017-03-22 00:07:10 +03:00
Alexey Sedunov
f186e9f11f Move: Fix processing of references to non-real (fake override, etc.) members of companion object
#KT-15559 Fixed
2017-03-22 00:07:09 +03:00
Alexey Sedunov
d774807204 Implement post-refactoring optimization of unused imports
#KT-15822 Fixed
 #KT-13755 Fixed
2017-03-22 00:07:08 +03:00
Alexey Sedunov
a4e35011e4 Move: Check that constructor call corresponds to class being moved before
transforming outer instance to argument (fixes tests broken after the
commit before)
2017-03-22 00:07:07 +03:00
Alexey Sedunov
d14f341187 Move: Exclude conflict-associated usages from refactoring. Move file internal usages search to MoveKotlinDeclarationsProcessor 2017-03-22 00:07:06 +03:00
Alexey Sedunov
6cbdb53433 Move: Use Kotlin declaration mover on KtFile because existing file mover
does not process conflicts
 #KT-13911 Fixed
2017-03-22 00:07:05 +03:00
Yan Zhulanow
7a5f94129c Add ClassBuilderMode.KAPT3 tests 2017-03-21 20:49:36 +03:00
Yan Zhulanow
e25e19c4d6 Refactoring: Remove light analysis test data
The light analysis test data is not needed anymore cause the light analysis result is now automatically checked against the one from the full analysis.
2017-03-21 20:49:36 +03:00
Yan Zhulanow
c50881fd02 Refactoring: Extract light analysis tests from box tests 2017-03-21 20:49:34 +03:00
Mikhail Glukhikh
23848fa728 Suggest bound references in "Lambda --> Reference" for 1.1+ only 2017-03-21 20:32:15 +03:00
Ilya Chernikov
0f21db1ecb Copy base script classes to script-runtime before building bootstrap 2017-03-21 16:30:51 +01:00
Ilya Chernikov
08f6b6c93c minor: get rid of the compiler-test dependency in source-sections test 2017-03-21 16:30:50 +01:00
Ilya Chernikov
1eab936618 minor: Bump rubygrapefruit native-platform version to 0.14 2017-03-21 16:30:49 +01:00
Ilya Chernikov
d439c13fb5 minor: correct measurement error in eval bench test 2017-03-21 16:30:48 +01:00
Ilya Chernikov
4043f491da minor: replace Pair with data class in daemon client connectAndLease call
backport from 1.0.7
2017-03-21 16:30:47 +01:00
Ilya Chernikov
4b430b49a7 Implement source sections compiler plugin
allows to compile only parts of the source files, denoted by top-level
"sections" (function with lambda param calls), but preserving original
file line/column numbers for easier diagnostics. Allow e.g. to compile
gradle "buildscript" section without preprocessing original file in
advance. See tests for examples.
2017-03-21 16:30:46 +01:00
Ilya Chernikov
63c276d444 Create extension points and register plugins earlier...
to allow plugins to affect source files creation
2017-03-21 16:30:45 +01:00
Alexander Udalov
7dfa3bea18 Update tools & libraries projects to use JDK 8 when needed 2017-03-21 17:45:53 +03:00
Alexander Udalov
33a0ae0fcd Skip kotlin-maven-plugin integration test if "skipTests" is defined
Similarly to kotlin-maven-plugin-test/pom.xml
2017-03-21 17:45:51 +03:00
Alexander Udalov
4273357adf Skip kotlin-maven-plugin-test tests if "skipTests" property is defined
"mvn -DskipTests ..." or "mvn -DskipTests=true ..." should not invoke
any tests
2017-03-21 17:45:51 +03:00
Sergey Igushkin
132393cc64 Fix for androidTest Gradle build
Replaced adding Kotlin sources with dependency on copy*KotlinClasses,
which might not be called since Android Gradle plugin sometimes
bypasses the tasks in finalizedBy .
Added a test for androidTest build apart from general build.

Issues: #KT-16897 Fixed
2017-03-21 17:30:59 +03:00
Dmitry Jemerov
ba9213234c Increase -Xmx for running Ant from AntTaskTestGenerated
The current value is no longer sufficient when running under JDK 8.
2017-03-21 15:19:55 +01:00
Sergey Igushkin
498c4dddea Fix for compatibility with Android Gradle plugin 2.4.0-alpha1
Deferred resolution of JAR-to-AAR mapping, since the Android Gradle
plugin now resolves dependencies at execution phase.
Dropped the code related to the Jack toolchain compatibility.
Throwing a build error when Jack is enabled.
Changed warning about Jack into a build error.
2017-03-21 16:56:09 +03:00
Simon Ogorodnik
439e158fb2 Fix failing test after migration to IDEA 171
BasicCompletionWeigherTestGenerated$ExpectedInfo.testPreferMatchingThis
Looks like IDEA now rearranges elements with same weight by length and
then alphabetically
2017-03-21 16:47:16 +03:00
Dmitry Jemerov
f0b7891d41 Turn off API usage inspection 2017-03-21 14:44:20 +01:00
Pavel V. Talanov
a03e9d340e Wrap sourceScope() and binaryScope() using sourceFilterScope
To avoid having to wrap at call site
2017-03-21 16:20:02 +03:00
Pavel V. Talanov
06fd1f3c44 Drop unused LibrarySourceHacks 2017-03-21 16:20:02 +03:00
Pavel V. Talanov
dec9fa0324 SourceNavigationHelper: fix navigation to callables
Previously we could differentiate between callables with the same name
    when relevant type declaration were in the same file only
Problem manifested most severely when several copies of sources were attached
    to the same library
2017-03-21 16:20:01 +03:00
Pavel V. Talanov
d9a9d50602 KotlinScriptConfigurationManager#notifyRootsChanges: run synchronously in tests
Allows to unmute some of the ScriptConfigurationNavigation tests
2017-03-21 16:20:00 +03:00
Pavel V. Talanov
88447d69cb Introduce ScriptDependenciesSourceModuleInfo
Implement SourceForBinaryModuleInfo api to support navigation
Support in getModuleInfo and KotlinCacheServiceImpl
2017-03-21 16:19:59 +03:00
Pavel V. Talanov
434018f679 ScriptConfigurationNavigationTest: test navigation to kotlin library 2017-03-21 16:19:59 +03:00
Pavel V. Talanov
115474b90f SourceNavigationHelper: use API to narrow search scope 2017-03-21 16:19:58 +03:00
Pavel V. Talanov
4dee108afe J2K SourceNavigationHelper: convert to Kotlin and prettify 2017-03-21 16:19:57 +03:00
Pavel V. Talanov
aa74ccf163 J2K SourceNavigationHelper: rename file 2017-03-21 16:19:57 +03:00
Pavel V. Talanov
4c94d931fa findDecompiledDeclaration: narrow decompiled declaration search scope
Search scope of library that descriptor originated from
Introduce API that matches binaries and its' sources via IdeaModuleInfos
2017-03-21 16:19:56 +03:00
Pavel V. Talanov
569e7ac593 getModuleInfo, minor: clarify parameter parameter 2017-03-21 16:19:55 +03:00
Pavel V. Talanov
c7f147d058 Introduce NavigationWithMultipleLibrariesTest
Test navigation to library decompiled and source declaration when
there are multiple copies of the same library in project
Related to ba1ee99e97
2017-03-21 16:19:54 +03:00
Pavel V. Talanov
47e77201d5 AbstractNavigateToLibraryTest: refactor, extract utility code 2017-03-21 16:19:54 +03:00
Alexander Udalov
2d1b15b6fb Drop usages of '-XX:MaxPermSize' in run configurations on JDK 8 2017-03-21 16:09:18 +03:00
Dmitry Jemerov
04b64fa30c Sort Kotlin versions loaded from Maven by number
Otherwise we get 1.0.7 on top of 1.1.1, which is suboptimal
2017-03-21 14:03:25 +01:00
Dmitry Jemerov
8f8db75bb4 getNonConfiguredModules(project, configurator) excludes modules already configured with other configurators
#KT-16381 Fixed
2017-03-21 14:02:05 +01:00
Dmitry Jemerov
95bc0813f8 Don't show "Configure Kotlin" notification with an empty list of configurators (context: KT-16070) 2017-03-21 14:02:05 +01:00
Dmitry Jemerov
9f8af1feea Refactor getNonConfiguredModules(Project)
Rename to getNonConfiguredModulesWithKotlinFiles() to match what it
actually does, remove duplicate configurator status check, extract code
for collecting all configurators
2017-03-21 14:02:05 +01:00
Dmitry Jemerov
b86fe60a24 Don't report "can be configured" status if the file is already configured with another Gradle configurator 2017-03-21 14:02:05 +01:00
Dmitry Jemerov
1f96ead801 "Configure Kotlin in project" handles modules from Gradle source roots
THose modules are now always collapsed to their base modules.
 #KT-11828 Fixed
2017-03-21 14:02:05 +01:00
Dmitry Jemerov
b1a65e4c74 Don't show pre-1.1.0 version of Kotlin in version chooser when configuring JS projects
#KT-16400 Fixed
2017-03-21 14:02:05 +01:00
Dmitry Jemerov
8e26d5257f Don't add stdlib-jre7 or stdlib-jre8 dependencies when configuring Kotlin with pre-1.1 version
#KT-16401 Fixed
2017-03-21 14:02:05 +01:00
Dmitry Jemerov
cd4636a1e5 Add current version to "Configure Kotlin in project" version chooser if it is a release version and it wasn't found in the search results
#KT-16571 Fixed
2017-03-21 14:01:37 +01:00
Dmitry Jemerov
0f21595e4b Don't show "Configure Kotlin" if module is configured, project is not
Report CAN_BE_CONFIGURED from Gradle configurator only if we didn't
find any file containing valid configuration (normally the top-level
project file in an Android project doesn't have any Kotlin
configuration, so we report CAN_BE_CONFIGURED even though the module
file contains valid configuration)
2017-03-21 14:01:37 +01:00
Dmitry Jemerov
b48b3b3237 Show "Configure Kotlin" notification at most once after project opening
Don't show notification after every sync; trigger it from
rootsChanged handler because the root model is not yet updated at
syncDone point
 #KT-16590 Fixed
2017-03-21 14:01:37 +01:00
Dmitry Jemerov
0a586291b6 Check jar name before trying to load JS library version
#KT-16596 Fixed
2017-03-21 14:01:37 +01:00
Dmitry Jemerov
09b60e3f77 JsLibraryStdDetectionUtil: J2K 2017-03-21 14:01:37 +01:00
Dmitry Jemerov
dffff77a5d JsLibraryStdDetectionUtil: rename to .kt 2017-03-21 14:01:37 +01:00
Dmitry Jemerov
ad3be8f8b5 Add test for checking JS runtime version 2017-03-21 14:01:37 +01:00
Dmitry Jemerov
1c0acee989 Remove obsolete code for removing obsolete JS library 2017-03-21 14:01:37 +01:00
shiraji
27e1462b00 Apply quick-fix "Make visible" for INVISIBLE_FAKE #KT-16131 Fixed 2017-03-21 13:50:49 +03:00
Alexander Udalov
d4500878cb Do not strip some classes from xercesImpl.jar in compiler.pro
Note that with this config, the kotlin-compiler.jar's size is increased
by 1.5Mb

 #KT-16968 Fixed
2017-03-21 13:03:19 +03:00
Alexander Udalov
af5fbef4ea Use JDK 1.6 to compile modules under "core"
Outputs of these modules go into kotlin-stdlib and kotlin-reflect, both
of which must be usable on Java 6
2017-03-21 13:03:18 +03:00
Dmitry Jemerov
d80891e823 Add xercesImpl.jar to core classpath as it's now required for JDOMUtil 2017-03-20 18:46:13 +01:00
Alexey Sedunov
2e3617adbb Spring Support: Fix tests in IDEA 2017.1
Filter out duplicate reference targets.
Fix test data as directory references are available
inside of string literals.
Fix test data as Spring @Autowired inspection
no more reports parameterless methods.
Fix gutter checking as configuration bean references now resolve
to @ComponentScan annotation
2017-03-20 18:46:12 +01:00
Simon Ogorodnik
2804264289 Fix regression of completion inside string templates
CompletionContributor should not store offsets inside
replacement zone(part of file which are replaced with
dummy identifier) in offsetMap
 #KT-16848 fixed
2017-03-20 18:46:11 +01:00
Dmitry Jemerov
cf18c2243f Fix test: check highlighting only in one direction
Otherwise, when we check the highlighting on one of the files, the text
of the other still contains the <lineMarker> annotation and can't be
indexed as valid Kotlin code.
2017-03-20 18:46:10 +01:00
Alexander Udalov
555b3f12ee Use LinkedHashSet instead of HashSet in DataFlowInfo.getCollectedTypes
This fixes DiagnosticsTestGenerated$Tests.testImplicitIntersection,
which began to fail after update to JDK 8 because the iteration order of
HashMap/HashSet has changed in JDK 8:
http://openjdk.java.net/jeps/180
http://hg.openjdk.java.net/jdk8/jdk8/jdk/rev/43bd5ee0205e
2017-03-20 18:46:09 +01:00
Mikhael Bogdanov
211b58ac6e kt1770.kt test rewrote during migration to 171 platform 2017-03-20 18:46:08 +01:00
Dmitry Jemerov
10aedaf0f4 Adjust test data for IDEA 2017.1
Since https://github.com/JetBrains/intellij-community/commit/9c8003c
deprecated methods are considered to be entry points, so the Safe
Delete quickfix is no longer available for them.
2017-03-20 18:46:08 +01:00
Alexander Udalov
999e1061b8 Update test data for ant task tests
Looks like javac 1.8 started to report compilation errors a bit
differently here
2017-03-20 18:46:07 +01:00
Alexander Udalov
449d1f6ad2 Fix KotlinVersionsTest, use SAX parser instead of DOM 2017-03-20 18:46:06 +01:00
Alexander Udalov
33e9e660c4 Fix JvmRuntimeDescriptorLoaderTestGenerated
- Use FULL_JDK instead of mock JDK in some tests because mock JDK is
  created from JDK 6 and full JDK is now JDK 8, so there are differences
  in the behavior in the compiler and at runtime
- Remove some '*.runtime.txt' files which were workarounds to JDK 6
  reflection issues regarding generic inner classes; code in these tests
  is now loaded exactly the same in the compiler and at runtime
- Change supertype in SupertypesAndBounds.kt: the class in the supertype
  is not relevant to that test, it checks that annotations can be loaded
  on types
2017-03-20 18:46:05 +01:00
Alexander Udalov
3c96099f7c Fix compileJavaAgainstKotlin tests
- Use another API to get file name out of a javac diagnostic
  (.getSource().getName()'s behavior changed in JDK 8)
- Delete .txt files for those tests which check that javac reported a
  compilation error; the order and content of declarations in those
  files is undefined
2017-03-20 18:46:05 +01:00
Nikolay Krasko
4edfd0d960 Move getting source position to manager thread in tests
Real usages are performed in this thread too. Using AWT now fails
under runInReadActionWithWriteActionPriorityWithRetries added in
b0e995b41e
2017-03-20 18:46:04 +01:00
Alexey Sedunov
ecd56c6a40 Safe Delete: Fix tests in IDEA 2017.1
Now Java refactoring checks for side effects when deleting
arguments, so instantiation of Kotlin FunctionN is treated as
"unsafe"
2017-03-20 18:46:03 +01:00
Alexey Sedunov
b65460c12f Move: Fix tests in IDEA 2017.1
Do not prevent usages search if target directory is not known yet.
Force content root configuration for multi-module tests
2017-03-20 18:46:02 +01:00
Mikhael Bogdanov
496a21254b Black box update 2017-03-20 18:46:01 +01:00
Alexey Tsvetkov
40574d31ac JPS tests: avoid using deprecated API 2017-03-20 18:46:00 +01:00
Dmitry Jemerov
3a8cf68541 Keep class file version during shrinking; generate Java 8 bytecode
sometimes
2017-03-20 18:45:59 +01:00
Dmitry Jemerov
4cae0538a8 Don't warn about ElementTraversal
IDEA now (since commit 6ff87c6) uses this class to build classpath
for Xerces, and we don't use Xerces
2017-03-20 18:45:59 +01:00
Dmitry Jemerov
0638106bf3 Fix NPE in tests when ProjectFileIndex is not available 2017-03-20 18:45:51 +01:00
Dmitry Jemerov
0d86bdd216 Remove Java 6/7 warning from expected output of the compiler 2017-03-20 18:45:51 +01:00
Dmitry Jemerov
2adacf74ac Reduce -Xmx of "All Non-Compiler Tests" configuration
This should prevent VM crashes on TeamCity
2017-03-20 18:45:50 +01:00
Dmitry Jemerov
a8bd529871 Register MetaLanguage.EP_NAME in J2K test 2017-03-20 18:45:49 +01:00
Dmitry Jemerov
61f157e89d Remove write action around finishLookup(), according to IJ 2017.1 req 2017-03-20 18:45:48 +01:00
Dmitry Jemerov
b9f326bfa1 Register MetaLanguage extension point in ParsingTestCase 2017-03-20 18:45:47 +01:00
Dmitry Jemerov
097ba45783 Fix service and EP registration according to changes in 2017.1
Remove ControlFlowFactory (which is now registered in the platform),
register MetaLanguage (new in 2017.1)
2017-03-20 18:45:46 +01:00
Dmitry Jemerov
a539939388 Fix testdata according to contract inference changes in 2017.1 2017-03-20 18:45:46 +01:00
Dmitry Jemerov
ad821e83bd Fix testdata according to comment selection changes in 2017.1 2017-03-20 18:45:45 +01:00
Dmitry Jemerov
d6709b726e Fix testdata according to changes in automatic renaming rules in 17.1 2017-03-20 18:45:44 +01:00
Dmitry Jemerov
374cf517e1 Don't try to create "add modifier" fix for read-only elements
This fixes a failure of KotlinCleanupInspectionTest on IDEA 17.1.
2017-03-20 18:45:43 +01:00
Dmitry Jemerov
3d98237304 Fix GradleFacetImportTest: run write action only in EDT 2017-03-20 18:45:43 +01:00
Dmitry Jemerov
49a4625368 Fix testdata: Android projects use kotlin-stdlib-jre7 2017-03-20 18:45:42 +01:00
Dmitry Jemerov
12fc89f35d Update to 171.SNAPSHOT to pick up fix for IDEA-169570; fix compilation 2017-03-20 18:45:41 +01:00
Nikolay Krasko
1d29c81346 ! (TODO) Update build test data in 171 2017-03-20 18:45:40 +01:00
Nikolay Krasko
7da424d53f Port setInPerformanceTest -> setInStressTest 2017-03-20 18:45:39 +01:00
Nikolay Krasko
e57b3651c2 Replace removed method in LibraryPresentationProviders 2017-03-20 18:45:39 +01:00
Nikolay Krasko
615f9d3a1f Try to avoid exception in getOffset() call 2017-03-20 18:45:38 +01:00
Nikolay Krasko
eb8415a1f3 Use new api from idea 171 in KotlinStepOverInlinedLinesHint 2017-03-20 18:45:37 +01:00
Nikolay Krasko
bcf29e6fbf Run tests in read action and not in EDT thread
Otherwise test will fail because of runInReadActionWithWriteActionPriority call in EDT
2017-03-20 18:45:36 +01:00
Nikolay Krasko
82a2a705fb Do not wrap analyze into write action priority in tests
In tests the code is executed in EDT and runInReadActionWithWriteActionPriority fails

See: MergingUpdateQueue.setPassThrough() and ExternalToolPassFactory() constructor
2017-03-20 18:45:36 +01:00
Nikolay Krasko
95061885b0 Update after separating JPS builders into two modules 2017-03-20 18:45:35 +01:00
Nikolay Krasko
3e6f57b684 Updated nullability in RunLineMarkerContributor 2017-03-20 18:45:34 +01:00
Nikolay Krasko
4f079d2768 LightQuickFixTestCase.parseActionHint() method was removed 2017-03-20 18:45:33 +01:00
Nikolay Krasko
d5aac7df25 Copy dropped method nameToCompare() to test utils 2017-03-20 18:45:33 +01:00
Nikolay Krasko
9f51b12193 Update guava 19.0 sources jar 2017-03-20 18:45:32 +01:00
Nikolay Krasko
ed9e083008 Remove unused import 2017-03-20 18:45:31 +01:00
Mikhail Glukhikh
e6cefba98b Fix imports vs 2016.3 (ResourceFoldingBuilder) 2017-03-20 18:45:30 +01:00
Mikhail Glukhikh
83a8b041ad Fix ConfigureProjectTestGenerated / GradleConfigureProject ... for branch 163 (jre7->jre8) 2017-03-20 18:45:29 +01:00
Nikolay Krasko
2eb6c393a4 Move android modules to Java 8 SDK 2017-03-20 18:45:29 +01:00
Dmitry Jemerov
715410a9bc Workaround for hanging test 2017-03-20 18:45:28 +01:00
Dmitry Jemerov
60a2151a33 Fix compilation
(cherry picked from commit 46b9041)
2017-03-20 18:45:27 +01:00
Yan Zhulanow
0995f2700e doMoveFile() now accepts not-null PsiDirectory
(cherry picked from commit 8a16c90)
2017-03-20 18:45:26 +01:00
Yan Zhulanow
59055e28ee CreateFileResourceQuickFix now accepts ResourceFolderType instead of ResourceType
(cherry picked from commit 55f350f)
2017-03-20 18:45:26 +01:00
Ilya Chernikov
4be5fcc14a Fix test code after UsefulTestCase api changes 2017-03-20 18:45:25 +01:00
Vyacheslav Gerasimov
180ae070ee Fixed KotlinAndroidResourceQuickFixProvider for AS 2.2 2017-03-20 18:45:24 +01:00
Dmitry Jemerov
594e2b6a77 fix compilation 2017-03-20 18:45:23 +01:00
Dmitry Jemerov
ab5067a0d3 remove write action around closeAndDeleteProject() 2017-03-20 18:45:23 +01:00
Dmitry Jemerov
b10073465c fix compilation of new lint checks against IDEA 163 2017-03-20 18:45:22 +01:00
Alexey Tsvetkov
05f278ce20 JPS: implement tracking of null annotations
#KT-12933 fixed
    #KT-14266 fixed
2017-03-20 18:45:21 +01:00
Alexey Tsvetkov
6d958eb32b Fix dist by ignoring some library classes during compiler shrinking 2017-03-20 18:45:20 +01:00
Dmitry Jemerov
b101550cae Advance idea.plugins.compatible.build 2017-03-20 18:45:19 +01:00
Dmitry Jemerov
e51018406f register PsiElementFinder extensions before JavaPsiFacade is registered 2017-03-20 18:45:18 +01:00
Dmitry Jemerov
036bfed984 Add resources_en.jar to properties plugin classpath 2017-03-20 18:45:18 +01:00
Konstantin Bulenkov
fcdd5e0a19 update Kotlin icons according to new IntelliJ style 2017-03-20 18:45:17 +01:00
Dmitry Jemerov
aced2e7eb4 Update compatible build number range 2017-03-20 18:45:16 +01:00
Dmitry Jemerov
a2b0b3d6eb fix compilation against branch 163 2017-03-20 18:45:15 +01:00
Yan Zhulanow
24c9b6e171 Migrate IDEA plugin code to Android Studio 2.2 (br 145) 2017-03-20 18:45:15 +01:00
Dmitry Jemerov
99af2a809b Update IDEA to 171.2613.7 2017-03-20 18:45:14 +01:00
Dmitry Jemerov
4d10b18fe1 Fix for 171 platform 2017-03-20 18:44:14 +01:00
Ilya Gorbunov
87c055cc61 Fix progression iterators to respect the Iterator contract.
#KT-16923 Fixed
2017-03-20 20:13:54 +03:00
Ilya Gorbunov
e5a28311bc Fix infinite sequence being terminated prematurely when being iterated without calling hasNext
#KT-16922 Fixed
2017-03-20 20:13:54 +03:00
Valentin Kipyatkov
f00ab135d6 Do not insert redundant space 2017-03-20 19:08:03 +03:00
Valentin Kipyatkov
3ec28f1242 Attempt to preserve partial substitution when detecting expected type for smart completion 2017-03-20 19:08:03 +03:00
Valentin Kipyatkov
b5dd2cc540 Completion of lambda parameters
Also changed policy for sorting of smart completion items in basic completion

 #KT-16800 Fixed
 #KT-12002 Fixed
2017-03-20 19:08:02 +03:00
Nikolay Krasko
c6b9aebfcf Minor: remove warning 2017-03-20 17:49:23 +03:00
Nikolay Krasko
afc0892d1f Synchronize state of parser and lexer for LONG_TEMPLATE_ENTRY (KT-14865)
Lexer monitors "long string template" state end and will produce
LONG_TEMPLATE_ENTRY_END token when it is reached. If parser continues
without waiting for it, it will eventually get handling token that
will produce irrelevant error. Such behaviour also breaks lazy
elements (LAMBDA_EXPRESSION in this case) contract: range of parsed text
in eager mode should be same to one parsed in lazy mode.

 #KT-14865 Fixed
2017-03-20 17:47:29 +03:00
Alexander Udalov
87ff70ee0f Replace JS metadata version with '$ABI_VERSION$' in tests
Similarly to the JVM metadata version, this is done in order to avoid
changing any test data when the version is increased
2017-03-20 17:22:29 +03:00
Alexander Udalov
e6f6b0dad5 JS: merge LibrarySourcesConfig into JsConfig 2017-03-20 17:22:29 +03:00
Alexander Udalov
bf90cb5cc0 JS: support -Xskip-metadata-version-check for incompatible ABI libraries
Allow the compiler to read such libraries without any errors, at the
risk of crashing with an exception.

Also fix a minor bug in the diagnostic message in LibrarySourcesConfig
and in the corresponding test in KotlinJpsBuildTest
2017-03-20 17:22:29 +03:00
Alexander Udalov
30dfd5cc1b JS: support '-Xskip-metadata-version-check' to allow pre-release libraries 2017-03-20 17:22:29 +03:00
Alexey Sedunov
a795a256f4 Configuration: Fix behavior of "output directory" control
Do not show file chooser twice.
Disable/enable control on component initialization and change of
"Use project settings" option

 #KT-16952 Fixed
 #KT-16953 Fixed
2017-03-20 17:19:13 +03:00
Simon Ogorodnik
f56af41d1e Fix TypeAliasConstructorDescriptor's to create only once when required
Some IDE features relates onto that same descriptors will remain same
between resolve calls
Fix it to be true for TypeAliasConstructorDescriptor's

 #KT-16265 fixed
2017-03-20 16:55:40 +03:00
Sergey Mashkov
23cbb83c75 IDL2K: drop garbage code, refactor to improve readability 2017-03-20 16:51:32 +03:00
Mikhail Zarechenskiy
1a4b9cb228 Show warning for mod from built-ins since API=1.1 2017-03-20 00:45:18 +03:00
Mikhail Zarechenskiy
e4188f889e Do not show warning for mod from built-ins when LV=1.0
#KT-16372 Fixed
2017-03-20 00:41:58 +03:00
Alexey Sedunov
071744a57f Extract Superclass/Interface: show inapplicability error before choosing the extraction container
#KT-15339 Fixed
2017-03-19 17:20:32 +03:00
Alexey Sedunov
eb9c775476 Navigation: Support NEW_AS_CONSTRUCTOR flag for constructor calls
#KT-15398 Fixed
 #KT-15536 Fixed
2017-03-19 17:20:24 +03:00
Alexey Sedunov
5e8cd654ec Find Usages: Fix processing of label references in 'return' expressions
#KT-7516 Fixed
2017-03-19 17:20:17 +03:00
Alexey Sedunov
275cdbbea7 Rename: Fix renaming of function by label reference inside of lambda argument
#KT-7520 Fixed
2017-03-19 17:20:10 +03:00
Alexey Sedunov
b1df91395a Minor: Use handler autodetection in some rename tests 2017-03-19 17:20:02 +03:00
Alexey Sedunov
871d42f05a Rename: Support renaming class by short reference to companion object
#KT-16108 Fixed
2017-03-19 17:19:55 +03:00
Alexey Sedunov
834cdd63ab Create from Usage: Support class generation by class literal expression
#KT-16188 Fixed
2017-03-19 17:19:48 +03:00
Alexey Sedunov
505a6bcbf2 JPS: Copy project-level settings before use
Sharing these settings for reading/writing
between different module during JPS build
may lead to compiler settings
(plugionOptions, in particular) of several
modules to be mixed

 #KT-16888 Fixed
2017-03-19 17:19:40 +03:00
Alexey Sedunov
2e1b4cd692 Misc: Fix test 2017-03-19 17:19:33 +03:00
Alexey Sedunov
2bb7bdfc3f Kotlin Facet: Fix reading of v1 configuration
Favor language/api version specified in <versionInfo> element
in case it differs from the one in
<option name="_commonCompilerArguments">

#KT-16861 Fixed
2017-03-19 17:19:26 +03:00
Alexey Sedunov
ca46100581 Kotlin Facet: Add tab for compiler plugin options
#KT-15768 Fixed
2017-03-19 17:19:18 +03:00
Alexey Sedunov
c264a2e15f Configuration: Improve presentation of the settings override warning 2017-03-17 21:08:44 +03:00
Alexey Sedunov
7c1249746f Kotlin Facet: Show scripting section only if target platform is JVM
#KT-16316 Fixed
2017-03-17 21:03:29 +03:00
Alexey Sedunov
f63828ff20 Configuration: Make UI improvements
Fix layout
Fix label names
Replace "Generate no warnings" checkbox with "Report compiler warnings"
2017-03-17 21:03:22 +03:00
Nikolay Krasko
f38753ee3c Remove explicit AppScheduledExecutorService shutdown (commit revert)
Revert "Problem: manually shutdown AppScheduledExecutorService to allow compiler stop properly"

The commit was added during update to 162.1024.1 to fix hangs in ant
tasks on teamcity because of some thread created in
AppScheduledExecutorService service.

Remove the commit because can't reproduce those hangs under 162.2946
(Probably 12a079ef41 fixed the hangs).

This should also be addressed in fix for https://youtrack.jetbrains.com/issue/IDEA-169562

This reverts commit 99a75021e1.
2017-03-17 18:02:11 +03:00
Nikolay Krasko
a63953432e Set "weak warning" severity for SameParameterValue inspection 2017-03-17 17:27:54 +03:00
Nikolay Krasko
52789df812 Minor: fix warnings in AbstractKotlinParsing.java 2017-03-17 17:27:53 +03:00
Sergey Mashkov
49c2f40f7d KT-16572 Add links to Mozilla Developer Network to kdocs of classes that we generate from IDL
regenerate
2017-03-17 13:04:34 +03:00
Sergey Mashkov
8842b6894e KT-16572 Add links to Mozilla Developer Network to kdocs of classes that we generate from IDL 2017-03-17 13:04:34 +03:00
Sergey Mashkov
02721a0b7f KT-16252 IDL2K: Add ItemArrayLike interface implementation to collection-like classes
regenerate
2017-03-17 13:04:33 +03:00
Sergey Mashkov
496795dd56 IDL2K eliminate attribute modality change caused by inheritance
always override attributes in class if it is inherited from an interface
2017-03-17 13:04:33 +03:00
Sergey Mashkov
a5d6541f1e KT-16252 IDL2K: Add ItemArrayLike interface implementation to collection-like classes 2017-03-17 13:04:32 +03:00
Vyacheslav Gerasimov
a795313c7d Add inspection for usages of Kotlin internal declarations in Java
#KT-11393 Fixed
2017-03-16 21:12:05 +03:00
Alexander Udalov
bd53922c64 Minor, don't shade com.sampullara in compiler-embeddable
See 73b879e
2017-03-16 15:40:06 +03:00
Alexander Udalov
332a0f5adc Use 'languageVersionSettings' extension instead of key directly
Also fix compilation of kotlin-script-util
2017-03-16 14:18:01 +03:00
Alexey Sedunov
0e4c3ec202 Kotlin Facet: Do not present imported -d/-cp in "Additional arguments" 2017-03-16 03:14:41 +03:00
Alexey Sedunov
88a394e892 Kotlin Facet: Validate "additional arguments"
Validate consistency of "additional arguments" with respect to settings specified in other UI controls
2017-03-16 03:14:40 +03:00
Alexey Sedunov
fa06965ed6 Kotlin Facet: Add import test for Maven project with submodule 2017-03-16 03:14:39 +03:00
Alexey Sedunov
cf9d7a0470 Kotlin Facet: Detect platform by stdlib dependency in android-gradle projects
#KT-16827 Fixed
2017-03-16 03:14:38 +03:00
Alexey Sedunov
040f5f88f2 Configuration: Show warning in project settings if they'are overridden in some modules(s) 2017-03-16 03:14:37 +03:00
Alexey Sedunov
5dc5ca551f Configuration: Make UI improvements
Use JTextField for output file prefix/postfix.
Use TextFieldWithBrowseButton for output directory
Improve layout
2017-03-16 03:14:36 +03:00
Alexey Sedunov
ee36abd73a Kotlin Facet: Drop obsolete facet detection infrastructure 2017-03-16 03:14:35 +03:00
Alexey Sedunov
5c55b9fbbe Configuration: Check that project-level common arguments are not changed through platform-specific holders 2017-03-16 03:14:34 +03:00
Alexey Sedunov
ce434585e3 J2K: Convert BaseKotlinCompilerSettings and its inheritors 2017-03-16 03:14:32 +03:00
Alexey Sedunov
f8e5065845 J2K: Convert BaseKotlinCompilerSettings and its inheritors (rename to .kt) 2017-03-16 03:14:31 +03:00
Pavel V. Talanov
f1c0d5316f Refactor delegate members to light members conversion 2017-03-15 20:55:42 +03:00
Pavel V. Talanov
eedcc19209 J2K KtLightClassBase: rename file 2017-03-15 20:55:41 +03:00
Pavel V. Talanov
04591bb938 LightClassDataHolder: refactor, extract subinterfaces 2017-03-15 20:55:40 +03:00
Pavel V. Talanov
6d595e30c2 ClassFileFactory, minor: make done() public and use in LightClassDataProvider 2017-03-15 20:55:40 +03:00
Pavel V. Talanov
d62db8dc6b LightClassGenerationSupport: refactor, minor
Use typealias where appropriate
Less verbose method names
2017-03-15 20:55:39 +03:00
Pavel V. Talanov
a645dc109a KotlinLightClassBuilderFactory, LightClassBuilder: refactor, clarify 2017-03-15 20:55:38 +03:00
Pavel V. Talanov
c73e58516b Refactor LightClassDataProvider: drop LightClassDataProvider class
Move code to inheritors
Improve api to avoid getting empty file lists in random places
2017-03-15 20:55:37 +03:00
Pavel V. Talanov
ab0d939626 searchHelpers: remove hack relying on light classes triggering resolve 2017-03-15 20:55:08 +03:00
Pavel V. Talanov
feae5079ed Light classes: refactor, introduce lazyPub util to reduce verbosity 2017-03-15 20:55:07 +03:00
Pavel V. Talanov
ba185d7616 LightClassDataProvider: refactor, extract class filters to separate classes 2017-03-15 20:55:05 +03:00
Pavel V. Talanov
48cae0e480 KtLightField/Method: Use equality in equivalence checks
Avoid computing delegate to determine equivalence
2017-03-15 20:55:03 +03:00
Pavel V. Talanov
8054020f61 IDELightClassContexts: @PublishedApi affects codegen 2017-03-15 20:55:02 +03:00
Pavel V. Talanov
d846d05527 PsiElementChecker: minor
Check own members before inners' since it triggers the computation of outer stub
2017-03-15 20:55:01 +03:00
Pavel V. Talanov
d34b73befb Light class codegen: all objects are considered static
Simplify code handling access flag computation
Fix a problem where kotlin nested object wasn't producing a nested light class
2017-03-15 20:55:01 +03:00
Pavel V. Talanov
d94da5af40 Frontend: create component functions for properties with error types
Fixes an inconsistency in light classes where we could have different
  class structure depending on whether the type was resolved
2017-03-15 20:55:00 +03:00
Pavel V. Talanov
fa58f1b4d7 KtLightMethod(Field): use dummyDelegate to determine modifier properties 2017-03-15 20:54:59 +03:00
Pavel V. Talanov
abf206a134 KtLightMethod(Field): do not use clsDelegate in hashCode && equality checks 2017-03-15 20:54:58 +03:00
Pavel V. Talanov
fee29c47c8 KtLightMethod: use dummy delegate to compute parameter count and isContructor 2017-03-15 20:54:56 +03:00
Pavel V. Talanov
3e7357a5d7 IDELightClassTest: provide tools to check laziness of light class construction
StubComputationTracker knows which context was used to construct light class
2017-03-15 20:54:55 +03:00
Pavel V. Talanov
daef8a0eed Light classes in IDE: Make light class delegate construction a two step process
Step 0: Light class object is created, no delegates are computed
Step 1: constructs dummy delegate which can not be relied upon to know signature of any member
		It can be used to construct light field and light method objects
		(which can correctly respond to some queries) before constructing real delegate
Step 2:
		Construct real delegate if dummy delegate is not enough to respond to a query

This speeds up multiple scenarios where getMethods() and getFields() are called on numerous classes

Dummy delegate's faster consruction is achieved by using specially setup dumb analysis instead of ide analysis

Introduce LazyLightClassDataHolder: which manages creation of Step 1 and Step 2 delegates
Introduce MemberIndex: keeping track of member creation order, helps matching light class delegates created in different contexts
KtLightMethod and Field: make use of dummy delegate
KtLightMethod no longer extends LightMethod since it requires eager delegate construction
KtLightMethod now implements PsiAnnotationMethod for convenience (ClsMethodImpl implements PsiAnnotationMethod)
2017-03-15 20:54:55 +03:00
Pavel V. Talanov
ed9e94c632 KtLightModifierListWithExplicitModifiers: fix equals 2017-03-15 20:53:59 +03:00
Pavel V. Talanov
d01aaeb65c Refactor light classes: Delegate LightClassDataHolder construction to LightClassGenerationSupport 2017-03-15 20:53:58 +03:00
Pavel V. Talanov
00e84fb483 Light classes: Refactor construction
Introduce LightClassDataHolder: which now is reponsible for constructing clsDelegate
Move out light big chunk of delegate building logic out of LightClassDataProvider into LightClassBuilder
LightClassData only holds information about single class
2017-03-15 20:53:37 +03:00
Pavel V. Talanov
22fb9ec5e1 Refactor light classes: move light members creation to their respective classes 2017-03-15 20:52:51 +03:00
Pavel V. Talanov
15b063d236 J2K LightClassGenerationSupport: rename file 2017-03-15 20:52:50 +03:00
Pavel V. Talanov
dd2d9c1dc2 J2K LightClassGenerationSupport: convert code 2017-03-15 20:52:49 +03:00
Pavel V. Talanov
71161e218b Refactor LightClassData: remove redundant entities 2017-03-15 20:52:48 +03:00
Pavel V. Talanov
0a0e628068 Refactor: move code to new package 2017-03-15 20:52:26 +03:00
Pavel V. Talanov
ac368ac182 Light classes test: test methods & fields with same name 2017-03-15 20:52:25 +03:00
Pavel V. Talanov
955fe9e1e6 Light class tests: add tests
- test Jvm* annotations with wrong arguments
  - test JvmStatic annotation
  - test JvmName annotation
2017-03-15 20:52:24 +03:00
Pavel V. Talanov
dbcd141a46 Extract superclass from AnnotationResolver 2017-03-15 20:52:24 +03:00
Pavel V. Talanov
8794005234 JvmPlatform#getDefaultImports: avoid recomputing JvmBuiltins
We need to use LockBasedStorageManager() (instead of NO_LOCKS) since getDefaultImports()
    can be called concurrently in certain scenarios
2017-03-15 20:52:23 +03:00
Pavel V. Talanov
bbe3b3cabe WrappedType: introduce WrappedTypeFactory to encapsulate wrapped types creation 2017-03-15 20:52:22 +03:00
Pavel V. Talanov
85420d1ffd MemberCodegen: Do not try to write inner class metadata for inner class 2017-03-15 20:51:22 +03:00
Pavel V. Talanov
1441aea2ea Light classes: allow light classes for inner/nested classes to be build separately
Avoid analyzing/generating bytecode for outers
2017-03-15 20:51:22 +03:00
Pavel V. Talanov
6924ddeace Clarify logic in KotlinTypeMapper.mapType() dealing with enum entries
This allows to write correct class signatures for enum entries
    regardless of whether ASM_TYPE slice was written to
2017-03-15 20:51:20 +03:00
Pavel V. Talanov
6f6a595fef Refactor FileScopeFactory 2017-03-15 20:51:19 +03:00
Pavel V. Talanov
d7c1993194 FileScopeFactory: postpone default import resolver construction 2017-03-15 20:51:18 +03:00
Pavel V. Talanov
babb3b557d J2K ImportPath: kotlinify 2017-03-15 20:51:17 +03:00
Pavel V. Talanov
50d0f5bde6 J2K ImportPath: autoconvert 2017-03-15 20:50:12 +03:00
Pavel V. Talanov
91e8d9e211 J2K ImportPath: rename file 2017-03-15 20:49:22 +03:00
Simon Ogorodnik
e7753c31db Minor: Add Dokka format param to build-docs script
To have an ability to change it in TeamCity between custom builds
2017-03-15 19:43:14 +03:00
Simon Ogorodnik
38047240d3 Fix documentation for stdlib
Add forgotten files to file list used by
Dokka when generating documentation
2017-03-15 18:26:52 +03:00
Simon Ogorodnik
5c4ba53f42 Optimization of Basic Code Completion
Now we first search for simple reference variants, then for extensions
 Because extension search is slow
 #KT-16856
2017-03-15 17:50:29 +03:00
Simon Ogorodnik
4906ddfc29 Optimization of Basic Code Completion
Now we don't perform code formatting on temporary psi used
  in ShadowedDeclarationFilter
  #KT-16856
2017-03-15 17:50:20 +03:00
Mikhail Glukhikh
bbab0f11ca Cleanup: fix some "leaking this" warnings 2017-03-15 17:36:08 +03:00
Mikhail Glukhikh
045a23ae10 Cleanup: apply "Convert lambda to reference" 2017-03-15 17:36:02 +03:00
Mikhail Glukhikh
b121bf8802 Cleanup: fix some compiler warnings (mostly deprecations, javaClass) 2017-03-15 17:35:31 +03:00
Mikhail Glukhikh
d0cc1635db Cleanup: apply "Use synthetic property access syntax" 2017-03-15 16:13:40 +03:00
Mikhail Glukhikh
1375267996 Cleanup: apply redundant curly braces in string template inspection 2017-03-15 16:13:22 +03:00
Mikhail Glukhikh
e37800d056 Cleanup: apply redundant string template inspection 2017-03-15 16:12:59 +03:00
Igor Chevdar
10ea2883f7 Supported KProperty2 and KMutableProperty2 for delegated properties
Consider this code:
object Delegate {
    operator fun getValue(t: Any?, p: KProperty<*>): String {
        return ""
    }
}

class A {
    val String.ext by Delegate
}

then the type of <p> is KProperty2 (it has 2 receivers).

Test fix + review fixes
2017-03-15 12:20:57 +03:00
Alexander Udalov
d58d75c6ef Refactor "do not check impl" flag for multi-platform projects
Instead of LanguageFeature, make it an AnalysisFlag, which is more clear
2017-03-15 11:03:05 +03:00
Alexander Udalov
56201a6dc4 Refactor skipMetadataVersionCheck flag
To make addition of other flags easier in the future, provide a more
abstract 'isFlagEnabled' in LanguageVersionSettings
2017-03-15 11:03:04 +03:00
Alexander Udalov
7a240b63c7 Use LanguageFeature.State enum instead of CoroutineSupport 2017-03-15 11:03:03 +03:00
Alexander Udalov
34e131c928 Refactor LanguageVersionSettings.isApiVersionExplicit
Pass it in the CompilerConfiguration instead of LanguageVersionSettings.
This is better because LanguageVersionSettings is accessible everywhere
in front-end and back-end, and this flag should not be used there
2017-03-15 11:03:01 +03:00
Alexander Udalov
32826c1686 Introduce LanguageFeature.State, drop coroutines-related pseudofeatures
Previously there were three LanguageFeature instances -- Coroutines,
DoNotWarnOnCoroutines and ErrorOnCoroutines -- which were handled very
awkwardly in the compiler and in the IDE to basically support a language
feature with a more complex state: not just enabled/disabled, but also
enabled with warning and enabled with error. Introduce a new enum
LanguageFeature.State for this and allow LanguageVersionSettings to get
the state of any language feature with 'getFeatureSupport'.

One noticeable drawback of this approach is that looking at the API, one
may assume that any language feature can be in one of the four states
(enabled, warning, error, disabled). This is not true however; there's
only one language feature at the moment (coroutines) for which these
intermediate states (warning, error) are handled in any way. This may be
refactored further by abstracting the logic that checks the language
feature availability so that it would work exactly the same for any
feature.

Another issue is that the difference among ENABLED_WITH_ERROR and
DISABLED is not clear. They are left as separate states because at the
moment, different diagnostics are reported in these two cases and
quick-fixes in IDE rely on that
2017-03-15 11:03:00 +03:00
Alexander Udalov
cf7048dd0f Do not inject CompilerConfiguration into compiler front-end
Inject LanguageVersionSettings instead; all information relevant to the
analysis should be now passed via an instance of LanguageVersionSettings
(which should be renamed to a more general name in the future).

This is partially a revert of d499998 and related commits
2017-03-15 11:02:59 +03:00
Alexander Udalov
a879cb0cfd Minor, take LanguageVersionSettings in CompilerDeserializationConfiguration 2017-03-15 11:02:58 +03:00
Alexander Udalov
ac530ac49c Move skipMetadataVersionCheck flag to LanguageVersionSettings
This makes it possible to avoid the CompilerConfiguration instance in
injectors, because CompilerDeserializationConfiguration was the only
left component that required it.

LanguageVersionSettings is not a good name for this entity anymore, it
should be renamed in the future
2017-03-15 11:02:58 +03:00
Alexander Udalov
f5d4dd33da Inject JvmTarget into some JVM-specific call checkers
This makes it possible to drop CompilerConfiguration from
CallCheckerContext, which in turn helps to avoid passing the entire
CompilerConfiguration instance through front-end
2017-03-15 11:02:57 +03:00
Alexander Udalov
573c6ab5d4 Move JvmTarget to frontend.java, introduce TargetPlatformVersion
Previously JvmTarget was declared in module 'util' which is accessible
for example from 'frontend', which is not very good.

Also add a superinterface named TargetPlatformVersion which is going to
be used in platform-independent injectors in 'frontend' in the following
commits. Use it in one place (LanguageVersionSettingsProviderImpl.kt)
instead of DescriptionAware because TargetPlatformVersion sounds like a
better abstraction than DescriptionAware here
2017-03-15 11:02:56 +03:00
Denis Zharkov
d2cd5d46fa Minor. Use static method from super class
It was a code with warning
2017-03-15 10:47:12 +03:00
Denis Zharkov
dcc98e3839 Improve check for statements-only postfix templates
Before this change the check was quite complicated
because of cases like:
for (i in 1..9)
    foo(i)<caret>

It's not located in a block, but in the same time it's a stament.
So we had a tricky heuristics that if is parent is not a block, then
we should check if element isn't used as expression.

Of course this heuristics is wrong, e.g. for import/package nodes.

The solution is to reuse similar logic from BasicExpressionTypingVisitor.
it has been checked once that statement container is one of:
- KtBlockExpression
- KtContainerNodeForControlStructureBody
- KtWhenEntry

So there's no need to check anything else

 #KT-14986 Fixed
 #KT-14483 Fixed
2017-03-15 10:47:12 +03:00
Denis Zharkov
78ffe47bf8 Fix samples for 'iter' postfix template
#KT-14727 Fixed
2017-03-15 10:47:12 +03:00
Denis Zharkov
bd88919411 Refine predicate for 'iter' postfix template
Use IterableTypesDetection to determine if the given expression may be iterated

 #KT-14134 Fixed
 #KT-14129 Fixed
2017-03-15 10:47:12 +03:00
Denis Zharkov
465a424af4 Refactor postfix template selector
Allow to specify predicate by KtExpression instead of type predicate
It will be used for `for` template which need a context to determine
whether the expression is iterable
2017-03-15 10:47:12 +03:00
Vyacheslav Gerasimov
b8ebc087e2 Add inspection for calls of function with lambda expression body
Added "Unused return value of a function with lambda expression body" inspection with quickfix "Remove '=' token from function declaration"

#KT-10393 Fixed
2017-03-15 00:22:31 +03:00
Vyacheslav Gerasimov
087551ad61 Implement quick fix for "Invalid type of annotation member"
Quickfix changes array of boxed type to array of primitive type

#KT-8568 Fixed
2017-03-15 00:21:24 +03:00
Vyacheslav Gerasimov
b8563f7fcf Fix KotlinUastTypesTest.testCycleInTypeParameters 2017-03-15 00:20:40 +03:00
Mikhail Glukhikh
cab80812ef KT-13111: lambda --> reference supports also object members 2017-03-14 18:45:08 +03:00
Mikhail Glukhikh
631f58f27f Lambda --> reference: correct handling of companion references
Reference receivers are named more accurately now #KT-13341 Fixed
2017-03-14 18:45:06 +03:00
Mikhail Glukhikh
2c692de98f KT-13111: lambda --> reference support methods called via this now 2017-03-14 18:45:05 +03:00
Mikhail Glukhikh
19db4869e6 Lambda --> reference: correct handling of parameter-less function
Issue #KT-15556 Fixed
2017-03-14 18:45:04 +03:00
Mikhail Glukhikh
b6974a88c5 Refactoring: convert lambda --> reference intention 2017-03-14 18:45:02 +03:00
Mikhail Glukhikh
3a14a5c461 Lambda --> reference supports bound references now #KT-13111 Fixed 2017-03-14 18:45:01 +03:00
Mikhail Glukhikh
831467891c Reference --> lambda supports bound references now #KT-16292 Fixed 2017-03-14 18:45:00 +03:00
Yan Zhulanow
f6734e74e1 Minor, SamWithReceiver: Fix services for kotlinc CLI execution
Move service files to META-INF to support execution from CLI (using PluginCliParser).
2017-03-14 18:36:40 +03:00
Mikhael Bogdanov
23698f93e0 Fix reification for crossinline lambdas inlined into object literal
Inline lambda could capture reified parameter of containing inline function ('a' function)
when it is inlined in another one.
If it's inlined in any anonymous object we should track it and
add reification marker to such anonymous object instance creation
to rewrite it on inlining bytecode of 'a' function.

  #KT-15997 Fixed
2017-03-14 15:54:13 +01:00
Alexey Sedunov
6b6d7a5030 Configuration: Don't create kotlinc.xml if the settings don't differ from the defaults
#KT-16647 Fixed
2017-03-14 15:33:11 +03:00
Alexey Sedunov
e8749e639c Kotlin Facet: Add link to project-level compiler settings UI
#KT-16022 Fixed
2017-03-14 15:33:10 +03:00
Alexey Sedunov
8c91dc579a Kotlin Facet: Show project-level settings when "Use project settings" is selected
#KT-16023 Fixed
2017-03-14 15:33:09 +03:00
Alexey Sedunov
9bbea47f93 Kotlin Facet: Parse and merge compiler arguments specified in <arg> elements instead of appending them (to avoid duplication)
#KT-16776 Fixed
2017-03-14 15:33:08 +03:00
Alexey Sedunov
e5a128ab2e JPS: Parse and merge additional arguments with primary ones instead of
appending them (to avoid duplication)
 #KT-16788 Fixed
2017-03-14 15:33:07 +03:00
Alexey Sedunov
73b879ea89 Misc: Include cli-parser 1.1.2 sources into the project under different package and drop original library dependency
This would allow building the project with Kotlin JPS plugin on TeamCity where older library takes precendence due to appearing earlier in JPS classpath
2017-03-14 15:33:06 +03:00
Dmitry Jemerov
e037e9de39 Do not cache contents in VFS when reading contents of .jar files
This follows the standard IDEA policy of caching file contents.
2017-03-14 13:06:47 +01:00
Dmitry Jemerov
8d1d76cdae Try to recover from corrupt VFS data for a .kotlin_module file
#KT-13135 Fixed
2017-03-14 13:06:29 +01:00
Mikhail Zarechenskiy
da53317357 Fix exception when type parameters appear in object declaration
#KT-14536 Fixed
2017-03-14 01:10:00 +03:00
Mikhail Zarechenskiy
0568bc3ef1 Add note about JS to the changelog 2017-03-13 21:09:17 +03:00
Mikhail Zarechenskiy
fd80c0d1d1 Remove KT-15200 from the changelog
It was postponed until 1.1.2
2017-03-13 20:38:43 +03:00
Mikhail Zarechenskiy
05ef705609 Add IGNORE_BACKEND directive for native automatically
Also parse correctly case IGNORE_BACKEND: JS, NATIVE
2017-03-13 19:56:13 +03:00
Dmitry Jemerov
006062499c Optimize imports (to fix compilation under 171 branch) 2017-03-13 16:34:48 +01:00
Mikhail Zarechenskiy
774aa720b4 Update Changelog for version 1.1.1 2017-03-13 16:45:25 +03:00
Dmitry Petrov
a0a8beee82 Handle TypeAliasDescriptor in AdaptiveClassifierNamePolicy
(as ClassDescriptor)
2017-03-13 14:15:27 +03:00
Mikhael Bogdanov
ce3b455f57 Fix for KT-16801: Accessors of @PublishedApi property gets mangled
#KT-16801 Fixed
2017-03-13 10:51:10 +01:00
Dmitry Petrov
c46164481a KT-15871 Unnecessary boxing for equality operator on inlined primitive values
Allow kotlin.jvm.internal.Intrinsics#areEqual for boxed values.
Rewrite to primitive equality.

NB we can't do that for Float and Double, because java.lang.Float#equals
and java.lang.Double#equals behave differently from primitive equality comparisons.
2017-03-13 09:04:31 +03:00
Dmitry Petrov
a087ea559f Eliminate redundant CHECKCAST instructions
CHECKCAST is redundant if the corresponding static type exactly matches the target type.
CHECKCAST instructions to-be-reified should not be eliminated.

KT-14811 Unnecessary checkcast generated in parameterized functions
KT-14963 unnecessary checkcast java/lang/Object
2017-03-13 09:04:31 +03:00
Dmitry Petrov
ec403bfdbc KT-16245 Redundant null-check generated for a cast of already non-nullable value
KT-16194 Code with unnecessary safe call contains redundant boxing/unboxing for primitive values
KT-12839 Two null checks are generated when manually null checking platform type

Recognize some additional cases of trivial null checks and trivial instance-of checks.

A variable is "checked for null", if it is:
- a function parameter checked with 'INVOKESTATIC kotlin/jvm/internal/Intrinsics.checkParameterIsNotNull'
- checked for nullability with 'IFNULL/IFNONNULL'
- checked for nullability with 'INSTANCEOF'
  (if objectref is instance-of T, then objectref is non-null)

Before analyzing nullability, introduce synthetic assumptions for execution branches
where a variable is guaranteed to be null or not null. For example, the following bytecode:

     ALOAD 1 // Ljava/lang/String;
     IFNULL L
     <non-null branch>
  L:
     <null branch>

is transformed to

     ALOAD 1
     IFNULL L1
     NEW java/lang/String
     ASTORE 1            // tells analyzer that variable 1 is non-null
     <non-null branch>
  L:
     <null branch>
  L1:
     ACONST_NULL
     ASTORE 1            // tells analyzer that variable 1 is null
     GOTO L

After the analysis is performed on a preprocessed method,
remember the results for "interesting" instructions
and revert the preprocessing transformations.

After that, perform bytecode transformations as usual.

Do not transform INSTANCEOF to-be-reified, because reification at call site
can introduce null checks. E.g.,

    inline fun <reified T> isNullable() = null is T
    ...
    assert(isNullable<String?>())
2017-03-13 09:04:31 +03:00
Dmitry Petrov
3c09a26e16 KT-5248 Don't wrap variable if it is captured only in inlined closures
Remove non-escaping Ref's on bytecode postprocessing pass.
2017-03-13 09:04:31 +03:00
Dmitry Petrov
3fc106572e Make redundant null check optimization independent of boxing optimization algorithm.
Run DCE after each single redundant null check optimization pass.
2017-03-13 09:04:31 +03:00
Ilya Matveev
eda43c8b45 Mute tests with standard collection extensions in native 2017-03-10 19:59:37 +03:00
Ilya Matveev
29e5ad5abe Mute tests with '::class' in native backend 2017-03-10 19:59:37 +03:00
Ilya Matveev
8a3fa2e4e5 Fix expected SMAPs after test muting for native 2017-03-10 19:59:37 +03:00
Ilya Matveev
a5e4e0284e Mute some box tests for native backend
This patch mutes the following test categories:
   * Tests with java dependencies (System class,
     java stdlib, jvm-oriented annotations etc).
   * Coroutines tests.
   * Reflection tests.
   * Tests with an inheritance from the standard
     collections.
2017-03-10 19:59:37 +03:00
Alexander Udalov
d21d362f0f Allow enum entries in double colon LHS with LV = 1.0
#KT-16782 Fixed
2017-03-10 19:44:00 +03:00
Denis Zharkov
39055229a1 Add diagnostic info to assertion on type argument consistency 2017-03-10 18:17:50 +03:00
Vyacheslav Gerasimov
830bf62d94 Fix SOE from UAST in containsLocalType
containsLocalType now properly handles start projections
#KT-16680 Fixed
2017-03-10 17:30:21 +03:00
Simon Ogorodnik
4e98394c38 Fix Sample reference to resolve cross-module packages correctly
Now @sample links to FqName in IDE will be resolved correctly
 Cause now we resolve packages over all modules in project
 #KT-14710 fixed
2017-03-10 15:33:47 +03:00
Nikolay Krasko
688802de51 Check breakpoints work in delegate initializer
Additional test after review
2017-03-10 14:59:37 +03:00
Nikolay Krasko
e6ee933b27 Fix "smart step into" for classes with complex hierarchy (KT-16667)
#KT-16667 Fixed
2017-03-10 14:58:21 +03:00
Nikolay Krasko
6d9b519bb2 Use new utility method for getting lexical scope
It's expected that for call expressing some nearest parent will have
lexical scope written in binding context. Under this circumstances it's
refactoring.
2017-03-10 14:58:17 +03:00
Nikolay Krasko
0a7a73d4be Refactoring: extract method for getting lexical scope without facade 2017-03-10 14:58:16 +03:00
Nikolay Krasko
9120ccc054 Fix breakpoints in inline calls in fields initialization (KT-16525)
Backend generates properties initializer in constructor context

 #KT-16525 Fixed
2017-03-10 14:58:15 +03:00
Nikolay Krasko
d886cd7d06 Fix breakpoints when inline call is in qualified expression (KT-16062)
Scope is stored for DOT_QUALIFIED_EXPRESSION not directly for
CALL_EXPRESSION.

 #KT-16062 Fixed
2017-03-10 14:58:14 +03:00
Nikolay Krasko
2719016539 Fix search of correspondent call expression by element (KT-11234)
getStrictParentOfType() looks for nearest parent of given type

In complex expressions like:

SamConversion.doAction({
  inlineCall {
    {
      // here <--
    }()
  }
})

doAction was found twice, while inlineCall was skipped.

See code:
// call(param, { <it> })
lambdaExpression?.typedParent<KtValueArgument>()?.typedParent<KtValueArgumentList>()?.typedParent<KtCallExpression>() ?:

// call { <it> }
lambdaExpression?.typedParent<KtLambdaArgument>()?.typedParent<KtCallExpression>()

 #KT-11234 Fixed
2017-03-10 14:58:13 +03:00
Nikolay Krasko
b240ae791c Minor: extract variable 2017-03-10 14:58:12 +03:00
Denis Zharkov
52d11eb22b Minor. Revert workarounds for problem on KClass from annotation
See KT-9453 for clarification
2017-03-10 13:49:07 +03:00
Denis Zharkov
82d7a269ed Minor. Make sure that implicit contract of mapSignature is satisfied
For ordinary functions mapSignature doesn't use original descriptor
and maps the given descriptor itself, but for constructor it obtained
the original value parameters.

Necessary `getOriginal` calls were added to the call-sites
2017-03-10 13:49:06 +03:00
Denis Zharkov
394c68c326 Minor. Move unwrapping of FunctionImportedFromObject
It should not affect the semantics, because mapSignatureWithCustomParameters
can only be called with FunctionImportedFromObject from mapSignature.

At the same time it's very nice to have all of these kinds
of custom unwrapping in the same place
2017-03-10 13:49:06 +03:00
Denis Zharkov
530214fcee Minor. Simplify mapping to callable method
There's no need in unwrapping for TypeAliasConstructorDescriptor
because mapSignatureSkipGeneric/mapDefaultMethod already do it
in some moment, and ConstructorDescriptor has getConstructedClass method
for mapping its owner
2017-03-10 13:49:05 +03:00
Denis Zharkov
be90f7d331 Make type aliases constructors return correct original descriptors
The problem was that when resolving super-calls we used known substitutor
when creating a type alias constructor, thus its original return itself,
while it's expected that it should return the descriptor before substitution

The main idea of the fix that `createIfAvailable` should always return
unsubstituted constructor.

Note that known substitutor for type alias constructor should be based
on abbreviation.

The test change seems to be correct as PROJECTION_IN_IMMEDIATE_ARGUMENT_TO_SUPERTYPE
is already reported.
Beside this, resolution behavior isn't expected to be changed dramatically
2017-03-10 13:49:05 +03:00
Denis Zharkov
2b21280ba9 Unwrap underlying typealias constructor earlier
The problem is very subtle (see the test): when generating a signature
for an object literal we also were mapping its super-class
(a type alias here).

Although we did unwrap its underlying constructor to map it properly
we did too late (after obtaining value parameters from the type alias constructor descriptor).

Another problem is that TypeAliasConstructorDescriptor.getOriginal
in the case does return itself, while it's expected to return
unsubstituted version

Note: everything works for common calls for such constructors
because they mapped through mapCallableMethod which contains
another custom unwrapping of type alias constructors

 #KT-16555 Fixed
2017-03-10 13:45:37 +03:00
Denis Zharkov
8761ef6694 Minor. Rename mapSignature overload to mapSignatureWithCustomParameters 2017-03-10 13:45:37 +03:00
Denis Zharkov
7173e56393 Make computation of arguments for raw types lazy
See how we translate raw types to Kotlin model:
RawType(A) = A<ErasedUpperBound(T1), ...>
ErasedUpperBound(T : G<t>) = G<*> // UpperBound(T) is a type G<t> with arguments
ErasedUpperBound(T : A) = A // UpperBound(T) is a type A without arguments
ErasedUpperBound(T : F) = UpperBound(F) // UB(T) is another type parameter F

Stack overflow happens with the following classes:
class A<X extends B> // NB: raw type B in upper bound
class B<Y extends A> // NB: raw type A in upper bound

when calculating raw type for A, we start calculate ErasedUpperBound(Y),
thus starting calculating raw type for B => ErasedUpperBound(X) => RawType(A),
so we have SOE here.
The problem is that we calculating the arguments for these raw types eagerly,
while from the definition of ErasedUpperBound(Y) we only need a type constructor
of raw type B (and the number of parameters), we don't use its arguments.

The solution is to make arguments calculating for raw types lazy

 #KT-16528 Fixed
2017-03-10 13:30:33 +03:00
Mikhael Bogdanov
f2fea9a04a Generate unboxing operation on boxed class not Number.class when possible 2017-03-10 10:04:30 +01:00
Mikhael Bogdanov
5e80d80797 Fix for KT-16732: Type 'java/lang/Number' (current frame, stack[0]) is not assignable to 'java/lang/Character
#KT-16732 Fixed
2017-03-10 10:04:29 +01:00
Mikhail Glukhikh
32bdb6becb KT-16714 related refactoring of tryRunWriteAction (now runWriteAction is not used if intention is called from J2K) 2017-03-10 10:46:49 +03:00
Alexey Sedunov
faa0dff649 Kotlin Facet: Do no present compiler plugin classpaths and options in additional arguments string
#KT-16313 Fixed
2017-03-09 23:06:52 +03:00
Alexey Sedunov
cc20c66bfc Kotlin Facet: Fix platform detection by Maven execution goals
#KT-15947 Fixed
 #KT-16342 Fixed
2017-03-09 23:06:47 +03:00
Alexey Sedunov
e8640b441d JPS: Fix earlier configurations with incorrect combination of language and API version 2017-03-09 23:06:42 +03:00
Alexey Sedunov
811b8978c2 Kotlin Facet: Escape additional compiler arguments when converting them to string and unescape before parsing
#KT-16700 Fixed
2017-03-09 23:06:38 +03:00
Alexey Sedunov
c5ee28da05 Kotlin Facet: Detect module platform by gradle plugin
#KT-16703 Fixed
 #KT-16342 Fixed
2017-03-09 23:06:33 +03:00
Alexey Sedunov
26537cd8fc Kotlin Facet: Distinguish compiler arguments specified for different source sets
#KT-16698 Fixed
2017-03-09 23:06:28 +03:00
Alexey Sedunov
0e583aa929 Kotlin Facet: Update Gradle import test data to use 1.1.0 plugin 2017-03-09 23:06:23 +03:00
Alexey Sedunov
278cc71c4a Kotlin Facet: Reuse configuration serialization in JPS (previous implementation is not usable after configuration refactoring) 2017-03-09 23:06:18 +03:00
Alexey Sedunov
641a9a7153 Kotlin Facet: Get rid of duplicating data in facet configuration 2017-03-09 23:06:12 +03:00
Alexey Sedunov
19ea18a340 Kotlin Facet: Correctly enable/disable "output directory" field when changing "Use project settings" option
#KT-16317 Fixed
2017-03-09 22:48:44 +03:00
Dmitry Jemerov
01a9d9a284 Support lazy conversion of parent chain; correctly check expected class 2017-03-09 17:07:43 +01:00
Dmitry Jemerov
8c3936a0ee Update to UAST 0.12 2017-03-09 17:07:43 +01:00
Simon Ogorodnik
3bf7223448 Internal Kotlin packages now should be completable in parent packages
Internal packages which are hard-excluded from completion and
 imports now should be visible there if file package are parent of
 excluded one
 e.g kotlin.jvm.internal.* now visible from kotlin and kotlin.jvm
 #KT-16214 fixed
2017-03-09 19:05:10 +03:00
Dmitry Petrov
27bf51c73f All multifile class tests should have 'TARGET_BACKEND: JVM' directive. 2017-03-09 17:22:28 +03:00
Dmitry Petrov
6a68eb218f KT-16077 Redundant private getter for private var in a class within a JvmMultifileClass annotated file 2017-03-09 17:22:28 +03:00
Dmitry Jemerov
c9df227fef Add more tests for coroutines; use higher-level API to check that changes have been applied 2017-03-09 13:57:45 +01:00
Dmitry Jemerov
73a2c8c436 Test quickfixes for updating language/API version and coroutine support in Gradle projects 2017-03-09 13:41:57 +01:00
Dmitry Jemerov
5d461ec6df Support updating language/API level specified with compact options 2017-03-09 13:41:57 +01:00
Dmitry Jemerov
4261880340 Add test for enabling coroutines/bumping language level, fix several breakages 2017-03-09 13:41:57 +01:00
Sergey Igushkin
999ef51653 Added gradle-plugins properties with fqnames
Added .property files to make the plugins available by fqnames in
order to publish them to Gradle Plugin Portal.

#KT-5756

(cherry picked from commit 991de64)
2017-03-09 14:13:40 +03:00
Dmitry Jemerov
cbccb68948 Fix logic for searching inner classes in LazyResolveBasedCache.findInPackageFragments()
#KT-14058 Fixed
2017-03-09 11:47:21 +01:00
Alexander Udalov
9f2ce3c521 Refactor synthesized invokes creation in resolution
Instead of verifying that the container of an 'invoke' is a
FunctionClassDescriptor instance, make sure that it's a function class
checking its FQ name instead (classId + isBuiltinFunctionClass calls).
This makes sure that we will create synthesized invokes in a setting
where function classes are not FunctionClassDescriptor instances
synthesized by the compiler, but ordinary classes from sources or
binaries as well, as is going to be the case in kotlin-native
2017-03-09 11:29:39 +03:00
Dmitry Petrov
d188de3086 KT-6014 Wrong ABSTRACT_MEMBER_NOT_IMPLEMENTED for toString implemented by delegation
Members declared in interface or overriding members declared in super-interfaces
can be implemented by delegation even if they override members declared in super-class
(NB for interface this can be only 'kotlin.Any').
2017-03-09 09:38:48 +03:00
Mikhail Glukhikh
5e8afd26e1 Do not run write actions from J2K #KT-16714 Fixed
Also #EA-97363 Fixed
2017-03-09 09:37:35 +03:00
Dmitry Petrov
f950ff4b8f 'ConstructorDescriptor#getConstructedClass()' should be used to obtain a descriptor for constructed class
(it can be different from 'getContainingDeclaration()' in case of type alias constructor).

KT-15109 Subclass from a type alias with named parameter in constructor will produce compiler exception
KT-15192 Compiler crashes on certain companion objects: "Error generating constructors of class Companion with kind IMPLEMENTATION"
2017-03-09 09:23:38 +03:00
Dmitry Petrov
9a2c9ed30e KT-13342 Unqualified super call should not resolve to a method of supertype overridden in another supertype 2017-03-09 09:16:21 +03:00
Dmitry Jemerov
954c1d853d Correctly locate build.gradle for modules created from source sets
(cherry picked from commit ecce92d)
2017-03-08 15:08:41 +01:00
Dmitry Jemerov
a2f7808ab1 Don't check Java version in LauncherScriptTest 2017-03-08 14:07:47 +01:00
Dmitry Jemerov
263cf85c5c Fix project leak in IdeReplExecutionTest 2017-03-08 13:47:09 +01:00
Dmitry Petrov
11caa03427 KT-16713 Insufficient maximum stack size
1. Analyze method node with fake jumps for loops to make sure that
all instructions reachable only through break/continue jumps are processed.
2. Fix stack for break/continue jumps.
3. Drop fake jumps for loops, analyze method node again.
4. Fix stack for try/catch and beforeInline.
2017-03-08 09:56:08 +01:00
Mikhail Glukhikh
80063b6f91 Quick-fix for DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE added #KT-15966 Fixed 2017-03-07 19:06:16 +03:00
Ilya Gorbunov
b83b534374 Add missing SinceKotlin to IntStream.toList. 2017-03-07 18:22:11 +03:00
Ilya Gorbunov
c038d3e9a3 Mark all api in kotlin.reflect.full package with SinceKotlin(1.1), since it actually appeared in that package only in 1.1. #KT-16557 Fixed.
It doesn't matter that some functions were since 1.0 in the old package.
2017-03-07 18:22:11 +03:00
Kirill Rakhman
646f50dd66 Extract method refactoring should order parameters by first usage
Fixes #KT-16198
2017-03-07 18:10:02 +03:00
Ilya Gorbunov
1296c5444b Fix warning that failed maven plugin smoke test. 2017-03-07 13:56:11 +03:00
Ilya Gorbunov
61e8848aa2 Add samples for sequence building API. 2017-03-07 13:32:39 +03:00
Ilya Gorbunov
a04e6de047 Add groupingBy and eachCount sample. 2017-03-07 13:31:44 +03:00
Ilya Gorbunov
75ae42121b Improve sample comments.
Improve sample for lastIndex property.
2017-03-07 13:31:44 +03:00
Mikhail Zarechenskiy
578dd1dc42 Update Changelog for Kotlin 1.1.1-RC 2017-03-07 12:12:04 +03:00
Dmitry Petrov
d096f1d381 'while' and 'do-while' loop generator fixes.
Generate 'do-while' loop body as IrComposite, because variables declared
in loop body should be visible in loop condition.
Wrap 'do-while' loop in IrBlock so that variables declared in loop body
are not visible outside of the loop.

Generate 'while' and 'do-while' loops as expressions of type Unit.
2017-03-07 11:56:52 +03:00
Dmitry Petrov
cb61c358ea Always generate primitive boolean constants as expressions of type 'kotlin.Boolean'. 2017-03-07 11:56:52 +03:00
Dmitry Petrov
1bbbc1ca1c KT-16684 hashCode doesn't check data class property value of generic type for null 2017-03-07 11:56:52 +03:00
Dmitry Petrov
68fab55251 Minor: cleanup unused imports 2017-03-07 11:56:52 +03:00
Dmitry Petrov
6bc6c1b6cc KT-16671 Calls to members imported from objects should be desugared in PSI2IR 2017-03-07 11:56:52 +03:00
Dmitry Petrov
4ba8268a29 KT-16669 Exception in PSI2IR on type alias constructor in supertypes list 2017-03-07 11:56:52 +03:00
Dmitry Petrov
e4683a1e9f KT-16666 IMPLICIT_INTEGER_COERCION expression should have non-nullable type 2017-03-07 11:56:52 +03:00
Dmitry Petrov
8c32719f3d Render 'type' for IrTypeOperatorCall expressions, update testData. 2017-03-07 11:56:52 +03:00
Dmitry Petrov
b3aeddac85 Refactor: generalize postfix order transformation in InsertImplicitCasts 2017-03-07 11:56:52 +03:00
Dmitry Petrov
8e8f83656f KT-16618 IMPLICIT_INTEGER_COERCION isn't generated for global properties and default parameters 2017-03-07 11:56:52 +03:00
Sergey Igushkin
ee6aae7219 Enabled incremental compilation by default in Gradle plugin.
#KT-16546 Fixed

(cherry picked from commit 06715c5)
2017-03-07 11:32:26 +03:00
Alexey Andreev
ef38761dc2 JS: unmute now passing tests and mute test that passed by accident. 2017-03-07 10:46:09 +03:00
Alexey Andreev
a6ca2906d8 JS: add tests for reflection against external classes 2017-03-07 10:46:08 +03:00
Alexey Andreev
723c9be5a0 JS: fix class literal expression with primitive classes. See KT-16545 2017-03-07 10:46:08 +03:00
Alexey Andreev
8567db10b5 JS: fix coroutine transformation of callable references to local functions. See KT-16164 2017-03-07 10:46:07 +03:00
Dmitry Petrov
18fb70b32f Potential fix for KT-16673
See also:
http://stackoverflow.com/questions/42571812/unsupportedoperationexception-while-building-a-kotlin-project-in-idea

'original' for SamAdapterFunctionScope.MyFunctionDescriptor#doSubstitute should exactly match 'this.original',
so we can just provide it by default in SamAdapterFunctionScope.MyFunctionDescriptor#newCopyBuilder.
2017-03-06 22:00:09 +03:00
Dmitry Jemerov
268f7b715c "Configure Kotlin plugin updates" shows 1.2 and doesn't show 1.0.x 2017-03-06 19:50:58 +01:00
Ilya Chernikov
50e7973fc0 Implement verification workaround for annotation-like class InvalidScriptResolverAnnotation
fixes #KT-16621
2017-03-06 16:31:52 +01:00
Sergey Mashkov
243f718193 EA-88059 - assert: CompositeElement.addChild
ensure parent element for anchor elements so we never try to insert at wrong place
2017-03-06 17:34:36 +03:00
Sergey Mashkov
4637dcde33 EA-86479 - ISE: PomFile.<init>
don't apply any inspections for inappropriate pom files
2017-03-06 17:34:35 +03:00
Mikhael Bogdanov
ff9fe85507 Fix for KT-16614: Report inability to inline 1.8 bytecode into 1.6 bytecode as an error, no as an exception 2017-03-06 15:15:22 +01:00
Vyacheslav Gerasimov
5e4459f41d Fix broken MultiFileHighlightingTest
Android resource folding builder should not run in non-Android projects
2017-03-06 14:31:01 +03:00
Alexander Udalov
0111c4d581 Allow references to nested class constructors in objects in LV = 1.0
#KT-16598 Fixed
2017-03-06 11:03:24 +03:00
Alexander Udalov
7c22113c34 Refactor serialization of package FQ name extension
Instead of requiring to pass it in SerializerExtensionBase's
constructor, pass it always in serializePackage. This is more
straightforward and helps in a situation where one SerializerExtension
instance is used for the whole module, not one per-package
2017-03-06 11:03:24 +03:00
Kirill Rakhman
c952e26cbb Fix NPE caused by Rename Refactoring of backing field when caret is after the last character
#KT-16605 Fixed
2017-03-06 11:01:38 +03:00
Kirill Rakhman
1bad04db50 Fix Can't rename implicit lambda parameter 'it' when caret is placed right after the last character
#KT-14401 Fixed
2017-03-06 11:01:38 +03:00
Ilya Chernikov
e3391175d9 Rewrite parallel daemon start test to make it tougher but more robust 2017-03-05 11:29:54 +01:00
Anton Bannykh
4c6b9b695c JS: mute some tests with extension functions in external declarations 2017-03-03 21:39:40 +03:00
Anton Bannykh
fcffd190d0 JS: prohibited extension function arguments in external functions; removed extension receiver in jQuery declarations. 2017-03-03 20:37:59 +03:00
Sergey Igushkin
73e94ffde0 Added a test for the fix of KT-16434.
(cherry picked from commit 5a6d06f)
2017-03-03 18:04:23 +03:00
Sergey Igushkin
6605ba80e7 Fix for androidTest variants of Android Gradle build.
Added a workaround reflection call to TaskManager to create a
javac task since it is missing for androidTest variants with jack.
Added source configuration with the tested variant to make
the tested sources visible to the compiler.

#KT-16434 Fixed

(cherry picked from commit 84efd05)
2017-03-03 18:04:12 +03:00
Mikhail Glukhikh
0432e2e947 Quick-fix to add noinline to parameter with suspend function type + AddInlineModifierFix refactoring #KT-16074 Fixed 2017-03-03 17:28:37 +03:00
Mikhail Glukhikh
d9710ea4ff #EA-97027 Fixed 2017-03-03 17:28:35 +03:00
Mikhail Glukhikh
8965bb8977 Navigation: new icons for header <---> impl #KT-15842 Fixed 2017-03-03 17:28:34 +03:00
Vyacheslav Gerasimov
1376c8f8cf Implement quickfixes for Android Lint api issues
#KT-16624 Fixed
#KT-16625 Fixed
#KT-14947 Fixed
2017-03-03 16:22:36 +03:00
Vyacheslav Gerasimov
a907ec92b5 Implement Android resource reference folding
#KT-15451 Fixed
2017-03-03 16:18:20 +03:00
Vyacheslav Gerasimov
39010ab847 Fix broken isReferenceTo checking code for Android extensions
#KT-16132 Fixed
2017-03-03 16:17:52 +03:00
Alexander Udalov
25c1828288 JS: write and load pre-release flag on binaries 2017-03-03 13:33:51 +03:00
Alexander Udalov
de8dd37e44 Change DeserializedContainerSource.presentableFqName to String
To allow outputting something other than "Class 'XXX'" in the diagnostic
message for declarations deserialized from JS
2017-03-03 13:33:51 +03:00
Alexander Udalov
f120865350 Combine cls stub builders for built-ins and JS 2017-03-03 13:33:51 +03:00
Alexander Udalov
297eb952bc Extract common parts of built-ins and JS decompilers 2017-03-03 13:33:51 +03:00
Alexander Udalov
b52b90c182 Extract serialization of packageFqName extension to SerializerExtensionBase 2017-03-03 13:33:51 +03:00
Alexander Udalov
4e91dadfab Combine decompiler deserializers for built-ins and JS 2017-03-03 13:33:50 +03:00
Alexander Udalov
bafa0ec1ee Minor, don't throw exception on empty proto message 2017-03-03 13:33:50 +03:00
Alexander Udalov
5a00a97cf1 Extract common parts from deserialization of built-ins and JS 2017-03-03 13:33:50 +03:00
Alexander Udalov
3cb8f1ab20 Drop BuiltIns protobuf message, use ProtoBuf.PackageFragment instead 2017-03-03 13:33:50 +03:00
Alexander Udalov
a36e457c12 Introduce PackageFragment protobuf message for kjsm/builtins/common metadata 2017-03-03 13:33:50 +03:00
Alexander Udalov
2b1b1fb0d4 Merge VirtualFileKotlinClassFinder into VirtualFileFinder
VirtualFileKotlinClassFinder was the only direct subclass of VirtualFileFinder
2017-03-03 13:33:50 +03:00
Alexander Udalov
abb5bc6aba Simplify VirtualFileFinder and their factories' hierarchy
Since there's no JsVirtualFileFinder anymore, inline JvmVirtualFileFinder into
VirtualFileFinder and drop "Jvm" prefix everywhere
2017-03-03 13:33:50 +03:00
Alexander Udalov
ee0874a26d Drop JsVirtualFileFinder and its factory, refactor nearby
The only remaining usage was in KotlinRuntimeLibraryUtil.kt where we only
needed to check whether there's at least one file in a given package indexed by
KotlinJavaScriptMetaFileIndex. Move that logic to a public extension, drop
everything else
2017-03-03 13:33:50 +03:00
Alexander Udalov
67699bf17e Rename metadata version index and its subclasses 2017-03-03 13:33:50 +03:00
Alexander Udalov
57877bb007 Add default value to js_code_binary_version in js.proto
By default, assume the version is 1.0.0
2017-03-03 13:33:49 +03:00
Mikhael Bogdanov
a03ed6f742 Fix for KT-16581: VerifyError when calling default value parameter with jvm-target 1.8
#KT-16581 Fixed
2017-03-03 11:21:42 +01:00
Ilya Chernikov
ffe3453937 Do not pollute IDEA log with fake script dependencies 2017-03-03 10:59:28 +01:00
Mikhail Glukhikh
3060ecc066 Minor build fix: "Convert to apply" is now applicable only with 2+ calls with the same receiver 2017-03-03 11:10:01 +03:00
Dmitry Petrov
634d9834de Wrong receiver is generated for variable-as-function call on object.
Move 'generateExpressionForReferencedDescriptor' to CallGenerator,
use it in 'generateCall',
add PSI-free versions of some utility methods so that call elements can
be generated when we're already deep in ResolvedCall generation
and have forgotten about PSI.
2017-03-03 10:15:59 +03:00
Mikhail Zarechenskiy
d573962259 Add test for class delegation with private constructor
#KT-16583 Obsolete
2017-03-02 18:34:59 +03:00
Mikhail Zarechenskiy
e2dcec62d3 Fix access to top-level declarations inside anonymous initializer
#KT-16583 Fixed
2017-03-02 18:34:51 +03:00
shiraji
0e5603f644 Implement an intention converting several calls with same receiver to with/apply/run #KT-12183 Fixed 2017-03-02 16:56:56 +03:00
shiraji
c2e5fc5215 Move KtDotQualifiedExpression.deleteFirstReceiver to Utils.kt 2017-03-02 16:56:53 +03:00
Alexander Udalov
39d0cd7237 Test that all Kotlin versions in the project are consistent
There are two different tests: the one that checks that all versions are
consistent (but not equal, because some versions are major.minor.patch,
but some only major.minor), and the one that checks that versions of all
subprojects of the Maven projects are exactly equal (1.1-SNAPSHOT
currently)

 #KT-16455 Fixed
2017-03-02 16:36:51 +03:00
Denis Zharkov
6fb83c2ba3 Force wrapping java classes from annotation methods into KClasses
Before this change such wrapping happened only during coercion,
i.e. when a call-site expected a KClass instance.

But when call-site expects Any, for example, no wrapping happened,
and raw j.l.Class instance was left on stack.

The solution is to put wrapping code closer to generation of annotation's
method call itself to guarantee that necessary wrapping will happen.

 #KT-9453 Fixed
2017-03-02 15:19:09 +03:00
Denis Zharkov
415c3d57af Fix substitutor for synthetic SAM adapters
When synthetic member comes not from the receiver type itself,
but from one of its supertypes it doesn't make sense to subsitute
the member with receiver type, we should obtain relevant supertype
and use it instead.

 #KT-16578 Fixed
2017-03-02 15:06:59 +03:00
Anton Bannykh
9e5ecc11b7 JS: fixed Double.NaN behaviour (KT-13610). 2017-03-02 14:29:50 +03:00
Dmitry Petrov
f636ab21f8 Use proper descriptor for (generic) property assignment.
Insert IMPLICIT_INTEGER_COERCION only if Int is coerced to an integer type.
2017-03-02 14:25:58 +03:00
Dmitry Petrov
97fbbc74e6 KT-16440 ClassConstructorDescriptorImpl has null returnType
Set constructor return type in FunctionDescriptorResolver#createConstructorDescriptor
(it seems to be the only place where ClassConstructorDescriptorImpl#initialize(...)
is called, but returnType is not set).
2017-03-02 14:25:58 +03:00
Dmitry Petrov
dc1d92855d KT-16438 Strange dispatch receiver for descriptors of delegated members
Provide proper dispatch receiver parameter for delegated members.
Use dispatch receiver parameter for delegated members in IR generation
for delegated member body (and check that the receiver has corresponding type).
2017-03-02 14:25:58 +03:00
Dmitry Petrov
c92f118e5e Refactoring: introduce CopyBuilder for CallableMemberDescriptor and PropertyDescriptor.
Allow providing new dispatchReceiverParameter via CopyBuilder
(required for proper dispatch receiver for delegates).
2017-03-02 14:25:58 +03:00
Dmitry Petrov
9baaf607a3 KT-16566 Support destructuring declarations for lambda parameter in psi2ir 2017-03-02 14:25:58 +03:00
Dmitry Petrov
c226707a80 KT-16554 Local function with default arguments have no IR elements for them 2017-03-02 14:25:58 +03:00
Igor Chevdar
ab3681e164 Package level delegated properties have no dispatch receiver. 2017-03-02 12:33:01 +03:00
Igor Chevdar
3ef612f05a Added dispatch receiver to delegation implementing property 2017-03-02 12:33:01 +03:00
Simon Ogorodnik
6dd75f697a Fix Show implementation to show inheritance through type-aliases
Show implementation(Ctrl-Hover) now should show classes which inherit such class through type-alias
 #KT-15200 fixed
2017-03-01 23:05:19 +03:00
Yan Zhulanow
593fbadc98 Force using the 'kotlin-stdlib-jre7' artifact when configuring Android modules with JDK >= 1.8 as Dex can't process our 'kotlin-stdlib-jre8' artifact.
This fixes KT-16530: Configure Kotlin in Project inserts dependency to kotlin-stdlib-jre8 in Android projects.
2017-03-01 18:50:22 +03:00
Yan Zhulanow
060095d39f Remove kotlin-annotation-processing artifact from the serialized compiler options. It is unused in kapt3 (or if no annotation processor dependencies are provided) but is still imported into the IDEA module files. This leads to compilation error due to the plugin incompatibility.
Incompatibility reason: kotlin-annotation-processing has references to the shaded intellij-core, so, being provided to the unshaded kotlinc from the Kotlin plugin, it throws the AbstractMethodError.

This fixes #KT-16184.
2017-03-01 18:50:22 +03:00
Kirill Rakhman
2506bb6673 Inspection checking that destructuring variable name matches the name of different component #KT-12004 Fixed 2017-03-01 18:24:48 +03:00
Dmitry Jemerov
af7de9a0c5 Warn when running the compiler under Java 6 or 7
(cherry picked from commit 5537800)

(cherry picked from commit 5614874)
2017-03-01 16:21:57 +01:00
Simon Ogorodnik
000da2f6d0 Fix of <ERROR CLASS>-es pointing to public TypeAliases 2017-03-01 16:09:24 +01:00
Dmitry Jemerov
78b4cbdb69 Don't generate documentation for option that doesn't work in Gradle 2017-03-01 16:09:23 +01:00
Alexey Andreev
0c0e0aab09 JS: add some docs to declarations related to interop 2017-03-01 16:09:21 +01:00
Dmitry Jemerov
322379e6ae Assorted stdlib KDocs 2017-03-01 16:09:01 +01:00
Dmitry Jemerov
1d86bd5610 Build multiplatform stdlib docs 2017-03-01 16:08:38 +01:00
Dmitry Jemerov
adc937c57d Extract separate target for preprocessing JS stdlib sources 2017-03-01 16:08:28 +01:00
Kirill Rakhman
8d425a6f94 Add intention to add missing components to destructuring assignment #KT-16258 Fixed 2017-03-01 18:00:55 +03:00
Mikhael Bogdanov
4d47c0fd63 Partial fix for KT-16193: Incremental compilation generates invalid bytecode for crossinlined functions; avoid IllegalAccessError 2017-03-01 14:45:11 +01:00
Alexander Udalov
3ad4f18e1a Update grammar to Kotlin 1.1
Also drop obsolete comments and inline some trivial rules
2017-03-01 14:50:36 +03:00
Mikhail Zarechenskiy
875fdef917 Add tests for obsolete issues
#KT-15913 Obsolete
 #KT-12248 Obsolete
2017-03-01 14:07:09 +03:00
Anton Bannykh
318014e4ab Test vararg with Java behaviour only for JVM backends 2017-03-01 13:58:57 +03:00
Mikhail Glukhikh
91cd590395 Change log: note about javaClass added 2017-03-01 10:14:57 +03:00
Denis Zharkov
a7fc32c8da Add diagnostic on calling inner classes constructors without receiver
Otherwise there will be just an unresolved reference that doesn't give
any useful information

 #KT-8959 Fixed
2017-03-01 09:59:01 +03:00
Denis Zharkov
1e0ae04aba Minor. Convert if to when 2017-03-01 09:59:00 +03:00
Denis Zharkov
b5a8ffaddc Fix resolution of callable references
When there is unsuccessful (e.g invisible) result of one kind (static/non-static)
and there is a successful candidate for another kind, choose the latter one.

Note, that we have to postpone commiting trace until we choose one of the results,
otherwise errors of unsuccessful results are reported

TODO: Maybe it makes sense to report all results when all of them are
unsuccessful (NONE_APPLICABLE or something like this)

 #KT-16278 Fixed
2017-03-01 09:59:00 +03:00
Dmitry Petrov
dd61a5b2c6 KT-16553 Underscore variable values shall not be evaluated
Do not generate 'componentN' calls for '_' in destructuring assignment.
2017-03-01 09:25:38 +03:00
Dmitry Petrov
63b16e14d8 KT-16536 Wrong IR generated for '++x'
Make psi2ir confirm to JVM BE behavior for prefix increment/decrement.
TODO reconsider after design decision (in 1.2?).
2017-03-01 09:25:38 +03:00
Dmitry Petrov
885f397cdd KT-16535 'provideDelegate' convention is not supported in IR
Implement provideDelegate convention support.
NB delegate type now depends on 'provideDelegate' convention resolution.
2017-03-01 09:25:38 +03:00
Dmitry Petrov
6046b25f56 Minor: silence that irritating KT-14030 2017-03-01 09:25:38 +03:00
Dmitry Petrov
045a12ddc6 Minor: constructor IrExpressionBodyImpl(IrExpression) 2017-03-01 09:25:38 +03:00
Dmitry Petrov
e66c2621af KT-16436 Incorrect primitive constants handling
Expression '1.unaryMinus()' is resolved as Int::unaryMinus call with Int receiver.
However, this expression is implicitly coerced to a different integral type (Byte, Short, Long)
based on results of constant evaluation.

Introduce IMPLICIT_INTEGER_COERCION type operator to handle such cases.

TODO: should we use it for simple constant expressions like '1' and '-1'?
2017-03-01 09:25:38 +03:00
Dmitry Petrov
d0134f2c64 KT-16437 Incorrect type inference for some when coerced to Unit
If the result of 'when' is not used in an expression,
this 'when' expression has type 'Unit' despite of whatever FE has inferred.
2017-03-01 09:25:38 +03:00
Dmitry Petrov
e2e57e5b6d KT-16439 Generated methods of data classes have no expression for default arguments
Provide default argument expressions for generated 'copy' declaration.
2017-03-01 09:25:38 +03:00
Dmitry Petrov
0f1f354ba6 KT-16486 Strange IR for delegated members
Delegated implementations should refer to delegate field:
  $this: GET_FIELD <delegate_field> ...
    receiver: <this_for_containing_class>
2017-03-01 09:25:38 +03:00
Alexander Udalov
abbbdb5771 Update KotlinVersion.CURRENT to 1.1.2 2017-02-28 20:24:33 +03:00
Alexander Udalov
559da842c0 Clear reflection caches in black box codegen tests
To prevent tests from altering outcomes of the subsequent tests.

Also expose the clearCaches method (in the internal class
ReflectionFactoryImpl) so that it can be used in other places in similar
circumstances
2017-02-28 20:19:58 +03:00
Alexander Udalov
e19c1b5364 Drop MockTypeAliasDescriptor, use MockClassDescriptor instead
It's irrelevant whether the non-found classifier is a class or a
typealias
2017-02-28 20:19:58 +03:00
Alexander Udalov
12b48f86e7 Do not load error classes in ReflectionTypes
Previously ReflectionTypes.find returned an error class in case a class
is not found in the module dependencies. The problem with this approach
is that each call site should call ErrorUtils.isError on the result and
report an error if needed, in order to stop this type from reaching the
codegen, which can't handle error types.

Now we create a MockClassDescriptor instance instead. It's not an error
class, so it'll be handled correctly in the codegen. Also its scope is
empty and errors are reported on any non-trivial usage (see
MissingDependencyClassChecker), so this approach is not worse than error
classes

 #KT-16484 Fixed
2017-02-28 20:19:58 +03:00
Alexander Udalov
794cc1e3be Refactor API of NotFoundClasses
Move deserialization-related stuff to TypeDeserializer, because it's
going to be used in other places besides deserialization
2017-02-28 20:19:58 +03:00
Alexander Udalov
86994f81c3 Refactor ClassId.getOuterClassId, make it nullable 2017-02-28 20:19:57 +03:00
Mikhael Bogdanov
21de67cac1 Fix for KT-16532: Kotlin 1.1 RC - Android cross-inline synchronized won't run
Finnaly markers are used only for non-local return processing and are removed after inlining  to non-inline functions, same deletion should be performed on inlining to anonymous objects

 #KT-16532 Fixed
2017-02-28 15:40:04 +01:00
Alexey Sedunov
387c91f957 Kotlin Facet: Do not concat "additional argument" string as configuration gets duplicated
KT-16548 Fixed
2017-02-28 16:07:58 +03:00
Anton Bannykh
6608e97d35 JPS JS: simplified the code and added tests for the missing meta.js case (e.g. empty sourceroot; fixed by yole in 00ed0248d9a23701dbef52da02259d174a9999e7) 2017-02-28 16:05:16 +03:00
Anton Bannykh
2d9392aad4 JS: fixed callable reference to a class constructor within object (KT-16411). 2017-02-28 15:55:50 +03:00
Mikhail Glukhikh
6ed3672f8d Change log for 1.1 (release)
(cherry picked from commit afd6e0d)
2017-02-28 11:46:25 +03:00
Denis Zharkov
ecec87cbc7 Refine signature calculation for methods with default parameters
The problem was that he number of mask parameters for defaults when
generating methods declaration was being calculated upon resulting signature
(with additional parameters: extension receivers, enum name/ordinal),
while on call-sites the masks number was calculated by the arguments number
in resolved call, i.e. by the number of real value parameters.

And because of the additional synthetic parameters (like enum.ordinal) these
two numbers could be different.

The solution is just to use value parameters number in both places.
Note, that we only count value parameters from the original sourse
declaration, ignoring synthetic ones generated by backend (e.g.
Continuation for suspend functions)

 #KT-14565 Fixed
2017-02-28 10:42:07 +03:00
Denis Zharkov
9e03b712de Use flexible upper bound of parameter's type for vararg argument
See the issue and the test. The problem was that when generating
call to `foo` method in member scope of `AT<*>` its resulting descriptor
after substitution and approximation was: fun foo(x: Nothing..Array<out Nothing>).

This signature is correct, but when using this parameter type
for generating a vararg argument the assertion is violated that
the type of the argument must be an array
(by default we're using lower flexible bound everywhere)

The solution is using upper bound for flexible types that should
always have a form of Array<out T> for varargs (even for such corner cases)
both for Kotlin and Java declarations.

 #KT-14607 Fixed
2017-02-28 10:40:54 +03:00
Alexey Sedunov
14dad61fe5 Kotlin Facet: Import more configuration options from Maven
(cherry picked from commit dca696f)
2017-02-28 03:06:54 +03:00
Alexey Sedunov
90c2b14051 Kotlin Facet: Import Maven option specified in <jvmTarget> element
#KT-16329 In Progress
2017-02-28 03:05:13 +03:00
Nikolay Krasko
b9b4cce293 Set JVM target from facet settings on compiler configuration creation
Otherwise analyse in IDE is perfomed under default JVM target and wrong
diagnostics are reported.

 #KT-16329 In Progress
2017-02-28 02:32:59 +03:00
Roman Elizarov
266d7c15fe Documentation for createCoroutine/createCoroutineUnchecked 2017-02-27 16:48:24 +03:00
Nikolay Krasko
f0be88fc07 Use doResume name for suspend lambdas context (KT-16481)
#KT-16481 Fixed
2017-02-27 14:49:13 +03:00
Nikolay Krasko
dffbe0f707 Count JVM class name for inlined function from base declaration
Drop code with naive removing all anonymous classes.
Breakpoints now works when inline call is in anonymous call.
2017-02-27 14:49:12 +03:00
Nikolay Krasko
cd92e3fc98 Refactoring: use constants instead of string literals 2017-02-27 14:49:11 +03:00
Ilya Chernikov
fa5728b288 Use Void instead of Unit in RMI calls, should fix EA-82064
("Could not initialize class Kotlin.Unit")

(cherry picked from commit b3a1311)
2017-02-24 16:58:25 +01:00
Ilya Chernikov
00e8dfe1be Use sessions with connection to eliminate async shutdown problems
(cherry picked from commit 78d334b)
2017-02-24 16:58:25 +01:00
Ilya Chernikov
4202bde550 Make daemon connection more reliable by retrying on certain exceptions
(cherry picked from commit 74a0711)
2017-02-24 16:58:25 +01:00
Ilya Chernikov
c7a2422314 minor: Make parallel daemong start test less demanding 2017-02-24 16:58:25 +01:00
Ilya Chernikov
6d9ecc60ef Skip metadata version check in repl, improve JSR 223 template compatibility 2017-02-24 16:58:25 +01:00
Ilya Chernikov
a16f412b48 Add eval in eval benchmark tests 2017-02-24 16:58:25 +01:00
Ilya Chernikov
1ae95853e7 Fix merging errors 2017-02-24 16:58:25 +01:00
Ilya Chernikov
d3682b7f7d Implement JSR 223 script template with eval functions, some fixes 2017-02-24 16:58:25 +01:00
Ilya Chernikov
63aae56b11 Get rid of eval on daemon completely, fixes also JSR 223 examples 2017-02-24 16:58:24 +01:00
Ilya Chernikov
a3a782613a Cleanup 2017-02-24 16:58:24 +01:00
Ilya Chernikov
1032f0d39c Fix java 8 repl tests 2017-02-24 16:58:24 +01:00
Ilya Chernikov
b9469a9308 Fix script-util after changes in repl infrastruct 2017-02-24 16:58:24 +01:00
Ilya Chernikov
75234701c7 Fix remote repl state facade 2017-02-24 16:58:24 +01:00
Ilya Chernikov
b23911fd59 Reintroduce history check between compile and eval, place generation into code line and id 2017-02-24 16:58:24 +01:00
Ilya Chernikov
7b2ea001c1 Fix state conversion, fix tests 2017-02-24 16:58:24 +01:00
Ilya Chernikov
c5bc58ad32 Implement remote part of the new repl state handling 2017-02-24 16:58:24 +01:00
Ilya Chernikov
f9dedab8c8 Extract repl state as a separate object 2017-02-24 16:58:24 +01:00
Anton Bannykh
3eb5b3e08c JS: changed BoxedChar visibility to internal 2017-02-24 13:46:29 +03:00
Dmitry Jemerov
5c9f0df256 Download specific build of IJ 162, not a snapshot 2017-02-24 11:19:43 +01:00
Nikolay Krasko
6b62686019 Add blank lines tab to Kotlin code style UI with two basic options
KEEP_BLANK_LINES_IN_CODE
KEEP_BLANK_LINES_IN_DECLARATIONS

#KT-15504 In Progress
2017-02-22 20:13:28 +03:00
Nikolay Krasko
bc90d52873 Minor: remove warnings in KotlinSpacingBuilder.kt 2017-02-22 20:13:24 +03:00
Nikolay Krasko
6a4590839c Don't merge two lines in formatter after line comment (KT-16032)
#KT-16032 Fixed
2017-02-22 20:12:19 +03:00
Nikolay Krasko
20f92c6200 Use own kotlin settings for spacing instead of default set
Mostly affected by settings:
- KEEP_LINE_BREAKS,
- KEEP_BLANK_LINES_IN_DECLARATIONS
- KEEP_BLANK_LINES_IN_CODE

Allow settings KEEP_LINE_BREAKS in UI.
2017-02-22 20:04:34 +03:00
Nikolay Krasko
5ed5f8f048 Minor: reuse DO_RESUME_METHOD_NAME constant instead of literal 2017-02-22 19:58:50 +03:00
Alexander Udalov
a9678010a8 Invert LanguageFeature responsible for warning on coroutines
The problem was that LanguageVersionSettingsImpl.DEFAULT did not have
"WarnOnCoroutines" as a feature and so it was manually added to the settings,
but only in two places: in the compiler and in the IDE
2017-02-22 18:55:48 +03:00
Dmitry Jemerov
e3dab96715 Add Trove4j license 2017-02-22 16:04:33 +01:00
Ilya Gorbunov
6e8f227121 Drop ERROR deprecations in JS library that were introduced in 1.1-rc 2017-02-22 17:28:02 +03:00
Ilya Gorbunov
b393c66426 Drop ERROR deprecations from kotlin-reflect. 2017-02-22 17:28:02 +03:00
Ilya Gorbunov
c0c01d6e49 Drop HIDDEN deprecations from kotlin-stdlib. 2017-02-22 17:28:02 +03:00
Ilya Gorbunov
8e951dee16 Drop remaining ERROR deprecations from kotlin-stdlib-js.
Leave only `native`, `parseInt`, `parseFloat` and `noImpl`.
2017-02-22 17:28:02 +03:00
Ilya Gorbunov
eebb820060 Do not refer to java packages in common completion tests 2017-02-22 17:28:02 +03:00
Ilya Gorbunov
3cea5c4510 Drop entire java.util package from kotlin-stdlib-js
#KT-6561 Fixed
2017-02-22 17:28:02 +03:00
Ilya Gorbunov
5867d27fb7 [Standard Library] Take the javaClass deprecation back as its replacement is often inconvenient. 2017-02-22 17:27:20 +03:00
Alexander Udalov
d124912c91 Specify language / API version in .idea/kotlinc.xml 2017-02-22 14:45:57 +03:00
Anton Bannykh
909d83c3af JS: Force Rhino to load files using UTF8 encoding. Fixes failing kt14597 on windows agents. 2017-02-22 14:39:46 +03:00
Alexey Andreev
66f5a12cc4 JS: fix translation of && and || operators when their RHS declare temporary variables. See KT-16350 2017-02-22 11:10:07 +03:00
Dmitry Jemerov
c6bfb02754 Move JsAnalyzerFacade to ide-common module to enable its use in Dokka 2017-02-21 18:39:21 +01:00
Stanislav Erokhin
0a24bf1613 Fix type deserialization for suspend function types which was written by pre-release compiler.
Notes: if arity == 0, it means that type was `suspend () -> String` => arguments.size == 1, and it means that SuspendFunction0 has only one type argument and it is return type.
2017-02-21 17:26:07 +03:00
Stanislav Erokhin
81df7645e0 Fix potential CCE -- use unwrappedType after instanceof check. 2017-02-21 17:19:50 +03:00
Mikhael Bogdanov
d24ebf711b Fix for KT-16441: NoSuchFieldError: $$delegatedProperties when delegating through provideDelegate in companion object
#KT-16441 Fixed
2017-02-21 13:01:40 +01:00
Mikhael Bogdanov
a8625b632d Fix for KT-16411, KT-16412: Exception from compiler when try call SAM constructor where argument is callable reference to nested class inside object
#Fixed KT-16411
  #Fixed KT-16412
2017-02-21 11:40:25 +01:00
Denis Zharkov
85f9e2e47b Fix CCE in generated code that happens when comparing boxed chars
The problem was that when obtaining char from the wrapper,
codegen used int as expected type that led
to a ClassCastException: java.lang.Character cannot be cast to java.lang.Number

The solution is using coercion to chars, it's still correct,
because of implicit widening coercion in JVM from C to I

 #KT-15105 Fixed
2017-02-21 12:33:45 +03:00
Denis Zharkov
378acbf7ec Minor. Clarify method patchOpcode contract 2017-02-21 12:33:45 +03:00
Alexander Udalov
21449763ab Add extension CompilerConfiguration.languageVersionSettings for convenience 2017-02-21 10:58:19 +03:00
Alexander Udalov
103bd6dbde Minor, convert CommonConfigurationKeys to Kotlin 2017-02-20 16:18:00 +03:00
Alexander Udalov
d499998655 Inject CompilerConfiguration instead of LanguageVersionSettings
LanguageVersionSettings can be read from the configuration. Also, the
configuration may be used for other stuff, not related to language version
settings, soon
2017-02-20 16:18:00 +03:00
Alexander Udalov
4b31e75550 Refactor createContainerForLazyResolve/createLazyResolveSession 2017-02-20 16:18:00 +03:00
Alexander Udalov
ee1152bc98 Simplify injection of LanguageVersionSettings into JVM analysis
Pass the LanguageVersionSettings instance inside the CompilerConfiguration,
since it's needed anyway. In compiler and tests, the configuration comes from
KotlinCoreEnvironment; in IDE, we're constructing it in JvmAnalyzerFacade
2017-02-20 16:18:00 +03:00
Denis Zharkov
f2aacf774e Get rid of redundant not-null assertion for parameter
The problem was that in `Function<T>.apply(T)` T is now not-platform,
so when checking if not-null assertion is needed for parameter in SAM,
it's defined by the upper bounds of T that is a platform (Any..Any?),
and while it's definitely not marked as nullable it's still nullable
in a sense that it can contain null as a value.

So the solution is obvious

 #KT-16413 Fixed
2017-02-20 15:46:49 +03:00
Dmitry Jemerov
1bb7a617ad Don't overwrite explicitly specified language version in facet with version from dependencies; add tests for setting language version based on dependencies
(cherry picked from commit fc2b9f6)
2017-02-20 11:32:11 +01:00
Denis Zharkov
a3baca829f Drop KotlinTarget.INNER_CLASS entry
In most of the cases it was used together with CLASS_ONLY and vice versa
They only case when CLASS_ONLY was used without INNER_CLASS
is possibleParentTargetMap.COMPANION_KEYWORD.

But after diagnostic NESTED_OBJECT_NOT_ALLOWED has been introduced,
there's no sense in the restriction of exactly the companion's parent

For clarification see test data changed
2017-02-20 13:24:42 +03:00
Denis Zharkov
d1b17f050b Prohibit objects inside inner classes
#KT-16232 Fixed
2017-02-20 13:24:42 +03:00
Denis Zharkov
5b9b003e02 Prohibit inner sealed classes
#KT-16233 Fixed
2017-02-20 13:24:42 +03:00
Alexey Andreev
86d1c7b7ec JS: fix absence of temporary variable in secondary constructors. See KT-16377 2017-02-20 11:31:38 +03:00
Alexey Tsvetkov
3b222f13f3 Replace daemon's message after start with constant string
#KT-15783 fixed

When a daemon client cannot find an existing daemon, it starts a new one.
The client waits for a daemon to start and initialize.
Then the daemon is expected to signal that it is ready for compiling by printing message in stdout.
Before this change the message was the daemons' run path (a directory where all daemons store
their "flag" files).
However the path printed by the daemon was not matched by the path expected by the client somehow
on Windows for a user with a username containing non-English letters.
This commit replaces the message with the constant string.
2017-02-18 19:35:06 +03:00
Alexey Tsvetkov
b2de822fd4 Start daemon with explicit server ip address to prevent host name resolution 2017-02-18 19:35:06 +03:00
Denis Zharkov
0d8f64353a Fix JVM signature mapping for multi-dimensional arrays
#KT-11314 Fixed
2017-02-17 17:50:43 +03:00
Dmitry Jemerov
83d64e8eba Don't replace explicitly configured project settings with autodetected ones
(cherry picked from commit f16f975)
2017-02-17 14:44:37 +01:00
Nikolay Krasko
7bae72113b Rename: ExtraSteppingFilter -> KotlinExtraSteppingFilter 2017-02-17 15:57:11 +03:00
Nikolay Krasko
f7391f6c1a Minor: refactoring 2017-02-17 15:57:11 +03:00
Nikolay Krasko
d58707972d Keep empty bodies for declarations with comments (KT-16078)
#KT-16078 Fixed
2017-02-17 15:57:11 +03:00
Denis Zharkov
e16b0524b6 Fix inline codegen on local functions inside inlined lambda
The problem was that anonymous classes wasn't regenerated
although they capture another anonymous class that is a subject
for regeneration

 #KT-8689 Fixed
2017-02-17 13:48:19 +03:00
Alexey Tsvetkov
dfb60ba4ac Minor: remove the word 'experimental' from Gradle IC description 2017-02-16 21:27:04 +03:00
Alexey Tsvetkov
62a15e803b Avoid storing absolute paths in SyncOutputTask
#KT-16003 fixed
2017-02-16 21:26:50 +03:00
Alexey Tsvetkov
6e0f3b7f1f Avoid having -d and -module set at the same time
#KT-14619 fixed
2017-02-16 21:26:50 +03:00
Alexey Tsvetkov
667c00e3ed Copy compiler arguments from compile task to kapt task
#KT-15994 fixed
2017-02-16 21:26:50 +03:00
Dmitry Jemerov
3225c93ce0 Don't pass paths to non-existing metadata files from dependent modules 2017-02-16 19:16:19 +01:00
Mikhail Glukhikh
797813a8d4 Change log update (final) for 1.1-RC 2017-02-16 18:55:14 +03:00
Dmitry Jemerov
6aa3c26f78 Disable facet detection; force detection of API/language level from dependencies on project opening 2017-02-16 16:51:09 +01:00
Dmitry Jemerov
58713270bb Ask to update runtime library when increasing language version for module 2017-02-16 16:50:47 +01:00
Alexander Udalov
de2117663c Fix overload resolution ambiguity on *Array.clone() with runtime 1.0
#KT-16371 Fixed
2017-02-16 18:46:05 +03:00
Alexander Udalov
9d11f0b92f Minor, check every deserialized value in refsAreSerializable.kt 2017-02-16 18:00:19 +03:00
Alexander Udalov
1ee2053a16 Make callable references Serializable on JVM
#KT-11254 Fixed
2017-02-16 18:00:18 +03:00
Dmitry Jemerov
4d451356eb Quickfixes to enable unsupported and experimental features handle API level correctly and support updating the runtime library 2017-02-16 12:41:42 +01:00
Dmitry Jemerov
ea228a2fa8 Fix testdata for SimpleKotlinRenderLogTest 2017-02-16 11:43:16 +01:00
Alexander Udalov
612481f0f4 Fix stub builder for builtins after cdeabf26b4 2017-02-16 10:35:07 +03:00
Alexander Udalov
cdeabf26b4 Fix NPE from KotlinBuiltInDecompiler
This happened because of bae955aafd: similarly to the corresponding code in
the compiler, the IDE should also skip the metadata for kotlin.Cloneable when
decompiling built-ins because the deserializer is not going to resolve this
class from the metadata
2017-02-16 01:31:44 +03:00
Mikhail Glukhikh
4d4e2c5c94 Change log for 1.1-RC updated
(cherry picked from commit 4897af1)
2017-02-15 20:53:44 +03:00
Alexander Udalov
8e407d548a Suggest to provide explicit dependency on new kotlin-reflect
In case when there's kotlin-stdlib 1.1 and kotlin-reflect 1.0 in the classpath
2017-02-15 20:43:25 +03:00
Alexander Udalov
71fcb07fad Infer API version from older runtime in compiler's classpath
For example, if you invoke kotlinc 1.1 with kotlin-stdlib 1.0 in the classpath,
we now infer -api-version 1.0 automatically
2017-02-15 20:43:25 +03:00
Alexander Udalov
b56639a775 Filter out files with the same paths in runtime version checker
To prevent listing them several times in the diagnostic message
2017-02-15 20:43:25 +03:00
Alexander Udalov
8457ab7c58 Report warnings instead of errors in runtime version checker 2017-02-15 20:43:25 +03:00
Alexander Udalov
ba84338862 Support smart cast for nullability in LHS of class literal
#KT-16291 Fixed
2017-02-15 20:43:25 +03:00
Alexander Udalov
bae955aafd Serialize metadata for Cloneable and discard it during deserialization
#KT-16358 Fixed
2017-02-15 20:43:25 +03:00
Alexander Udalov
46bd64f59a Rename FunctionImpl -> FunctionBase, restore abstract class FunctionImpl
This fixes the IncompatibleClassChangeError which happens when kotlin-reflect
1.0.x and kotlin-stdlib 1.1.x are in the classpath

 #KT-16358 In Progress
2017-02-15 20:43:25 +03:00
Dmitry Jemerov
41f7950ab8 UAST tests: don't null out the application if we have a valid one that we restored from a previous test 2017-02-15 18:21:37 +01:00
Anton Bannykh
4c808e8691 JS: concat vararg arguments using Kotlin.concat and Kotlin.concatPrimitive functions in order to be binary compatible with (Kotlin PrimitiveArray -> JS TypedArrays) mapping. 2017-02-15 18:58:29 +03:00
Ilya Gorbunov
a903c4ab0e Change log clarifications regarding stdlib
(cherry picked from commit ba857a83ff)
2017-02-15 18:17:11 +03:00
Dmitry Jemerov
7704310359 Fix Kotlin facet autodetection so that it actually works and stores the correct language/API level based on project dependencies 2017-02-15 15:48:43 +01:00
Mikhail Glukhikh
3bc322c2ce Change log for 1.1-RC updated 2017-02-15 17:45:47 +03:00
Dmitry Jemerov
f06d46fe9a Advance until-build to 172.* 2017-02-15 14:43:53 +01:00
Yan Zhulanow
8e9536f61d Revert "Kapt3: Add generated source files to Java compile task after kapt execution. Filter only .java files."
This reverts commit 82c2ce3a33.
2017-02-15 16:28:33 +03:00
Yan Zhulanow
35b41b9401 Kapt3: Fix annotation processor option passing 2017-02-15 16:28:26 +03:00
Dmitry Jemerov
95bfe8668d UAST tests no longer leave a disposed application around 2017-02-15 12:56:21 +01:00
Alexey Sedunov
5d65e6bc9b Kotlin Facet: Facet migration workaround for the case pre-1.1-beta -> 1.1.rc+ (reset useProjectSettings to false for old configurations) 2017-02-15 14:40:09 +03:00
Alexey Sedunov
2e01f62afe Kotlin Facet: Detect language/API version by stdlib when "Use project settings" is enabled, but project-level language/api version is not specified explicitly 2017-02-15 14:40:04 +03:00
Alexey Sedunov
0d2122bb1d Kotlin Facet: Do not rewrite language/API version based on compiler arguments if they do not contain explicit language/API version 2017-02-15 14:30:41 +03:00
Alexey Sedunov
2790fcf4bd Kotlin Facet: Synchronize version info on opening the configuration editor 2017-02-15 14:30:40 +03:00
Dmitry Jemerov
060a865fb1 Use correct resolution facade for resolving cross-module links in KDoc comments
#KT-15647 Fixed
2017-02-15 12:08:18 +01:00
Mikhail Glukhikh
4b7380bea4 Change log for 1.1-RC added 2017-02-15 12:49:22 +03:00
Alexander Udalov
8e3cb912c7 Make Ref classes for shared vars Serializable
#KT-14566 Fixed
2017-02-15 10:46:48 +03:00
Alexander Udalov
c10524586a Use proguard to remove unused symbols from kotlin-reflect.jar
#KT-16268 Fixed
2017-02-15 10:46:48 +03:00
Alexander Udalov
2e8bfde2e7 Move -Xskip-metadata-version-check from JVM to common arguments
To be used in JS
2017-02-15 10:46:48 +03:00
Alexander Udalov
a1a71a01b1 Drop JvmMetadataVersion.skipCheck, support this correctly
Pass the value of this flag via DeserializationConfiguration
2017-02-15 10:46:48 +03:00
Alexey Sedunov
e1463f9e0f Kotlin Facet: Fix detection of pre-1.1-beta JS-stdlib dependencies 2017-02-14 18:28:44 +03:00
Mikhail Zarechenskiy
5515a63911 Replace KotlinBuiltIns.isBuiltIn with corresponding package checking
Method `isBuiltIn` may not work correctly as built-ins are becoming
more and more like a usual dependency. Also behaviour of this method is
depend on the target platform.
2017-02-14 16:21:17 +03:00
Alexey Sedunov
8c84717cbc Kotlin Facet: Reset all coroutine support flags before importing them frm Gradle 2017-02-14 16:19:21 +03:00
Vyacheslav Gerasimov
a2e429a912 Fixed exception in getUastLocation of class annotation argument
#KT-16326 Fixed
2017-02-14 15:56:37 +03:00
Stanislav Erokhin
b6fa10cf9e Disable some features when LV=1.1 API=1.0.
Feature list:
 - bound callable references
 - local delegated properties
 - coroutines.

#KT-16017 Fixed
2017-02-13 20:29:38 +03:00
Dmitry Jemerov
be0211cd49 Ugly deadlock workaround for KT-16149: members of DataBindingComponent are calculated via annotations search which causes resolve reentrering 2017-02-13 17:20:10 +01:00
Simon Ogorodnik
2490318f93 KT-16076 Completion inserts FQN kotlin.text.String
KT-14831 Don't add import statement and FQN on converting lambda to reference if typealias is used
KT-16088 Completion wrongly inserts FQN for `kotlin` package
 #KT-16076 fixed
 #KT-14831 fixed
 #KT-16088 fixed
2017-02-13 16:48:14 +03:00
Ilya Gorbunov
fee676a281 Introduce 'takeUnless' function which is like 'takeIf' but with the predicate inverted.
#KT-7858
2017-02-13 16:07:34 +03:00
Sergey Igushkin
9e1afe71f2 Fixed Kotlin2Js output not being the output of the compileKotlin2Js tasks.
Therefore, fixed Kotlin2Js output not present in JAR.
Reworked the clean behavior in regard to compileKotlin2Js tasks.
Fixed duplicate source roots passed to the compiler.

Issues:
- #KT-15829 Fixed
- #KT-16267 Fixed
- #KT-15902 Fixed
2017-02-13 15:44:05 +03:00
Anton Bannykh
ad313750e7 JS: Fixed lateinit property initialization 2017-02-13 14:56:50 +03:00
Alexey Sedunov
1452d7e4a6 Kotlin Gradle Plugin: Extend implicit argument set 2017-02-13 14:53:18 +03:00
Alexey Sedunov
75c56d58ae Line Markers: Do not attempt to resolve suspend call candidates which are not call-like expressions 2017-02-13 14:53:17 +03:00
Alexey Sedunov
add16dec3d Extract Function: Fix detection of suspend calls containing extracted parameters
#KT-16251 Fixed
2017-02-13 14:53:17 +03:00
Alexey Sedunov
574a0e629e Kotlin Facet: Fix stdlib dependency detection 2017-02-13 14:53:16 +03:00
Alexey Sedunov
7fbca4e122 Kotlin Facet: Scan classpath backwards when looking for kotlin-gradle-plugin dependency
#KT-15899 Fixed
2017-02-13 14:53:15 +03:00
Alexey Sedunov
330beebb2c Kotlin Facet: Check contradictory values of "coroutine support" option
#KT-16109 Fixed
2017-02-13 14:53:14 +03:00
Alexander Udalov
9397b16bb9 Minor, fix typo in comment 2017-02-13 14:10:19 +03:00
Alexander Udalov
407815449a Minor, improve error message 2017-02-13 14:09:58 +03:00
Alexander Udalov
57f2feb6fb Fix unreported deprecation on variables called as functions
#KT-16272 Fixed
2017-02-13 14:09:53 +03:00
Alexander Udalov
6793861fd4 Add target FIELD for SinceKotlin, annotate CallableReference.receiver/NO_RECEIVER 2017-02-13 14:09:43 +03:00
Alexander Udalov
20d856fa77 Minor, remove blank line in extra help 2017-02-13 14:09:38 +03:00
Alexander Udalov
8fee62a8c5 Minor, explain what CompilerMessageSeverity.STRONG_WARNING is 2017-02-13 12:11:16 +03:00
Alexander Udalov
4c9afb9d20 Move testable IS_PRE_RELEASE flag to KotlinCompilerVersion
It'll be used in the JS back-end as well soon, so
DeserializedDescriptorResolver is not the best place for it
2017-02-13 12:11:15 +03:00
Stanislav Erokhin
3efda0e45a Reserve yield if it isn't function call. 2017-02-13 02:53:37 +03:00
Ilya Chernikov
9eae929084 Fixes after review 2017-02-11 16:27:27 +01:00
Ilya Chernikov
39d204c550 Adjust test after introducing shutdown delay 2017-02-11 16:27:26 +01:00
Ilya Chernikov
cb7de0e262 Implement more reliable daemon election, fixes KT-15562
also making shutdown more reliable
2017-02-11 16:27:25 +01:00
Ilya Chernikov
ebf9e386b0 Add test reproducing "Service is dying" problem (KT-15562) 2017-02-11 16:27:24 +01:00
Alexey Andreev
7192529733 JS: drop support of old library format 2017-02-10 21:04:50 +03:00
Ilya Chernikov
82320bdf7d Make maven/aether dependencies optional in the script-util
(cherry picked from commit 8197240)
2017-02-10 16:03:06 +01:00
Ilya Chernikov
46894da981 Get rid of daemon-client dependency on openapi, making others "provided"
(cherry picked from commit 175d74c)
2017-02-10 16:02:55 +01:00
Ilya Chernikov
f6fd9441e9 Move scripting options into separate panel
(cherry picked from commit c06592e)
2017-02-10 14:44:36 +01:00
Dmitry Petrov
20dc1a047d KT-16250 Handle type alias as imported name qualifier
#KT-16250 Fixed
2017-02-10 16:32:07 +03:00
Denis Zharkov
5f843f6759 Fix intrinsic for String.plus for explicit calls
#KT-14567 Fixed
2017-02-10 16:05:15 +03:00
Denis Zharkov
fcb4db0226 Remove redundant ACC_VARARGS on methods generated with @JvmOverloads
#KT-15424 Fixed
2017-02-10 16:05:15 +03:00
Denis Zharkov
1f179a6f01 Add test on obsolete issue
#KT-15196 Obsolete
2017-02-10 16:05:15 +03:00
Denis Zharkov
b989bfce59 Fix VerifyError with @JvmStatic annotated getter
The problem was that for property getter 'context.getContextDescriptor()'
references the containing property, while 'context.getFunctionDescriptor()'
the accessor itself

 #KT-15594 Fixed
2017-02-10 16:05:15 +03:00
Denis Zharkov
dd275eda78 Minor. Refine class name: JvmStaticGenerator -> JvmStaticInCompanionObjectGenerator 2017-02-10 16:05:15 +03:00
Dmitry Jemerov
87187437ab Update UAST to version 1.0.11 2017-02-10 13:55:25 +01:00
Ilya Chernikov
da2f310895 Convert line endings when creating ReplCodeLine, fixes KT-15861
(cherry picked from commit 894ee4c)
2017-02-09 22:00:30 +01:00
Ilya Gorbunov
c6cb389591 JS kotlin.dom: deprecate asElementList harder.
Minor: correct exception message.
2017-02-09 22:15:51 +03:00
Ilya Gorbunov
9a7405adc6 Make javaClass extension property inline to remove further references from Kotlin. 2017-02-09 22:15:25 +03:00
Ilya Gorbunov
63f591bde9 Deprecate some utils and provide sensible replacements from stdlib. 2017-02-09 18:21:51 +03:00
Anton Bannykh
c7d4a4edf4 JS: test property inline through fake override 2017-02-09 15:46:06 +03:00
Stanislav Erokhin
58c2466a52 Minor. use when instead of if sequence. 2017-02-09 15:42:33 +03:00
Stanislav Erokhin
b616ef0a40 Do not force resolve descriptors for explicit imports. Create lazy scope instead. 2017-02-09 15:42:30 +03:00
Stanislav Erokhin
cc429cd865 Fix NewKotlinTypeChecker for case SimpleType with CapturedTypeConstructor.
Usually, we have only CapturedType with such constructor.
We should prevent creation such types in the future (KT-16147).
Also added test for KT-14740 where this problem originally appears.
2017-02-09 15:32:18 +03:00
Alexander Udalov
7147008e21 Fix functionFromStdlib.kt by making the member accessible
#KT-16263 Open
2017-02-09 14:56:27 +03:00
Dmitry Petrov
a4f9e46c08 Fix https://ea.jetbrains.com/browser/ea_reports/1337846:
Properly handle AbbreviatedTypeBinding for error types.
Get rid of code duplication.
2017-02-09 12:36:52 +03:00
Mikhael Bogdanov
b1e2db21d3 Fix for KT-16225: enumValues non-reified stub implementation references nonexistent method
#KT-16225 Fixed
2017-02-09 10:23:32 +01:00
Alexey Sedunov
ba73269ee0 Kotlin Facet: Do not show implicit compiler arguments in "Additional arguments" field 2017-02-09 11:41:05 +03:00
Alexey Sedunov
52102d359a Kotlin Gradle Plugin: Expose default compiler arguments via compilation task API 2017-02-09 11:41:04 +03:00
Ilya Gorbunov
ec01200997 Introduce ItemArrayLike interface and replace multiple asList adapters with the single one. 2017-02-08 23:31:58 +03:00
Ilya Gorbunov
41c980bcab Massive deprecations in kotlin.dom 2017-02-08 23:31:58 +03:00
Ilya Gorbunov
365f8d0256 Drop pre-1.0 deprecated dom helpers. 2017-02-08 23:31:58 +03:00
Simon Ogorodnik
a9f2f5c7d0 Fix for complete slowdown of DefaultImportProvider after introducing languageVersion for default imports
KT-16243 Very slow completion after variable of type `ArrayList`
 #KT-16243 fixed
2017-02-08 21:30:32 +03:00
Ilya Gorbunov
e9f40c41c2 Minor: refactor and rename parameters. 2017-02-08 20:16:10 +03:00
Ilya Gorbunov
31da36bedf Minor: Add test cases for adding and removing null value to/from set.
Fix unused value in removeAll test.
2017-02-08 20:13:22 +03:00
Ilya Gorbunov
c37540c727 Minor: fix missing angle bracket. 2017-02-08 20:13:22 +03:00
Ilya Gorbunov
287a513f23 Provide KDoc for js collection implementations. 2017-02-08 20:13:22 +03:00
Ilya Gorbunov
2269b9839f Restrict visibility of AbstractMap.SimpleEntry in JS 2017-02-08 20:13:22 +03:00
Ilya Gorbunov
fc7b1c8611 KDoc for mutable abstract collections.
Document abstract overrides.
2017-02-08 20:13:22 +03:00
Ilya Gorbunov
ef5e53b37b KDoc for read-only abstract collections 2017-02-08 20:13:22 +03:00
Ilya Gorbunov
7c54c48e00 Add a note about generic parameter variance to Iterable, Collection, List, Set, Map and their mutable counterparts.
Minor: correct docs, code formatting.
2017-02-08 20:13:22 +03:00
Alexander Udalov
ccbfa2e81d Fix Member.getKPackage and temporarily revert functionFromStdlib.kt 2017-02-08 20:02:49 +03:00
Alexander Udalov
6d16ea0a3a Fix reflection on top level declarations from other modules
The main problem here is that moduleName that is being passed to KPackageImpl
is useless: as can be seen in
ClosureCodegen.generateCallableReferenceDeclarationContainer, the name of the
current module is always written to the class file for a callable reference,
not the name of the module of the referenced declaration. This resulted in
reflection not loading the correct .kotlin_module file and subsequently not
finding the required file facade for a top-level function.

The commit does not fix the issue with the incorrect module name written in the
back-end, but workarounds it. It turns out, reflection can figure out the name
of the module of the referenced declaration itself by parsing the header from
the given java.lang.Class object for a single-file/multi-file package facade
and extract the package_module_name protobuf extension. Similar code was
already there in Member.getKPackage() in ReflectJvmMapping.kt but it did not
support multi-file classes, of which there are a lot in the standard library;
this is now supported

 #KT-12630 Fixed
 #KT-14731 Fixed
2017-02-08 19:23:18 +03:00
Alexander Udalov
8a79482c5c Minor, rename packageFacadeProvider -> packagePartProvider 2017-02-08 19:23:18 +03:00
Yan Zhulanow
131570080d Kapt3: Generate import statements in stubs 2017-02-08 19:01:17 +03:00
Yan Zhulanow
69a063b0b2 Kapt3: Serialize annotation processor options to base64 to support spaces in option values 2017-02-08 19:01:16 +03:00
Yan Zhulanow
8479618632 Kapt3: Invoke integration tests with the Kotlin runtime in the compile classpath (this fixes integration tests, nullability annotations from org.jetbrains were not found) 2017-02-08 19:01:15 +03:00
Yan Zhulanow
823781ea6c Kapt3: "$annotations" are not always ACC_PRIVATE now (see also KT-15993) 2017-02-08 19:01:14 +03:00
Yan Zhulanow
2553513205 Kapt3: Allow users to disable error type correction (and now it's disabled by default) 2017-02-08 19:01:13 +03:00
Yan Zhulanow
297f8d4161 Kapt3: Use the javac's finalCompiler log to determine if there were any annotation processing errors (KT-16176) 2017-02-08 19:01:13 +03:00
Yan Zhulanow
62092f31cc Minor: Update test data because of KT-15697 2017-02-08 19:01:12 +03:00
Yan Zhulanow
de3cb4567f Minor: Remove obsolete JAVA_FILE_PARSING_ERROR constant, fix corresponding test 2017-02-08 19:01:11 +03:00
Yan Zhulanow
08b98f7133 Kapt3: Ignore declarations with illegal Java identifiers (KT-16153) 2017-02-08 19:01:10 +03:00
Yan Zhulanow
7296d9cb7c Kapt3: Fix working in verbose mode (NPE in JavacFiler.java:597) (KT-16146) 2017-02-08 19:01:09 +03:00
Yan Zhulanow
43a377d3e1 Kapt: Fix error messages map name 2017-02-08 19:01:08 +03:00
Yan Zhulanow
1819194a4c Kapt3: Allow annotations with Kotlin-only targets, such as PROPERTY (KT-15697) 2017-02-08 19:01:07 +03:00
Yan Zhulanow
6ded5939eb Kapt: Fix javac error reporting in Kotlin daemon, also fix parsing error reporting (KT-15524) 2017-02-08 19:01:06 +03:00
Yan Zhulanow
cde7cb1076 Kapt3: Write Intellij annotations (NotNull/Nullable) to stubs 2017-02-08 19:01:05 +03:00
Yan Zhulanow
5a46c01f76 Kapt3: Add generated source files to Java compile task after kapt execution. Filter only .java files.
This is needed to generate Kotlin files using kapt.
2017-02-08 19:01:04 +03:00
Yan Zhulanow
1797ea62f4 NoArg: Support @Embeddable JPA annotation (KT-15946) 2017-02-08 19:01:03 +03:00
Yan Zhulanow
349095cd14 Maven: Make compiler plugin option reporting more user-friendly 2017-02-08 19:01:03 +03:00
Yan Zhulanow
277490b903 AllOpen, NoArg: Use presets in Maven plugins 2017-02-08 17:36:19 +03:00
Yan Zhulanow
52ecd05301 AllOpen, NoArg: Use presets in Gradle plugins 2017-02-08 17:36:19 +03:00
Yan Zhulanow
feb5397f6f AllOpen, NoArg: Refactoring, support presets in order to hold special annotations for Spring and JPA in one place 2017-02-08 17:36:19 +03:00
Denis Zharkov
f4690ebff9 Initialize JvmBuiltins for module configuration used in test
This method is only used within tests, and they didn't fail
mostly by coincidence.

But because of more eager reading of
JvmBuiltIns.isAdditionalBuiltInsFeatureSupported (that checks if built-ins
have been initialized) these tests started failing
2017-02-08 16:04:19 +03:00
Denis Zharkov
1bb40afada Simplify compatibility mode with ll=1.0 on JDK dependent built-ins
A lot of problem arise with current solution
(loading them with lowpriority annotation + additional call checkers):
- We errorneously treated ArrayList.stream as an existing method, while
  it's just a fake override from List
- The same problem arises when creating a class delegating to List.
  Also the latter case is failing with codegen internal error
  (see issue KT-16171)

The negative side of this solution is that instead of reporting meaningful
diagnostic, there will be UNRESOLVED_REFERENCE.
But it seems to be better than having strange problems like ones described above.

 #KT-16073 Fixed
 #KT-16171 Fixed
2017-02-08 16:04:19 +03:00
Mikhail Zarechenskiy
d84c303029 Do not report 'const' inapplicability on property of error type
#KT-12477 Fixed
2017-02-08 15:42:48 +03:00
Mikhail Zarechenskiy
e7ea076093 Do not apply constant folding for non built-in functions
#KT-15872 Fixed
2017-02-08 15:42:39 +03:00
Mikhail Zarechenskiy
935f7b1cc1 Add warning if constant conforms to infinity or zero
#KT-3805 Fixed
2017-02-08 15:42:33 +03:00
Sergey Igushkin
292f010e59 Fixed Kotlin2JsCompile not picking dependencies from configurations other than compile.
Example:

	apply plugin: 'kotlin2js'

    dependencies {
    	...
    	testCompile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
    }

Here, the `:compileTestKotlin2Js` task did not pick the dependency and used the `compile` classpath.
This has been fixed.

Also, fixed `testCompileTestCouldAccessProduction` and added `testJsCustomSourceSet`.
2017-02-08 14:36:18 +03:00
Mikhail Glukhikh
607e205ad4 Resolve to descriptor: call safe version in background (~ isApplicable) #KT-12261 Fixed
Also #KT-11010 Fixed
Also #KT-12881 Fixed
Also #KT-16162 Fixed
2017-02-08 13:55:34 +03:00
Dmitry Jemerov
00003684e8 Add test for converting a string literal to UAST 2017-02-08 11:29:53 +01:00
Dmitry Jemerov
5dc178460e Update UAST to 1.0.10; move uast-kotlin tests to Kotlin project 2017-02-08 11:29:53 +01:00
Alexander Udalov
cfe159181d Deprecate kotlin.reflect.findAnnotation with ERROR 2017-02-08 13:05:27 +03:00
Alexander Udalov
5987e8a47c Annotate findAnnotation and IllegalPropertyDelegateAccessException with SinceKotlin(1.1) 2017-02-08 13:05:27 +03:00
Alexander Udalov
845d6526b0 Annotate new API in runtime.jvm with SinceKotlin(1.1) 2017-02-08 13:05:27 +03:00
Dmitry N. Petrov
5e10a9d506 Merge pull request #1027 from JetBrains/rr/matveev
Override acceptChildren method in IrSetterCallImpl
2017-02-08 12:38:29 +03:00
Alexey Sedunov
615c316262 Kotlin Gradle Plugin: Postpone friend dependency collection until the actual compilation as it may cause an error during Gradle-IDEA project synchronization
#KT-16174 Fixed
2017-02-08 11:57:00 +03:00
Alexey Sedunov
4325632b3e Kotlin Facet: Always parse argument string to proper compiler arguments bean
#KT-16137 Fixed
 #KT-16157 Fixed
 #KT-16206 Fixed
2017-02-08 11:56:59 +03:00
Alexey Andreev
9d6f4d7770 JS: don't treat library without JS metadata as error, report warning and continue instead. See KT-16158 2017-02-08 11:29:30 +03:00
Alexey Andreev
ffca68d85e JS: escape quotes in some diagnostics with parametrized messages 2017-02-08 11:29:29 +03:00
Mikhael Bogdanov
37a94eaf07 Use appropriate ApiVersion if LanguageVersion is specified in test 2017-02-08 09:10:22 +01:00
Mikhael Bogdanov
5095ef1ea4 Revert 'Temporary disable new intrinsics usage in ieee754 arithmetic' 2017-02-08 09:10:22 +01:00
Denis Zharkov
80638ebc99 Prohibit unsupported suspend operators
contains/get/set operators don't work properly on both backends

Also add box test checking that 'compareTo' operator works just fine

 #KT-16219 Fixed
2017-02-08 11:07:27 +03:00
Denis Zharkov
4921bd822d Mark as UNSUPPORTED suspension points in default parameters
#KT-16124 Fixed
 #KT-16218 Open
2017-02-08 11:07:26 +03:00
Denis Zharkov
4ee818addf Add callee name to diagnostic about illegal suspension call
#KT-15938 Fixed
2017-02-08 11:07:26 +03:00
Anton Bannykh
a74fffeac8 JS: companion object dispatch receiver translation fixed (KT-16160); imported function inlining fixed. 2017-02-08 09:21:18 +03:00
Anton Bannykh
a2431f0d85 JS: fixed inlining functions called through inheritor ("fake" override) from another module (#KT-16144) 2017-02-08 09:19:50 +03:00
Dmitry Jemerov
0709561869 Add missing required type checks; correctly skip elements which have no UAST equivalents when converting an element together with parent; correctly convert string template entries (they aren't expressions) 2017-02-07 19:18:05 +01:00
Simon Ogorodnik
be7158eeb2 KT-16110 Missing suspend keyword completion inside generic arguments
#KT-16110 fixed
2017-02-07 19:48:05 +03:00
Roman Elizarov
5895c211a1 Fixed corotine context performance by using reference equality for contexts and keys
Added documentation explaining that keys are compared by reference
2017-02-07 19:33:46 +03:00
Ilya Matveev
0759ff7bc2 Override acceptChildren method in IrSetterCallImpl 2017-02-07 18:20:33 +03:00
Nikolay Krasko
2f0e7b54d5 Return old hack with returning null as file scope for standard scripts
(cherry picked from commit ef55bd1)
2017-02-07 15:16:04 +01:00
Ilya Gorbunov
b8de78dd43 Deprecate javaClass with replacement this::class.java.
Suppress deprecation in diagnostics tests.
2017-02-07 16:30:22 +03:00
Sergey Igushkin
d6a60424a9 Weakened testSuppressWarnings() so that it doesn't fail on the environment STRONG_WARNING. 2017-02-07 16:19:40 +03:00
Ilya Chernikov
99b902f5f2 Fix version calculation code
(cherry picked from commit fb74040)
2017-02-07 13:45:22 +01:00
Ilya Chernikov
f6ce74edb3 Set jvmTarget property for repl compilation from sys prop or java version, fixes KT-16126
(cherry picked from commit 4cf2bce)
2017-02-07 13:45:12 +01:00
Alexey Sedunov
396e9afffd Compiler Configuration: Minor UI improvements 2017-02-07 15:36:39 +03:00
Alexey Sedunov
0c331a3846 Kotlin Facet: Support multiple configuration editor
#KT-15914 Fixed
2017-02-07 15:36:38 +03:00
Alexey Sedunov
8849d0e2a3 Kotlin Facet: Combine "General" and "Compiler" tabs 2017-02-07 15:36:37 +03:00
Ilya Gorbunov
03cdc20d64 Update public API dump: new coroutine builder intrinsics 2017-02-07 14:42:00 +03:00
Denis Zharkov
52f1194247 Update public API dump: areEqual helpers for ieee 754 comparisons 2017-02-07 14:41:58 +03:00
Ilya Gorbunov
d4d647ab00 Remove public synthetic annotation holder methods from public API dump. 2017-02-07 14:41:56 +03:00
Ilya Gorbunov
970490e097 Revert "Update rendered public API". This reverts commit a10c6f00f9.
Revert "Update stdlib reference and binary compatibility test data". This reverts commit 2d02e5106f.
2017-02-07 14:41:31 +03:00
Mikhail Zarechenskiy
d7093db5c5 Allow to use emptyArray in annotation as argument
#KT-14236 Fixed
2017-02-07 14:07:20 +03:00
Mikhail Zarechenskiy
9f0403f72c Fix exception at accidentally wrong annotation argument type
#KT-13740 Fixed
2017-02-07 14:07:13 +03:00
Mikhail Zarechenskiy
655cf82534 Copy compileTimeInitializer for const property descriptor
#KT-15802 Fixed
2017-02-07 14:07:06 +03:00
Denis Zharkov
81c3edfc00 Refine cc7f0e2d83
getDispatchReceiver/getExtensionReceiver always return not-null value,
but in the absence of receiver this value is equal StackValue.none(), i.e.
has a size 1

The tests were passing because of the problems with the test framework:
4b9e20ab8c
2017-02-07 13:12:02 +03:00
Denis Zharkov
4b9e20ab8c Rethrow boxError in case of test failure 2017-02-07 12:48:06 +03:00
Denis Zharkov
cc7f0e2d83 Fix codegen problem with safe-call on suspension point with two receivers
#KT-16145 Fixed
2017-02-07 11:56:37 +03:00
Denis Zharkov
a10c6f00f9 Update rendered public API 2017-02-07 11:32:10 +03:00
Denis Zharkov
9697196473 Put startCoroutineUninterceptedOrReturn header to common stdlib 2017-02-07 11:08:27 +03:00
Denis Zharkov
4f6a77cf38 Introduce createCoroutineUnchecked intrinsic
Also use it for buildSequence implenentation

 #KT-16155 Fixed
2017-02-07 11:08:27 +03:00
Roman Elizarov
9a71a20ad6 Docs for startCoroutineUninterceptedOrReturn 2017-02-07 11:07:04 +03:00
Denis Zharkov
230564fb4a Minor. Get rid of code duplications for resume call wrapping in stdlib
Use processBareContinuationResume instead
2017-02-07 11:07:04 +03:00
Denis Zharkov
6dde567be4 Optimize startCoroutine impls, move them to common stdlib
Do not wrap initial continuation for startCoroutine in SafeContinuation

This changes leaves only internal declarations and intrinsics as platform
dependent parts of the coroutine library, the rest parts (public API)
is implemented through them in common module
2017-02-07 11:07:04 +03:00
Denis Zharkov
a65d86293b Improve coroutines library layout
- Split CoroutinesLibrary into common and JVM parts
- Get rid of startCoroutine duplications
- Make suspendCoroutine implementation to be platform independent
2017-02-07 11:07:04 +03:00
Denis Zharkov
258ee0db75 Introduce startCoroutineUninterceptedOrReturn coroutine intrinsic
#KT-15716 Fixed
2017-02-07 11:07:04 +03:00
Denis Zharkov
29b0b30031 Make createCoroutine return a safe continuation
#KT-15718 Fixed
2017-02-07 11:06:50 +03:00
Alexander Udalov
b780e6d374 Do not import "kotlin.comparisons" by default for language version 1.0
#KT-16199 Fixed
2017-02-07 10:15:57 +03:00
Alexander Udalov
8014000bd1 Update light analysis test data 2017-02-06 19:41:32 +03:00
Alexander Udalov
85e55810a7 Merge light-analysis tests into black box codegen tests
#KT-15382 Fixed
2017-02-06 19:41:29 +03:00
Alexander Udalov
5bd1a35eb1 Refactor bytecode listing & light analysis tests
Simplify AbstractLightAnalysisModeCodegenTest so that its logic can be merged
with black box codegen tests
2017-02-06 19:41:20 +03:00
Alexander Udalov
2d02e5106f Update stdlib reference and binary compatibility test data
After 0db60bf and 5cffb38
2017-02-06 19:39:15 +03:00
Alexander Udalov
e58baa51ae Rename DoubleColonLHS.Expression.isObject -> isObjectQualifier 2017-02-06 19:39:15 +03:00
Alexander Udalov
478352b7e7 Fix callable reference to constructor of nested class in object
#KT-15951 Fixed
2017-02-06 19:39:15 +03:00
Alexander Udalov
ca1ed850b8 Improve error on runtime of version different than API version
Include the actual runtime version in the error message
2017-02-06 19:39:15 +03:00
Alexander Udalov
57f8ef372f Report different runtime versions earlier than incompatibility with API version
Previously if you had kotlin-reflect 1.0 and kotlin-runtime 1.1 in the
classpath, checkCompatibleWithApiVersion was invoked first, and an error was
reported that suggested to pass "-api-version" to the compiler. However, no
correct "-api-version" can be passed in this case, because
checkMatchingVersions would then report that the two libraries have different
versions anyway. So, now we first ensure that all libraries have the same
version, and only then do check if the version is correct
2017-02-06 19:39:15 +03:00
Alexander Udalov
3a7eec8635 Check API version instead of language in JVM runtime versions checker
It should be a valid case to invoke the 1.1 compiler with the 1.0 runtime in
the classpath and "-api-version 1.0". However, previously it was an error and
the message suggested to specify "-language-version 1.0". Language version 1.0
implies API version 1.0, so this effectively made the "-api-version" option
useless
2017-02-06 19:39:15 +03:00
Dmitry Petrov
e0cea468fa KT-15862 Inline generic functions can unexpectedly box primitives
Previous version of the boxing/unboxing analysis treated merging boxed and non-boxed values as a hazard.
If such merged values are not used (e.g., early return + local variables reused in inlined calls),
corresponding boxing/unboxing operations still can be optimized out.

All information related to boxed value usage by instructions is moved to 'BoxedValueDescriptor'.
Introduce "tainted" (and "clean") boxed values, with the following rules:

  merge(B, B) = B, if unboxed types are compatible,
                T, otherwise

  merge(B, X) = T

  merge(T, X) = T

  where
    X is a non-boxed value,
    B is a "clean" boxed value,
    T is a "tainted" boxed value.

Postpone decision about value merge hazards until a "tainted" value is used.
2017-02-06 16:22:26 +03:00
Simon Ogorodnik
98269c10d8 KT-15744 Intention to import sleep wrongly suggests Thread.sleep
#KT-15744 fixed
2017-02-06 14:56:18 +03:00
Alexander Udalov
389ddf26b3 Do not use LanguageVersionSettings.languageVersion directly 2017-02-03 19:35:17 +03:00
Alexander Udalov
b784680fe2 Fix NPE on equals/hashCode for callable references without kotlin-reflect
#KT-11316 Fixed
 #KT-15847 Fixed
2017-02-03 19:35:16 +03:00
Alexander Udalov
0db60bf6cb Do not always generate synthetic "$annotations" as private
Since annotations are a part of the declaration, they must have the same
visibility as the declaration in the bytecode. Otherwise obfuscators like
Proguard might strip the "$annotations" method and no annotations would be
found via Kotlin reflection

 #KT-15993 Fixed
2017-02-03 19:35:15 +03:00
Mikhail Glukhikh
81e083a133 Join declaration and assignment: extra descriptor check for assignment of the same property 2017-02-03 19:26:51 +03:00
Mikhail Glukhikh
153bc79c08 Join declaration & assignment: do not suggest for non-first line of init / constructor #KT-15545 Fixed 2017-02-03 19:26:49 +03:00
Mikhail Glukhikh
ea6e3c828d Join declaration & assignment: treat assignment with this. correctly #KT-16000 Fixed 2017-02-03 19:26:48 +03:00
Ilya Gorbunov
84f324e04f Add deprecated parseInt overload without radix parameter to provide better replacement. 2017-02-03 18:39:24 +03:00
Mikhail Glukhikh
6db698f5aa Correct order added for 'suspend' modifier #KT-16104 Fixed 2017-02-03 18:24:47 +03:00
Vyacheslav Gerasimov
1452129b60 Fixed InvalidMirrorException in uast while getting annotation argument location 2017-02-03 18:06:05 +03:00
Vyacheslav Gerasimov
bad15249e7 Fixed exception in android lint 2017-02-03 18:06:05 +03:00
Vyacheslav Gerasimov
1ea2e8c1d1 Fixed KotlinLintTestGenerated.testJavaPerformance 2017-02-03 18:06:05 +03:00
Vyacheslav Gerasimov
6699b03c0b Fixed error reporting in AnnotationDetector
#KT-14920 Fixed

(cherry picked from commit 3647d53)
2017-02-03 18:06:05 +03:00
Vyacheslav Gerasimov
10517c16ee Uast 1.0.9 2017-02-03 18:06:04 +03:00
Denis Zharkov
5888c75d41 Minor. Refine implicit receiver for destructuring scope
Actually it should not be very important, but for sake of consistency
we should use null receiver even if we have one in an outer scope

This is a post-review fix
2017-02-03 17:58:52 +03:00
Ilya Gorbunov
da81fb32a6 Add LowPriority annotation to deprecated functions to allow star-importing their replacements from kotlin.reflect.full. 2017-02-03 17:53:16 +03:00
Ilya Gorbunov
af443ac046 Search java version in java.specification.version, prepare to that starting from java 9 it will contain only a single component. 2017-02-03 17:52:13 +03:00
Alexey Tsvetkov
62e42d6f45 Fix kapt1 with stubs test to main internal references 2017-02-03 17:16:08 +03:00
Alexey Tsvetkov
de24e68adc Revert "Avoid having -d and -module set at the same time"
This reverts commit ac241e2676.
2017-02-03 17:16:08 +03:00
Denis Zharkov
2d88419c38 Fix annotation deserialization on suspend functions
Use proper initial/frontend version of suspend descriptor
when writing METHOD_FOR_FUNCTION, because serializer uses this version

Also this commit contains adjustments of neighboring code to the describe
change

 #KT-16093 Fixed
2017-02-03 16:44:22 +03:00
Sergey Igushkin
2516583ecf Fixed empty -libraries passed from Gradle plugin in CLI. 2017-02-03 13:20:53 +03:00
Anton Bannykh
f0e3c87b84 JPS: fixed duplicate meta.js in case of multiple source roots in the same module. 2017-02-03 13:03:12 +03:00
Anton Bannykh
289a7a9cc3 JS: fixed support for test source roots (KT-6627) 2017-02-03 13:03:12 +03:00
Alexey Andreev
97b6c3013a JS: fix destructuring declaration and increment in coroutines. See KT-16058 2017-02-03 11:09:10 +03:00
Alexey Andreev
b929db1b07 JS: don't generate object literal for local delegated properties, generate call to getValue/setValue on each use site instead. 2017-02-03 11:09:10 +03:00
Alexey Andreev
0f049a90aa JS: prohibit nested classes, objects and enums in external interface. See KT-16012 2017-02-03 11:09:09 +03:00
Denis Zharkov
cc28fecacd Fix VerifyError in coroutines caused by null spilling
While within a method by the JVM spec null-value has a special
Nothing-like type, when we spill it for a coroutine, we must choose
some real type to CHECKCAST to after restoring the variable's value.

But the problem is that such a real type depends on usage of that null value,
and there may be more than one usage.

The solution is not to spill such variables into fields, but instead
init them with ACONST_NULL after each suspension point

 #KT-16122 Fixed
2017-02-03 10:32:28 +03:00
Denis Zharkov
60c2579436 Allow destructuring in suspend lambda with suspend componentX
#KT-16113 Fixed
2017-02-03 10:32:28 +03:00
Alexey Sedunov
59fe7444d1 Rename/Find Usages: Disable text occurrence search for KtParameter 2017-02-02 19:09:20 +03:00
Alexey Sedunov
79e67f4e50 Kotlin Facet: Support multiple artifact Ids corresponding to target platform 2017-02-02 19:09:19 +03:00
Mikhael Bogdanov
aa3f64bc93 Temporary disable new intrinsics usage in ieee754 arithmetic 2017-02-02 16:31:49 +01:00
Mikhael Bogdanov
560226cc84 Use proper type for nullability check in 'calcTypeForIEEE754ArithmeticIfNeeded' 2017-02-02 16:31:49 +01:00
Mikhael Bogdanov
5cffb3892d Added intrinsics for nullable Double/Float equals check 2017-02-02 16:31:49 +01:00
Mikhael Bogdanov
87529f957d Update for "Fix for KT-15868: NPE when comparing nullable doubles" 2017-02-02 16:31:49 +01:00
Denis Zharkov
529b526763 Support parameter destructuring in suspend lambdas
#KT-16092 Fixed
2017-02-02 18:09:19 +03:00
Denis Zharkov
0878049f15 Support tailrec suspend functions in JVM backend
The main problem is that inside a state machine for a named suspend
function parameters of it's owner are available as a usual captured
closure parameters (i.e. through synthetic fields), while
TailRecursion codegen expects that parameters are straight local
variables.

So, the solution is just to define local var for each of real parameters
(all but the last continuation parameters) for tailrec functions.

 #KT-15759 Fixed
2017-02-02 18:09:19 +03:00
Denis Zharkov
d7403ca185 Minor. Simplify ClosureCodegen.calculateConstructorParameters 2017-02-02 18:09:19 +03:00
Denis Zharkov
a167539d2e Minor. Move recordField call into Closure.captureVariable 2017-02-02 18:09:19 +03:00
Mikhail Glukhikh
212f6e0432 Stub creation from cls fixed for suspend function types
(cherry picked from commit f49ef8e)
2017-02-02 17:54:06 +03:00
Stanislav Erokhin
a4272caa8c Fix serialization for suspend function types.
Since now `suspend (Int) -> String` will be serialized as `(Int, Continuation<String>) -> Any?` + suspend flag.

Before this change such type serialized like this: Function2<Int, String> + suspend flag. And yes, type `Function2<Int, String>` isn't correct, because Function2 expect 3 type arguments.
We have special logic for this case and we deserialize such error-written types correctly.

(cherry picked from commit 3518cbe)
2017-02-02 16:48:59 +03:00
Stanislav Erokhin
382122470f Use LanguageVersionSettings from project instead of LanguageVersionSettingsImpl.DEFAULT for sdk and library resolver.
General effect will be the following:
- all member scopes for libraries and JDK will be constructed with -language-version/-api-version specified in project settings
- for modules with another (not like in project settings) -api-version or -language-version we will have not correct member scope -- for example we will see typealiases from such libraries.

#KT-15979 Fixed

(cherry picked from commit 0001865)
2017-02-02 16:47:53 +03:00
Dmitry Jemerov
ac4be88627 Prevent duplicate addition of "org.jetbrains.kotlin" prefix when copying sources to Maven projects 2017-02-02 14:06:55 +01:00
Mikhail Glukhikh
4c2ae5e3dd Generate test support: error hints moved out of write action 2017-02-02 15:33:18 +03:00
Mikhail Glukhikh
d8f0167d1f Let implement interface: create write action manually to avoid AWT events inside 2017-02-02 15:29:31 +03:00
Mikhail Glukhikh
b839e522e9 Generate equals or hash code: do not run in write action to avoid AWT events inside 2017-02-02 15:29:30 +03:00
Mikhail Glukhikh
a204e57877 Move file to package matching directory: run write action manually to avoid AWT events inside 2017-02-02 15:29:29 +03:00
Mikhail Glukhikh
72b8b85563 Create kotlin sub class: run write action manually to avoid AWT events inside 2017-02-02 15:29:27 +03:00
Mikhail Glukhikh
9664a066a4 Generate test support: ask everything before write action to avoid AWT events inside 2017-02-02 15:29:26 +03:00
Mikhail Glukhikh
70c5d8b9ad Create test intention: do not start in write action to avoid AWT events inside 2017-02-02 15:29:25 +03:00
Mikhail Glukhikh
07f06352d7 if-then --> safe access: run write action manually to avoid AWT events inside 2017-02-02 15:29:23 +03:00
Mikhail Glukhikh
834c3f5d62 if-then --> elvis: run write action manually to avoid AWT events inside 2017-02-02 15:29:22 +03:00
Dmitry Jemerov
9594147c55 Find Usages checks that the signature of the method a property usage resolves to matches the signature of the method being searched
#KT-15291 Fixed
2017-02-02 12:44:54 +01:00
Alexey Sedunov
dbfe3370aa Kotlin Facet: Ignore invalid platform-specific compiler arguments 2017-02-02 13:40:11 +03:00
Mikhael Bogdanov
1e2b50332d Test data update 2017-02-02 09:39:03 +01:00
Mikhail Glukhikh
5f6d65cd44 Change log: last-shot issues for 1.1-Beta2 2017-02-01 21:06:51 +03:00
Mikhail Glukhikh
a15454429d Change log: 1.1-RC --> 1.1-Beta2
(cherry picked from commit 7ee259d)
2017-02-01 21:01:21 +03:00
Dmitry Jemerov
bc9c40883c Avoid repeated reading of file contents from disk while building stubs 2017-02-01 18:14:57 +01:00
Dmitry Jemerov
66f7382e3a Advance binary stub version due to coroutine metadata format changes 2017-02-01 18:10:50 +01:00
Mikhael Bogdanov
a2c5c94ee6 Fix for KT-15868: NPE when comparing nullable doubles
#KT-15868 Fixed
2017-02-01 17:43:56 +01:00
Alexey Tsvetkov
79bea6710f Increment data container cache version
Reason: coroutines metadata format has been changed (since 1.1-beta-1)
2017-02-01 18:50:06 +03:00
Alexey Tsvetkov
1818289772 Avoid checking incremental caches versions if corresponding property is set 2017-02-01 18:50:06 +03:00
Alexey Tsvetkov
2eeb7e36b9 Refactoring: extract checking caches versions to function 2017-02-01 18:50:06 +03:00
Anton Bannykh
385a02ea55 Added forgotten kt8666.txt for LightAnalysisModeCodegenTestGenerated 2017-02-01 18:20:30 +03:00
Dmitry Petrov
7600f89f0b KT-15574 Can't instantiate Array through Type Alias
Array instatiation code should handle type alias constructors properly.

So far, we don't have constructors with type parameters
different from the type parameters of the resulting type,
so we can safely take type arguments of the underlying type.
2017-02-01 17:14:50 +03:00
Anton Bannykh
f5a431490c JS: verified that String concatenation with large Long's is fixed (KT-8666) 2017-02-01 15:36:02 +03:00
Sergey Mashkov
20f9e67244 KT-16043 IDL: mark inline helper function as InlineOnly (generate) 2017-02-01 14:44:48 +03:00
Sergey Mashkov
4c2edd54a6 KT-16043 IDL: mark inline helper function as InlineOnly 2017-02-01 14:44:48 +03:00
Mikhail Glukhikh
5fbb3211de Minor change log fix
(cherry picked from commit ef519dc)
2017-02-01 14:42:09 +03:00
Natalia Ukhorskaya
68f722b337 Debugger: fix evaluate expression when breakpoint is set on function without body inside object
#KT-15855 Fixed
2017-02-01 14:31:35 +03:00
Dmitry Jemerov
faac1c3156 When calculating import candidates, skip redundant deduplication performed by PsiShortNamesCacheImpl
#KT-16071 Fixed
2017-02-01 12:23:16 +01:00
Dmitry Jemerov
1d37c8cfea Calculate autoimport candidates in daemon thread when import fix is created, not in EDT 2017-02-01 12:23:16 +01:00
Denis Zharkov
e9262b875b Implement makeNullableAsSpecified for TypeTemplate properly
This change fixes an SOE in isCastErased:
    @JvmStatic
    fun isCastErased(supertype: KotlinType, subtype: KotlinType, typeChecker: KotlinTypeChecker): Boolean {
        if (supertype.isMarkedNullable || subtype.isMarkedNullable) {
            return isCastErased(TypeUtils.makeNotNullable(supertype), TypeUtils.makeNotNullable(subtype), typeChecker)
        }

TypeUtils.makeNotNullable(TypeTemplate) should not return the same object
if isMarkedNullable returned true on the instance


 #KT-15516 Fixed
2017-02-01 11:51:15 +03:00
Mikhail Glukhikh
dc57f97196 1.1-RC change log polishing 2017-01-31 19:01:03 +03:00
Ilya Gorbunov
3be8558a1a Edit 1.1-RC changelog regarding Standard Library and JS 2017-01-31 18:45:53 +03:00
Mikhail Glukhikh
8d48452c1a 1.1-RC: change log (final?) update 2017-01-31 17:31:03 +03:00
Alexey Tsvetkov
c57dac159b Avoid having -d and -module set at the same time
#KT-14619 fixed
2017-01-31 16:53:34 +03:00
Alexey Tsvetkov
9b5129a0f3 Fix annotation processors outputting to classes dir with kapt 3
#KT-15915 fixed

 Annotation processor can access a classes directory provided by AP environment.
Previously kapt 3 was using kotlin-classes directory as a a classes directory.
However compileKotlin task does not expect this.
Also having multiple tasks with the same output dir is a bad practise in Gradle.

This change introduces a separate directory for classes generated by kapt 3.
Its output is copied to a resulting classes dir (just as a kotlin-classes dir).
2017-01-31 16:53:34 +03:00
Alexey Tsvetkov
34f04f3482 Fix downgrading from 1.1 to 1.0.x in Gradle
If @Input property is added in new plugin version
and this property has a new type (a class/enum which is not presented in previous plugin)
then downgrading leads to an exception,
because Gradle tries to deserialize the property value from its caches,
but the type of value does not exist.

Workaround: add new String property.
2017-01-31 16:53:34 +03:00
Alexey Tsvetkov
49d0f69227 Fix exception when Groovy lazy string (GString) is in freeCompilerArgs
#KT-15500 fixed

GString is an object that represents string literal like `"${project.name}"`
in Groovy. It is not an instance of string.
Groovy automatically converts GString to String when it is passed where String is expected.
However freeCompilerArgs is a List<String>, so type parameter info is lost at runtime.
When iterating freeCompilerArgs in Kotlin as a list of string, an exception
is thrown because GString cannot be casted to String (toString should be called instead).
2017-01-31 16:53:34 +03:00
Dmitry Jemerov
fa6bfe932e More efficient implementation of containsFilesWithExactPackage() (don't materialize KtFile instances we don't actually need) 2017-01-31 14:44:28 +01:00
Dmitry Jemerov
62e1d49def Make sure that we don't have multiple coroutine status flags in the facet settings if one flag was set before parsing the command line options and another is specified through the command line options.
#KT-16075 Fixed
2017-01-31 14:32:09 +01:00
Alexander Udalov
464820458e JS: rename "-library-files" argument to "-libraries" and change separator
Use the system separator (':' or ';') instead of commas

 #KT-16083 Fixed
2017-01-31 16:26:35 +03:00
Dmitry Jemerov
fd24031a69 Don't read file content to see if file is Kotlin-compiled if we have cached attribute but don't have complete data 2017-01-31 13:50:35 +01:00
Dmitry Jemerov
ffa3cf0027 Don't show "Convert lambda to reference" for lambdas passed to suspend functions
#KT-16072 Fixed
2017-01-31 13:42:38 +01:00
Mikhail Glukhikh
7021b0bf15 Change log update for 1.1.0 2017-01-31 15:21:13 +03:00
Simon Ogorodnik
c2ba4e3ab9 KT-14252 Completion could suggest constructors available via typealiases
#KT-14252 fixed
2017-01-31 15:14:18 +03:00
Denis Zharkov
39fc1789e0 Prohibit inline lambda parameters of suspend function type
#KT-16068 Fixed
2017-01-31 14:55:48 +03:00
Stanislav Erokhin
67835b642d Do not show url for multi platform projects. 2017-01-31 13:07:54 +03:00
Mikhail Zarechenskiy
f3385e093e Introduce language feature for type inference on generics for callable references
#KT-16061 Fixed
2017-01-31 01:15:02 +03:00
Nikolay Krasko
563196a8aa Stop in the method with suitable name if no descriptor found
Absence of descriptor is possible when sources are outdated or absent.
Early stop is better than iterating in step into till the program end.
2017-01-30 21:28:59 +03:00
Nikolay Krasko
c8999c4141 Fix in test bad behaviour of smart step into for stored lambda
When lambda is stored and not executed immediately, smart step into
doesn't work.
2017-01-30 21:28:59 +03:00
Nikolay Krasko
4a4a8250fd Fix smart step into functions call with suspend lambdas (KT-14700)
#KT-14700 Fixed
2017-01-30 21:28:59 +03:00
Nikolay Krasko
2add36ef32 Exclude errors descriptors from the set of conflicting declarations
Resolve hanging in evaluate expression
2017-01-30 21:28:59 +03:00
Alexander Udalov
ad0178ee64 Increase SOURCE_STUB_VERSION
Because of a974ed1 and b9f9894
2017-01-30 20:27:17 +03:00
Alexander Udalov
8811165de8 Report error on callable reference or class literal with "-no-stdlib"
Also workaround the NoSuchElementException that was happening because error
type never has any type arguments

 #KT-14547 Fixed
2017-01-30 20:27:17 +03:00
Alexander Udalov
7371dc9b54 Minor, fix typo in assertion message 2017-01-30 20:27:17 +03:00
Alexander Udalov
424afba246 Add hint to use "-language-version", when applicable, in JVM runtime checker 2017-01-30 20:27:17 +03:00
Alexander Udalov
7167139c2e Refactor JvmRuntimeVersionsConsistencyChecker for readability 2017-01-30 20:27:16 +03:00
Alexander Udalov
9e877b4a9e Do not report error on libraries that bundle Kotlin runtime in classpath
Instead, report a strong warning, suggesting to remove such libraries from the
classpath

 #KT-15995 Fixed
2017-01-30 20:27:16 +03:00
Alexander Udalov
2d975d74cb Slightly refactor inline functions at serializationUtils.kt
Extract large bodies to separate functions, use KType.classifier instead of
KClass.createType
2017-01-30 20:22:54 +03:00
Alexander Udalov
f6c3aa0807 Fix JvmBuildMetaInfoTest.testSerialization
Do not check against hard-coded values of parameters, because they might be
changed a lot in the future
2017-01-30 20:22:54 +03:00
Mikhail Glukhikh
8bf233e686 Change log update for 1.1.0 2017-01-30 20:21:13 +03:00
Yan Zhulanow
1b337e1a48 Generate enum values with bodies properly (KT-15803) 2017-01-30 20:13:08 +03:00
Yan Zhulanow
18e0baa13e Kapt: Allow empty .kt files list in kapt in order to support kapt with Java-only source files. (KT-15675) 2017-01-30 20:13:08 +03:00
Ilya Gorbunov
38b79a51d5 Fix tests after introducing exlcusions to default imports of kotlin.js package. 2017-01-30 19:44:51 +03:00
Ilya Gorbunov
33f3106157 Do not use Math in common code. 2017-01-30 19:44:51 +03:00
Ilya Gorbunov
66abea1f19 Add explicit imports of kotlin.js.* to stdlib where required. 2017-01-30 19:44:51 +03:00
Ilya Gorbunov
25c3064554 Add explicit imports of kotlin.js.* to generated files. 2017-01-30 19:44:51 +03:00
Ilya Gorbunov
cd5f68f119 Add exclusions to JS platform default imports 2017-01-30 19:44:51 +03:00
Alexey Andreev
d0b7dc8f4e JS: don't fail when generating signature for function which refers to undefined type 2017-01-30 19:26:24 +03:00
Ilya Gorbunov
f4ef98c327 Remove test for named native 2017-01-30 19:21:41 +03:00
Ilya Gorbunov
c4a0bb727d Change LoadBuiltinsTest testData, add runtime and import to box tests.
#KT-16030
2017-01-30 18:55:05 +03:00
Ilya Gorbunov
4ac7be9fa5 Retract bitwise operators from builtins for Byte and Short and add them as extensions in kotlin.experimental package in stdlib.
#KT-16030
2017-01-30 18:54:59 +03:00
Dmitry Jemerov
9b820202b5 Don't run decompiler to check whether reference is in copied fragment
#KT-16038 Fixed
2017-01-30 16:32:46 +01:00
Dmitry Jemerov
8968d5663d Minor fixes for stdlb kdoc 2017-01-30 16:13:49 +01:00
Alexey Sedunov
60edc46d8c Spring Support: Consider declaration open if it's supplemented with a preconfigured annotation in corresponding compiler plugin
#KT-15444 Fixed
2017-01-30 17:54:53 +03:00
Dmitry Jemerov
f73d32afeb Look at parent project when checking whether the Kotlin Maven plugin is applied in a module
#KT-15954 Fixed
2017-01-30 15:53:37 +01:00
Alexey Andreev
06e8f7b328 JS: don't report error when FAKE function overrides external function with optional parameters. Report only when it overrides at least two such functions. See KT-15961 2017-01-30 17:26:07 +03:00
Simon Ogorodnik
d117b0210f Revert "KT-14252 Completion could suggest constructors available via typealiases"
Reverted due problems with tests
This reverts commit 55eeb74c08.
2017-01-30 16:46:38 +03:00
Anton Bannykh
77aa685496 JS: char boxing 2017-01-30 16:31:44 +03:00
Simon Ogorodnik
55eeb74c08 KT-14252 Completion could suggest constructors available via typealiases
#KT-14252 fixed
2017-01-30 16:24:12 +03:00
Alexander Udalov
167155388d Rename JsBinaryVersion -> JsMetadataVersion
For consistency with JvmMetadataVersion
2017-01-30 16:05:46 +03:00
Alexander Udalov
e9a737b85a Promote severity of configuration warnings to STRONG_WARNING
The reason is that these configuration problems may be the reason of
compilation errors, but they were hidden from the output because warnings are
not reported when there's at least one error
2017-01-30 16:01:29 +03:00
Alexander Udalov
7ac96163ac Introduce CompilerMessageSeverity.STRONG_WARNING
This is a severity for mandatory warnings, i.e. those which should be reported
in any case, even if there are compilation errors
2017-01-30 16:01:27 +03:00
Alexander Udalov
268d10d3f0 Advance JvmMetadataVersion to 1.1.4, change IS_PRE_RELEASE to false
Kotlin 1.1 is no longer considered a pre-release
2017-01-30 16:00:05 +03:00
Alexander Udalov
1025fe9307 Minor, remove unnecessary logging for valid erroneous case
It seems that it's normal for VirtualFile in this place to be invalid in this
way
2017-01-30 15:57:51 +03:00
Alexander Udalov
933bcb3511 JS: do not require "id" in the File protobuf message 2017-01-30 15:55:20 +03:00
Denis Zharkov
88b82d5fa2 Exclude coroutine inrinsics and internal packages
#KT-16018
2017-01-30 15:45:02 +03:00
Denis Zharkov
b0ebbe99d6 Fix coroutine-related VerifyError
The problem was that we spilled the `origin` variable (see test) as Object, because
we determined the type of merge(null, String) incorrectly.

 #KT-15973 Fixed
2017-01-30 15:45:02 +03:00
Zalim Bashorov
0dd3f11175 KJS: mark as inline only some functions form js stdlib 2017-01-30 15:35:45 +03:00
Zalim Bashorov
a49ad3ca69 KJS: change visibility of subSequence helper function to internal to avoid to use it directly from kotlin 2017-01-30 15:35:45 +03:00
Zalim Bashorov
d5dca38d68 KJS: rename baseClass field in metadata to interfaces since we plan to store there only implemented interfaces (see KT-15037) 2017-01-30 15:35:45 +03:00
Zalim Bashorov
1b8b6bea43 KJS: turn Json class into external interface
#KT-12712 Fixed
2017-01-30 15:35:45 +03:00
Dmitry Jemerov
3a3cf048a6 Register ControlFlowFactory in KotlinCoreProjectEnvironment
#KT-16047 Fixed
2017-01-30 13:22:47 +01:00
Dmitry Jemerov
f0e890797a Disable "Create type alias from usage" fix when language level doesn't support type aliases
#KT-16036 Fixed
2017-01-30 12:37:31 +01:00
Dmitry Jemerov
17c73cea7f Disable "Introduce type alias" refactoring when type aliases aren't supported by the current language level 2017-01-30 12:37:31 +01:00
Dmitry Jemerov
720da176db Exclude keywords from completion if the corresponding feature is unsupported by the language level selected for the module 2017-01-30 12:32:41 +01:00
Alexander Udalov
eb61a1c5a8 Make KTypeProjection's constructor public
To make it easier to create a KTypeProjection instance given a KVariance
instance (otherwise you currently need to do a "when" on it). Also it's exposed
via automatically generated "copy" anyway
2017-01-30 11:31:20 +03:00
Alexander Udalov
e5680565b3 JS: drop "-kjsm" flag, merge logic with "-meta-info"
#KT-16049 Fixed
2017-01-30 11:31:03 +03:00
Alexander Udalov
17b0b7704f JS: minor, drop obsolete VFS_PROTOCOL 2017-01-30 11:31:02 +03:00
Alexander Udalov
ef42e3e4aa JS: write full version (major.minor.patch) to .meta.js 2017-01-30 11:31:02 +03:00
Alexander Udalov
038e4da83c Do not crash JS decompiler on non-existing .jar entries
See the comment for clarification
2017-01-30 11:31:02 +03:00
Alexander Udalov
b5fef84e9c Update tests on decompiled text for JS
Because .kjsm files now contain all declarations from the package (contrary to
the JVM decompiler which produces one file for one class/package facade), some
common decompiled text tests started to behave differently on JVM and JS.
Update two of them (Modifiers, ClassWithClassObject) to make results the same,
copy another (TypeAliases) to JVM-/JS-specific tests with different outputs
2017-01-30 11:31:02 +03:00
Alexander Udalov
805e3e4d0f Drop tests on JS decompiled text / stub consistency
They're no longer needed because the logic of the decompiler / stub builder is
now trivial (see KotlinJavaScriptDeserializerForDecompiler,
KotlinJavaScriptStubBuilder) and after it's merged to the decompiler for
built-ins, it's going to be tested anyway with BuiltInDecompilerConsistencyTest
2017-01-30 11:31:02 +03:00
Alexander Udalov
1045689911 JS: simplify KotlinJavascriptSerializationUtil
Inline recently introduced SerializerCallbacks
2017-01-30 11:31:02 +03:00
Alexander Udalov
63c24c56ec JS: serialize .kjsm package-wise, adapt decompiler & stub builder
Instead of multiple .kjsm files for different classes and .kotlin_string_table,
.kotlin_file_table, .kotlin_classes files for each package, serialize the
contents of each package to a single foo/bar/baz/baz.kjsm file. The short name
of the file is the last segment in the FQ name of the package, or
"root-package" if the package is root.

There are two main reasons for this change:
1) Such structure takes less space, is more IO-friendly and will not cause
   multiple exceptions as the old one, where we sometimes tried to read
   non-existing files
2) This is exactly the same format that is used to serialize built-in
   declarations (.kotlin_builtins) at the moment, which will allow us to reuse
   some code

Also write a separate Header protobuf message to the beginning of the .kjsm
file. This will be used as arguments of the kotlin.Metadata annotation are used
in the JVM-specific parts of the compiler: to be able to provide some general
information about the binary file without parsing the whole protobuf data.

This commit breaks decompiled text & stub builder consistency tests. This is OK
because they're removed in a future commit.

Fixes EA-79605, EA-81947, EA-84277 and maybe EA-86787

 #KT-10894 Fixed
 #KT-14124 Fixed
 #KT-15755 Fixed
2017-01-30 11:31:02 +03:00
Alexander Udalov
46bf057b47 JS: do not generate .meta.js and .kjsm for built-ins 2017-01-30 11:31:02 +03:00
Alexander Udalov
4b81dfb7c1 JS: improve binary representation format of metadata in .meta.js
Instead of writing many different files and serializing this "virtual file
system" to a byte array in a protobuf message, just write the needed stuff
directly, as fields in the Library message. Make it consist of many Part
messages, where the Part message is equivalent to the BuiltIns message in
builtins.proto. The next step would be to combine Library.Part and BuiltIns,
which will allow us to simplify some serialization-related code soon.

In this commit, no changes happened to the .kjsm format. But since the code
that serialized the abovementioned files was shared, a temporary abstraction
over two serialization formats was made, see SerializerCallbacks.

This commit temporarily breaks .kjsm decompiler and stub builder
2017-01-30 11:31:01 +03:00
Dmitry Petrov
77ea0614f9 Fix testData in smart completion test
(abbreviation is preserved for 'arrayListOf').
2017-01-30 10:51:47 +03:00
Vyacheslav Gerasimov
7bd6314ee1 Implemented building Kotlin Android projects with Jack toolchain enabled
#KT-13275 Fixed
Implemented KotlinJillTask for converting kotlin classes to jace format which could be consumed by Jack transform task
2017-01-29 23:39:53 +03:00
Zalim Bashorov
29ac01f2e2 KJS: allow to use packages with names starting with "kotlin" only if the -Xallow-kotlin-package command line option is specified
#KT-14668 Fixed
2017-01-29 17:21:01 +03:00
Ilya Gorbunov
7195e26ae2 Rollback Closeable.use implementation as it was in 1.0 in order not to call functions that were introduced in 1.1 from this inline function.
#KT-16026
2017-01-29 02:41:12 +03:00
Ilya Gorbunov
36436ae240 Maven build: change module build order. 2017-01-29 01:15:14 +03:00
Simon Ogorodnik
b422b0e24d KT-14722 completion list isn't filled up for typealias to object
#KT-14722 fixed
2017-01-28 21:42:39 +03:00
Stanislav Erokhin
e38ca44595 Create different KotlinBuiltIns for modules with different language feature settings.
For sdkModule we create builtIns with default language feature settings.
Also when we create sdkModuleResolverProvider we create builtIns cache.
Then for every other module we get builtIns cached by value isAdditionalBuiltInsFeatureSupported.
2017-01-28 19:13:48 +01:00
Ilya Chernikov
7c0cdf90cf Move daemon session flag files to daemon discovery dir by default + minor fixes:
- Move flag files from the temp dir, because right now JPS cleans temp dir on each build start. Should fix KT-15707, also may affect KT-15562.
- change compiler runner to allow the fix above
- Fix flag file name filtering
- Fix ifAlive handling on the new compile method in the daemon.
2017-01-28 15:36:06 +01:00
Dmitry Jemerov
ddbb476211 Add quickfix to increase language level by editing build.gradle 2017-01-28 13:14:39 +01:00
Dmitry Jemerov
c170c7b98f Add quickfix to enable coroutines by editing build.gradle
#KT-15955 Fixed
2017-01-28 13:14:39 +01:00
Dmitry Jemerov
da6640971f Import new Gradle coroutines DSL setting into Kotlin facet 2017-01-28 13:14:39 +01:00
Dmitry Jemerov
c7115e7233 Copy language and API version from compiler options to version info 2017-01-28 13:14:39 +01:00
Stanislav Erokhin
6ef96017e8 Mute test and create issue KT-15972. 2017-01-28 03:25:47 +03:00
Stanislav Erokhin
ec2eec33e3 Added hint url for coroutines and multiplatform diagnostics. 2017-01-28 03:25:45 +03:00
Stanislav Erokhin
b033ad1b2b Add positioning strategy DECLARATION_NAME for DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE. 2017-01-28 03:25:44 +03:00
Stanislav Erokhin
2aa2df75ae Make property java available on KClass<T> where T is type parameter without upper bounds. 2017-01-28 03:25:43 +03:00
Ilya Chernikov
bd47337be2 Using stdlib instead of runtime in the JSR 223 engines 2017-01-27 22:20:45 +01:00
Ilya Chernikov
b8b044c6b0 Reuse script args substitution for replacing bindings in JSR 223 sample engines, fixes KT-15450 2017-01-27 22:20:44 +01:00
Ilya Chernikov
b86ed0c5d9 Comment out failing test part - temporary, see TODO 2017-01-27 22:20:44 +01:00
Ilya Chernikov
0b689a4ecb PR-1021 review: minor fixes
# Conflicts:
#	compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/repl/GenericReplCompilingEvaluator.kt
#	compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/repl/GenericReplEvaluator.kt
#	compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/GenericReplCompiler.kt
2017-01-27 22:20:44 +01:00
apatrida
5ad06e1e92 PR-1021: Merge Keplin project scripting code into Kotlin core.
Overhauls the scripting layers (GenericRepl and related, and JSR223 and related)
Adds repeating modes (none, only latest eval'd line, or random order)
Also adds better thread-safe IO capturing, default imports, SimpleRepl wrapper, more unit tests

NOTE: the script-util part of the pull request was rejected due to various problems and incompatibilities.
It may be incorporated into the code later.

(originally cherry picked from commit 6f7d517)
2017-01-27 22:20:44 +01:00
Ilya Chernikov
8caf607378 PR-1021 preparations: prepare files to preserve important history
- Split GenericRepl.kt into separate files
- Rename Repl.kt
2017-01-27 22:20:44 +01:00
mglukhikh
34dd259900 Changelog 1.1.0: issue 15790 removed 2017-01-27 23:40:25 +03:00
Mikhail Glukhikh
d8a4a32e9f Do not report UNUSED_PARAMETER in function literal for 1.0 compatibility mode #KT-16010 Fixed 2017-01-27 23:39:08 +03:00
Mikhail Glukhikh
9fdf16e5d7 Quick-fix to add 'suspend' to the receiver of startCoroutine / createCoroutine #KT-15738 Fixed 2017-01-27 23:39:04 +03:00
Mikhail Glukhikh
5f455bbe3a Do not suggest renaming to underscore in 1.0 compatibility mode #KT-16019 Fixed 2017-01-27 23:39:01 +03:00
Mikhail Glukhikh
67e207acb0 Do not suggest destructuring in function literal in 1.0 compatibility mode #KT-15134 Fixed 2017-01-27 23:38:59 +03:00
Mikhail Glukhikh
3cd4d7cbfe Operator to function: rem or mod depending on version #KT-15969 Fixed 2017-01-27 23:38:57 +03:00
Roman Elizarov
a1571657f3 Updated test to experimental package 2017-01-27 23:24:13 +03:00
Roman Elizarov
8dc318dd92 Fixed KT-15963 (coroutines machinery should not use equals on results) 2017-01-27 23:24:13 +03:00
Denis Zharkov
c362a9154b Rename SUSPENDED_MARKER to COROUTINE_SUSPENDED 2017-01-27 23:24:13 +03:00
Denis Zharkov
246946bc18 Move buildSequence/buildIterator to kotlin.coroutines.experimental 2017-01-27 23:24:13 +03:00
Denis Zharkov
35e9f0a89a Update a test result temporary
Currently common stdlib doesn't contain Continuation interface
2017-01-27 23:24:13 +03:00
Denis Zharkov
68fc6fa217 Support non-CoroutineImpl instances in createCoroutine 2017-01-27 23:24:13 +03:00
Denis Zharkov
463af85f78 Minor. Update light-classes test data after coroutine-related changes 2017-01-27 23:24:13 +03:00
Denis Zharkov
1d5144b168 Move coroutine-related diagnostic tests to run them with stdlib
It's necessary because all coroutine related declarations (Continuation, etc)
are now in the stdlib
2017-01-27 23:24:13 +03:00
Denis Zharkov
8fa8ba7055 Move coroutine-related runtime parts to kotlin.coroutines.experimental package
#KT-15975 Fixed
2017-01-27 23:24:13 +03:00
Denis Zharkov
cb4914ab56 Make 'suspendCoroutineOrReturn' inline-only 2017-01-27 23:24:13 +03:00
Denis Zharkov
0e132b9857 Move all coroutine-related declarations from built-ins to stdlib
Also move internal declarations from runtime.jvm module into new package
kotlin.coroutines.jvm.internal in stdlib

The necessity of these declarations being in built-ins is controversial,
but also it will complicate the migration of current coroutine runtime
to a separate jar if we ever need this
2017-01-27 23:24:13 +03:00
Denis Zharkov
b61c152b4e Minor. Drop a couple of unused properties 2017-01-27 23:24:13 +03:00
Zalim Bashorov
4a72404ac2 Support a larger set of symbols as module name in "MODULE" directive 2017-01-27 23:15:43 +03:00
Zalim Bashorov
66fd566df0 KJS: fix inlining from modules with non valid identifier name 2017-01-27 23:13:53 +03:00
Zalim Bashorov
487419e762 KJS: don't export inline functions with InlineOnly annotation and inline functions with reified generic parameter 2017-01-27 22:47:10 +03:00
Zalim Bashorov
16405d080d Minor: remove outdated references form jslib_files.xml 2017-01-27 22:47:09 +03:00
Ilya Gorbunov
267703e6b7 Change references to kotlin-stdlib-js.jar in plugin.
Change test projects for js project configurator.
#KT-15940
2017-01-27 22:19:49 +03:00
Ilya Gorbunov
0df31f1223 Build kotlin-stdlib-js.jar in ant
#KT-15940
2017-01-27 22:19:40 +03:00
Ilya Gorbunov
d0e917e7f9 Fix maven references to stdlib-js in IDEA project
#KT-15940
2017-01-27 22:19:35 +03:00
Ilya Gorbunov
078f606cdc List artifacts required for maven plugin IT in extraArtifacts rather than in dependencies.
#KT-15940
2017-01-27 22:19:31 +03:00
Ilya Gorbunov
ea9be01034 Fix maven references to stdlib-js
#KT-15940
2017-01-27 22:19:26 +03:00
Ilya Gorbunov
ba1d7104a3 Rename JS standard library artifact #KT-15940 2017-01-27 22:09:46 +03:00
Simon Ogorodnik
2a08e3c679 KT-14767 typealias to annotation class should appear in the completion list
#KT-14767 fixed
2017-01-27 21:29:23 +03:00
Alexey Andreev
4c831cab9e JS: regenerate stdlib files from IDL 2017-01-27 20:54:43 +03:00
Alexey Andreev
72bcdf8869 JS: add enum emulation to IDL2K 2017-01-27 20:54:43 +03:00
Alexey Andreev
04e9405082 JS: regenerate stdlib files from IDL 2017-01-27 20:54:42 +03:00
Alexey Andreev
68d14de000 JS: add support of Promise<T> in IDL2K 2017-01-27 20:54:42 +03:00
Alexey Andreev
563a3a25cb JS: add Promise class 2017-01-27 20:54:41 +03:00
Mikhail Glukhikh
f5d5079b0d 1.1.0 change log update 2017-01-27 20:19:13 +03:00
Alexey Sedunov
be3e33051e Kotlin Facet: Fix Gradle import without "module per source set" option
#KT-15812 Fixed
2017-01-27 20:05:01 +03:00
Alexey Sedunov
34b0e175ca Configuration: Prohibit api-version > language-version in Facet and Project Settings
#KT-16015 Fixed
2017-01-27 20:05:00 +03:00
Alexey Tsvetkov
1420bd1b33 Add Kotlin Gradle DSL to configure coroutines from build.gradle 2017-01-27 19:04:49 +03:00
Mikhail Glukhikh
08caf0a011 Object literal to lambda: handle last comment correctly #KT-15670 Fixed 2017-01-27 18:15:56 +03:00
Mikhail Glukhikh
c0f5cafbd8 Set type reference: destructuring support #KT-14994 Fixed 2017-01-27 18:15:54 +03:00
Mikhail Glukhikh
f4513e9c70 Remove explicit lambda parameter types: destructuring support #KT-15162 Fixed
Also #KT-14993 Fixed
2017-01-27 18:15:52 +03:00
Nikolay Krasko
2c17773715 Minor: better name 2017-01-27 18:00:14 +03:00
Nikolay Krasko
370e7cd9f5 Stop considering injected files as Kotlin source roots (KT-15032)
We should have a special facade for them as descriptors are not
present in ordinal project facade.

Caused by change in idea 171 (b3527d9a20)

 #KT-15032 Fixed
2017-01-27 18:00:14 +03:00
Dmitry Jemerov
1361d5e915 EA-85853 - (KT-13415) AIOOBE: LightClassUtilsKt.toPsiTypeParameters 2017-01-27 14:48:05 +01:00
Dmitry Jemerov
59e2645293 EA-82902 - IOOBE: KtLightAnnotation$LightExpressionValue.unwrapArray 2017-01-27 14:48:05 +01:00
Kirill Rakhman
956094e062 Add Merge ifs intention (#975)
Fixes #KT-9912
2017-01-27 14:20:11 +01:00
Mikhael Bogdanov
456037a30d Generate proper annotaions on parameters for @JvmOverloads;
Fix for KT-15743: Overloaded Kotlin extensions annotates wrong parameters in java

 #KT-15743 Fixed
2017-01-27 14:09:13 +01:00
Mikhael Bogdanov
ab464ea86e Fix for KT-15726: Kotlin can't compile nested try-catch with return
#KT-15726 Fixed
2017-01-27 14:09:13 +01:00
Dmitry Jemerov
2c1c3d1f31 Workaround for compilation issue: don't use a Java shim to access token name, use toString() instead (for all relevant tokens, it will return the name, and for all others, the return value won't match the Java keyword filter regexp) 2017-01-27 13:32:20 +01:00
Dmitry Petrov
de14d4abc8 KT-15748 Type alias constructor return type should have a corresponding abbreviation 2017-01-27 15:16:04 +03:00
Ilya Gorbunov
dbaf31effe sourceDirs exclude the original test dir, so add it explicitly. 2017-01-27 14:53:33 +03:00
Ilya Gorbunov
01f53d0173 Return NaN as an average of an empty collection.
#KT-15399 Fixed
2017-01-27 14:53:33 +03:00
Dmitry Jemerov
6704ba05de Don't try to get siblings of PsiDirectory either (EA-94811 - assert: FileManagerImpl.findDirectory) 2017-01-27 12:47:41 +01:00
Dmitry Jemerov
731aeac04f Delete quick fix which was needed to migrate users to the version of Kotlin which was the latest in 2014 (EA-93982 - assert: PsiModificationTrackerImpl.fireEvent) 2017-01-27 12:47:41 +01:00
Dmitry Jemerov
6cbb2a4491 Replace incorrect assertion with explicit check (EA-93946 - assert: UnusedSymbolInspection.hasNonTrivialUsages) 2017-01-27 12:47:41 +01:00
Dmitry Jemerov
7236aa45f2 Fix IAE when rendering unknown type (EA-89031 - IAE: SmartTypeRenderer.render) 2017-01-27 12:47:41 +01:00
Dmitry Jemerov
2342aeef49 Don't try to resolve a class with no containing file (such as LightBRClass) to descriptor (EA-91890 - (AS only, no containing file, from Java light classes) LET: GetModuleInfoKt$getModuleInfo$.invoke) 2017-01-27 12:47:41 +01:00
Dmitry Jemerov
1337a5216c Don't try to get text for invalid file (EA-86393 - PIEAE: PsiFileImpl.getText) 2017-01-27 12:47:41 +01:00
Dmitry Jemerov
b987e37e82 Diagnostics for EA-86712 2017-01-27 12:47:41 +01:00
Ilya Gorbunov
661ff81e67 Specify names for parameters of functional types with two or more parameters to ease lambda completion.
#KT-13826
2017-01-27 14:46:29 +03:00
Kirill Rakhman
96d0f91afc Implement Smart Enter handler for class body (#1022)
Fixes #KT-9011
2017-01-27 12:35:33 +01:00
Dmitry Jemerov
e6a7808d8e Fix ConfigureKotlinUtilTest 2017-01-27 12:27:39 +01:00
Mikhail Zarechenskiy
0c6a860a22 ReplaceWith annotation resolver: use module from resolution facade to build imports scope
#KT-15873 Fixed

Using module from original element may lead to exceptions as it could be
<built-ins module> (after deprecation of `mod` operator)
2017-01-27 14:13:13 +03:00
Dmitry Petrov
e05f2eaff6 KT-15017 Throwing exception in the end of inline suspend-functions lead to internal compiler error
Suspend function call with a reachable (alive) begin marker and unreachable (dead) end marker
is an exit point for the corresponding coroutine.
It isn't a suspension point, and doesn't introduce a new state in the coroutine FSM.
2017-01-27 10:43:00 +03:00
Ilya Gorbunov
3be1174824 Replace @native with external in tests 2017-01-27 01:29:15 +03:00
Ilya Gorbunov
20f175d091 Soften back deprecation level for nativeGetter/Setter/Invoke annotations. 2017-01-27 00:48:46 +03:00
Simon Ogorodnik
4202abac63 Fix test 2017-01-26 23:19:42 +03:00
Ilya Chernikov
4bb5e978a7 Implement SamWithReceiverAnnotations annotation and it's handling (KT-15848)
TODO: tests
2017-01-26 20:53:24 +01:00
Simon Ogorodnik
f1c4230a68 KT-14680 import statement to typealias reported as unused when using only TA constructor
#KT-14680 fixed
2017-01-26 21:18:20 +03:00
Dmitry Jemerov
46bb636cea Fix ConfigureProjectTestGenerated 2017-01-26 19:08:57 +01:00
Dmitry Jemerov
c4032908c0 Don't show "Kotlin not configured" notifications while Gradle sync is running
#KT-15279 Fixed
2017-01-26 19:08:57 +01:00
Dmitry Jemerov
ac35b182b5 KotlinConfigurationCheckerComponent: J2K 2017-01-26 19:08:57 +01:00
Dmitry Jemerov
c6a20d39b4 KotlinConfigurationCheckerComponent: rename to .kt 2017-01-26 19:08:57 +01:00
Dmitry Jemerov
c7ea4eead7 Add Gradle JavaScript configurator 2017-01-26 19:08:57 +01:00
Dmitry Jemerov
c6251fdad7 Add JS variant of Gradle framework support provider
#KT-13632 Fixed
2017-01-26 19:08:57 +01:00
Dmitry Jemerov
e76cd15e5b Update different stdlib/gradle inspection to handle kotlin-stdlib-jre* 2017-01-26 19:08:57 +01:00
Dmitry Jemerov
163cef6457 Configuring project with Maven adds kotlin-stdlib-jre7 or kotlin-stdlib-jre8 if the selected JDK is of a high enough version
#KT-15712 Fixed
2017-01-26 19:08:57 +01:00
Dmitry Jemerov
7eea8f3849 Configuring project with Gradle adds kotlin-stdlib-jre7 or kotlin-stdlib-jre8 if the selected JDK is of a high enough version 2017-01-26 19:08:57 +01:00
Dmitry Jemerov
acc19f2ab6 Don't add 'kotlin' source root to build.gradle by default
#KT-14830 Fixed
2017-01-26 19:08:57 +01:00
Dmitry Jemerov
85a74f4cca Detect version 1.1.0-beta as 1.1 prerelease 2017-01-26 19:08:57 +01:00
Dmitry Jemerov
56bbb8ec78 Disable incompletely implemented Inline Function refactoring 2017-01-26 19:05:47 +01:00
Dmitry Jemerov
68bd5bd323 Fix project leak due to not disposed dialog 2017-01-26 18:55:17 +01:00
Dmitry Jemerov
d4af75bc50 Add write action which is required in 171 branch 2017-01-26 18:26:14 +01:00
Yan Zhulanow
bb0b70d27b Kapt: Fix extending configurations in Gradle, create "main" configuration if it does not exist yet. Also fix checking kapt configuration dependencies, use allDependencies instead (KT-15814) 2017-01-27 02:01:04 +09:00
Yan Zhulanow
3b4a8e0f33 Kapt3: Write qualified name of classes on error type conversion, handle declaration-site variance properly. 2017-01-27 01:20:01 +09:00
Yan Zhulanow
72bbf9697b Kapt3: As javac now reads stubs from Java files, not from AST, we should provide the valid names for all identifiers (at least names should not clash with Java keywords).
Rename identifiers if it clashes with Java keywords. (KT-15838)
2017-01-27 01:20:01 +09:00
Yan Zhulanow
e28b4dfbc7 Kapt3: Do not check type for star projection, it causes the infinite recursion. Also limit recursion depth to 10. (KT-15841) 2017-01-27 01:20:00 +09:00
Dmitry Jemerov
48a66c9d41 Generate Markdown documentation for Gradle options 2017-01-26 17:03:30 +01:00
Alexey Sedunov
deb9258994 Misc: Reverted 1fb90ac0fd 'Copy compiler arguments from iml even if "Use project settings" checkbox is checked' as it's rendered obsolete due to "Use project settings" being turned off by default in Gradle/Maven projects 2017-01-26 18:06:19 +03:00
Alexey Sedunov
6e8d0b520e Kotlin Facet: Import Gradle properties defined in gradle.properties file 2017-01-26 18:06:17 +03:00
Alexey Sedunov
f8349da608 Kotlin Facet: Import compiler arguments from Maven project model 2017-01-26 18:06:16 +03:00
Alexey Sedunov
74bfaa4ffe Quick Fixes: Change API level as well as language level in "Enable unsupported feature fix"
#KT-15918 Fixed
2017-01-26 18:06:15 +03:00
Alexey Sedunov
591910a216 Kotlin Facet: Import compiler arguments from Gradle project
#KT-15819 Fixed
 #KT-15929 Fixed
2017-01-26 18:06:14 +03:00
Alexey Sedunov
dafb6f8b3c Kotlin Gradle Plugin: Provide serialized list of compiler arguments in compilation tasks 2017-01-26 18:06:13 +03:00
Mikhail Glukhikh
bb54f23472 Change log updated for 1.1 2017-01-26 16:45:10 +03:00
Mikhael Bogdanov
25d75bcd8b Delegates to java defaults methods in compatibility mode 2017-01-26 14:32:33 +01:00
Mikhael Bogdanov
0006a04b01 Report warning on hided override by delegation when compile to 1.0 version 2017-01-26 14:32:33 +01:00
Alexey Tsvetkov
09a8a999c8 Correct construction of UnicastRemoteObject
#KT-15837 fixed
2017-01-26 16:07:44 +03:00
Alexey Tsvetkov
470a7706aa Fix build 2017-01-26 15:49:40 +03:00
Mikhail Zarechenskiy
462aed35d3 Don't exclude callable references with type parameters from completion 2017-01-26 14:48:37 +03:00
Alexey Tsvetkov
e04d18f3de Minor: make functions public to avoid error on teamcity 2017-01-26 14:23:21 +03:00
Alexey Tsvetkov
f46217129b EA-95293: do not report OUTPUT messages to message collector if outputs collector is specified 2017-01-26 13:38:52 +03:00
Alexey Tsvetkov
b9dbe69232 Rebuild all kotlin files when EAP flag is changed 2017-01-26 13:38:52 +03:00
Alexey Tsvetkov
4a63e47aa0 Save JvmBuildMetaInfo to file after build 2017-01-26 13:38:52 +03:00
Alexey Tsvetkov
6dbc4ff303 Introduce JvmBuildMetaInfo to hold last build settings 2017-01-26 13:38:52 +03:00
Simon Ogorodnik
82a70283b5 KT-15789 Kotlin plugin incorrectly converts for-loops from Java to Kotlin
#KT-15789 fixed
2017-01-26 13:33:06 +03:00
Simon Ogorodnik
bf3d4471cd KT-14710 Sample references aren't resolved in IDE
#KT-14710 fixed
2017-01-26 13:27:57 +03:00
Simon Ogorodnik
cd73d17bd4 KT-15311 "Add Import" intention generates incorrect code
#KT-15311 fixed
2017-01-26 13:24:41 +03:00
Dmitry Petrov
1613ad0505 KT-15898 Cannot use type alias to qualify enum entry
Type alias static scope includes enum entries for underlying enum class.
2017-01-26 10:23:56 +03:00
Dmitry Petrov
a974ed1049 Support custom accessors for top-level properties in scripts. 2017-01-26 10:12:13 +03:00
Dmitry Petrov
ab2448307e Functions imported from objects should be properly mapped to "real" suspend function descriptors. 2017-01-26 09:39:53 +03:00
Dmitry Petrov
9d4047f5e4 Calls for suspend functions imported from object should be checked in CoroutineSuspendCallChecker. 2017-01-26 09:39:53 +03:00
Dmitry Petrov
500667ff45 Function and property descriptors imported from object should keep track of the original imported descriptor,
otherwise they break an assumption that 'getOriginal()' chain would eventually converge on some callable descriptor.
2017-01-26 09:39:53 +03:00
Ilya Gorbunov
b1b295f00f Fix variance of Map.minus in expected diagnostics output. 2017-01-26 07:27:00 +03:00
Ilya Gorbunov
c00d684ece Fix deprecared API usages in test 2017-01-26 04:31:20 +03:00
Mikhail Zarechenskiy
b0c3c7463b Fix internal compiler error about arithmetic exception
#KT-8264 Fixed
2017-01-26 03:39:50 +03:00
Kirill Rakhman
ca86dbee72 Android: Add intention to generate View constructor convention
Fixes #KT-15150
2017-01-26 00:56:33 +03:00
Kirill Rakhman
f74c0950d2 use property syntax 2017-01-26 00:56:33 +03:00
Ilya Gorbunov
384b6410f2 New minus overloads appears in quickfix test data 2017-01-25 22:08:48 +03:00
Ilya Gorbunov
2e0209395a Restore Map.minus(key/keys) and Map.minusAssign(key/keys) operators.
#KT-13353
2017-01-25 22:08:46 +03:00
Ilya Gorbunov
288e0b3c7e Allow to use Regex matches CharSequence and CharSequence matches Regex in infix form
#KT-14279
2017-01-25 21:31:42 +03:00
Ilya Gorbunov
387564d140 JS: Rewrite RegExpMatch without @nativeGetter 2017-01-25 21:29:53 +03:00
Ilya Gorbunov
03019dc638 Deprecate qunit (with ERROR) and jquery (with WARNING) 2017-01-25 21:29:53 +03:00
Ilya Gorbunov
70f3cee9ff Harden deprecations to prepare for cleanup. 2017-01-25 21:29:53 +03:00
Ilya Gorbunov
1ccc655cdc Harden deprecation level on remaining API in java.util in kotlin-stdlib-js 2017-01-25 21:29:53 +03:00
Simon Ogorodnik
3948c1e007 KT-15153 Support typeAlias extensions in completion and add import
#KT-15153 fixed
2017-01-25 20:47:48 +03:00
Dmitry Jemerov
9bc45a9c91 Correctly dispose KotlinCoreEnvironment after use 2017-01-25 17:30:10 +01:00
Alexey Andreev
1c8478e46b JS: fix translation of enum entries without parentheses that call secondary constructors, constructors with default parameters and varargs. See KT-15900, KT-14097 2017-01-25 18:09:23 +03:00
Alexey Andreev
0f87320f9e JS: regenerate test data 2017-01-25 18:09:23 +03:00
Alexey Andreev
31c758994d JS: remove diagnostic about callable reference to built-in 2017-01-25 18:09:22 +03:00
Alexey Andreev
ad4fb44827 JS: report about using of external interfaces in class literals 2017-01-25 18:09:22 +03:00
Alexey Andreev
deaac83e70 JS: report about wrong module usage in class literals. See KT-15253 2017-01-25 18:09:21 +03:00
Alexey Andreev
f52eebd302 Add extension point for back-ends to perform platform-specific checks of class literals 2017-01-25 18:09:21 +03:00
Alexey Andreev
9000d54d8a JS: when checking calls to JsModule declarations, check arguments passed to reified type parameters. See KT-15253 2017-01-25 18:09:20 +03:00
Mikhael Bogdanov
4c7a07bed6 Optimize defaults format: avoid reduntant stack normalization operations 2017-01-25 15:56:56 +01:00
Mikhael Bogdanov
fc4be17623 Fix for KT-14966: Regression: VerifyError on access super implementation from delegate
#KT-14966 Fixed
2017-01-25 15:56:55 +01:00
Mikhael Bogdanov
11578c602e Added inline tests for jvm 8 target 2017-01-25 15:56:55 +01:00
Simon Ogorodnik
32f1ce7551 Added "kotlin.reflect.jvm.internal" to excluded from completion and auto imports list 2017-01-25 17:45:59 +03:00
Simon Ogorodnik
e220a20eed KT-15796 Import of class referenced only in KDoc not preserved after copy-paste
#KT-15796 fixed
2017-01-25 17:41:26 +03:00
Simon Ogorodnik
4ca10c61fd KT-11308 Hide kotlin.jvm.internal package contents from completion and auto-import
#KT-11308 fixed
2017-01-25 17:39:36 +03:00
Simon Ogorodnik
5c52bdc684 KT-14859 "Parameter Info" doesn't work properly in one case
#KT-14859 fixed
2017-01-25 17:32:57 +03:00
Ilya Chernikov
e3338c1e31 Fix testdata 2017-01-25 15:29:15 +01:00
Ilya Chernikov
ec7e8873f4 Update daemon client with wrappers for basic compiler API
Other changes to extract results for compiler, tests.
2017-01-25 15:29:15 +01:00
Nikolay Krasko
afd0655776 Fix after review 2017-01-25 17:19:53 +03:00
Nikolay Krasko
c525a59df8 Make breakpoints work in suspend functions 2017-01-25 16:46:35 +03:00
Nikolay Krasko
649ec9a73d Check that breakpoints work in suspend function without suspension points 2017-01-25 16:46:33 +03:00
Nikolay Krasko
1a3d333da1 Add diagnostic for null error in KotlinClsStubBuilder 2017-01-25 16:46:32 +03:00
Mikhail Glukhikh
d13978e64f Change log 1.1-RC (preliminary) 2017-01-25 15:27:19 +03:00
Alexey Sedunov
983ad55357 Code Insight: Preserve identifier quotes in "Generate equals()/hashCode()/toString()" actions
#KT-15883 Fixed
2017-01-25 14:24:51 +03:00
Alexey Sedunov
7382d7c7d6 Extract Function: Add 'suspend' modifier if extracted function contains suspend-calls
#KT-14704 Fixed
2017-01-25 14:24:49 +03:00
Alexey Sedunov
41f5a3e864 Support "Change parameter type" for parameters with type-mismatched default value
#KT-15627 Fixed
2017-01-25 14:24:48 +03:00
Denis Zharkov
ba0f8b908f Fix Kotlin bytecode toolwindow showing wrong code for suspend functions
Use binding context from the full resolve, because otherwise control-flow
analysis is not being run, that is very important for suspend functions
(tail-call optimizations)

 #KT-15827 Fixed
2017-01-25 14:22:40 +03:00
Alexey Andreev
e15b2b0dd0 Fix compilation of project 2017-01-25 14:15:23 +03:00
Mikhail Glukhikh
426619e47c Change log from 1.1-Beta added to master branch 2017-01-25 14:02:05 +03:00
Denis Zharkov
9ce3880ac6 Support getValue/setValue/provideDelegate suspend functions in JVM backend
- Determine if there are non-tail calls to getValue/setValue simply
by existance of such a property
(it might be too strict, but implementing more granular check may be rather hard)

- Change in ExpressionCodegen is relevant for provideDelegate,
that in case of local variables uses OnStack as StackValue
(see the comment near these changes)

 #KT-15933 Fixed
2017-01-25 13:54:01 +03:00
Denis Zharkov
9ca9a988a6 Fix accessor generation for suspend functions
1. JVM view of suspend accessors must be also an instance of AccessorForFunctionDescriptor,
thus `createSubstitutedCopy` should be correctly overidden.

2. accessibleFunctionDescriptor should unwap the initial suspend descriptor,
for the same reasons as for type aliases constructors and etc:
these descriptors are used as keys of the map of accessors, so
to avoid duplication for suspend view and initial suspend descriptor,
we always use the latter one as a key.

 #KT-15907 Fixed
 #KT-15935 Fixed
2017-01-25 13:54:01 +03:00
Denis Zharkov
0693bd6b62 Fix codegen issue on suspend functions with receiver
When the extension receiver of a named suspend function was marked as used
from the inner lambda, codegen used to throw a "Don't know how to generate outer expression for class" exception.

It may seem quite tricky, but currently for suspend lambda body
its extension receiver is treated as it's defined inside the relevant "doResume"
(there is an actual bytecode part that fills the relevant local variable)

The problem was that inside ExpressionCodegen for "doResume" of named
suspend function we couldn't determine that original function has
an extension receiver.

 #KT-15821 Fixed
 #KT-15820 Fixed
2017-01-25 13:54:01 +03:00
Denis Zharkov
131c008ba3 Minor. Refine naming for original suspend lambda descriptors
Also inline some methods with single usage
2017-01-25 13:54:01 +03:00
Denis Zharkov
02b40326cc Fix incorrect coroutines codegen behavior
If all the suspension calls in a suspend function were "hidden"
under the for-convention (iterator/next/hasNext) calls,
control-flow didn't find them, thus supposing that there is no
suspension points and there is no need to generate a coroutine state machine

The solution is to add relevant calls to CFG

 #KT-15824 Fixed
2017-01-25 13:54:01 +03:00
Alexey Andreev
8cbea903f4 JS: add checker that checks if JsQualifier has wrong format 2017-01-25 13:52:19 +03:00
Alexey Andreev
ba65e58fdd JS: add checker to detect non-external declarations in files marked by JsModule or JsQualifier annotation 2017-01-25 13:52:19 +03:00
Alexey Andreev
cc67f6c9f7 JS: add support of JsQualifier annotation. See KT-15905 2017-01-25 13:52:18 +03:00
Alexey Andreev
6624736ccf JS: fix is check on Throwable instances 2017-01-25 13:52:18 +03:00
Alexey Andreev
aef7b83932 JS: fix toString in case of kotlin.Throwable 2017-01-25 13:52:17 +03:00
Alexey Andreev
6b2f1ba4e4 JS: move couple of helper functions from TranslationUtils to JsDescriptorUtils 2017-01-25 13:52:17 +03:00
Alexey Andreev
115f6ced87 JS: fix support of throwable constructors without message and/or cause parameters 2017-01-25 13:52:16 +03:00
Alexey Andreev
6f4d8decc7 JS: add support of custom exceptions inherited from kotlin.Throwable that call super constructor from secondary constructor 2017-01-25 13:52:16 +03:00
Alexey Andreev
f34093db9f JS: make kotlin.Throwable = Error. See KT-15312 2017-01-25 13:52:13 +03:00
Alexey Andreev
c565697e77 JS: refactor FunctionIntrinsic 2017-01-25 13:51:54 +03:00
Alexey Andreev
0a9c536c01 JS: make defensive copy of argument list in JsInvocation and JsNew constructor 2017-01-25 13:51:53 +03:00
Alexey Andreev
51e5b5aac7 JS: allow to inherit external class from kotlin.Throwable. See KT-15336 2017-01-25 13:51:53 +03:00
Anton Bannykh
847ec9e550 JS: fixed subSequence in CharSequence descendants (KT-14035) + added support for function intrics in delegation 2017-01-25 12:59:53 +03:00
Vyacheslav Gerasimov
4fe040eeb9 Fixed several bugs in Android lint ApiDetector (KT-15002, KT-12024, KT-14737, KT-14825, KT-12023, KT-15018)
Merged IntelliJApiDetector to ApiDetector

#KT-15002 Fixed
#KT-12024 Fixed
#KT-14737 Fixed
#KT-14825 Fixed
#KT-12023 Fixed
#KT-15018 Fixed

(cherry picked from commit e830e8b55f)
2017-01-25 10:50:36 +03:00
Vyacheslav Gerasimov
d0f1b81bfa Fixed bugs in Kotlin Android Lint CleanupDetector
#KT-14780 Fixed
#KT-14677 Fixed

(cherry picked from commit f591b4958e)
2017-01-25 10:50:35 +03:00
Mikhail Zarechenskiy
68b223211c Fix bogus integer overflow warning for 'mod' operator
#KT-15875 Fixed
2017-01-25 02:24:28 +03:00
Ilya Gorbunov
f9e552e3c2 Build kotlin-stdlib in addition to kotlin-runtime in ant build. 2017-01-24 22:38:05 +03:00
Ilya Gorbunov
a2bd3bfc7b List artifacts explicitly for test. 2017-01-24 22:04:46 +03:00
Ilya Gorbunov
43003cffbb Make kotlin-runtime dependency optional for kotlin script executor for maven, but still add if it's found. 2017-01-24 22:04:46 +03:00
Ilya Gorbunov
070f9d9d17 Binary compatibility validation: dump public API of merged stdlib to another file 2017-01-24 22:04:46 +03:00
Ilya Gorbunov
4da4de1104 Replace kotlin-runtime with kotlin-stdlib, where it was used as a dependency. 2017-01-24 22:04:46 +03:00
Ilya Gorbunov
e025050dd9 Replace kotlin-runtime with kotlin-stdlib in kotlin-script-util and its tests 2017-01-24 22:04:46 +03:00
Ilya Gorbunov
19dd7ee09e Build kotlin-test after kotlin-stdlib, build kotlin-test sources with kotlin-stdlib tests again 2017-01-24 22:04:46 +03:00
Ilya Gorbunov
a0cfd8d35e Change builtins module name to kotlin-runtime to match that of maven built artifact. 2017-01-24 22:04:46 +03:00
Ilya Gorbunov
7ccaa77c5b Shade kotlin-runtime into kotlin-stdlib 2017-01-24 22:04:46 +03:00
Ilya Gorbunov
8e9bbe276c JS: Make Date.getTime return Double instead of Int.
#KT-4141 Fixed
2017-01-24 21:55:48 +03:00
Alexey Andreev
46d251df1b JS: deprecate noImpl 2017-01-24 20:18:42 +03:00
Alexey Andreev
5243b451f7 JS: replace noImpl with definedExternally in hand-written stdlib 2017-01-24 20:18:42 +03:00
Alexey Andreev
c05870b461 JS: regenerate stdlib 2017-01-24 20:15:22 +03:00
Alexey Andreev
a9069d8973 JS: replace noImpl with definedExternally in stdlib generator 2017-01-24 20:15:21 +03:00
Alexey Andreev
c9a190b405 JS: regenerate stdlib sources from IDL 2017-01-24 20:15:19 +03:00
Alexey Andreev
e3da9066c4 JS: replace noImpl with definedExternally in IDL2K 2017-01-24 20:14:32 +03:00
Alexey Andreev
26abc19aa6 JS: replace noImpl with definedExternally in diagnostics and their messages 2017-01-24 20:14:32 +03:00
Alexey Andreev
aedf8bd232 JS: replace noImpl with definedExternally in tests 2017-01-24 20:14:31 +03:00
Alexey Andreev
71a5d8a4ee JS: add definedExternally property as a replacement for noImpl, support it in checkers. See KT-15144 2017-01-24 20:14:31 +03:00
Alexey Andreev
26a3ac5a9b JS: fix translation of delegated local variables in coroutines. See KT-15834 2017-01-24 20:13:53 +03:00
Alexey Andreev
8040d781b4 JS: fix translation of suspend lambda when it's not passed to another function 2017-01-24 20:13:53 +03:00
Alexey Andreev
1a5e0e4b06 JS: improve performance of suspend function calling suspen function when no suspension ever occur. 2017-01-24 20:12:12 +03:00
Alexey Andreev
bf55744e64 JS: fix translation of safe calls if suspend functions. See KT-15892 2017-01-24 20:11:55 +03:00
Alexey Andreev
2adaaf5e9f JS: recognize LANGUAGE_VERSION directive in testData 2017-01-24 20:11:30 +03:00
Alexey Andreev
9aeba1d5cf JS: fix names in stdlib and tests WRT to new mangling algorithm 2017-01-24 20:11:29 +03:00
Alexey Andreev
2ae46ceb4b JS: change how signature for mangling is generated, taking into account more information. See KT-15285 2017-01-24 20:10:17 +03:00
Alexey Andreev
119bf52adf JS: fix translation of callable reference to property of outer class with private setter 2017-01-24 20:09:32 +03:00
Alexey Andreev
d35ddc1017 JS: unmute tests that now pass 2017-01-24 20:09:32 +03:00
Alexey Andreev
d261f8eddf Move generation of fake call to common CodegenUtil to share between JS and JVM 2017-01-24 20:09:31 +03:00
Alexey Andreev
c100826629 JS: reduce number of functions to create callable references 2017-01-24 20:09:31 +03:00
Alexey Andreev
dcb8b7b92c JS: fix inlining of callable references 2017-01-24 20:09:30 +03:00
Alexey Andreev
7a0f75f164 JS: refactor generation of callable references to functions 2017-01-24 20:09:29 +03:00
Alexey Andreev
1b0648a926 JS: refactor generation of property callable references 2017-01-24 20:09:29 +03:00
Sergey Mashkov
66de78e82a kotlin-test: migrate multiplatform integration test to use common test module 2017-01-24 19:39:05 +03:00
Sergey Mashkov
e500eba59f Maven: test js compiler test scope dependencies 2017-01-24 19:39:05 +03:00
Ilya Gorbunov
5a28e8cc20 Install kotlin-test artifacts to local repo when testing maven plugin 2017-01-24 19:39:05 +03:00
Ilya Gorbunov
609405b8d4 Add kotlin-test-js dependency where required. 2017-01-24 19:39:05 +03:00
Ilya Gorbunov
7d9554b6b8 Remove sources.xml and maven-assembly-plugin execution. 2017-01-24 19:39:05 +03:00
Ilya Gorbunov
d3ed55549a Make dependency on kotlin-test-common optional, i.e. non-transitive. 2017-01-24 19:39:05 +03:00
Ilya Gorbunov
9b9852cdc9 kotlin-test: rename shared module to common.
Do not use shared kotlin-test while building js stdlib.
2017-01-24 19:39:05 +03:00
Dmitry Petrov
5ef27f7ad3 KT-15010 Missing error on an usage non-constant property in annotation default argument 2017-01-24 17:52:52 +03:00
Mikhael Bogdanov
df8394bcd2 Fix for KT-14597: "When" over smartcasted enum is broken and breaks all other "when"
#KT-14597 Fixed
2017-01-24 15:17:47 +01:00
Dmitry Petrov
ee9a174c1f KT-7897 Do not require to call enum constructor for each entry if all parameters have default values
Do not report an error on enum entry without initializer if all parameters have default values
(error is still reported if there is no such constructor, or if the constructor call is ambiguous).

Record resolved call on KtEnumEntry.

NB is the enum entry has a corresponding subclass, we still have to generate the "default" constructor call,
because FE doesn't know about the platform-specific representation of that class and its constructors.

See also KT-14097, KT-15900
2017-01-24 16:59:47 +03:00
Nikolay Krasko
d13c34200b Remove method deprecated in 171 and explicitly set mainClass before calling toCommandLine() 2017-01-24 16:43:22 +03:00
Mikhail Glukhikh
fb913bc071 Operator to function: mod --> rem, modAssign --> remAssign #KT-15874 Fixed 2017-01-24 15:19:36 +03:00
Mikhail Glukhikh
bfb31a465f Quick-fix to add 'suspend' to the containing function #KT-15800 Fixed 2017-01-24 15:17:55 +03:00
mglukhikh
96cddb6b7b False positive in "Remove redundant let" fixed #KT-15884 Fixed 2017-01-24 15:17:48 +03:00
mglukhikh
be75ef919e Change visibility modifier: now works on no-modifier type aliases #KT-15066 Fixed 2017-01-24 15:17:41 +03:00
Mikhail Glukhikh
60fcdeb5ee Test added: suppress on function reference #KT-15839 Obsolete 2017-01-24 14:59:53 +03:00
shiraji
d9ec8a92f2 KT-15553 Support compile constant for "Copy concatenation text to clipboard"
#KT-15553 Fixed
2017-01-24 14:33:52 +03:00
Kirill Rakhman
909007d984 Add inspection for private primary constructors in data classes
Fixes #KT-15709
2017-01-24 14:08:05 +03:00
mglukhikh
f64345634b WHEN_ENUM_CAN_BE_NULL_IN_JAVA is no more reported after smart cast to not-null #KT-15201 Fixed 2017-01-24 13:51:15 +03:00
mglukhikh
b53ebd115b Pattern matching: work-around for smart cast target type instability #KT-14705 Fixed 2017-01-24 13:51:14 +03:00
Alexey Andreev
bc0550d7b7 JS: don't report about inline modifier on inline extension fun to external class 2017-01-24 12:27:02 +03:00
Alexey Andreev
0ca2ae7279 JS: regenerate Kotlin JS bindings from IDL files with new rules 2017-01-24 12:27:01 +03:00
Alexey Andreev
36d2a91057 JS: prevent IDL2K from generating @nativeGetter/@nativeSetter annotations, generate inline extension function with asDynamic() instead 2017-01-24 12:27:01 +03:00
Alexey Andreev
c1838d423b JS: transfer all empty statement simplifications RedundantLabelRemoval to EmptyStatementElimination, so that empty statements can be eliminated everywhere, not in labeled blocks only. 2017-01-24 12:26:21 +03:00
Alexey Andreev
ac0df8eef9 JS: when recursive local function does not capture variables, give it name from top-level scope. See KT-15770 2017-01-24 12:25:23 +03:00
Alexander Udalov
70d2296e61 Update public API dump after adding KPropertyN.getDelegate 2017-01-24 10:59:44 +03:00
Ilya Gorbunov
a603de8bd7 Ensure string to number conversion fails on empty and blank inputs.
#KT-4497
2017-01-24 07:22:58 +03:00
Ilya Gorbunov
4018d10bf6 Deprecate parseInt and parseFloat. Replace deprecated usages in tests.
#KT-4497
2017-01-24 07:22:51 +03:00
Ilya Gorbunov
4e5e14c9a0 Provide string-to-number conversions in JS and common stdlib.
Relates to #KT-8286
#KT-4497 Fixed
2017-01-24 07:20:57 +03:00
Mikhail Zarechenskiy
2cac6a9e7d Improve inference on generics for callable references
#KT-10711 Fixed
 #KT-12802 Fixed
 #KT-12964 Fixed
 #KT-15439 Fixed

Analyze callable references in `dependent` mode, then complete them with
respect to expected types
2017-01-24 02:15:26 +03:00
Anton Bannykh
07bb7ef4d3 JS: extension lambdas translated same as local lambdas (KT-13312 fixed) 2017-01-23 20:09:36 +03:00
Dmitry Petrov
5021be351d KT-15878 Extension shadowed by member shouldn't be reported for infix/operator extensions when member is non-infix/operator 2017-01-23 16:46:43 +03:00
Sergey Mashkov
98075c17c9 kotlin-test: extract from JS library, convert to multiplatform 2017-01-23 15:43:02 +03:00
Alexey Sedunov
c264de5795 Project Settings: Expose API version setting in Kotlin compiler configuration UI 2017-01-23 15:16:14 +03:00
Alexey Sedunov
57c27299dd JPS: Use facet configuration to determine if module should be compiled to JS 2017-01-23 15:16:12 +03:00
Alexey Sedunov
7b12a66b21 Kotlin Facet: Warn about libraries configured for non-current platform
#KT-15628 Fixed
2017-01-23 15:16:11 +03:00
Alexey Sedunov
597068a704 Kotlin Facet: Import API version from Maven
#KT-15772 Fixed
2017-01-23 15:16:10 +03:00
Alexey Sedunov
fc9b001ccd Kotlin Facet: Use project settings by default
#KT-15624 Fixed
2017-01-23 15:16:09 +03:00
Alexey Sedunov
b35eba0621 Kotlin Facet: Annotate CompilerSettings properties with @JvmField to make them available for copyBean()
#KT-15621 Fixed
 #KT-15623 Fixed
2017-01-23 15:16:08 +03:00
Roman Elizarov
07dc937e2e typo if start/createCoroutine docs fixed 2017-01-23 14:25:04 +03:00
Zalim Bashorov
76a20fc104 Minor: fix copyright in polyfills.js 2017-01-23 14:14:16 +03:00
Zalim Bashorov
4f36e9af08 Minor: remove extra comment block with copyright 2017-01-23 14:14:15 +03:00
Zalim Bashorov
cd04e794ee KJS: class MathClass -> object Math 2017-01-23 14:14:13 +03:00
Zalim Bashorov
cb210b6c78 KJS: fix stub consistency test which was broken after JsonClass was renamed and transformed to object
`kotlin.js.Console` is used instead of `kotlin.js.JSON` to avoid problems on case-sensitive filesystems since right now we also have `kotlin.js.Json` (will be removed later)
2017-01-23 14:13:58 +03:00
Mikhail Glukhikh
b7fb45f36e DFA: only stable values or qualified with stable receiver can be bound in x = y #KT-15792 Fixed 2017-01-23 13:38:24 +03:00
Mikhail Glukhikh
905e67e713 Data flow information: take language version into account while processing safe calls and bound values #KT-14350 Fixed 2017-01-23 13:38:24 +03:00
Alexander Udalov
ebd577e52a Introduce KProperty{1,2}.getExtensionDelegate
These two functions are supposed to fix an inconvenience in the design of
KProperty{1,2}.getDelegate for extension properties, where you have to pass an
instance of the extension receiver which is going to be completely ignored

 #KT-8384 Fixed
2017-01-23 12:25:36 +03:00
Alexander Udalov
78f2515e95 Introduce KProperty{0,1,2}.getDelegate
#KT-8384 In Progress
2017-01-23 12:25:35 +03:00
Alexander Udalov
f1cd2ee6fd Introduce PropertyDescriptor.isDelegated, write new flag to metadata
#KT-8384 In Progress
2017-01-23 12:25:34 +03:00
Alexander Udalov
76fc3b40d5 Do not consider Kotlin compiler as library in runtime versions checker
Otherwise because there's no Kotlin-Version in its manifest, it's regarded as a
1.0 runtime library which conflicts with 1.1 libraries
2017-01-23 11:30:53 +03:00
Dmitry Petrov
e31e12474f KT-15844
Property with type inferred from getter could access primary constructor parameters inside the getter
(which is incorrect, and caused problems in compilation).
Fix scopes for property descriptor resolution.
'getScopeForMemberDeclarationResolution' in AbstractLazyMemberScope should always return member declaration resolution scope.
Two scopes are required, because both property initializer and property accessors should see property type parameters.
2017-01-23 10:22:34 +03:00
Denis Zharkov
2edcd369a8 Fix inference issue with Stream.collect
See doNotCaptureSupertype test for clarification:
When resolving b.collect(toList()) we're building a common system with
two variables T and R.

The problem was that when introducing the constraint
C<T, Inv<T>> <: C<in String, R> we then were seeing the constraint
T <= in String, and add the constaint T=Captured(in String)

That lead to R=Inv<T>=Inv<Captured(in String)>, and after approximation
R=Inv<in String>, that is not the desirable result (Inv<String> suits here)

But the root problem was that we add captured constaint when projection was from supertype,
that seems to be wrong, and for example Java doesn't do that in the similar situation.

 #KT-11259 Fixed
2017-01-22 13:29:08 +03:00
Alexander Udalov
a18720154c Fix diagnostic test data 2017-01-21 12:59:01 +03:00
Alexander Udalov
fc637eb420 Change runtime component from "Core" to "Main"
This is needed to allow the old compiler have the new runtime libraries in the
classpath. See the previous commit for a more elaborate explanation
2017-01-21 12:57:15 +03:00
Alexander Udalov
139d37cfd0 Support "Main" component in JVM runtime version consistency checker
The point here is to disable the "checkNotNewerThanCompiler" check because it
breaks a real life use case of compiling with an old compiler against the new
runtime library (that may come implicitly as a transitive dependency of another
library). However, to keep the possibility of restoring this check in the
future without backporting the needed changes into the old branches, we now
only perform this check for the "Core" runtime components, and all other checks
-- for "Core" and "Main" runtime components. In the follow-up commit, we change
the runtime component of our libraries to "Main". If we decide we need the
"checkNotNewerThanCompiler" behavior in the future, we can change the runtime
component to "Core", effectively restoring this check in the old compilers
2017-01-21 12:57:14 +03:00
Alexander Udalov
7b4e826650 Enable JVM runtime version consistency checker in 1.1 2017-01-21 12:57:14 +03:00
Ilya Gorbunov
3a1ed41436 Create deprecated MutableList.sort extensions to guide how to replace them.
#KT-15790 Fixed
2017-01-21 03:14:42 +03:00
Dmitry Petrov
6e2ebaa300 KT-12846 Forbid vararg of type 'Nothing' and 'Nothing?' 2017-01-20 17:50:19 +03:00
Mikhail Glukhikh
1f573bb115 EA-92388: Fix of exception in import action creation 2017-01-20 17:39:14 +03:00
Mikhael Bogdanov
818773b7e2 Updated android test configuration 2017-01-20 13:16:58 +01:00
Mikhael Bogdanov
da1b8a02ed Exclude builtins members mapped to java default methods from delegation 2017-01-20 13:16:58 +01:00
Dmitry Petrov
03a697a707 Prohibit renaming operator to another operator on import. 2017-01-20 13:01:39 +03:00
Mikhail Glukhikh
9625c32527 Exhaustive when on sealed trees implemented #KT-13130 Fixed
Also #KT-13227 Fixed
2017-01-20 11:04:54 +03:00
Ilya Gorbunov
3d7bcbdff9 Minor: add two cases for Map.getOrDefault test
Relates to #KT-15610
2017-01-19 22:33:20 +03:00
Ilya Gorbunov
3ec48ab244 Add kotlin.comparisons package to default imports. 2017-01-19 18:21:14 +03:00
shiraji
ad9bf1626f Fix the problem with ConvertPrimaryConstructorToSecondaryIntention for enum #KT-15406 Fixed 2017-01-19 17:57:33 +03:00
Alexey Andreev
245f23e7c2 JS: fix translation of references to external nested classes in files marked with @JsModule. See KT-15797 2017-01-19 16:30:57 +03:00
Dmitry Petrov
5fc8208504 KT-13355: fix Kotlin compilation. 2017-01-19 16:09:29 +03:00
Dmitry Petrov
b36e3bc083 KT-13355
An overridden abstract member with a more specific "return type" than an overridden concrete member
should be explicitly overridden even if the class in question can have abstract members.
2017-01-19 16:09:29 +03:00
Dmitry Petrov
f89de02ff0 OverrideResolver: convert to Kotlin & cleanup. 2017-01-19 16:09:29 +03:00
Dmitry Petrov
7f2085b4e4 OverrideResolver: .java -> .kt 2017-01-19 16:09:29 +03:00
Denis Zharkov
bbb5d4eb0f Fix 1.0-compatibility mode for JDK dependendent built-ins
Do not report UNSUPPORTED_FEATURE if there is no overridden descriptors
E.g. in case of property accessors
2017-01-19 15:20:57 +03:00
Ilya Gorbunov
7696d20adf Deprecate moved reflection 1.1 api with ERROR 2017-01-19 14:07:17 +03:00
Alexey Andreev
af1b7c49b4 JS: insert dummy initializers for property that initialized on init block or in secondary constructors. See KT-8211 2017-01-19 13:20:24 +03:00
Alexey Andreev
a927770935 JS: fix scope of function generated for primary constructor. See KT-15678 2017-01-19 13:09:59 +03:00
Alexey Andreev
daac24b62e JS: prohibit referencing noImpl property from non-external declarations. See KT-15306 2017-01-19 13:09:06 +03:00
Alexey Andreev
199790276b JS: prohibit dynamic values as handlers of property delegates. Prohibit delegation of classes by dynamic values. See KT-15283 2017-01-19 13:07:58 +03:00
Alexey Andreev
a4b2abc7d5 JS: prohibit spread operator and destructuring declaration in dynamic values. See KT-15283 2017-01-19 13:07:57 +03:00
Alexey Andreev
31d0e0b7c4 JS: prohibit .. operation on dynamic type. See KT-15184 2017-01-19 13:07:56 +03:00
Alexey Andreev
e6be418dd3 JS: prevent optimizer from removing access to dynamic property access. See KT-15278 2017-01-19 13:07:56 +03:00
Mikhael Bogdanov
e1bec0df2e Proper generate interval for catch block variable; Fix for KT-15646: InconsistentDebugInfoException when stepping over throw
#KT-15646 Fixed
2017-01-19 09:33:10 +01:00
Denis Zharkov
4ab6b6954d Fix false positive "Null can not be a value of a non-null type"
Inferred type of receiver of orElse  is Optional<T & Any>
Generic descriptor is orElse(E!): E!
Substituted descriptor is orElse(T): T , and that is the problem.

Seems that E!  => (T & Any)!  gets expanded to just T  or T & Any , however it should be expanded to
(T & Any) .. (T & Any)?  => T & Any .. T & Any

T & Any is NotNullTypeParameter(T)

The problem is that (T & Any)?  is expanded to T & Any,
that is seems to be wrong.

 #KT-15236 Fixed
2017-01-19 10:20:35 +03:00
Denis Zharkov
5d4f51d9b6 Refine 1.0-compatibility mode for JDK dependent members
- calls must be prohibited iff they refer to some additonal built in member
- override must be prohibited iff all of the overridden descriptors are additional

Other usages were able to be successfully compiled by 1.0.x

Solution with @Deprecated(level=Error) doesn't work properly, because
deprecation propagates to overridden, thus call 'java.util.ArrayList<String>().stream()'
becomes invalid, while it was correct in 1.0.x

 #KT-15794 Fixed
2017-01-19 10:20:35 +03:00
Dmitry Petrov
b9f9894310 KT-15677 KT-15775
Update parser & descriptor renderer to handle parenthesized types and function types properly.
Resolve annotations in parenthesized types.

AnnotationsImpl.isEmpty() returned false for targeted annotations only
(e.g., 'fun @receiver:Ann C?.foo()').
Properly keep track of targeted annotations.
2017-01-19 09:53:17 +03:00
Ilya Gorbunov
a429992e81 Do not generate headers for JS-only functions. 2017-01-18 22:16:49 +03:00
Łukasz Wojtów
be15dea6b5 Fix typo 2017-01-18 21:51:31 +03:00
Ilya Gorbunov
ed9b9d972c Make 'add' function abstract in AbstractMutableSet in JVM 2017-01-18 20:07:24 +03:00
Mikhail Glukhikh
b6443eed9e Data flow information: stable complex expressions introduced back for brackets / elvis / if / when #KT-13468 Fixed
This reverts commit e515d7f773 and
also commit 1c9f08e986

(cherry picked from commit 9fa155b)
2017-01-18 18:54:08 +03:00
Mikhail Glukhikh
86bc49558d Tests for KT-13468 / KT-13765
(cherry picked from commit 2e4c0b4)
2017-01-18 18:53:55 +03:00
Nikolay Krasko
ffc1624484 Stop using idea isNullOrEmpty function (KT-15786)
#KT-15786 Fixed
2017-01-18 18:36:19 +03:00
Alexander Udalov
4f36376291 Do not report KCLASS_WITH_NULLABLE_ARGUMENT_IN_SIGNATURE anymore
It was only reported in already erroneous cases
2017-01-18 18:21:30 +03:00
Alexander Udalov
d02404b07b Report error on expression of nullable type in class literal
#KT-15740 Fixed
2017-01-18 18:21:29 +03:00
Alexander Udalov
6a352a1da7 Report error on nullable type alias in class literal
#KT-15736 Fixed
2017-01-18 18:21:28 +03:00
Zalim Bashorov
284b9d2ba6 KJS: make deep copy of additional arguments before expose them in KotlinFunctionIntrinsic 2017-01-18 14:43:33 +03:00
Zalim Bashorov
ca2930600a KJS: introduce $kotlin_test_internal$ to expose some helper functions in the tests 2017-01-18 14:42:40 +03:00
Zalim Bashorov
bbd69a05dc KJS: make JSON object and allow to pass null to stringify methods 2017-01-18 14:41:22 +03:00
Zalim Bashorov
1b09fa29fb Fix maven build 2017-01-18 14:40:57 +03:00
Zalim Bashorov
8cf44e9f36 KJS: increase ABI version 2017-01-18 14:40:56 +03:00
Zalim Bashorov
cfba99c704 KJS: remove unused polyfill String.prototype.contains 2017-01-18 14:40:55 +03:00
Zalim Bashorov
264e319487 KJS: type -> kind 2017-01-18 14:40:54 +03:00
Zalim Bashorov
70423e8129 KJS: remove obsolete classIndex 2017-01-18 14:40:51 +03:00
Zalim Bashorov
be694d53ef KJS: trait -> interface 2017-01-18 14:40:50 +03:00
Zalim Bashorov
c6f0d0fa59 KJS: split kotlin_* files to several files 2017-01-18 14:40:49 +03:00
Zalim Bashorov
d635d7859e KJS: remove obsolete kotlin.modules 2017-01-18 14:40:48 +03:00
Zalim Bashorov
3ef1321841 KJS: implement throw* functions in Kotlin 2017-01-18 14:40:47 +03:00
Zalim Bashorov
6f56079f7e KJS: add external declaration for parseFloat; remove obsolete safeParseInt and safeParseDouble 2017-01-18 14:40:46 +03:00
Zalim Bashorov
d0c7c8022e KJS: remove obsolete functions from kotlin_lib.js 2017-01-18 14:40:44 +03:00
Zalim Bashorov
6b38b5f5ba KJS: implement array factory function intrinsics in Kotlin 2017-01-18 14:40:42 +03:00
Zalim Bashorov
a71fbda8a1 KJS: remove deprecated splitWithRegex and it's implementation in kotlin_lib.js 2017-01-18 14:25:36 +03:00
Zalim Bashorov
d985d30f91 KJS: reimplement collectionSort in Kotlin 2017-01-18 14:25:36 +03:00
Zalim Bashorov
20c482598a KJS: reimplement Json.add in Kotlin 2017-01-18 14:25:36 +03:00
Zalim Bashorov
edf1c2da0f KJS: reimplement deleteProperty in Kotlin 2017-01-18 14:25:36 +03:00
Zalim Bashorov
6ea6e4ab98 KJS: move println to kotlin.io; import kotlin.io by default in Default platform 2017-01-18 14:25:36 +03:00
Zalim Bashorov
7f10ce072f KJS: move js part of "kotlin.js" and related files to "js.libraries" module 2017-01-18 14:25:36 +03:00
Zalim Bashorov
08e1f757a9 Minor: fix typo 2017-01-18 14:25:36 +03:00
Zalim Bashorov
45b92be1ae KJS: extract string polyfills to separate file 2017-01-18 14:25:36 +03:00
Zalim Bashorov
12a1c63bda KJS: move some files inside js.libraries module 2017-01-18 14:25:36 +03:00
Mikhael Bogdanov
de52a5bc20 Fixed diagnostic message 2017-01-18 11:19:36 +01:00
Denis Zharkov
22ddfed911 Do not load PlatformDependent annotated built-in members with lv=1.0
#KT-15780 Fixed
2017-01-18 13:00:32 +03:00
Mikhael Bogdanov
591de36666 Added deprecated diagnostic for invoking default methods within jvm-target 1.6 2017-01-18 10:50:59 +01:00
Mikhael Bogdanov
7a27a9d51f Propagate 'CompilerConfiguration' to frontend checkers 2017-01-18 10:23:40 +01:00
Mikhael Bogdanov
9b1c258cdf Android test fix 2017-01-18 10:23:40 +01:00
Denis Zharkov
37b364a70a Fix processing of uninitialized instances for coroutines
The problem is that code in the attached test led to VerifyError at runtime
because the Bar's uninitialized instance created in 'map' was being stored
to the field (leaked from the JVM point of view).

The actual problem was that after repeating visiting of NEW operation
we used to drop the set of already visited copy usages.

For clarification see the comment before 'processUninitializedStores'

 #KT-15016 Fixed
2017-01-18 12:00:46 +03:00
Denis Zharkov
630fab1952 Fix signature of accessor for suspend function
It must be a suspend function too to have an additional Continuation parameter

 #KT-15715 Fixed
2017-01-18 12:00:45 +03:00
Denis Zharkov
d0d617b44e Fix signature mapping for default suspend function from interface
Use jvm suspend function view in function codegen.
Also use SUSPEND_FUNCTION_TO_JVM_VIEW slice if the value exists
for the given key

 #KT-15552 Fixed
2017-01-18 12:00:45 +03:00
Denis Zharkov
fae9cc1c63 Fix codegen issue of safe-qualified suspension points
#KT-15527 Fixed
2017-01-18 12:00:44 +03:00
Denis Zharkov
8cf8e0fce0 Minor. Extract method 2017-01-18 11:44:21 +03:00
Alexey Tsvetkov
f024f14c1e Fix passing friend paths from Gradle to Kotlin daemon when compiling with IC 2017-01-17 19:18:23 +03:00
Alexey Tsvetkov
58fd2530d2 Pass compiler args from facets when compiling in fallback mode from JPS 2017-01-17 19:18:18 +03:00
Ilya Chernikov
3fcbc7bfa3 Rollback commit with native platform lib relocation - it seems breaks functionality on Windows
(cherry picked from commit d3ff19e)
2017-01-17 14:30:28 +01:00
Alexander Udalov
8499db1f42 Update JvmMetadataVersion to 1.1.3
This is needed because 1.1.2 binaries are considered pre-release (see
DeserializedDescriptorResolver), so it wasn't possible to compile
non-pre-release binaries with -language-version 1.0
2017-01-17 15:00:52 +03:00
Yan Zhulanow
5adc3bacff SamWithReceiver: Call onContainerComposed() properly for module dependencies as well. Inject SamWithReceiverResolver by instance. 2017-01-17 20:39:28 +09:00
Alexey Sedunov
75e76dda54 Kotlin Facet: Do not reset configuration if "Use project settings" is switched on
#KT-15735 Fixed
2017-01-16 18:27:30 +03:00
Alexey Sedunov
aeb6af546f Kotlin Facet: Switch off "Use project settings" on Maven/Gradle import
#KT-15682 Fixed
2017-01-16 18:27:29 +03:00
Denis Zharkov
9f217de10b Write kotlin metadata on class-files for coroutine state machines
Otherwise it breaks JPS assumptions, that leads to exceptions like:
Error:Kotlin: [Internal Error] java.lang.AssertionError: Couldn't load KotlinClass from /Users/jetbrains/IdeaProjects/KotlinPlaygroundBeta11/out/production/KotlinPlaygroundBeta11/Counter$both$1.class; it may happen because class doesn't have valid Kotlin annotations
    at org.jetbrains.kotlin.build.GeneratedJvmClass.<init>(generatedFiles.kt:36)
    at org.jetbrains.kotlin.jps.build.KotlinBuilder.getGeneratedFiles(KotlinBuilder.kt:469)
    at org.jetbrains.kotlin.jps.build.KotlinBuilder.doBuild(KotlinBuilder.kt:241)
    at org.jetbrains.kotlin.jps.build.KotlinBuilder.build(KotlinBuilder.kt:140)
...
2017-01-16 17:53:15 +03:00
mglukhikh
93b2c56bb4 Fixed KNPE in convert primary constructor to secondary #KT-14745 Fixed 2017-01-16 17:35:51 +03:00
Dmitry Petrov
cd33a40612 KT-15734
Combine nullability for nested type alias expansion result.
2017-01-16 17:26:28 +03:00
Dmitry Petrov
954204da82 KT-1560
Report warning on extensions shadowed by members.
2017-01-16 17:25:13 +03:00
Nikolay Krasko
ded7d5911b Fix tests
Addition to 5d08e82aaf
2017-01-16 16:05:02 +03:00
Roman Elizarov
25739a08ea CoroutineContext Key and Element are now inside CoroutineContext interface itself (just like Map.Entry)
ContinuationInterceptor companion object is named Key
CoroutineContext.Element property for key is named just key
AbstractCoroutineContextElement implements all of CoroutineContext.Element, including key
2017-01-16 14:33:02 +03:00
Nikolay Krasko
ea7fac07c4 Ban import member intentions from import directives (KT-13710)
#KT-13710 Fixed
2017-01-16 13:00:50 +03:00
Nikolay Krasko
ad72918ff9 Remove deprecated ConcurrentWeakValueHashMap 2017-01-16 13:00:48 +03:00
Nikolay Krasko
5d08e82aaf Fix look up for breakpoint in crossinline lambdas in android (KT-15282)
#KT-15282 Fixed
2017-01-16 13:00:46 +03:00
Mikhail Glukhikh
b94c62649a Create header implementation: select among modules only with configured source roots #KT-15641 Fixed 2017-01-16 11:31:07 +03:00
Ilya Gorbunov
07e529c8ec Fix completion test: expected appearance of 'takeIf' and 'also' 2017-01-16 09:32:17 +03:00
Ilya Gorbunov
914c55b57f Refactor: use new functions in stdlib code 2017-01-16 09:31:45 +03:00
Ilya Gorbunov
1ae56c374f Introduce new function 'takeIf' to replace value with null if it doesn't match the predicate.
#KT-7858
2017-01-16 05:58:51 +03:00
Ilya Gorbunov
1ac9815d76 Introduce new scope function: 'also'. Works like 'apply' but with 'it' instead of 'this' inside lambda.
#KT-6903
2017-01-16 05:58:51 +03:00
Stanislav Erokhin
0ef1234f2e Added special error for incorrect KClass type in signatures. 2017-01-16 05:44:46 +03:00
Ilya Gorbunov
3d70d73964 Rename file class CoroutinesLibraryKt to CoroutinesKt 2017-01-15 20:57:11 +03:00
Yan Zhulanow
1fb90ac0fd Copy compiler arguments from iml even if "Use project settings" checkbox is checked. This is deadly needed for the compiler plugins no-arg and all-open, assuming that the default state of the checkbox is "on". (KT-15686, KT-15686).
This is a temporary fix, and it should be reverted when "Use project settings" will be disabled by default in modules imported from external build tools (Maven, Gradle).
2017-01-15 22:11:11 +09:00
Yan Zhulanow
50a7164efe Kapt3, Gradle: Fix kapt execution in tests. Check filtered dependencies list properly (KT-15459) 2017-01-15 22:11:11 +09:00
Yan Zhulanow
ec291455fa Kapt3: Replace error/NonExistentClass with the actual type (from PSI) (KT-15421) 2017-01-15 22:11:11 +09:00
Yan Zhulanow
ee57446397 Kapt3, Gradle: Prevent circular dependency between kapt and kotlinCompile tasks (KT-15713) 2017-01-15 22:11:11 +09:00
Yan Zhulanow
c136498cc0 Minor: Add uast-kotlin to 'idea' module classpath (fix failing Lint tests) 2017-01-15 22:11:10 +09:00
Ilya Gorbunov
9f303ed06e Migrate to new coroutines API, rename Iterator implementation, annotate new API with SinceKotlin. 2017-01-14 20:14:06 +03:00
Ilya Gorbunov
ffb183a2f3 Move a bit of bytecode out of next() 2017-01-14 20:14:05 +03:00
Ilya Gorbunov
560c184fd4 Merge AbstractIterator and SequenceBuilder, remove hasNext call from next. 2017-01-14 20:14:03 +03:00
Ilya Gorbunov
141ad43039 Introduce buildSequence and buildIterator functions based on coroutines. 2017-01-14 20:14:01 +03:00
Ilya Gorbunov
3225ec8935 Provide headers for coroutine building blocks 2017-01-14 20:14:00 +03:00
Denis Zharkov
14f942aca7 Refine ABI for coroutine lambdas
Make their invoke work in the same way as any other suspend function:
it should return SUSPENDED_MARKER iff. it indeed became suspended
2017-01-14 19:51:05 +03:00
Denis Zharkov
85a3fefcc6 Get rid of SuspendFunctionX interfaces
Use a pair of effectively abstract methods in CoroutineImpl instead
2017-01-14 15:13:37 +03:00
Denis Zharkov
d346cbbe61 Update test data for light-analysis/coroutines 2017-01-14 15:13:37 +03:00
Denis Zharkov
c7f76d7ec8 Minor. Fix tests after CoroutineContext introduction 2017-01-14 15:13:36 +03:00
Denis Zharkov
6a1ad3a279 Get rid of unnecessary additional declarations in tests 2017-01-14 13:24:53 +03:00
Ilya Gorbunov
2dfcb490a5 Fix CoroutineContext tests, update public API dump 2017-01-14 13:24:53 +03:00
Roman Elizarov
8d6a913cee CoroutineContext and ContinuationInterceptor (instead of dispatcher) 2017-01-14 13:24:53 +03:00
Denis Zharkov
f611e39a69 Fix return keyword completetion tests
Now suspendOrReturn is toplevel, so we should explicitly choose "return" item
2017-01-14 13:24:53 +03:00
Denis Zharkov
f56d9cfb26 Ignore failing coroutine related tests on JS 2017-01-14 13:24:53 +03:00
Denis Zharkov
10e67a9b4e Minor. Run Generate tests 2017-01-14 13:24:53 +03:00
Denis Zharkov
c479aa7d65 JS: simplify how suspend functions inlined 2017-01-14 13:24:53 +03:00
Denis Zharkov
2fcc2bbae0 JS: allow to call suspend function from any position within another suspend function 2017-01-14 13:24:53 +03:00
Denis Zharkov
1f0d0028b2 Minor. Simplify coroutine related code in ExpressionCodegen
After previous change (treating suspend function as they return j/l/Object)
most of existing hacks concerning suspend functions' return type
became unnecessary
2017-01-14 13:24:53 +03:00
Denis Zharkov
2286027bed Fix verify error with 'return when/if/try' in suspend function
The problem appears for tail-optimized suspend functions,
we erroneously assumed that when/if/try expressions in tail-call
position have simple types like `I` while actually, they can return SUSPENDED
object, i.e. must have `java/lang/Object` as return type.

But this only concerns branching operations in tail-call position,
so we have to make an additional analysis for remembering whether
a given expression is in a tail-call position.

Also, it's important here that we now assume
the return type of the current function  as `java/lang/Object`
that is necessary to avoid wrong checkcasts.

 #KT-15364 Fixed
2017-01-14 13:24:53 +03:00
Denis Zharkov
de9c41c412 Fix overridability rules for suspend functions
Treat suspend and non-suspend functions as conflicting

 #KT-15413 Fixed
2017-01-14 13:24:53 +03:00
Denis Zharkov
978f53414f Prohibit local suspend functions
#KT-15392 Fixed
2017-01-14 13:24:53 +03:00
Denis Zharkov
d43a4199f8 Prohibit suspend function type in supertype list
#KT-15391 Fixed
2017-01-14 13:24:53 +03:00
Denis Zharkov
f12409504f Prohibit callable references to suspend functions
#KT-15662 Fixed
2017-01-14 13:24:53 +03:00
Denis Zharkov
695b6d9e67 Minor. Add test on local vars of suspend function type 2017-01-14 13:24:53 +03:00
Denis Zharkov
7837d736f7 Merge RestrictedCoroutineImpl into CoroutineImpl 2017-01-14 13:24:53 +03:00
Denis Zharkov
d487c1ef0f Refine dispatching convention
Dispatching happens only via `suspendWithCurrentContinuation` calls
instead of each `resume` call

 #KT-15657 Fixed
2017-01-14 13:24:53 +03:00
Denis Zharkov
0240ab0738 Support non-tail suspend calls in JVM back-end
#KT-15597 In Progress
2017-01-14 13:24:53 +03:00
Denis Zharkov
a048dde7a5 Support non-tail suspend calls in front-end
#KT-15597 In Progress
2017-01-14 13:24:53 +03:00
Denis Zharkov
2cb9d3a8ad Move coroutine intrinsics to kotlin.coroutine.intrinsics package
Also rename val SUSPENDED to SUSPENDED_MARKER

 #KT-15698 Fixed
2017-01-14 13:24:53 +03:00
Alexey Tsvetkov
e0fa11b0c1 Fix handling OUTPUT message from daemon in JPS client 2017-01-13 22:17:41 +03:00
SuperVlad
5edb872224 Fix for KT-9594 J2K: null cast incorrect conversion.
#KT-9594 fixed
2017-01-13 22:03:24 +03:00
Mikhael Bogdanov
e5b8943d41 Added 'languageVersion' parameter to DiagnosticTestLanguageVersionSettings 2017-01-13 18:01:05 +01:00
Mikhael Bogdanov
b88a9025e0 Don't check DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE when compiling to 1.0 2017-01-13 18:01:05 +01:00
Ilya Gorbunov
80f2efb625 joinTo/joinToString: Do not call toString on elements that are already CharSequence or Char.
#KT-15557
2017-01-13 19:49:57 +03:00
Ilya Gorbunov
0c27e07e8c Improve headers of Appendable and StringBuilder 2017-01-13 19:41:59 +03:00
Ilya Gorbunov
afdc7b94da Add headers for print and println.
#KT-15458 fixed
2017-01-13 19:41:59 +03:00
Ilya Gorbunov
be95f66b13 Minor: remove unnecessary header. 2017-01-13 19:41:59 +03:00
Ilya Gorbunov
cdfb72ab76 Provide protected toArray implementation in AbstractCollection.
Relates to #KT-13898
2017-01-13 19:38:28 +03:00
Mikhael Bogdanov
bbf61664ea Test fix 2017-01-13 14:30:01 +01:00
Mikhael Bogdanov
d8b7c7bc34 Added run configuration for Java 8 test on jdk 9 2017-01-13 13:52:58 +01:00
Mikhael Bogdanov
09eeb414fe New test for jvm8 nondefaults target 2017-01-13 13:52:57 +01:00
Mikhael Bogdanov
d278a5c6d5 Move java 8+defaults tests to separate folder 2017-01-13 13:52:57 +01:00
Mikhael Bogdanov
0a363fd1a5 Introduced test flag: JVM8_TARGET_WITH_DEFAULTS 2017-01-13 13:52:56 +01:00
Mikhael Bogdanov
7f8acbb759 Use proper flag for interface method invocation 2017-01-13 13:52:55 +01:00
Mikhael Bogdanov
0f2139f27d InstructionAdapter.invokeX updated to non-deprecated ones 2017-01-13 13:52:55 +01:00
Mikhael Bogdanov
62514e126d Enable jvm 1.8 platform in cli 2017-01-13 13:52:54 +01:00
Mikhael Bogdanov
b6bf53f96f Revert ' Temporary remove JVM_1_8 target from facet settings' 2017-01-13 13:52:54 +01:00
Sergey Mashkov
a3f5d8e68a KT-15673 Couldn't use header function in 3rd module 2017-01-13 15:34:14 +03:00
Sergey Mashkov
39ad8fb22c Maven: tests support for multiplatform projects 2017-01-13 15:34:13 +03:00
Alexey Sedunov
a9645e1ae9 Extract Superclass: Drop inapplicable modifiers when converting property-parameter to ordinary parameter
#KT-15674 Fixed
2017-01-13 15:17:45 +03:00
Alexey Sedunov
ea7bf6b7c1 Extract Interface: Red-highlight members inherited from a super-interface when that interface reference itself is not extracted
#KT-15598 Fixed
2017-01-13 15:17:44 +03:00
Alexey Sedunov
57d364e7d4 Extract Superclass/Interface: Fix bogus visibility warning inside a member when it's being moved as abstract
#KT-15635 Fixed
2017-01-13 15:17:43 +03:00
Alexey Sedunov
65b9049d59 Extract Interface/Pull Up: Warn about private members with usages in the original class
#KT-15606 Fixed
2017-01-13 15:17:42 +03:00
Alexey Sedunov
1c16d2af1a Extract Superclass/Interface/Pull Up: Reformat modifier lists of generated declarations (to add spaces where needed)
#KT-15639 Fixed
2017-01-13 15:17:41 +03:00
Alexey Sedunov
e10b50a648 Extract Interface/Pull Up: Drop 'final' modifier when moving to an interface
#KT-15640 Fixed
2017-01-13 15:17:39 +03:00
Alexey Sedunov
66f1925f16 Extract Interface/Pull Up: Disable internal/protected members when moving to an interface
#KT-15607 Fixed
2017-01-13 15:17:38 +03:00
Alexey Sedunov
c9781f5014 Extract Interface/Pull Up: Disable "Make abstract" and assume it to be true for primary constructor parameter when moving to an interface
#KT-15643 Fixed
2017-01-13 15:17:37 +03:00
Alexey Sedunov
52e9117e9d Extract Superclass/Interface: Allow extracting class with special name (and quotes)
#KT-15353 Fixed
2017-01-13 15:17:37 +03:00
Alexey Sedunov
5de4e9fdac Pull Up/Extract Interface: Disable "Make abstract" and assume it to be true for abstract members of an interface
#KT-15355 Fixed
2017-01-13 15:17:36 +03:00
Alexey Sedunov
8c882f0d27 Override Members: Allow overriding virtual synthetic members (e.g. equals(), hashCode(), toString(), etc.) in data classes
#KT-15563 Fixed
2017-01-13 15:17:35 +03:00
Alexey Sedunov
862966fd33 Override/Implement Members: Support all nullability annotations respected by the Kotlin compiler
#KT-12704 Fixed
 #KT-15583 Fixed
2017-01-13 15:17:34 +03:00
Alexey Sedunov
d94243ac7b Extract Interface: Disable inline/external/lateinit members 2017-01-13 15:17:33 +03:00
Alexey Sedunov
e67d10c028 Extract Interface/Superclass: Disable "Make abstract" for inline/external/lateinit members
#KT-15602 Fixed
2017-01-13 15:17:32 +03:00
Alexey Sedunov
edf5d7da10 Pull Up: Fix subclass map initialization which prevents pull-up from object to superclass 2017-01-13 15:17:31 +03:00
Alexey Sedunov
6fb943765d Extract Interface/Superclass: Disable const-properties
#KT-15611 Fixed
2017-01-13 15:17:30 +03:00
Alexey Tsvetkov
3d07c40887 Minor: rename CompilationResultSink->CompilationResults 2017-01-13 15:08:12 +03:00
Alexey Tsvetkov
bdae0b5efb Fix the build 2017-01-13 15:08:12 +03:00
Alexey Tsvetkov
41c5568b74 Minor: add comment 2017-01-13 15:08:12 +03:00
Alexey Tsvetkov
7a29c00ec3 Minor: fix typo EventManger->EventManager 2017-01-13 15:08:12 +03:00
Alexey Tsvetkov
39b37b85e3 Minor: rename Storage->Sink 2017-01-13 15:08:12 +03:00
Alexey Tsvetkov
f027860ac0 Minor: rename CompilationResult->CompilationResultCategory 2017-01-13 15:08:12 +03:00
Alexey Tsvetkov
a3415d8d0e Minor: move CompilerMode 2017-01-13 15:08:12 +03:00
Alexey Tsvetkov
072edf4b5a Minor: introduce EXCEPTION report category 2017-01-13 15:08:12 +03:00
Alexey Tsvetkov
c2a125ff1c Minor: fix naming 2017-01-13 15:08:12 +03:00
Alexey Tsvetkov
a56c92f28d Minor rename parameters to match parent constructor 2017-01-13 15:08:12 +03:00
Alexey Tsvetkov
2ec9773e15 Minor: fix CompilerMessageSeverity order 2017-01-13 15:08:12 +03:00
Alexey Tsvetkov
16352ff2e5 Refactor messages sending 2017-01-13 15:08:12 +03:00
Alexey Tsvetkov
e44cc43ada Move CompilerMode and TargetPlatform to CompilationOptions 2017-01-13 15:08:12 +03:00
Alexey Tsvetkov
c5a5463f50 Rename AdditionalCompilerArguments->CompilationOptions 2017-01-13 15:08:12 +03:00
Alexey Tsvetkov
bf50a23221 Remove operations tracer from compile() interface 2017-01-13 15:08:12 +03:00
Alexey Tsvetkov
99c72b6dff Refactor JPS daemon client 2017-01-13 15:08:12 +03:00
Alexey Tsvetkov
73f7b76b5d Enable verbose messages when debug is enabled 2017-01-13 15:08:12 +03:00
Alexey Tsvetkov
c9a874cba9 Refactor gradle daemon client 2017-01-13 15:08:12 +03:00
Alexey Tsvetkov
d4d1d5ad0f Refactor daemon interface 2017-01-13 15:08:12 +03:00
Alexey Tsvetkov
d19a92bab5 Make ICReporter interface 2017-01-13 15:08:12 +03:00
Alexey Tsvetkov
d80c1ad10d Add integer value to compiler message severity 2017-01-13 15:08:12 +03:00
Alexey Tsvetkov
1fcd7d07e2 Make compiler arguments serializable 2017-01-13 15:08:12 +03:00
Dmitry Petrov
8756f00849 Fix testData for debugger test. 2017-01-13 13:54:07 +03:00
Ilya Chernikov
1e68b2436f Relocate non-native/jni part of net.rubygrapefruit.platform in attempt to fix #KT-15570 2017-01-13 10:48:29 +01:00
Alexander Udalov
2ba18beb89 Report JVM runtime version inconsistency as errors instead of warnings
(cherry picked from commit f8fc7e94ac)
2017-01-13 11:53:52 +03:00
Alexander Udalov
e3f4b6e77e Do not allow to use suspend functions in 1.0.6+ 2017-01-13 11:53:52 +03:00
Dmitry Petrov
4dd100122b Explicitly remove NOPs inserted for bytecode analysis in post-conditional loops.
Remove redundant NOPs during bytecode optimization.

NOP instruction is required iff one of the following is true:
(a) it is a first bytecode instruction in a try-catch block (JVM BE assumption);
(b) it is a sole bytecode instruction in a source code line (breakpoints on that line will not work).
All other NOP instructions can be removed.

Note that it doesn't really affect the performance for mature JVM implementations.
However, the perceived quality of the generated code is somewhat improved :).

Related: KT-15609
2017-01-13 10:31:07 +03:00
Dmitry Petrov
ba933fa887 KT-15112, KT-15631
Revert changes for "tolerant to uninitialized values" in OptimizationBasicInterpreter:
this approach doesn't converge for some specific cases where local variable is reused
(e.g., in several inlined functions - see https://youtrack.jetbrains.com/issue/KT-15112).

Instead, treat fake always-false conditional jump in the beginning of the post-condition loop as a "reference point" for stack on loop break / continue.
This requires an extra abstraction layer in FixStackAnalyzer, since we can't perform fine-grain manipulations on Frames
(such as "combine frame C from local variables of frame A and stack of frame B").

NB additional NOPs will be generated for post-condition loops.
Should make a separate bytecode postprocessing pass to get rid of unnecessary NOPs
(several YT issues for perceived quality of the generated bytecode are about such NOPs).
2017-01-13 10:31:07 +03:00
Mikhail Glukhikh
c09a71b178 Multi-platform refactoring: get rid of PlatformKind (replace with MultiTargetPlatform) 2017-01-12 18:58:13 +03:00
Mikhail Glukhikh
aeb6bff145 Create header implementation fix: check import directive, change / add it if needed 2017-01-12 18:58:07 +03:00
Alexey Andreev
f33d421bab JS: make JS parser to store function's name in AST. See KT-15475 2017-01-12 18:12:40 +03:00
Alexey Andreev
a016147a79 JS: fix translation of return statement surrounded by try..finally block in suspend lambda. See KT-15625 2017-01-12 18:12:39 +03:00
Alexey Andreev
2907eafa18 JS: make functions called call to inline properly. See KT-7004 2017-01-12 18:12:39 +03:00
Alexey Andreev
10a3fbf53f JS: disable TemporaryAssignmentElimination, fix KT-15512 2017-01-12 18:12:39 +03:00
Alexey Andreev
7d170c0fcd JS: fix translation of reassignment of inline properties. See KT-15590 2017-01-12 18:12:38 +03:00
Alexey Andreev
4eed7c1fcb JS: fix translation of augmented assignment in class initializer. See KT-15569 2017-01-12 18:12:38 +03:00
Alexey Andreev
ee74342fbe JS: fix compiler crash when optimizing JS AST with empty do..while statement. See KT-15513 2017-01-12 18:12:37 +03:00
Alexey Andreev
bad6f41d6e JS: make some JVM tests compatible with JS BE 2017-01-12 18:12:37 +03:00
Alexey Andreev
70176dfacc JS: translate call arguments in the order the occur in source code, not in order of parameters in descriptor. See KT-15506 2017-01-12 18:12:36 +03:00
Alexey Andreev
e6b78f68cd JS: support case when class inherits method from superclass and both implements same method (but with optional parameter) from superinterface. 2017-01-12 18:12:36 +03:00
Alexey Andreev
d2050ace72 JS: refactor generation of functions with optional parameters. Fix #KT-7302, #KT-13888 2017-01-12 18:12:35 +03:00
Simon Ogorodnik
4b3cf432dc KT-5629 Quickfix to import extension method when arguments of non-extension method do not match
#KT-5629 fixed
2017-01-12 18:06:31 +03:00
Dmitry Jemerov
f8f73d338b Use UTryStatement.isResources() instead of getting the resource list (for which there is no portable API ATM) 2017-01-12 14:30:49 +01:00
Simon Ogorodnik
0cf02dcb7b KT-15092 Suppress inspection "use property access syntax" for some getters and fix completion for them
#KT-15092 fixed
2017-01-12 14:53:38 +03:00
Nikolay Krasko
c1538aea43 Get annotation for injection from reference descriptor (KT-15548)
#KT-15548 Fixed
2017-01-12 14:21:47 +03:00
Nikolay Krasko
0cbe19b930 Remove unused files 2017-01-12 13:49:31 +03:00
Alexander Udalov
abe2ad155c Sanitize names for script class files
Use the same process that is done for package parts in the JVM back-end, except
adding the "Kt" suffix

 #KT-15225 Fixed
2017-01-12 11:24:24 +03:00
Alexander Udalov
6ffa56b640 Move name sanitization utilities to module 'descriptors' 2017-01-12 11:24:23 +03:00
Alexander Udalov
f4d59304e2 Fix JvmPackageTableTest by preserving package order in ModuleMapping.create 2017-01-12 11:08:23 +03:00
Svyatoslav Scherbina
d9023bdf70 backend: move some JVM lowering to common 2017-01-12 11:56:32 +07:00
Svyatoslav Scherbina
5a5f4fc224 backend: extract common lowering utils 2017-01-12 11:56:31 +07:00
Svyatoslav Scherbina
f85538129d backend: introduce common backend context 2017-01-12 11:56:30 +07:00
Svyatoslav Scherbina
2e88dd0675 backend: fix minor bug in LocalFunctionsLowering
extension receiver parameter should be remapped too
(e.g. to support lambda with receiver)
2017-01-12 11:56:29 +07:00
Svyatoslav Scherbina
e6c9a709b2 backend: fix minor bug in SharedVariablesLowering 2017-01-12 11:56:28 +07:00
8778 changed files with 124835 additions and 101253 deletions

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-XX:MaxPermSize=100m -J-ea" />
<antCommandLine value="-J-ea" />
<maximumHeapSize value="1024" />
</buildFile>
<buildFile url="file://$PROJECT_DIR$/update_dependencies.xml" />

View File

@@ -11,7 +11,6 @@
<element id="directory" name="META-INF">
<element id="dir-copy" path="$PROJECT_DIR$/jps-plugin/src/META-INF" />
</element>
<element id="extracted-dir" path="$PROJECT_DIR$/dependencies/cli-parser-1.1.2.jar" path-in-jar="/" />
<element id="module-output" name="cli-common" />
<element id="module-output" name="idea-jps-common" />
<element id="module-output" name="jps-plugin" />

View File

@@ -10,6 +10,7 @@
<root id="root">
<element id="directory" name="lib">
<element id="archive" name="kotlin-plugin.jar">
<element id="extracted-dir" path="$PROJECT_DIR$/dependencies/cli-parser-1.1.2.jar" path-in-jar="/" />
<element id="module-output" name="backend" />
<element id="module-output" name="frontend" />
<element id="module-output" name="descriptors" />
@@ -24,6 +25,7 @@
<element id="module-output" name="js.parser" />
<element id="module-output" name="cli-common" />
<element id="module-output" name="idea-jps-common" />
<element id="module-output" name="build-common" />
<element id="module-output" name="preloader" />
<element id="module-output" name="deserialization" />
<element id="module-output" name="backend-common" />

7
.idea/dictionaries/4u7.xml generated Normal file
View File

@@ -0,0 +1,7 @@
<component name="ProjectDictionaryState">
<dictionary name="4u7">
<words>
<w>foldable</w>
</words>
</dictionary>
</component>

View File

@@ -2,6 +2,7 @@
<dictionary name="Nikolay.Krasko">
<words>
<w>accessors</w>
<w>crossinline</w>
<w>fqname</w>
<w>goto</w>
<w>gradle</w>

View File

@@ -1,7 +1,6 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0" is_locked="false">
<profile version="1.0">
<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">
@@ -236,10 +235,6 @@
<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" />
@@ -347,11 +342,12 @@
<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="true" level="ERROR" enabled_by_default="true">
<inspection_tool class="Since15" enabled="false" level="ERROR" enabled_by_default="false">
<scope name="IDEA Test Sources" level="ERROR" enabled="false" />
</inspection_tool>
<inspection_tool class="SocketResource" enabled="true" level="WARNING" enabled_by_default="true">

4
.idea/kotlinc.xml generated
View File

@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="KotlinCommonCompilerArguments">
<option name="languageVersion" value="1.1" />
<option name="apiVersion" value="1.1" />
</component>
<component name="KotlinCompilerSettings">
<option name="additionalArguments" value="-version -Xallow-kotlin-package -Xskip-metadata-version-check" />
</component>

View File

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

View File

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

View File

@@ -9,7 +9,7 @@
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/dependencies/guava-17.0-sources.jar!/" />
<root url="jar://$PROJECT_DIR$/dependencies/guava-19.0-sources.jar!/" />
<root url="jar://$PROJECT_DIR$/dependencies/asm5-src.zip!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.jar!/" />
</SOURCES>

View File

@@ -9,7 +9,7 @@
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/dependencies/guava-17.0-sources.jar!/" />
<root url="jar://$PROJECT_DIR$/dependencies/guava-19.0-sources.jar!/" />
<root url="jar://$PROJECT_DIR$/dependencies/asm5-src.zip!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.jar!/" />
</SOURCES>

View File

@@ -10,7 +10,7 @@
<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$/dependencies/guava-19.0-sources.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.jar!/" />
</SOURCES>
</library>

View File

@@ -5,6 +5,7 @@
</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

@@ -3,11 +3,13 @@
<CLASSES>
<root url="jar://$PROJECT_DIR$/dependencies/uast-common.jar!/" />
<root url="jar://$PROJECT_DIR$/dependencies/uast-java.jar!/" />
<root url="jar://$PROJECT_DIR$/dependencies/uast-tests.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/dependencies/uast-common-sources.jar!/" />
<root url="jar://$PROJECT_DIR$/dependencies/uast-java-sources.jar!/" />
<root url="jar://$PROJECT_DIR$/dependencies/uast-tests-sources.jar!/" />
</SOURCES>
</library>
</component>

3
.idea/misc.xml generated
View File

@@ -6,7 +6,6 @@
</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>
@@ -49,7 +48,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_6" default="false" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="SuppressABINotification">

1
.idea/modules.xml generated
View File

@@ -92,6 +92,7 @@
<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 -Xmx900m -XX:MaxPermSize=320m -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=64m -Djna.nosys=true" />
<option name="VM_PARAMETERS" value="-ea -XX:+HeapDumpOnOutOfMemoryError -Xmx1024m -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 -Xmx1100m -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=128m -Djna.nosys=true" />
<option name="VM_PARAMETERS" value="-ea -XX:+HeapDumpOnOutOfMemoryError -Xmx900m -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

@@ -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 -Xmx700m -XX:MaxPermSize=300m -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=64m -Djna.nosys=true" />
<option name="VM_PARAMETERS" value="-ea -XX:+HeapDumpOnOutOfMemoryError -Xmx1024m -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

@@ -0,0 +1,28 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Java 8 Tests 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.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<module name="compiler-tests-java8" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<option name="ALTERNATIVE_JRE_PATH" value="9-ea" />
<option name="PACKAGE_NAME" value="org.jetbrains.kotlin" />
<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=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" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<envs />
<patterns />
<method />
</configuration>
</component>

View File

@@ -3,6 +3,636 @@
<!-- Find: ([^\`/\[])(KT-\d+) -->
<!-- Replace: $1[`$2`](https://youtrack.jetbrains.com/issue/$2) -->
## 1.1.1
### IDE
- [`KT-16714`](https://youtrack.jetbrains.com/issue/KT-16714) J2K: Write access is allowed from event dispatch thread only
### Compiler
- [`KT-16801`](https://youtrack.jetbrains.com/issue/KT-16801) Accessors of `@PublishedApi` property gets mangled
- [`KT-16673`](https://youtrack.jetbrains.com/issue/KT-16673) Potentially problematic code causes exception when work with SAM adapters
### Libraries
- [`KT-16557`](https://youtrack.jetbrains.com/issue/KT-16557) Correct `SinceKotlin(1.1)` for all declarations in `kotlin.reflect.full`
## 1.1.1-RC
### IDE
- [`KT-16481`](https://youtrack.jetbrains.com/issue/KT-16481) Kotlin debugger & bytecode fail on select statement blocks (IllegalStateException: More than one package fragment)
### Gradle support
- [`KT-15783`](https://youtrack.jetbrains.com/issue/KT-15783) Gradle builds don't use incremental compilation due to an error: "Could not connect to kotlin daemon"
- [`KT-16434`](https://youtrack.jetbrains.com/issue/KT-16434) Gradle plugin does not compile androidTest sources when Jack is enabled
- [`KT-16546`](https://youtrack.jetbrains.com/issue/KT-16546) Enable incremental compilation in gradle by default
### Compiler
- [`KT-16184`](https://youtrack.jetbrains.com/issue/KT-16184) AbstractMethodError in Kapt3ComponentRegistrar while compiling from IntelliJ using Kotlin 1.1.0
- [`KT-16578`](https://youtrack.jetbrains.com/issue/KT-16578) Fix substitutor for synthetic SAM adapters
- [`KT-16581`](https://youtrack.jetbrains.com/issue/KT-16581) VerifyError when calling default value parameter with jvm-target 1.8
- [`KT-16583`](https://youtrack.jetbrains.com/issue/KT-16583) Cannot access private file-level variables inside a class init within the same file if a secondary constructor is present
- [`KT-16587`](https://youtrack.jetbrains.com/issue/KT-16587) AbstractMethodError: Delegates not generated correctly for private interfaces
- [`KT-16598`](https://youtrack.jetbrains.com/issue/KT-16598) Incorrect error: The feature "bound callable references" is only available since language version 1.1
- [`KT-16621`](https://youtrack.jetbrains.com/issue/KT-16621) Kotlin compiler doesn't report an error if a class implements Annotation interface but doesn't implement annotationType method
- [`KT-16441`](https://youtrack.jetbrains.com/issue/KT-16441) `NoSuchFieldError: $$delegatedProperties` when delegating through `provideDelegate` in companion object
### JavaScript support
- Prohibit function types with receiver as parameter types of external declarations
- Remove extension receiver for function parameters in `jQuery` declarations
## 1.1
### Compiler exceptions
- [`KT-16411`](https://youtrack.jetbrains.com/issue/KT-16411) Exception from compiler when try to inline callable reference to class constructor inside object
- [`KT-16412`](https://youtrack.jetbrains.com/issue/KT-16412) Exception from compiler when try call SAM constructor where argument is callable reference to nested class inside object
- [`KT-16413`](https://youtrack.jetbrains.com/issue/KT-16413) When we create sam adapter for java.util.function.Function we add incorrect null-check for argument
### Standard library
- [`KT-6561`](https://youtrack.jetbrains.com/issue/KT-6561) Drop java.util.Collections package from js stdlib
- `javaClass` extension property is no more deprecated due to migration problems
### IDE
- [`KT-16329`](https://youtrack.jetbrains.com/issue/KT-16329) Inspection "Calls to staic methods in Java interfaces..." always reports warning undependent of jvm-target
## 1.1-RC
### Reflection
- [`KT-16358`](https://youtrack.jetbrains.com/issue/KT-16358) Incompatibility between kotlin-reflect 1.0 and kotlin-stdlib 1.1 fixed
### Compiler
#### Coroutine support
- [`KT-15938`](https://youtrack.jetbrains.com/issue/KT-15938) Changed error message for calling suspend function outside of suspendable context
- [`KT-16092`](https://youtrack.jetbrains.com/issue/KT-16092) Backend crash fixed: "Don't know how to generate outer expression" for destructuring suspend lambda
- [`KT-16093`](https://youtrack.jetbrains.com/issue/KT-16093) Annotations are retained during reading the binary representation of suspend functions
- [`KT-16122`](https://youtrack.jetbrains.com/issue/KT-16122) java.lang.VerifyError fixed in couroutines: (String, null, suspend () -> String)
- [`KT-16124`](https://youtrack.jetbrains.com/issue/KT-16124) Marked as UNSUPPORTED: suspension points in default parameters
- [`KT-16219`](https://youtrack.jetbrains.com/issue/KT-16219) Marked as UNSUPPORTED: suspend get/set, in/!in operators for
- [`KT-16145`](https://youtrack.jetbrains.com/issue/KT-16145) Beta-2 coroutine regression fixed (wrong code generation)
#### Kapt3
- [`KT-15524`](https://youtrack.jetbrains.com/issue/KT-15524) Fix javac error reporting in Kotlin daemon
- [`KT-15721`](https://youtrack.jetbrains.com/issue/KT-15721) JetBrains nullability annotations are now returned from Element.getAnnotationMirrors()
- [`KT-16146`](https://youtrack.jetbrains.com/issue/KT-16146) Fixed work in verbose mode
- [`KT-16153`](https://youtrack.jetbrains.com/issue/KT-16153) Ignore declarations with illegal Java identifiers
- [`KT-16167`](https://youtrack.jetbrains.com/issue/KT-16167) Fixed compilation error with kapt arguments in build.gradle
- [`KT-16170`](https://youtrack.jetbrains.com/issue/KT-16170) Stub generator now adds imports for corrected error types to stubs
- [`KT-16176`](https://youtrack.jetbrains.com/issue/KT-16176) javac's finalCompiler log is now used to determine annotation processing errors
#### Backward compatibility
- [`KT-16017`](https://youtrack.jetbrains.com/issue/KT-16017) More graceful error message for disabled features
- [`KT-16073`](https://youtrack.jetbrains.com/issue/KT-16073) Improved backward compatibility mode with version 1.0 on JDK dependent built-ins
- [`KT-16094`](https://youtrack.jetbrains.com/issue/KT-16094) Compiler considers API availability when compiling language features requiring runtime support
- [`KT-16171`](https://youtrack.jetbrains.com/issue/KT-16171) Fixed regression "Unexpected container error on Kotlin 1.0 project"
- [`KT-16199`](https://youtrack.jetbrains.com/issue/KT-16199) Do not import "kotlin.comparisons.*" by default in language version 1.0 mode
#### Various issues
- [`KT-16225`](https://youtrack.jetbrains.com/issue/KT-16225) enumValues non-reified stub implementation references nonexistent method no more
- [`KT-16291`](https://youtrack.jetbrains.com/issue/KT-16291) Smart cast works now when getting class of instance
- [`KT-16380`](https://youtrack.jetbrains.com/issue/KT-16380) Show warning when running the compiler under Java 6 or 7
### JavaScript backend
- [`KT-16144`](https://youtrack.jetbrains.com/issue/KT-16144) Fixed inlining of functions called through inheritor ("fake" override) from another module
- [`KT-16158`](https://youtrack.jetbrains.com/issue/KT-16158) Error is not reported now when library path contains JAR file without JS metadata, report warning instead
- [`KT-16160`](https://youtrack.jetbrains.com/issue/KT-16160) Companion object dispatch receiver translation fixed
### Standard library
- [`KT-7858`](https://youtrack.jetbrains.com/issue/KT-7858) Add extension function `takeUnless`
- `javaClass` extension property is deprecated, use `instance::class.java` instead
- Massive deprecations are coming in JS standard library in `kotlin.dom` and `kotlin.dom.build` packages
### IDE
#### Configuration issues
- [`KT-15899`](https://youtrack.jetbrains.com/issue/KT-15899) Kotlin facet: language and api version for submodule setup for 1.0 are filled now as 1.0 too
- [`KT-15914`](https://youtrack.jetbrains.com/issue/KT-15914) Kotlin facet works now with multi-selected modules in Project Settings too
- [`KT-15954`](https://youtrack.jetbrains.com/issue/KT-15954) Does not suggest to configure kotlin for the module after each new kt-file creation
- [`KT-16157`](https://youtrack.jetbrains.com/issue/KT-16157) freeCompilerArgs are now imported from Gradle into IDEA
- [`KT-16206`](https://youtrack.jetbrains.com/issue/KT-16206) Idea no more refuses to compile a kotlin project defined as a maven project
- [`KT-16312`](https://youtrack.jetbrains.com/issue/KT-16312) Kotlin facet: import from gradle: don't import options which are set implicitly already
- [`KT-16325`](https://youtrack.jetbrains.com/issue/KT-16325) Kotlin facet: correct configuration after upgrading the IDE plugin
- [`KT-16345`](https://youtrack.jetbrains.com/issue/KT-16345) Kotlin facet: detect JavaScript if the module has language 1.0 `kotlin-js-library` dependency
#### Coroutine support
- [`KT-16109`](https://youtrack.jetbrains.com/issue/KT-16109) Error fixed: The -Xcoroutines can only have one value
- [`KT-16251`](https://youtrack.jetbrains.com/issue/KT-16251) Fix detection of suspend calls containing extracted parameters
#### Intention actions, inspections and quick-fixes
##### 2017.1 compatibility
- [`KT-15870`](https://youtrack.jetbrains.com/issue/KT-15870) "Package name does not match containing directory" inspection: fixed throwable "AWT events are not allowed inside write action"
- [`KT-15924`](https://youtrack.jetbrains.com/issue/KT-15924) Create Test action: fixed throwable "AWT events are not allowed inside write action"
##### Bug fixes
- [`KT-14831`](https://youtrack.jetbrains.com/issue/KT-14831) Import statement and FQN are not added on converting lambda to reference for typealias
- [`KT-15545`](https://youtrack.jetbrains.com/issue/KT-15545) Inspection "join with assignment" does not change now execution order for properties
- [`KT-15744`](https://youtrack.jetbrains.com/issue/KT-15744) Fix: intention to import `sleep` wrongly suggests `Thread.sleep`
- [`KT-16000`](https://youtrack.jetbrains.com/issue/KT-16000) Inspection "join with assignment" handles initialization with 'this' correctly
- [`KT-16009`](https://youtrack.jetbrains.com/issue/KT-16009) Auto-import for JDK classes in .kts files
- [`KT-16104`](https://youtrack.jetbrains.com/issue/KT-16104) Don't insert modifiers (e.g. suspend) before visibility
#### Completion
- [`KT-16076`](https://youtrack.jetbrains.com/issue/KT-16076) Completion does not insert more FQN kotlin.text.String
- [`KT-16088`](https://youtrack.jetbrains.com/issue/KT-16088) Completion does not insert more FQN for `kotlin` package
- [`KT-16110`](https://youtrack.jetbrains.com/issue/KT-16110) Keyword 'suspend' completion inside generic arguments
- [`KT-16243`](https://youtrack.jetbrains.com/issue/KT-16243) Performance enhanced after variable of type `ArrayList`
#### Various issues
- [`KT-15291`](https://youtrack.jetbrains.com/issue/KT-15291) 'Find usages' now does not report property access as usage of getter method in Java class with parameter
- [`KT-15647`](https://youtrack.jetbrains.com/issue/KT-15647) Exception fixed: KDoc link to member of class from different package and module
- [`KT-16071`](https://youtrack.jetbrains.com/issue/KT-16071) IDEA deadlock fixed: when typing "parse()" in .kt file
- [`KT-16149`](https://youtrack.jetbrains.com/issue/KT-16149) Intellij Idea 2017.1/Android Studio 2.3 beta3 and Kotlin plugin 1.1-beta2 deadlock fixed
### Coroutine libraries
- [`KT-15716`](https://youtrack.jetbrains.com/issue/KT-15716) Introduced startCoroutineUninterceptedOrReturn coroutine intrinsic
- [`KT-15718`](https://youtrack.jetbrains.com/issue/KT-15718) createCoroutine now returns safe continuation
- [`KT-16155`](https://youtrack.jetbrains.com/issue/KT-16155) Introduced createCoroutineUnchecked intrinsic
### Gradle support
- [`KT-15829`](https://youtrack.jetbrains.com/issue/KT-15829) Gradle Kotlin JS plugin: removed false "Duplicate source root:" warning for kotlin files
- [`KT-15902`](https://youtrack.jetbrains.com/issue/KT-15902) JS: gradle task output is now considered as source set output
- [`KT-16174`](https://youtrack.jetbrains.com/issue/KT-16174) Error fixed during IDEA-Gradle synchronization for Kotlin JS
- [`KT-16267`](https://youtrack.jetbrains.com/issue/KT-16267) JS: fixed regression in 1.1-beta2 for multi-module gradle project
- [`KT-16274`](https://youtrack.jetbrains.com/issue/KT-16274) Kotlin JS Gradle unexpected compiler error / absolute path to output file
- [`KT-16322`](https://youtrack.jetbrains.com/issue/KT-16322) Circlet project Gradle import issue fixed
### REPL
- [`KT-15861`](https://youtrack.jetbrains.com/issue/KT-15861) Use windows line separator in kotlin's JSR implementation
- [`KT-16126`](https://youtrack.jetbrains.com/issue/KT-16126) Proper `jvmTarget` for REPL compilation
## 1.1-Beta2
### Language related changes
- [`KT-7897`](https://youtrack.jetbrains.com/issue/KT-7897) Do not require to call enum constructor for each entry if all parameters have default values
- [`KT-8985`](https://youtrack.jetbrains.com/issue/KT-8985) Support T::class.java for T with no non-null upper bound
- [`KT-10711`](https://youtrack.jetbrains.com/issue/KT-10711) Type inference works now on generics for callable references
- [`KT-13130`](https://youtrack.jetbrains.com/issue/KT-13130) Support exhaustive when for sealed trees
- [`KT-15898`](https://youtrack.jetbrains.com/issue/KT-15898) Cannot use type alias to qualify enum entry
- [`KT-16061`](https://youtrack.jetbrains.com/issue/KT-16061) Smart type inference on callable references in 1.1 mode only
### Reflection
- [`KT-8384`](https://youtrack.jetbrains.com/issue/KT-8384) Access to the delegate object for a KProperty
### Compiler
#### Coroutine support
- [`KT-15016`](https://youtrack.jetbrains.com/issue/KT-15016) VerifyError with coroutine: fix processing of uninitialized instances
- [`KT-15527`](https://youtrack.jetbrains.com/issue/KT-15527) Coroutine compile error: wrong code generated for safe qualified suspension points
- [`KT-15552`](https://youtrack.jetbrains.com/issue/KT-15552) Accessor implementation of suspended function produces AbstractMethodError
- [`KT-15715`](https://youtrack.jetbrains.com/issue/KT-15715) Coroutine generate invalid invoke
- [`KT-15820`](https://youtrack.jetbrains.com/issue/KT-15820) Coroutine Internal Error regression with dispatcher + this@
- [`KT-15821`](https://youtrack.jetbrains.com/issue/KT-15821) Coroutine internal error regression: Could not inline method call apply
- [`KT-15824`](https://youtrack.jetbrains.com/issue/KT-15824) Coroutine iterator regression: Object cannot be cast to java.lang.Boolean
- [`KT-15827`](https://youtrack.jetbrains.com/issue/KT-15827) Show Kotlin Bytecode shows wrong bytecode for suspending functions
- [`KT-15907`](https://youtrack.jetbrains.com/issue/KT-15907) Bogus error about platform declaration clash with private suspend functions
- [`KT-15933`](https://youtrack.jetbrains.com/issue/KT-15933) Suspend getValue/setValue/provideDelegate do not work properly
- [`KT-15935`](https://youtrack.jetbrains.com/issue/KT-15935) Private suspend function in file causes UnsupportedOperationException: Context does not have a "this"
- [`KT-15963`](https://youtrack.jetbrains.com/issue/KT-15963) Coroutine: runtime error if returned object "equals" does not like comparison to SUSPENDED_MARKER
- [`KT-16068`](https://youtrack.jetbrains.com/issue/KT-16068) Prohibit inline lambda parameters of suspend function type
#### Diagnostics
- [`KT-1560`](https://youtrack.jetbrains.com/issue/KT-1560) Report diagnostic for a declaration of extension function which will be always shadowed by member function
- [`KT-12846`](https://youtrack.jetbrains.com/issue/KT-12846) Forbid vararg of Nothing
- [`KT-13227`](https://youtrack.jetbrains.com/issue/KT-13227) NO_ELSE_IN_WHEN in when by sealed class instance if is-check for base sealed class is used
- [`KT-13355`](https://youtrack.jetbrains.com/issue/KT-13355) Type mismatch on inheritance is not reported on abstract class
- [`KT-15010`](https://youtrack.jetbrains.com/issue/KT-15010) Missing error on an usage of non-constant property in annotation default argument
- [`KT-15201`](https://youtrack.jetbrains.com/issue/KT-15201) Compiler is complaining about when statement without null condition even if null is checked before.
- [`KT-15736`](https://youtrack.jetbrains.com/issue/KT-15736) Report an error on type alias expanded to a nullable type on LHS of a class literal
- [`KT-15740`](https://youtrack.jetbrains.com/issue/KT-15740) Report error on expression of a nullable type on LHS of a class literal
- [`KT-15844`](https://youtrack.jetbrains.com/issue/KT-15844) Do not allow to access primary constructor parameters from property with custom getter
- [`KT-15878`](https://youtrack.jetbrains.com/issue/KT-15878) Extension shadowed by member should not be reported for infix/operator extensions when member is non-infix/operator
- [`KT-16010`](https://youtrack.jetbrains.com/issue/KT-16010) Do not highlight lambda parameters as unused in 1.0 compatibility mode
#### Kapt
- [`KT-15675`](https://youtrack.jetbrains.com/issue/KT-15675) Kapt3 does not generate classes annotated with AutoValue
- [`KT-15697`](https://youtrack.jetbrains.com/issue/KT-15697) If an annotation with AnnotationTarget.PROPERTY is tagged on a Kotlin property, it breaks annotation processing
- [`KT-15803`](https://youtrack.jetbrains.com/issue/KT-15803) Kotlin 1.0.6 broke Dagger
- [`KT-15814`](https://youtrack.jetbrains.com/issue/KT-15814) Regression: Kapt is not working in 1.0.6 / 1.1-M04 / 1.1-Beta
- [`KT-15838`](https://youtrack.jetbrains.com/issue/KT-15838) kapt3 1.1-beta: KaptError: Java file parsing error
- [`KT-15841`](https://youtrack.jetbrains.com/issue/KT-15841) 1.1-Beta + kapt3 fails to build the project with StackOverflowError
- [`KT-15915`](https://youtrack.jetbrains.com/issue/KT-15915) Kapt: Kotlin class target directory is cleared before compilation (and after kapt task)
- [`KT-16006`](https://youtrack.jetbrains.com/issue/KT-16006) Cannot determine if type is an error type during annotation processing
#### Exceptions / Errors
- [`KT-8264`](https://youtrack.jetbrains.com/issue/KT-8264) Internal compiler error: java.lang.ArithmeticException: BigInteger: modulus not positive
- [`KT-14547`](https://youtrack.jetbrains.com/issue/KT-14547) NoSuchElementException when compiling callable reference without stdlib in the classpath
- [`KT-14966`](https://youtrack.jetbrains.com/issue/KT-14966) Regression: VerifyError on access super implementation from delegate
- [`KT-15017`](https://youtrack.jetbrains.com/issue/KT-15017) Throwing exception in the end of inline suspend-functions lead to internal compiler error
- [`KT-15439`](https://youtrack.jetbrains.com/issue/KT-15439) Resolved call is not completed for generic callable reference in if-expression
- [`KT-15500`](https://youtrack.jetbrains.com/issue/KT-15500) Exception passing freeCompilerArgs to gradle plugin
- [`KT-15646`](https://youtrack.jetbrains.com/issue/KT-15646) InconsistentDebugInfoException when stepping over `throw`
- [`KT-15726`](https://youtrack.jetbrains.com/issue/KT-15726) Kotlin compiles invalid bytecode for nested try-catch with return
- [`KT-15743`](https://youtrack.jetbrains.com/issue/KT-15743) Overloaded Kotlin extensions annotates wrong parameters in java
- [`KT-15868`](https://youtrack.jetbrains.com/issue/KT-15868) NPE when comparing nullable doubles for equality
- [`KT-15995`](https://youtrack.jetbrains.com/issue/KT-15995) Can't build project with DataBinding using Kotlin 1.1: incompatible language version
- [`KT-16047`](https://youtrack.jetbrains.com/issue/KT-16047) Internal Error: org.jetbrains.kotlin.util.KotlinFrontEndException while analyzing expression
#### Type inference issues
- [`KT-10268`](https://youtrack.jetbrains.com/issue/KT-10268) Wrong type inference related to captured types
- [`KT-11259`](https://youtrack.jetbrains.com/issue/KT-11259) Wrong type inference for Java 8 Stream.collect.
- [`KT-12802`](https://youtrack.jetbrains.com/issue/KT-12802) Type inference failed when irrelevant method reference is used
- [`KT-12964`](https://youtrack.jetbrains.com/issue/KT-12964) Support type inference for callable references from parameter types of an expected function type
#### Smart cast issues
- [`KT-13468`](https://youtrack.jetbrains.com/issue/KT-13468) Smart cast is broken after assignment of 'if' expression
- [`KT-14350`](https://youtrack.jetbrains.com/issue/KT-14350) Make smart-cast work as it does in 1.0 when -language-version 1.0 is used
- [`KT-14597`](https://youtrack.jetbrains.com/issue/KT-14597) When over smartcast enum is broken and breaks all other "when"
- [`KT-15792`](https://youtrack.jetbrains.com/issue/KT-15792) Wrong smart cast after y = x, x = null, y != null sequence
#### Various issues
- [`KT-15236`](https://youtrack.jetbrains.com/issue/KT-15236) False positive: Null can not be a value of a non-null type
- [`KT-15677`](https://youtrack.jetbrains.com/issue/KT-15677) Modifiers and annotations are lost on a (nullable) parenthesized type
- [`KT-15707`](https://youtrack.jetbrains.com/issue/KT-15707) IDEA unable to parallel compile different projects
- [`KT-15734`](https://youtrack.jetbrains.com/issue/KT-15734) Nullability is lost during expansion of a type alias
- [`KT-15748`](https://youtrack.jetbrains.com/issue/KT-15748) Type alias constructor return type should have a corresponding abbreviation
- [`KT-15775`](https://youtrack.jetbrains.com/issue/KT-15775) Annotations are lost on value parameter types of a function type
- [`KT-15780`](https://youtrack.jetbrains.com/issue/KT-15780) Treat Map.getOrDefault overrides in Java the same way as in 1.0.x compiler with language version 1.0
- [`KT-15794`](https://youtrack.jetbrains.com/issue/KT-15794) Refine backward compatibility mode for additional built-ins members from JDK
- [`KT-15848`](https://youtrack.jetbrains.com/issue/KT-15848) Implement additional annotation processing in the `KotlinScriptDefinitionFromAnnotatedTemplate` for SamWithReceiver plugin
- [`KT-15875`](https://youtrack.jetbrains.com/issue/KT-15875) Operation has lead to overflow for 'mod' with negative first operand
- [`KT-15945`](https://youtrack.jetbrains.com/issue/KT-15945) Feature Request: Andrey Breslav to grow a beard.
### JavaScript backend
#### Coroutine support
- [`KT-15834`](https://youtrack.jetbrains.com/issue/KT-15834) JS: Local delegate in suspend function
- [`KT-15892`](https://youtrack.jetbrains.com/issue/KT-15892) JS: safe call of suspend functions causes compiler to crash
#### Diagnostics
- [`KT-14668`](https://youtrack.jetbrains.com/issue/KT-14668) Do not allow declarations in 'kotlin' package or subpackages in JS
- [`KT-15184`](https://youtrack.jetbrains.com/issue/KT-15184) JS: prohibit `..` operation with `dynamic` on left-hand side
- [`KT-15253`](https://youtrack.jetbrains.com/issue/KT-15253) JS: no error when use class external class with JsModule in type context when compiling with plain module kind
- [`KT-15283`](https://youtrack.jetbrains.com/issue/KT-15283) JS: additional restrictions on dynamic
- [`KT-15961`](https://youtrack.jetbrains.com/issue/KT-15961) Could not implement external open class with function with optional parameter
#### Language feature support
- [`KT-14035`](https://youtrack.jetbrains.com/issue/KT-14035) JS: support implementing CharSequence
- [`KT-14036`](https://youtrack.jetbrains.com/issue/KT-14036) JS: use Int16 for Char when it possible and box to our Char otherwise
- [`KT-14097`](https://youtrack.jetbrains.com/issue/KT-14097) Wrong code generated for enum entry initialization using non-primary no-argument constructor
- [`KT-15312`](https://youtrack.jetbrains.com/issue/KT-15312) JS: map kotlin.Throwable to JS Error
- [`KT-15765`](https://youtrack.jetbrains.com/issue/KT-15765) JS: support callable references on built-in and intrinsic functions and properties
- [`KT-15900`](https://youtrack.jetbrains.com/issue/KT-15900) JS: Support enum entry with empty initializer with vararg constructor
#### Standard library support
- [`KT-4141`](https://youtrack.jetbrains.com/issue/KT-4141) JS: wrong return type for Date::getTime
- [`KT-4497`](https://youtrack.jetbrains.com/issue/KT-4497) JS: add String.toInt, String.toDouble etc extension functions, `parseInt` and `parseFloat` are deprecated in favor of these new ones
- [`KT-15940`](https://youtrack.jetbrains.com/issue/KT-15940) JS: rename all js standard library artifacts (both in maven and in compiler distribution) to `kotlin-stdlib-js.jar`
- Add `Promise<T>` external declaration to the standard library
- Types like `Date`, `Math`, `Console`, `Promise`, `RegExp`, `Json` require explicit import from `kotlin.js` package
#### External declarations
- [`KT-15144`](https://youtrack.jetbrains.com/issue/KT-15144) JS: rename `noImpl` to `definedExternally`
- [`KT-15306`](https://youtrack.jetbrains.com/issue/KT-15306) JS: allow to use `definedExternally` only inside a body of external declarations
- [`KT-15336`](https://youtrack.jetbrains.com/issue/KT-15336) JS: allow to inherit external classes from kotlin.Throwable
- [`KT-15905`](https://youtrack.jetbrains.com/issue/KT-15905) JS: add a way to control qualifier for external declarations inside file
- Deprecate `@native` annotation, to be removed in 1.1 release.
#### Exceptions / Errors
- [`KT-10894`](https://youtrack.jetbrains.com/issue/KT-10894) Infinite indexing at projects with JS modules
- [`KT-14124`](https://youtrack.jetbrains.com/issue/KT-14124) AssertionError: strings file not found on K2JS serialized data
#### Various issues
- [`KT-8211`](https://youtrack.jetbrains.com/issue/KT-8211) JS: generate dummy init for properties w/o initializer to avoid to have different hidden classes for different instances
- [`KT-12712`](https://youtrack.jetbrains.com/issue/KT-12712) JS: Json should not be a class
- [`KT-13312`](https://youtrack.jetbrains.com/issue/KT-13312) JS: can't use extension lambda where expected lambda and vice versa
- [`KT-13632`](https://youtrack.jetbrains.com/issue/KT-13632) Add template kotlin js project under gradle in "New Project" window
- [`KT-15278`](https://youtrack.jetbrains.com/issue/KT-15278) JS: don't treat property access through dynamic as side effect free
- [`KT-15285`](https://youtrack.jetbrains.com/issue/KT-15285) JS: take into account as many characteristics from the signature as possible when mangling
- [`KT-15678`](https://youtrack.jetbrains.com/issue/KT-15678) JS: Generated local variable named 'element' clashes with actual local variable named 'element'
- [`KT-15755`](https://youtrack.jetbrains.com/issue/KT-15755) JS compiler produces a lot of empty kotlin_file_table files for irrelevant packages
- [`KT-15770`](https://youtrack.jetbrains.com/issue/KT-15770) Name clash between recursive local functions with same name
- [`KT-15797`](https://youtrack.jetbrains.com/issue/KT-15797) JS: wrong code for accessing nested class inside js module
- [`KT-15863`](https://youtrack.jetbrains.com/issue/KT-15863) JS: Extension function reference shifts parameters loosing the receiver
- [`KT-16049`](https://youtrack.jetbrains.com/issue/KT-16049) JS: drop "-kjsm" command line option, merge the logic into "-meta-info"
- [`KT-16083`](https://youtrack.jetbrains.com/issue/KT-16083) JS: rename "-library-files" argument to "-libraries" and change separator from comma to system file separator
### Standard Library
- [`KT-13353`](https://youtrack.jetbrains.com/issue/KT-13353) Add Map.minus(key) and Map.minus(keys)
- [`KT-13826`](https://youtrack.jetbrains.com/issue/KT-13826) Add parameter names in function types used in the standard library
- [`KT-14279`](https://youtrack.jetbrains.com/issue/KT-14279) Make String.matches(Regex) and Regex.matches(String) infix
- [`KT-15399`](https://youtrack.jetbrains.com/issue/KT-15399) Iterable.average() now returns NaN for an empty collection
- [`KT-15975`](https://youtrack.jetbrains.com/issue/KT-15975) Move coroutine-related runtime parts to `kotlin.coroutines.experimental` package
- [`KT-16030`](https://youtrack.jetbrains.com/issue/KT-16030) Move bitwise operations on Byte and Short to `kotlin.experimental` package
- [`KT-16026`](https://youtrack.jetbrains.com/issue/KT-16026) Classes compiled in 1.1 in 1.0-compatibility mode may contain references to CloseableKt class from 1.1
### IDE
#### Configuration issues
- [`KT-15621`](https://youtrack.jetbrains.com/issue/KT-15621) Copy compiler options values from project settings on creating a kotlin facet for Kotlin (JVM) project
- [`KT-15623`](https://youtrack.jetbrains.com/issue/KT-15623) Copy compiler options values from project settings on creating a kotlin facet for Kotlin (JavaScript) project
- [`KT-15624`](https://youtrack.jetbrains.com/issue/KT-15624) Set option "Use project settings" in newly created Kotlin facet
- [`KT-15712`](https://youtrack.jetbrains.com/issue/KT-15712) Configuring a project with Maven or Gradle should automatically use stdlib-jre7 or stdlib-jre8 instead of standard stdlib
- [`KT-15772`](https://youtrack.jetbrains.com/issue/KT-15772) Facet does not pick up api version from maven
- [`KT-15819`](https://youtrack.jetbrains.com/issue/KT-15819) It would be nice if compileKotlin options are imported into Kotlin facet from gradle/maven
- [`KT-16015`](https://youtrack.jetbrains.com/issue/KT-16015) Prohibit api-version > language-version in Facet and Project Settings
#### Coroutine support
- [`KT-14704`](https://youtrack.jetbrains.com/issue/KT-14704) Extract Method should work in coroutines
- [`KT-15955`](https://youtrack.jetbrains.com/issue/KT-15955) Quick-fix to enable coroutines through Gradle project configuration
- [`KT-16018`](https://youtrack.jetbrains.com/issue/KT-16018) Hide coroutines intrinsics from import and completion
- [`KT-16075`](https://youtrack.jetbrains.com/issue/KT-16075) Error:Kotlin: The -Xcoroutines can only have one value
#### Backward compatibility issues
- [`KT-15134`](https://youtrack.jetbrains.com/issue/KT-15134) Do not suggest using destructuring lambda if this will result in "available since 1.1" error
- [`KT-15918`](https://youtrack.jetbrains.com/issue/KT-15918) Quick fix "Set module language level to 1.1" should also set API version to 1.1
- [`KT-15969`](https://youtrack.jetbrains.com/issue/KT-15969) Replace operator with function should use either rem or mod for % depending on language version
- [`KT-15978`](https://youtrack.jetbrains.com/issue/KT-15978) Type alias from Kotlin 1.1 are suggested in completion even if language level is set to 1.0 in settings
- [`KT-15979`](https://youtrack.jetbrains.com/issue/KT-15979) Usages of type aliases are not shown as errors in editor if language version is set to 1.0
- [`KT-16019`](https://youtrack.jetbrains.com/issue/KT-16019) Do not suggest renaming to underscore in 1.0 compatibility mode
- [`KT-16036`](https://youtrack.jetbrains.com/issue/KT-16036) "Create type alias from usage" quick-fix should not be suggested at language level 1.0
#### Intention actions, inspections and quick-fixes
##### New features
- [`KT-9912`](https://youtrack.jetbrains.com/issue/KT-9912) Merge ifs intention
- [`KT-13427`](https://youtrack.jetbrains.com/issue/KT-13427) "Specify type explicitly" should support type aliases
- [`KT-15066`](https://youtrack.jetbrains.com/issue/KT-15066) "Make private/.." intention on type aliases
- [`KT-15709`](https://youtrack.jetbrains.com/issue/KT-15709) Add inspection for private primary constructors in data classes as they are accessible via the copy method
- [`KT-15738`](https://youtrack.jetbrains.com/issue/KT-15738) Intention to add `suspend` modifier to functional type
- [`KT-15800`](https://youtrack.jetbrains.com/issue/KT-15800) Quick-fix to convert a function to suspending on error when calling suspension inside
##### Bug fixes
- [`KT-13710`](https://youtrack.jetbrains.com/issue/KT-13710) Import intention action should not appear in import list
- [`KT-14680`](https://youtrack.jetbrains.com/issue/KT-14680) import statement to type alias reported as unused when using only TA constructor
- [`KT-14856`](https://youtrack.jetbrains.com/issue/KT-14856) TextView internationalisation intention does not report the problem
- [`KT-14993`](https://youtrack.jetbrains.com/issue/KT-14993) Keep destructuring declaration parameter on inspection "Remove explicit lambda parameter types"
- [`KT-14994`](https://youtrack.jetbrains.com/issue/KT-14994) PsiInvalidElementAccessException and incorrect generation on inspection "Specify type explicitly" on destructuring parameter
- [`KT-15162`](https://youtrack.jetbrains.com/issue/KT-15162) "Remove explicit lambda parameter types" intentions fails with destructuring declaration with KNPE at KtPsiFactory.createLambdaParameterList()
- [`KT-15311`](https://youtrack.jetbrains.com/issue/KT-15311) "Add Import" intention generates incorrect code
- [`KT-15406`](https://youtrack.jetbrains.com/issue/KT-15406) Convert to secondary constructor for enum class should put new members after enum values
- [`KT-15553`](https://youtrack.jetbrains.com/issue/KT-15553) Copy concatenation text to clipboard with Kotlin and string interpolation does not work
- [`KT-15670`](https://youtrack.jetbrains.com/issue/KT-15670) 'Convert to lambda' quick fix in IDEA leaves single-line comment and } gets commented out
- [`KT-15873`](https://youtrack.jetbrains.com/issue/KT-15873) Alt+Enter menu isn't shown for deprecated mod function
- [`KT-15874`](https://youtrack.jetbrains.com/issue/KT-15874) Replace operator with function call replaces % with deprecated mod
- [`KT-15884`](https://youtrack.jetbrains.com/issue/KT-15884) False positive "Redundant .let call"
- [`KT-16072`](https://youtrack.jetbrains.com/issue/KT-16072) Intentions to convert suspend lambdas to callable references should not be shown
#### Android support
- [`KT-13275`](https://youtrack.jetbrains.com/issue/KT-13275) Kotlin Gradle plugin for Android does not work when jackOptions enabled
- [`KT-15150`](https://youtrack.jetbrains.com/issue/KT-15150) Android: Add quick-fix to generate View constructor convention
- [`KT-15282`](https://youtrack.jetbrains.com/issue/KT-15282) Issues debugging crossinline Android code
#### KDoc
- [`KT-14710`](https://youtrack.jetbrains.com/issue/KT-14710) Sample references are not resolved in IDE
- [`KT-15796`](https://youtrack.jetbrains.com/issue/KT-15796) Import of class referenced only in KDoc not preserved after copy-paste
#### Various issues
- [`KT-9011`](https://youtrack.jetbrains.com/issue/KT-9011) Shift+Enter should insert curly braces when invoked after class declaration
- [`KT-11308`](https://youtrack.jetbrains.com/issue/KT-11308) Hide kotlin.jvm.internal package contents from completion and auto-import
- [`KT-14252`](https://youtrack.jetbrains.com/issue/KT-14252) Completion could suggest constructors available via type aliases
- [`KT-14722`](https://youtrack.jetbrains.com/issue/KT-14722) Completion list isn't filled up for type alias to object
- [`KT-14767`](https://youtrack.jetbrains.com/issue/KT-14767) Type alias to annotation class should appear in the completion list
- [`KT-14859`](https://youtrack.jetbrains.com/issue/KT-14859) "Parameter Info" sometimes does not work properly inside lambda
- [`KT-15032`](https://youtrack.jetbrains.com/issue/KT-15032) Injected fragment: descriptor was not found for declaration: FUN
- [`KT-15153`](https://youtrack.jetbrains.com/issue/KT-15153) Support typeAlias extensions in completion and add import
- [`KT-15786`](https://youtrack.jetbrains.com/issue/KT-15786) NoSuchMethodError: com.intellij.util.containers.UtilKt.isNullOrEmpty
- [`KT-15883`](https://youtrack.jetbrains.com/issue/KT-15883) Generating equals() and hashCode(): hashCode does not correctly honor variable names with back ticks
- [`KT-15911`](https://youtrack.jetbrains.com/issue/KT-15911) Kotlin REPL will not launch: "Neither main class nor JAR path is specified"
### J2K
- [`KT-15789`](https://youtrack.jetbrains.com/issue/KT-15789) Kotlin plugin incorrectly converts for-loops from Java to Kotlin
### Gradle support
- [`KT-14830`](https://youtrack.jetbrains.com/issue/KT-14830) Kotlin Gradle plugin configuration should not add 'kotlin' source directory by default
- [`KT-15279`](https://youtrack.jetbrains.com/issue/KT-15279) 'Kotlin not configured message' should not be displayed while gradle sync is in progress
- [`KT-15812`](https://youtrack.jetbrains.com/issue/KT-15812) Create Kotlin facet on importing gradle project with unchecked option Create separate module per source set
- [`KT-15837`](https://youtrack.jetbrains.com/issue/KT-15837) Gradle compiler attempts to connect to daemon on address derived from DNS lookup
- [`KT-15909`](https://youtrack.jetbrains.com/issue/KT-15909) Copy Gradle compiler options to facets in Intellij/AS
- [`KT-15929`](https://youtrack.jetbrains.com/issue/KT-15929) Gradle project imported with wrong 'target platform'
### Other issues
- [`KT-15450`](https://youtrack.jetbrains.com/issue/KT-15450) JSR 223 - support eval with bindings
## 1.1.0-Beta
### Reflection
- [`KT-15540`](https://youtrack.jetbrains.com/issue/KT-15540) findAnnotation returns T?, but it throws NoSuchElementException when there is no matching annotation
- Reflection API in `kotlin-reflect` library is moved to `kotlin.reflect.full` package, declarations in the package `kotlin.reflect` are left deprecated. Please migrate according to the hints provided.
### Compiler
#### Coroutine support
- [`KT-15379`](https://youtrack.jetbrains.com/issue/KT-15379) Allow invoke on instances of suspend function type inside suspend function
- [`KT-15380`](https://youtrack.jetbrains.com/issue/KT-15380) Support suspend function type with value parameters
- [`KT-15391`](https://youtrack.jetbrains.com/issue/KT-15391) Prohibit suspend function type in supertype list
- [`KT-15392`](https://youtrack.jetbrains.com/issue/KT-15392) Prohibit local suspending function
- [`KT-15413`](https://youtrack.jetbrains.com/issue/KT-15413) Override regular functions with suspending ones and vice versa
- [`KT-15657`](https://youtrack.jetbrains.com/issue/KT-15657) Refine dispatchResume convention
- [`KT-15662`](https://youtrack.jetbrains.com/issue/KT-15662) Prohibit callable references to suspend functions
#### Diagnostics
- [`KT-9630`](https://youtrack.jetbrains.com/issue/KT-9630) Cannot create extension function on intersection of types
- [`KT-11398`](https://youtrack.jetbrains.com/issue/KT-11398) Possible false positive for INACCESSIBLE_TYPE
- [`KT-13593`](https://youtrack.jetbrains.com/issue/KT-13593) Do not report USELESS_ELVIS_RIGHT_IS_NULL for left argument with platform type
- [`KT-13859`](https://youtrack.jetbrains.com/issue/KT-13859) Wrong error about using unrepeatable annotation when mix implicit and explicit targets
- [`KT-14179`](https://youtrack.jetbrains.com/issue/KT-14179) Prohibit to use enum entry as type parameter
- [`KT-15097`](https://youtrack.jetbrains.com/issue/KT-15097) Inherited platform declarations clash: regression under 1.1 when indirectly inheriting from java.util.Map
- [`KT-15287`](https://youtrack.jetbrains.com/issue/KT-15287) Kotlin runtime 1.1 and runtime 1.0.x: Overload resolution ambiguity
- [`KT-15334`](https://youtrack.jetbrains.com/issue/KT-15334) Incorrect "val cannot be reassigned" inside do-while
- [`KT-15410`](https://youtrack.jetbrains.com/issue/KT-15410) "Protected function call from public-API inline function" for protected constructor call
#### Kapt3
- [`KT-15145`](https://youtrack.jetbrains.com/issue/KT-15145) Kapt3: Doesn't compile with multiple errors
- [`KT-15232`](https://youtrack.jetbrains.com/issue/KT-15232) Kapt3 crash due to java codepage
- [`KT-15359`](https://youtrack.jetbrains.com/issue/KT-15359) Kapt3 exception while annotation processing (DataBindings AS2.3-beta1)
- [`KT-15375`](https://youtrack.jetbrains.com/issue/KT-15375) Kapt3 can't find ${env.JDK_18}/lib/tools.jar
- [`KT-15381`](https://youtrack.jetbrains.com/issue/KT-15381) Unresolved references: R with Kapt3
- [`KT-15397`](https://youtrack.jetbrains.com/issue/KT-15397) Kapt3 doesn't work with databinding
- [`KT-15409`](https://youtrack.jetbrains.com/issue/KT-15409) Kapt3 Cannot find the getter for attribute 'android:text' with value type java.lang.String on android.widget.EditText.
- [`KT-15421`](https://youtrack.jetbrains.com/issue/KT-15421) Kapt3: Substitute types from Psi instead of writing NonExistentClass for generated type names
- [`KT-15459`](https://youtrack.jetbrains.com/issue/KT-15459) Kapt3 doesn't generate code in test module
- [`KT-15524`](https://youtrack.jetbrains.com/issue/KT-15524) Kapt3 - Error messages should display associated element information (if available)
- [`KT-15713`](https://youtrack.jetbrains.com/issue/KT-15713) Kapt3: circular dependencies between Gradke tasks
#### Exceptions / Errors
- [`KT-11401`](https://youtrack.jetbrains.com/issue/KT-11401) Error type encountered for implicit invoke with function literal argument
- [`KT-12044`](https://youtrack.jetbrains.com/issue/KT-12044) Assertion "Rewrite at slice LEXICAL_SCOPE" for 'if' with property references
- [`KT-14011`](https://youtrack.jetbrains.com/issue/KT-14011) Compiler crash when inlining: lateinit property allRecapturedParameters has not been initialized
- [`KT-14868`](https://youtrack.jetbrains.com/issue/KT-14868) CCE in runtime while converting Number to Char
- [`KT-15364`](https://youtrack.jetbrains.com/issue/KT-15364) VerifyError: Bad type on operand stack on ObserverIterator.hasNext
- [`KT-15373`](https://youtrack.jetbrains.com/issue/KT-15373) Internal error when running TestNG test
- [`KT-15437`](https://youtrack.jetbrains.com/issue/KT-15437) VerifyError: Bad local variable type on simplest provideDelegate
- [`KT-15446`](https://youtrack.jetbrains.com/issue/KT-15446) Property reference on an instance of subclass causes java.lang.VerifyError
- [`KT-15447`](https://youtrack.jetbrains.com/issue/KT-15447) Compiler backend error: "Don't know how to generate outer expression for class"
- [`KT-15449`](https://youtrack.jetbrains.com/issue/KT-15449) Back-end (JVM) Internal error: Couldn't inline method call
- [`KT-15464`](https://youtrack.jetbrains.com/issue/KT-15464) Regression: "Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:"
- [`KT-15575`](https://youtrack.jetbrains.com/issue/KT-15575) VerifyError: Bad type on operand stack
#### Various issues
- [`KT-11962`](https://youtrack.jetbrains.com/issue/KT-11962) Super call with default parameters check is generated for top-level function
- [`KT-11969`](https://youtrack.jetbrains.com/issue/KT-11969) ProGuard issue with private interface methods
- [`KT-12795`](https://youtrack.jetbrains.com/issue/KT-12795) Write information about sealed class inheritors to metadata
- [`KT-13718`](https://youtrack.jetbrains.com/issue/KT-13718) ClassFormatError on aspectj instrumentation
- [`KT-14162`](https://youtrack.jetbrains.com/issue/KT-14162) Support @InlineOnly on inline properties
- [`KT-14705`](https://youtrack.jetbrains.com/issue/KT-14705) Inconsistent smart casts on when enum subject
- [`KT-14917`](https://youtrack.jetbrains.com/issue/KT-14917) No way to pass additional java command line options to kontlinc on Windows
- [`KT-15112`](https://youtrack.jetbrains.com/issue/KT-15112) Compiler hangs on nested lock compilation
- [`KT-15225`](https://youtrack.jetbrains.com/issue/KT-15225) Scripts: generate classes with names that are valid Java identifiers
- [`KT-15411`](https://youtrack.jetbrains.com/issue/KT-15411) Unnecessary CHECKCAST bytecode when dealing with null
- [`KT-15473`](https://youtrack.jetbrains.com/issue/KT-15473) Invalid KFunction byte code signature for callable references
- [`KT-15582`](https://youtrack.jetbrains.com/issue/KT-15582) Generated bytecode is sometimes incompatible with Java 9
- [`KT-15584`](https://youtrack.jetbrains.com/issue/KT-15584) Do not mark class files compiled with a release language version as pre-release
- [`KT-15589`](https://youtrack.jetbrains.com/issue/KT-15589) Upper bound for T in KClass<T> can be implicitly violated using generic function
- [`KT-15631`](https://youtrack.jetbrains.com/issue/KT-15631) Compiler hang in MethodAnalyzer.analyze() fixed
### JavaScript backend
#### Coroutine support
- [`KT-15362`](https://youtrack.jetbrains.com/issue/KT-15362) JS: Regex doesn't work (properly) in coroutine
- [`KT-15366`](https://youtrack.jetbrains.com/issue/KT-15366) JS: error when calling inline function with optional parameters from another module inside coroutine lambda
- [`KT-15367`](https://youtrack.jetbrains.com/issue/KT-15367) JS: `for` against iterator with suspend `next` and `hasNext` functions does not work
- [`KT-15400`](https://youtrack.jetbrains.com/issue/KT-15400) suspendCoroutine is missing in JS BE
- [`KT-15597`](https://youtrack.jetbrains.com/issue/KT-15597) Support non-tail suspend calls inside named suspend functions
- [`KT-15625`](https://youtrack.jetbrains.com/issue/KT-15625) JS: return statement without value surrounded by `try..finally` in suspend lambda causes compiler error
- [`KT-15698`](https://youtrack.jetbrains.com/issue/KT-15698) Move coroutine intrinsics to kotlin.coroutine.intrinsics package
#### Diagnostics
- [`KT-14577`](https://youtrack.jetbrains.com/issue/KT-14577) JS: do not report declaration clash when common redeclaration diagnostic applies
- [`KT-15136`](https://youtrack.jetbrains.com/issue/KT-15136) JS: prohibit inheritance from kotlin Function{N} interfaces
#### Language features support
- [`KT-12194`](https://youtrack.jetbrains.com/issue/KT-12194) Exhaustiveness check isn't generated for when expressions in JS at all
- [`KT-15590`](https://youtrack.jetbrains.com/issue/KT-15590) Support increment on inlined properties
#### Native / external
- [`KT-8081`](https://youtrack.jetbrains.com/issue/KT-8081) JS: native inherited class shouldn't require super or primary constructor call
- [`KT-13892`](https://youtrack.jetbrains.com/issue/KT-13892) JS: restrictions for native (external) functions and properties
- [`KT-15307`](https://youtrack.jetbrains.com/issue/KT-15307) JS: prohibit inline members inside external declarations
- [`KT-15308`](https://youtrack.jetbrains.com/issue/KT-15308) JS: prohibit non-abstract members inside external interfaces except nullable properties (with accessors)
#### Exceptions / Errors
- [`KT-7302`](https://youtrack.jetbrains.com/issue/KT-7302) KotlinJS - Trait with optional parameter causes compilation error
- [`KT-15325`](https://youtrack.jetbrains.com/issue/KT-15325) JS: ReferenceError: $receiver is not defined
- [`KT-15357`](https://youtrack.jetbrains.com/issue/KT-15357) JS: `when` expression in primary-from-secondary constructor call
- [`KT-15435`](https://youtrack.jetbrains.com/issue/KT-15435) Call to 'synchronize' crashes JS backend
- [`KT-15513`](https://youtrack.jetbrains.com/issue/KT-15513) JS: empty do..while loop crashes compiler
#### Various issues
- [`KT-4160`](https://youtrack.jetbrains.com/issue/KT-4160) JS: compiler produces wrong code for escaped variable names with characters which Illegal in JS (e.g. spaces)
- [`KT-7004`](https://youtrack.jetbrains.com/issue/KT-7004) JS: functions named `call` not inlined
- [`KT-7588`](https://youtrack.jetbrains.com/issue/KT-7588) JS: operators are not inlined
- [`KT-7733`](https://youtrack.jetbrains.com/issue/KT-7733) JS: Provide overflow behavior for integer arithmetic operations
- [`KT-8413`](https://youtrack.jetbrains.com/issue/KT-8413) JS: generated wrong code for some float constants
- [`KT-12598`](https://youtrack.jetbrains.com/issue/KT-12598) JS: comparisons for Enums always translates using strong operator
- [`KT-13523`](https://youtrack.jetbrains.com/issue/KT-13523) Augmented assignment with array access in LHS is translated incorrectly
- [`KT-13888`](https://youtrack.jetbrains.com/issue/KT-13888) JS: change how functions optional parameters get translated
- [`KT-15260`](https://youtrack.jetbrains.com/issue/KT-15260) JS: don't import module more than once
- [`KT-15475`](https://youtrack.jetbrains.com/issue/KT-15475) JS compiler deletes internal function name in js("") text block
- [`KT-15506`](https://youtrack.jetbrains.com/issue/KT-15506) JS: invalid evaluation order when passing arguments to function by name
- [`KT-15512`](https://youtrack.jetbrains.com/issue/KT-15512) JS: wrong result when use break/throw/return in || and && operators
- [`KT-15569`](https://youtrack.jetbrains.com/issue/KT-15569) js: Wrong code generated when calling an overloaded operator function on an inherited property
### Standard Library
- [`KEEP-23`](https://github.com/Kotlin/KEEP/blob/master/proposals/stdlib/group-and-fold.md) Operation to group by key and fold each group simultaneously
- [`KT-15774`](https://youtrack.jetbrains.com/issue/KT-15774) `buildSequence` and `buildIterator` functions with `yield` and `yieldAll` based on coroutines
- [`KT-6903`](https://youtrack.jetbrains.com/issue/KT-6903) Add `also` extension, which is like `apply`, but with `it` instead of `this` inside lambda.
- [`KT-7858`](https://youtrack.jetbrains.com/issue/KT-7858) Add extension function `takeIf` to match a value against predicate and return null when it does not match
- [`KT-11851`](https://youtrack.jetbrains.com/issue/KT-11851) Provide extension `Map.getValue(key: K): V` which throws or returns default when key is not found
- [`KT-7417`](https://youtrack.jetbrains.com/issue/KT-7417) Add min, max on two numbers to standard library
- [`KT-13898`](https://youtrack.jetbrains.com/issue/KT-13898) Allow to implement `toArray` in collections as protected and provide protected toArray in AbstractCollection.
- [`KT-14935`](https://youtrack.jetbrains.com/issue/KT-14935) Array-like list instantiation functions: `List(count) { init }` and `MutableList(count) { init }`
- [`KT-15630`](https://youtrack.jetbrains.com/issue/KT-15630) Overloads of mutableListOf, mutableSetOf, mutableMapOf without parameters
- [`KT-15557`](https://youtrack.jetbrains.com/issue/KT-15557) Iterable<T>.joinTo loses information about each element by calling toString on them by default
- [`KT-15477`](https://youtrack.jetbrains.com/issue/KT-15477) Introduce Throwable.addSuppressed extension
- [`KT-15310`](https://youtrack.jetbrains.com/issue/KT-15310) Add dynamic.unsafeCast
- [`KT-15436`](https://youtrack.jetbrains.com/issue/KT-15436) JS stdlib: org.w3c.fetch.RequestInit has 12 parameters, all required
- [`KT-15458`](https://youtrack.jetbrains.com/issue/KT-15458) Add print and println to common stdlib
### IDE
- Project View: Fix presentation of Kotlin files and their members when @JvmName having the same name as the file itself
#### no-arg / all-open
- [`KT-15419`](https://youtrack.jetbrains.com/issue/KT-15419) IDE build doesn't pick settings of all-open plugin
- [`KT-15686`](https://youtrack.jetbrains.com/issue/KT-15686) IDE build doesn't pick settings of no-arg plugin
- [`KT-15735`](https://youtrack.jetbrains.com/issue/KT-15735) Facet loses compiler plugin settings on reopening project, when "Use project settings" = Yes
#### Formatter
- [`KT-15542`](https://youtrack.jetbrains.com/issue/KT-15542) Formatter doesn't handle spaces around 'by' keyword
- [`KT-15544`](https://youtrack.jetbrains.com/issue/KT-15544) Formatter doesn't remove spaces around function reference operator
#### Intention actions, inspections and quick-fixes
##### New features
- Implement quickfix which enables/disables coroutine support in module or project
- [`KT-5045`](https://youtrack.jetbrains.com/issue/KT-5045) Intention to convert between two comparisons and range check and vice versa
- [`KT-5629`](https://youtrack.jetbrains.com/issue/KT-5629) Quick-fix to import extension method when arguments of non-extension method do not match
- [`KT-6217`](https://youtrack.jetbrains.com/issue/KT-6217) Add warning for unused equals expression
- [`KT-6824`](https://youtrack.jetbrains.com/issue/KT-6824) Quick-fix for applying spread operator where vararg is expected
- [`KT-8855`](https://youtrack.jetbrains.com/issue/KT-8855) Implement "Create label" quick-fix
- [`KT-15056`](https://youtrack.jetbrains.com/issue/KT-15056) Implement intention which converts object literal to class
- [`KT-15068`](https://youtrack.jetbrains.com/issue/KT-15068) Implement intention which rename file according to the top-level class name
- [`KT-15564`](https://youtrack.jetbrains.com/issue/KT-15564) Add quick-fix for changing primitive cast to primitive conversion method
##### Bug fixes
- [`KT-14630`](https://youtrack.jetbrains.com/issue/KT-14630) Clearer diagnostic message for platform type inspection
- [`KT-14745`](https://youtrack.jetbrains.com/issue/KT-14745) KNPE in convert primary constructor to secondary
- [`KT-14889`](https://youtrack.jetbrains.com/issue/KT-14889) Replace 'if' with elvis operator produces red code if result is referenced in 'if'
- [`KT-14907`](https://youtrack.jetbrains.com/issue/KT-14907) Quick-fix for missing operator adds infix modifier to created function
- [`KT-15092`](https://youtrack.jetbrains.com/issue/KT-15092) Suppress inspection "use property access syntax" for some getters and fix completion for them
- [`KT-15227`](https://youtrack.jetbrains.com/issue/KT-15227) "Replace if with elvis" silently changes semantics
- [`KT-15412`](https://youtrack.jetbrains.com/issue/KT-15412) "Join declaration and assignment" can break code with smart casts
- [`KT-15501`](https://youtrack.jetbrains.com/issue/KT-15501) Intention "Add names to call arguments" shouldn't appear when the only argument is a trailing lambda
#### Refactorings (Extract / Pull)
- [`KT-15611`](https://youtrack.jetbrains.com/issue/KT-15611) Extract Interface/Superclass: Disable const-properties
- Pull Up: Fix pull-up from object to superclass
- [`KT-15602`](https://youtrack.jetbrains.com/issue/KT-15602) Extract Interface/Superclass: Disable "Make abstract" for inline/external/lateinit members
- Extract Interface: Disable inline/external/lateinit members
- [`KT-12704`](https://youtrack.jetbrains.com/issue/KT-12704), [`KT-15583`](https://youtrack.jetbrains.com/issue/KT-15583) Override/Implement Members: Support all nullability annotations respected by the Kotlin compiler
- [`KT-15563`](https://youtrack.jetbrains.com/issue/KT-15563) Override Members: Allow overriding virtual synthetic members (e.g. equals(), hashCode(), toString(), etc.) in data classes
- [`KT-15355`](https://youtrack.jetbrains.com/issue/KT-15355) Extract Interface: Disable "Make abstract" and assume it to be true for abstract members of an interface
- [`KT-15353`](https://youtrack.jetbrains.com/issue/KT-15353) Extract Superclass/Interface: Allow extracting class with special name (and quotes)
- [`KT-15643`](https://youtrack.jetbrains.com/issue/KT-15643) Extract Interface/Pull Up: Disable "Make abstract" and assume it to be true for primary constructor parameter when moving to an interface
- [`KT-15607`](https://youtrack.jetbrains.com/issue/KT-15607) Extract Interface/Pull Up: Disable internal/protected members when moving to an interface
- [`KT-15640`](https://youtrack.jetbrains.com/issue/KT-15640) Extract Interface/Pull Up: Drop 'final' modifier when moving to an interface
- [`KT-15639`](https://youtrack.jetbrains.com/issue/KT-15639) Extract Superclass/Interface/Pull Up: Add spaces between 'abstract' modifier and annotations
- [`KT-15606`](https://youtrack.jetbrains.com/issue/KT-15606) Extract Interface/Pull Up: Warn about private members with usages in the original class
- [`KT-15635`](https://youtrack.jetbrains.com/issue/KT-15635) Extract Superclass/Interface: Fix bogus visibility warning inside a member when it's being moved as abstract
- [`KT-15598`](https://youtrack.jetbrains.com/issue/KT-15598) Extract Interface: Red-highlight members inherited from a super-interface when that interface reference itself is not extracted
- [`KT-15674`](https://youtrack.jetbrains.com/issue/KT-15674) Extract Superclass: Drop inapplicable modifiers when converting property-parameter to ordinary parameter
#### Multi-platform project support
- [`KT-14908`](https://youtrack.jetbrains.com/issue/KT-14908) Actions (quick-fixes) to create implementations of header elements
- [`KT-15305`](https://youtrack.jetbrains.com/issue/KT-15305) Do not report UNUSED for header declarations with implementations and vice versa
- [`KT-15601`](https://youtrack.jetbrains.com/issue/KT-15601) Cannot suppress HEADER_WITHOUT_IMPLEMENTATION
- [`KT-15641`](https://youtrack.jetbrains.com/issue/KT-15641) Quick-fix "Create header interface implementation" does nothing
#### Android support
- [`KT-12884`](https://youtrack.jetbrains.com/issue/KT-12884) Android Extensions: Refactor / Rename of activity name does not change import extension statement
- [`KT-14308`](https://youtrack.jetbrains.com/issue/KT-14308) Android Studio randomly hangs due to Java static member import quick-fix lags
- [`KT-14358`](https://youtrack.jetbrains.com/issue/KT-14358) Kotlin extensions: rename layout file: Throwable: "PSI and index do not match" through KotlinFullClassNameIndex.get()
- [`KT-15483`](https://youtrack.jetbrains.com/issue/KT-15483) Kotlin lint throws unexpected exceptions in IDE
#### Various issues
- [`KT-12872`](https://youtrack.jetbrains.com/issue/KT-12872) Don't show "defined in <very long qualifier here>" in quick doc for local variables
- [`KT-13001`](https://youtrack.jetbrains.com/issue/KT-13001) "Go to Type Declaration" is broken for stdlib types
- [`KT-13067`](https://youtrack.jetbrains.com/issue/KT-13067) Syntax colouring doesn't work for KDoc tags
- [`KT-14815`](https://youtrack.jetbrains.com/issue/KT-14815) alt + enter -> "import" over a constructor reference is not working
- [`KT-14819`](https://youtrack.jetbrains.com/issue/KT-14819) Quick documentation for special Enum functions doesn't work
- [`KT-15141`](https://youtrack.jetbrains.com/issue/KT-15141) Bogus import popup for when function call cannot be resolved fully
- [`KT-15154`](https://youtrack.jetbrains.com/issue/KT-15154) IllegalStateException on attempt to convert import statement to * if last added import is to typealias
- [`KT-15329`](https://youtrack.jetbrains.com/issue/KT-15329) Regex not inspected properly for javaJavaIdentifierStart and javaJavaIdentifierPart
- [`KT-15383`](https://youtrack.jetbrains.com/issue/KT-15383) Kotlin Scripts can only resolve stdlib functions/classes if they are in a source directory
- [`KT-15440`](https://youtrack.jetbrains.com/issue/KT-15440) Improve extensions detection in IDEA
- [`KT-15548`](https://youtrack.jetbrains.com/issue/KT-15548) Kotlin plugin: @Language injections specified in another module are ignored
- Invoke `StorageComponentContainerContributor` extension for module dependencies container as well (needed for "sam-with-receiver" plugin to work with scripts)
### J2K
- [`KT-6790`](https://youtrack.jetbrains.com/issue/KT-6790) J2K: Static import of Map.Entry is lost during conversion
- [`KT-14736`](https://youtrack.jetbrains.com/issue/KT-14736) J2K: Incorrect conversion of back ticks in javadoc {@code} tag
- [`KT-15027`](https://youtrack.jetbrains.com/issue/KT-15027) J2K: Annotations are set on functions, but not on property accessors
### Gradle support
- [`KT-15376`](https://youtrack.jetbrains.com/issue/KT-15376) Kotlin incremental=true: fixed compatibility with AS 2.3
- [`KT-15433`](https://youtrack.jetbrains.com/issue/KT-15433) Kotlin daemon swallows exceptions: fixed stack trace reporting
- [`KT-15682`](https://youtrack.jetbrains.com/issue/KT-15682) Uncheck "Use project settings" option on import Kotlin project from gradle
## 1.1-M04 (EAP-4)
### Language related changes
@@ -469,6 +1099,23 @@ These artifacts include extensions for the types available in the latter JDKs, s
### IDE
- Project View: Fix presentation of Kotlin files and their members when @JvmName having the same name as the file itself
- [`KT-15611`](https://youtrack.jetbrains.com/issue/KT-15611) Extract Interface/Superclass: Disable const-properties
- Pull Up: Fix pull-up from object to superclass
- [`KT-15602`](https://youtrack.jetbrains.com/issue/KT-15602) Extract Interface/Superclass: Disable "Make abstract" for inline/external/lateinit members
- Extract Interface: Disable inline/external/lateinit members
- [`KT-12704`](https://youtrack.jetbrains.com/issue/KT-12704), [`KT-15583`](https://youtrack.jetbrains.com/issue/KT-15583) Override/Implement Members: Support all nullability annotations respected by the Kotlin compiler
- [`KT-15563`](https://youtrack.jetbrains.com/issue/KT-15563) Override Members: Allow overriding virtual synthetic members (e.g. equals(), hashCode(), toString(), etc.) in data classes
- [`KT-15355`](https://youtrack.jetbrains.com/issue/KT-15355) Extract Interface: Disable "Make abstract" and assume it to be true for abstract members of an interface
- [`KT-15353`](https://youtrack.jetbrains.com/issue/KT-15353) Extract Superclass/Interface: Allow extracting class with special name (and quotes)
- [`KT-15643`](https://youtrack.jetbrains.com/issue/KT-15643) Extract Interface/Pull Up: Disable "Make abstract" and assume it to be true for primary constructor parameter when moving to an interface
- [`KT-15607`](https://youtrack.jetbrains.com/issue/KT-15607) Extract Interface/Pull Up: Disable internal/protected members when moving to an interface
- [`KT-15640`](https://youtrack.jetbrains.com/issue/KT-15640) Extract Interface/Pull Up: Drop 'final' modifier when moving to an interface
- [`KT-15639`](https://youtrack.jetbrains.com/issue/KT-15639) Extract Superclass/Interface/Pull Up: Add spaces between 'abstract' modifier and annotations
- [`KT-15606`](https://youtrack.jetbrains.com/issue/KT-15606) Extract Interface/Pull Up: Warn about private members with usages in the original class
- [`KT-15635`](https://youtrack.jetbrains.com/issue/KT-15635) Extract Superclass/Interface: Fix bogus visibility warning inside a member when it's being moved as abstract
- [`KT-15598`](https://youtrack.jetbrains.com/issue/KT-15598) Extract Interface: Red-highlight members inherited from a super-interface when that interface reference itself is not extracted
- [`KT-15674`](https://youtrack.jetbrains.com/issue/KT-15674) Extract Superclass: Drop inapplicable modifiers when converting property-parameter to ordinary parameter
- [`KT-15444`](https://youtrack.jetbrains.com/issue/KT-15444) Spring Support: Consider declaration open if it's supplemented with a preconfigured annotation in corresponding compiler plugin
#### Intention actions, inspections and quickfixes
@@ -478,6 +1125,7 @@ These artifacts include extensions for the types available in the latter JDKs, s
- Implement quickfix which enables/disables coroutine support in module or project
- [`KT-15056`](https://youtrack.jetbrains.com/issue/KT-15056) Implement intention which converts object literal to class
- [`KT-8855`](https://youtrack.jetbrains.com/issue/KT-8855) Implement "Create label" quick fix
- [`KT-15627`](https://youtrack.jetbrains.com/issue/KT-15627) Support "Change parameter type" for parameters with type-mismatched default value
## 1.0.6

View File

@@ -145,10 +145,10 @@
</macrodef>
<target name="printStatistics">
<print-file-size-statistic path="${kotlin-home}/lib" file-name="kotlin-runtime.jar"/>
<print-file-size-statistic path="${kotlin-home}/lib" file-name="kotlin-stdlib.jar"/>
<print-file-size-statistic path="${kotlin-home}/lib" file-name="kotlin-reflect.jar"/>
<print-file-size-statistic path="${kotlin-home}/lib" file-name="kotlin-jslib.jar"/>
<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="${compiled.stdlib.meta.js}"/>
<print-file-size-statistic path="${js.stdlib.output.dir}" file-name="${compiled.stdlib.js}"/>

View File

@@ -22,7 +22,7 @@ import java.io.File
class Kotlin2JsTask : KotlinCompilerBaseTask() {
override val compilerFqName = "org.jetbrains.kotlin.cli.js.K2JSCompiler"
var library: Path? = null
var libraries: Path? = null
var outputPrefix: File? = null
var outputPostfix: File? = null
var sourceMap: Boolean = false
@@ -35,15 +35,9 @@ class Kotlin2JsTask : KotlinCompilerBaseTask() {
*/
var main: String? = null
fun createLibrary(): Path {
val libraryPath = library
if (libraryPath == null) {
val t = Path(getProject())
library = t
return t
}
return libraryPath.createPath()
fun createLibraries(): Path {
val libraryPaths = libraries ?: return Path(getProject()).also { libraries = it }
return libraryPaths.createPath()
}
override fun fillSpecificArguments() {
@@ -51,9 +45,9 @@ class Kotlin2JsTask : KotlinCompilerBaseTask() {
args.add(output!!.canonicalPath)
// TODO: write test
library?.let {
args.add("-library-files")
args.add(it.list().joinToString(separator = ",") { File(it).canonicalPath })
libraries?.let {
args.add("-libraries")
args.add(it.list().joinToString(File.pathSeparator) { File(it).canonicalPath })
}
outputPrefix?.let {

View File

@@ -29,8 +29,8 @@ internal object KotlinAntTaskUtil {
private val libPath: File by lazy {
// Find path of kotlin-ant.jar in the filesystem and find kotlin-compiler.jar in the same directory
val resourcePath = "/" + javaClass.name.replace('.', '/') + ".class"
val jarConnection = javaClass.getResource(resourcePath).openConnection() as? JarURLConnection
val resourcePath = "/" + this::class.java.name.replace('.', '/') + ".class"
val jarConnection = this::class.java.getResource(resourcePath).openConnection() as? JarURLConnection
?: throw UnsupportedOperationException("Kotlin compiler Ant task should be loaded from the JAR file")
val antTaskJarPath = File(jarConnection.jarFileURL.toURI())
@@ -54,7 +54,7 @@ internal object KotlinAntTaskUtil {
val cached = classLoaderRef.get()
if (cached != null) return cached
val myLoader = javaClass.classLoader
val myLoader = this::class.java.classLoader
if (myLoader !is AntClassLoader) return myLoader
val classLoader = ClassPreloadingUtils.preloadClasses(listOf(compilerJar), Preloader.DEFAULT_CLASS_NUMBER_ESTIMATE, myLoader, null)

View File

@@ -0,0 +1,75 @@
/*
* 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.build
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
import org.jetbrains.kotlin.config.ApiVersion
import org.jetbrains.kotlin.config.KotlinCompilerVersion
import org.jetbrains.kotlin.config.LanguageVersion
import org.jetbrains.kotlin.load.java.JvmBytecodeBinaryVersion
import org.jetbrains.kotlin.load.kotlin.JvmMetadataVersion
/**
* If you want to add a new field, check its type is supported by [serializeToPlainText], [deserializeFromPlainText]
*/
data class JvmBuildMetaInfo(
val isEAP: Boolean,
val compilerBuildVersion: String,
val languageVersionString: String,
val apiVersionString: String,
val coroutinesEnable: Boolean,
val coroutinesWarn: Boolean,
val coroutinesError: Boolean,
val multiplatformEnable: Boolean,
val metadataVersionMajor: Int,
val metadataVersionMinor: Int,
val metadataVersionPatch: Int,
val bytecodeVersionMajor: Int,
val bytecodeVersionMinor: Int,
val bytecodeVersionPatch: Int,
val ownVersion: Int = JvmBuildMetaInfo.OWN_VERSION,
val coroutinesVersion: Int = JvmBuildMetaInfo.COROUTINES_VERSION,
val multiplatformVersion: Int = JvmBuildMetaInfo.MULTIPLATFORM_VERSION
) {
companion object {
const val OWN_VERSION: Int = 0
const val COROUTINES_VERSION: Int = 0
const val MULTIPLATFORM_VERSION: Int = 0
fun serializeToString(info: JvmBuildMetaInfo): String =
serializeToPlainText(info)
fun deserializeFromString(str: String): JvmBuildMetaInfo? =
deserializeFromPlainText(str)
}
}
fun JvmBuildMetaInfo(args: CommonCompilerArguments): JvmBuildMetaInfo =
JvmBuildMetaInfo(isEAP = KotlinCompilerVersion.isPreRelease(),
compilerBuildVersion = KotlinCompilerVersion.VERSION,
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,
metadataVersionPatch = JvmMetadataVersion.INSTANCE.patch,
bytecodeVersionMajor = JvmBytecodeBinaryVersion.INSTANCE.major,
bytecodeVersionMinor = JvmBytecodeBinaryVersion.INSTANCE.minor,
bytecodeVersionPatch = JvmBytecodeBinaryVersion.INSTANCE.patch)

View File

@@ -0,0 +1,71 @@
/*
* 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.build
import kotlin.reflect.KClass
import kotlin.reflect.full.memberProperties
import kotlin.reflect.full.primaryConstructor
inline fun <reified T : Any> serializeToPlainText(instance: T): String = serializeToPlainText(instance, T::class)
fun <T : Any> serializeToPlainText(instance: T, klass: KClass<T>): String {
val lines = ArrayList<String>()
for (property in klass.memberProperties) {
val value = property.get(instance)
if (value != null) {
lines.add("${property.name}=$value")
}
}
return lines.joinToString("\n")
}
inline fun <reified T : Any> deserializeFromPlainText(str: String): T? = deserializeFromPlainText(str, T::class)
fun <T : Any> deserializeFromPlainText(str: String, klass: KClass<T>): T? {
val args = ArrayList<Any?>()
val properties = str
.split("\n")
.filter(String::isNotBlank)
.associate { it.substringBefore("=") to it.substringAfter("=") }
val primaryConstructor = klass.primaryConstructor
?: throw IllegalStateException("${klass.java} does not have primary constructor")
for (param in primaryConstructor.parameters.sortedBy { it.index }) {
val argumentString = properties[param.name]
if (argumentString == null) {
if (param.type.isMarkedNullable) {
args.add(null)
continue
}
else {
return null
}
}
val argument: Any? = when (param.type.classifier) {
Int::class -> argumentString.toInt()
Boolean::class -> argumentString.toBoolean()
String::class -> argumentString
else -> throw IllegalStateException("Unexpected property type: ${param.type}")
}
args.add(argument)
}
return primaryConstructor.call(*args.toTypedArray())
}

View File

@@ -19,9 +19,9 @@ package org.jetbrains.kotlin.compilerRunner;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.Function;
import com.intellij.util.containers.ComparatorUtil;
import com.sampullara.cli.Argument;
import org.jetbrains.annotations.NotNull;
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;

View File

@@ -24,7 +24,7 @@ import java.io.File
private val NORMAL_VERSION = 8
private val EXPERIMENTAL_VERSION = 4
private val DATA_CONTAINER_VERSION = 1
private val DATA_CONTAINER_VERSION = 2
private val NORMAL_VERSION_FILE_NAME = "format-version.txt"
private val EXPERIMENTAL_VERSION_FILE_NAME = "experimental-format-version.txt"

View File

@@ -19,14 +19,14 @@ package org.jetbrains.kotlin.incremental
import org.jetbrains.kotlin.cli.common.ExitCode
import java.io.File
abstract class ICReporter {
abstract fun report(message: ()->String)
interface ICReporter {
fun report(message: ()->String)
// used in Gradle plugin
@Suppress("unused")
open fun reportCompileIteration(sourceFiles: Iterable<File>, exitCode: ExitCode) {}
fun reportCompileIteration(sourceFiles: Collection<File>, exitCode: ExitCode) {}
open fun pathsAsString(files: Iterable<File>): String =
fun pathsAsString(files: Iterable<File>): String =
files.map { it.canonicalPath }.joinToString()
fun pathsAsString(vararg files: File): String =

View File

@@ -43,7 +43,6 @@ import org.jetbrains.kotlin.serialization.deserialization.TypeTable
import org.jetbrains.kotlin.serialization.deserialization.supertypes
import org.jetbrains.kotlin.serialization.jvm.BitEncoding
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBufUtil
import org.jetbrains.kotlin.utils.singletonOrEmptyList
import org.jetbrains.org.objectweb.asm.*
import java.io.File
import java.security.MessageDigest
@@ -272,7 +271,7 @@ open class IncrementalCacheImpl<Target>(
ProtoBuf.Class::getPropertyList
) + classData.classProto.enumEntryList.map { classData.nameResolver.getString(it.name) }
val companionObjectChanged = createChangeInfo(classFqName.parent(), classFqName.shortName().asString().singletonOrEmptyList())
val companionObjectChanged = createChangeInfo(classFqName.parent(), listOfNotNull(classFqName.shortName().asString()))
val companionObjectMembersChanged = createChangeInfo(classFqName, memberNames)
listOf(companionObjectMembersChanged, companionObjectChanged)
@@ -780,7 +779,7 @@ sealed class ChangeInfo(val fqName: FqName) {
protected open fun toStringProperties(): String = "fqName = $fqName"
override fun toString(): String {
return this.javaClass.simpleName + "(${toStringProperties()})"
return this::class.java.simpleName + "(${toStringProperties()})"
}
}

View File

@@ -50,5 +50,5 @@ class LocalFileKotlinClass private constructor(
override fun hashCode(): Int = file.hashCode()
override fun equals(other: Any?): Boolean = other is LocalFileKotlinClass && file == other.file
override fun toString(): String = "$javaClass: $file"
override fun toString(): String = "${this::class.java}: $file"
}

View File

@@ -42,7 +42,7 @@ import java.util.*
fun Iterable<File>.javaSourceRoots(roots: Iterable<File>): Iterable<File> =
filter { it.isJavaFile() }
filter(File::isJavaFile)
.map { findSrcDirRoot(it, roots) }
.filterNotNull()
@@ -145,7 +145,7 @@ fun LookupStorage.update(
filesToCompile: Iterable<File>,
removedFiles: Iterable<File>
) {
if (lookupTracker !is LookupTrackerImpl) throw AssertionError("Lookup tracker is expected to be LookupTrackerImpl, got ${lookupTracker.javaClass}")
if (lookupTracker !is LookupTrackerImpl) throw AssertionError("Lookup tracker is expected to be LookupTrackerImpl, got ${lookupTracker::class.java}")
removeLookupsFrom(filesToCompile.asSequence() + removedFiles.asSequence())

View File

@@ -46,7 +46,7 @@ abstract class BasicMap<K : Comparable<K>, V>(
fun dump(): String {
return with(StringBuilder()) {
with(Printer(this)) {
println(this@BasicMap.javaClass.simpleName)
println(this@BasicMap::class.java.simpleName)
pushIndent()
for (key in storage.keys.sorted()) {

View File

@@ -131,7 +131,7 @@ object ConstantsMapExternalizer : DataExternalizer<Map<String, Any>> {
output.writeByte(Kind.STRING.ordinal)
IOUtil.writeString(value, output)
}
else -> throw IllegalStateException("Unexpected constant class: ${value.javaClass}")
else -> throw IllegalStateException("Unexpected constant class: ${value::class.java}")
}
}
}

View File

@@ -0,0 +1,77 @@
/*
* 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.build
import junit.framework.TestCase
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
class JvmBuildMetaInfoTest : TestCase() {
@Test
fun testSerialization() {
val args = K2JVMCompilerArguments()
val info = JvmBuildMetaInfo(args)
val actual = JvmBuildMetaInfo.serializeToString(info)
val expectedKeys = listOf(
"apiVersionString",
"bytecodeVersionMajor",
"bytecodeVersionMinor",
"bytecodeVersionPatch",
"compilerBuildVersion",
"coroutinesEnable",
"coroutinesError",
"coroutinesVersion",
"coroutinesWarn",
"isEAP",
"languageVersionString",
"metadataVersionMajor",
"metadataVersionMinor",
"metadataVersionPatch",
"multiplatformEnable",
"multiplatformVersion",
"ownVersion"
)
assertEquals(expectedKeys, actual.split("\r\n", "\n").map { line -> line.split("=").first() })
}
@Test
fun testSerializationDeserialization() {
val args = K2JVMCompilerArguments()
val info = JvmBuildMetaInfo(args)
val serialized = JvmBuildMetaInfo.serializeToString(info)
val deserialized = JvmBuildMetaInfo.deserializeFromString(serialized)
assertEquals(info, deserialized)
}
@Test
fun testEquals() {
val args1 = K2JVMCompilerArguments()
args1.coroutinesEnable = true
val info1 = JvmBuildMetaInfo(args1)
val args2 = K2JVMCompilerArguments()
args2.coroutinesEnable = false
val info2 = JvmBuildMetaInfo(args2)
assertNotEquals(info1, info2)
assertEquals(info1, info2.copy(coroutinesEnable = true))
}
}

View File

@@ -0,0 +1,55 @@
/*
* 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.build
import junit.framework.TestCase
import org.junit.Test
class SerializationUtilsTest : TestCase() {
data class TestPropertyTypes(
val intNull: Int?,
val int: Int,
val stringNull: String?,
val string: String,
val boolNull: Boolean?,
val bool: Boolean
)
@Test
fun testPropertyTypes() {
val instance1 = TestPropertyTypes(null, 1, null, "abc", null, false)
val deserialized1 = deserializeFromPlainText<TestPropertyTypes>(serializeToPlainText(instance1))
assertEquals(instance1, deserialized1)
val instance2 = TestPropertyTypes(1, 2, "abc", "xyz", true, false)
val deserialized2 = deserializeFromPlainText<TestPropertyTypes>(serializeToPlainText(instance2))
assertEquals(instance2, deserialized2)
}
data class TestAddedField1(val x: Int)
data class TestAddedField2(val x: Int, val y: Int?)
@Test
fun testAddedField() {
val testAddedField1 = TestAddedField1(1)
val serialized = serializeToPlainText(testAddedField1)
val deserialized = deserializeFromPlainText<TestAddedField2>(serialized)
assertEquals(TestAddedField2(1, null), deserialized)
}
}

View File

@@ -144,7 +144,7 @@ private fun classFileToString(classFile: File): String {
out.write("\n------ string table types proto -----\n${DebugJvmProtoBuf.StringTableTypes.parseDelimitedFrom(input)}")
if (!classHeader!!.metadataVersion.isCompatible()) {
if (!classHeader.metadataVersion.isCompatible()) {
error("Incompatible class ($classHeader): $classFile")
}

View File

@@ -81,8 +81,8 @@ fun getModificationsToPerform(
val rules = mapOf<String, (String, File) -> Modification>(
newSuffix to { path, file -> ModifyContent(path, file) },
touchSuffix to { path, file -> TouchFile(path, touchPolicy) },
deleteSuffix to { path, file -> DeleteFile(path) }
touchSuffix to { path, _ -> TouchFile(path, touchPolicy) },
deleteSuffix to { path, _ -> DeleteFile(path) }
)
val modifications = ArrayList<Modification>()
@@ -130,7 +130,7 @@ fun getModificationsToPerform(
abstract class Modification(val path: String) {
abstract fun perform(workDir: File, mapping: MutableMap<File, File>)
override fun toString(): String = "${javaClass.simpleName} $path"
override fun toString(): String = "${this::class.java.simpleName} $path"
}
class ModifyContent(path: String, val dataFile: File) : Modification(path) {

242
build.xml
View File

@@ -1,4 +1,4 @@
<project name="Kotlin" default="dist" xmlns:if="ant:if" xmlns:unless="ant:unless">
<project xmlns:if="ant:if" xmlns:unless="ant:unless" name="Kotlin" default="dist">
<import file="common.xml" optional="false"/>
<property file="resources/kotlinManifest.properties"/>
@@ -28,7 +28,8 @@
<property name="protobuf-lite.jar" value="${basedir}/dependencies/protobuf-2.6.1-lite.jar"/>
<property name="javax.inject.jar" value="${basedir}/lib/javax.inject.jar"/>
<property name="java.target" value="1.6"/>
<property name="java.target" value="1.8"/>
<property name="java.target.1.6" value="1.6"/>
<condition property="bootstrap.or.local.build" value="true">
<or>
@@ -41,9 +42,10 @@
<include file="jslib_files.xml" />
<property name="compiled.builtins.js" value="builtins.js"/>
<property name="compiled.stdlib.js" value="stdlib.js"/>
<property name="compiled.stdlib.meta.js" value="kotlin.meta.js"/>
<property name="stdlib.js.dir" value="${basedir}/js/js.translator/testData"/>
<property name="stdlib.js.dir" value="${basedir}/js/js.libraries/src/js"/>
<!--
The compiler produced on the first step of the build (Bootstrap No Tests) is only guaranteed to work against the OLD runtime
@@ -71,7 +73,6 @@
<fileset dir="${basedir}/lib" includes="**/*.jar"/>
<fileset dir="${dependencies}" includes="jansi.jar"/>
<fileset dir="${dependencies}" includes="jline.jar"/>
<fileset dir="${dependencies}" includes="cli-parser-1.1.2.jar"/>
<fileset dir="${basedir}/ideaSDK/jps" includes="jps-model.jar"/>
</path>
@@ -313,6 +314,7 @@
<macrodef name="new-kotlin2js">
<attribute name="output"/>
<attribute name="additionalOptions" default=""/>
<element name="src"/>
<sequential>
@@ -340,10 +342,10 @@
<arg value="@{output}"/>
<arg value="-no-stdlib"/>
<arg value="-version"/>
<arg value="-meta-info"/>
<arg value="-kjsm"/>
<arg line="@{additionalOptions}"/>
<arg line="-main noCall"/>
<arg line="-module-kind commonjs"/>
<arg value="-Xallow-kotlin-package"/>
</java>
</sequential>
</macrodef>
@@ -366,16 +368,16 @@
output="${js.stdlib.output.dir}/kotlin.js"
outputWrapperFile="${stdlib.js.dir}/closure-wrapper.txt">
<sources dir="${stdlib.js.dir}">
<file name="kotlin_lib_ecma5.js"/>
<file name="kotlin_lib.js"/>
<file name="long.js"/>
</sources>
<sources dir="${js.stdlib.output.dir}">
<file name="builtins.js"/>
<file name="${compiled.stdlib.js}"/>
</sources>
<path>
<fileset dir="${stdlib.js.dir}">
<include name="**/*.js"/>
<exclude name="externs.js"/>
</fileset>
<fileset dir="${js.stdlib.output.dir}">
<include name="${compiled.builtins.js}"/>
<include name="${compiled.stdlib.js}"/>
</fileset>
</path>
<externs dir="${stdlib.js.dir}">
<file name="externs.js"/>
@@ -404,9 +406,13 @@
byline="true" encoding="UTF-8" />
</target>
<target name="js-stdlib">
<property environment="env"/>
<target name="js-stdlib-preprocess">
<kotlin-pp src="libraries/stdlib/src" output="${intermediate-sources}/stdlib/js" profile="JS" />
</target>
<target name="js-stdlib" depends="js-stdlib-preprocess">
<property environment="env"/>
<cleandir dir="${js.stdlib.output.dir}"/>
<!-- We don't want descriptors for built-ins to be serialized, so we compile these files separately. -->
<new-kotlin2js output="${js.stdlib.output.dir}/tmp-builtins/kotlin.js">
@@ -417,7 +423,7 @@
</src>
</new-kotlin2js>
<new-kotlin2js output="${js.stdlib.output.dir}/tmp/kotlin.js">
<new-kotlin2js output="${js.stdlib.output.dir}/tmp/kotlin.js" additionalOptions="-meta-info">
<src>
<union>
<fileset refid="kotlin.builtin.files"/>
@@ -426,7 +432,7 @@
</src>
</new-kotlin2js>
<move file="${js.stdlib.output.dir}/tmp-builtins/kotlin.js" tofile="${js.stdlib.output.dir}/builtins.js" />
<move file="${js.stdlib.output.dir}/tmp-builtins/kotlin.js" tofile="${js.stdlib.output.dir}/${compiled.builtins.js}" />
<move file="${js.stdlib.output.dir}/tmp/kotlin.js" tofile="${js.stdlib.output.dir}/${compiled.stdlib.js}" />
<move file="${js.stdlib.output.dir}/tmp/kotlin" todir="${js.stdlib.output.dir}" />
<move file="${js.stdlib.output.dir}/tmp/${compiled.stdlib.meta.js}" tofile="${js.stdlib.output.dir}/${compiled.stdlib.meta.js}" />
@@ -449,7 +455,7 @@
<arg line="js-stdlib-merge" />
</java>
<jar jarfile="${kotlin-home}/lib/kotlin-jslib.jar" duplicate="fail">
<jar jarfile="${kotlin-home}/lib/kotlin-stdlib-js.jar" duplicate="fail">
<zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/>
<zipfileset dir="${js.stdlib.output.dir}" prefix="">
<include name="kotlin.js"/>
@@ -460,7 +466,7 @@
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="${manifest.impl.attribute.kotlin.version}" value="${manifest.impl.value.kotlin.version}"/>
<attribute name="${manifest.impl.attribute.kotlin.runtime.component}" value="${manifest.impl.value.kotlin.runtime.component.core}"/>
<attribute name="${manifest.impl.attribute.kotlin.runtime.component}" value="${manifest.impl.value.kotlin.runtime.component.main}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.javascript.stdlib}"/>
@@ -468,26 +474,28 @@
<attribute name="Specification-Title" value="${manifest.spec.title.kotlin.javascript.lib}"/>
</manifest>
</jar>
<copy file="${kotlin-home}/lib/kotlin-stdlib-js.jar" tofile="${kotlin-home}/lib/kotlin-jslib.jar" />
</target>
<target name="pack-js-stdlib-sources">
<jar destfile="${kotlin-home}/lib/kotlin-jslib-sources.jar" duplicate="fail">
<target name="pack-js-stdlib-sources" depends="js-stdlib-preprocess">
<jar destfile="${kotlin-home}/lib/kotlin-stdlib-js-sources.jar" duplicate="fail">
<resources refid="js.lib.files" />
<fileset refid="kotlin.builtin.files" />
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="${manifest.impl.attribute.kotlin.version}" value="${manifest.impl.value.kotlin.version}"/>
<attribute name="${manifest.impl.attribute.kotlin.runtime.component}" value="${manifest.impl.value.kotlin.runtime.component.core}"/>
<attribute name="${manifest.impl.attribute.kotlin.runtime.component}" value="${manifest.impl.value.kotlin.runtime.component.main}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.jvm.runtime.sources}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
</manifest>
</jar>
<copy file="${kotlin-home}/lib/kotlin-stdlib-js-sources.jar" tofile="${kotlin-home}/lib/kotlin-jslib-sources.jar" />
</target>
<target name="kotlin-js-stdlib" depends="js-stdlib,pack-js-stdlib-sources"/>
<target name="kotlin-js-stdlib" depends="js-stdlib,js-kotlin-test,pack-js-stdlib-sources"/>
<target name="preloader">
<cleandir dir="${output}/classes/preloader"/>
@@ -581,7 +589,6 @@
<zipfileset src="${idea.sdk}/lib/oromatcher.jar"/>
<zipfileset src="${idea.sdk}/jps/jps-model.jar"/>
<zipfileset src="${dependencies}/jline.jar"/>
<zipfileset src="${dependencies}/cli-parser-1.1.2.jar"/>
<zipfileset src="${protobuf.jar}"/>
<manifest>
@@ -612,13 +619,6 @@
</target>
<target name="compiler">
<taskdef resource="proguard/ant/task.properties">
<classpath>
<pathelement path="${dependencies}/proguard.jar"/>
<pathelement path="${dependencies}/proguard-anttask.jar"/>
</classpath>
</taskdef>
<cleandir dir="${output}/classes/compiler"/>
<javac2 destdir="${output}/classes/compiler" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false"
@@ -640,17 +640,32 @@
unless:true="${shrink}" />
<sequential if:true="${shrink}">
<shrink configuration="${basedir}/compiler/compiler.pro"/>
</sequential>
<pack-compiler-for-maven/>
</target>
<macrodef name="shrink">
<attribute name="configuration"/>
<sequential>
<taskdef resource="proguard/ant/task.properties">
<classpath>
<pathelement path="${dependencies}/proguard.jar"/>
<pathelement path="${dependencies}/proguard-anttask.jar"/>
</classpath>
</taskdef>
<available property="rtjar" value="${java.home}/lib/rt.jar" file="${java.home}/lib/rt.jar"/>
<available property="rtjar" value="${java.home}/../Classes/classes.jar" file="${java.home}/../Classes/classes.jar"/>
<available property="jssejar" value="${java.home}/lib/jsse.jar" file="${java.home}/lib/jsse.jar"/>
<available property="jssejar" value="${java.home}/../Classes/jsse.jar" file="${java.home}/../Classes/jsse.jar"/>
<proguard configuration="${basedir}/compiler/compiler.pro"/>
<proguard configuration="@{configuration}"/>
</sequential>
<pack-compiler-for-maven/>
</target>
</macrodef>
<macrodef name="pack-compiler-for-maven">
<sequential>
@@ -751,7 +766,7 @@
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.daemon-client}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.daemon.client}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
</manifest>
</jar>
@@ -771,6 +786,27 @@
</jar>
</target>
<target name="compiler-client-embeddable">
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="dependencies/jarjar.jar"/>
<jarjar jarfile="${output}/kotlin-compiler-client-embeddable-before-shrink.jar">
<zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/>
<zipfileset src="${kotlin-home}/lib/kotlin-daemon-client.jar"/>
<fileset dir="${output}/classes/compiler"
includes="org/jetbrains/kotlin/daemon/common/** org/jetbrains/kotlin/cli/common/messages/CompilerMessage* org/jetbrains/kotlin/cli/common/messages/Message* org/jetbrains/kotlin/cli/common/repl/**"/>
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.compiler.client,embeddable}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
<attribute name="Class-Path" value="kotlin-stdlib.jar"/>
</manifest>
</jarjar>
<shrink configuration="${basedir}/compiler/compiler-client.pro"/>
</target>
<target name="android-extensions-compiler">
<cleandir dir="${output}/classes/android-extensions/android-extensions-compiler"/>
<javac2 destdir="${output}/classes/android-extensions/android-extensions-compiler" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false">
@@ -863,6 +899,29 @@
</jar>
</target>
<target name="source-sections-compiler-plugin">
<cleandir dir="${output}/classes/source-sections-compiler-plugin"/>
<javac2 destdir="${output}/classes/source-sections-compiler-plugin" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false">
<withKotlin modulename="source-sections">
<compilerarg value="-version"/>
</withKotlin>
<skip pattern="kotlin/Metadata"/>
<src>
<pathelement path="plugins/source-sections/source-sections-compiler/src"/>
</src>
<classpath>
<pathelement path="${idea.sdk}/core/intellij-core.jar"/>
<pathelement path="${kotlin-home}/lib/kotlin-compiler.jar"/>
</classpath>
</javac2>
<jar destfile="${kotlin-home}/lib/source-sections-compiler-plugin.jar">
<fileset dir="${output}/classes/source-sections-compiler-plugin"/>
<zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/>
<fileset dir="${basedir}/plugins/source-sections/source-sections-compiler/src" includes="META-INF/services/**"/>
</jar>
</target>
<target name="annotation-processing-under-jdk8">
<property environment="env"/>
@@ -1000,7 +1059,7 @@
</java>
<javac2 srcdir="${toString:src.dirset}" destdir="@{output}" debug="true" debuglevel="lines,vars,source"
includeAntRuntime="false" source="${java.target}" target="${java.target}">
includeAntRuntime="false" source="${java.target.1.6}" target="${java.target.1.6}">
<skip pattern="kotlin/Metadata"/>
<classpath>
<path refid="classpath.path"/>
@@ -1019,13 +1078,13 @@
<sequential>
<java classname="org.jetbrains.kotlin.preloading.Preloader" failonerror="true" fork="true" maxmemory="${max.heap.size.for.forked.jvm}">
<classpath>
<pathelement location="${kotlin-home}/lib/kotlin-preloader.jar"/>
<pathelement location="${bootstrap.compiler.home}/lib/kotlin-preloader.jar"/>
</classpath>
<assertions>
<enable/>
</assertions>
<arg value="-cp"/>
<arg value="${kotlin-home}/lib/kotlin-compiler.jar"/>
<arg value="${bootstrap.compiler.home}/lib/kotlin-compiler.jar"/>
<arg value="org.jetbrains.kotlin.preprocessor.PreprocessorCLI"/>
<arg value="@{src}"/>
<arg value="@{output}"/>
@@ -1035,7 +1094,7 @@
</macrodef>
<target name="builtins">
<new-kotlinc output="${output}/classes/builtins" moduleName="kotlin-builtins">
<new-kotlinc output="${output}/classes/builtins" moduleName="kotlin-runtime">
<src>
<include name="core/builtins/src"/>
<include name="core/runtime.jvm/src"/>
@@ -1060,18 +1119,37 @@
</target>
<target name="kotlin-test">
<new-kotlinc output="${output}/classes/kotlin-test" moduleName="kotlin-test">
<src>
<include name="libraries/kotlin.test/shared/src/main/kotlin" />
<include name="libraries/kotlin.test/shared/src/main/kotlin.jvm" />
<include name="libraries/kotlin.test/junit/src/main/kotlin" />
</src>
<class-path>
<pathelement path="${output}/classes/builtins"/>
<pathelement path="libraries/lib/junit-4.11.jar"/>
<pathelement path="${output}/builtins"/>
</class-path>
</new-kotlinc>
<path id="kotlin-test-compile-classpath">
<pathelement location="${output}/builtins"/>
<pathelement location="${output}/classes/builtins"/>
<pathelement location="${output}/classes/stdlib"/>
<pathelement location="libraries/lib/junit-4.11.jar"/>
</path>
<java classname="org.jetbrains.kotlin.preloading.Preloader" failonerror="true" fork="true" maxmemory="${max.heap.size.for.forked.jvm}">
<classpath>
<pathelement location="${kotlin-home}/lib/kotlin-preloader.jar"/>
</classpath>
<assertions>
<enable/>
</assertions>
<arg value="-cp"/>
<arg value="${kotlin-home}/lib/kotlin-compiler.jar"/>
<arg value="org.jetbrains.kotlin.cli.jvm.K2JVMCompiler"/>
<arg value="-d"/>
<arg value="${output}/classes/kotlin-test"/>
<arg value="-version"/>
<arg value="-no-stdlib"/>
<arg value="-classpath"/>
<arg value="${toString:kotlin-test-compile-classpath}"/>
<arg value="-module-name"/>
<arg value="kotlin-test"/>
<arg value="-Xallow-kotlin-package"/>
<arg value="-Xmulti-platform"/>
<arg value="libraries/kotlin.test/common/src/main/kotlin"/>
<arg value="libraries/kotlin.test/jvm/src/main/kotlin"/>
<arg value="libraries/kotlin.test/junit/src/main/kotlin"/>
</java>
<pack-runtime-jar jar-name="kotlin-test.jar" implementation-title="${manifest.impl.title.kotlin.test}" runtime-component="Test">
<jar-content>
@@ -1079,6 +1157,35 @@
</jar-content>
</pack-runtime-jar>
</target>
<target name="js-kotlin-test">
<java classname="org.jetbrains.kotlin.preloading.Preloader" failonerror="true" fork="true" maxmemory="${max.heap.size.for.forked.jvm}">
<classpath>
<pathelement location="${kotlin-home}/lib/kotlin-preloader.jar"/>
</classpath>
<assertions>
<enable/>
</assertions>
<arg value="-cp"/>
<arg value="${kotlin-home}/lib/kotlin-compiler.jar"/>
<arg value="org.jetbrains.kotlin.cli.js.K2JSCompiler"/>
<arg value="-output"/>
<arg value="${output}/classes/kotlin-test-js/kotlin-test.js"/>
<arg value="-version"/>
<arg value="-meta-info"/>
<arg line="-main noCall"/>
<arg line="-module-kind umd"/>
<arg value="-Xmulti-platform"/>
<arg value="-Xallow-kotlin-package"/>
<arg value="libraries/kotlin.test/common/src/main/kotlin"/>
<arg value="libraries/kotlin.test/js/src/main/kotlin"/>
</java>
<pack-runtime-jar jar-name="kotlin-test-js.jar" implementation-title="${manifest.impl.title.kotlin.test}" runtime-component="TestJs">
<jar-content>
<fileset dir="${output}/classes/kotlin-test-js" includes="**/*" excludes="kotlin/internal/OnlyInputTypes*,kotlin/internal/InlineOnly*,kotlin/internal"/>
</jar-content>
</pack-runtime-jar>
</target>
<target name="core">
<new-kotlinc output="${output}/classes/core" moduleName="kotlin-core">
@@ -1118,7 +1225,7 @@
<attribute name="jar-dir" default="${kotlin-home}/lib"/>
<attribute name="jar-name"/>
<attribute name="implementation-title"/>
<attribute name="runtime-component" default="${manifest.impl.value.kotlin.runtime.component.core}"/>
<attribute name="runtime-component" default="${manifest.impl.value.kotlin.runtime.component.main}"/>
<element name="jar-content"/>
<sequential>
@@ -1142,7 +1249,7 @@
</macrodef>
<target name="pack-runtime">
<pack-runtime-jar jar-name="kotlin-runtime.jar" implementation-title="${manifest.impl.title.kotlin.jvm.runtime}">
<pack-runtime-jar jar-name="kotlin-stdlib.jar" implementation-title="${manifest.impl.title.kotlin.jvm.runtime}">
<jar-content>
<fileset dir="${output}/classes/builtins"/>
<fileset dir="${output}/classes/stdlib"/>
@@ -1153,6 +1260,7 @@
</zipfileset>
</jar-content>
</pack-runtime-jar>
<copy file="${kotlin-home}/lib/kotlin-stdlib.jar" tofile="${kotlin-home}/lib/kotlin-runtime.jar"/>
<pack-runtime-jar jar-dir="${output}" jar-name="kotlin-reflect-before-jarjar.jar" implementation-title="${manifest.impl.title.kotlin.jvm.reflect}">
<jar-content>
@@ -1170,11 +1278,10 @@
</manifest>
</jar>
<delete file="${output}/kotlin-reflect-jarjar.jar" failonerror="false"/>
<sequential if:true="${obfuscate.reflect}">
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="dependencies/jarjar.jar"/>
<jarjar jarfile="${output}/kotlin-reflect-jarjar.jar" filesonly="true" filesetmanifest="merge">
<delete file="${output}/kotlin-reflect-after-jarjar.jar" failonerror="false"/>
<jarjar jarfile="${output}/kotlin-reflect-after-jarjar.jar" filesonly="true" filesetmanifest="merge">
<zipfileset src="${output}/kotlin-reflect-before-jarjar.jar"/>
<rule pattern="org.jetbrains.kotlin.**" result="kotlin.reflect.jvm.internal.impl.@1"/>
<rule pattern="javax.inject.**" result="kotlin.reflect.jvm.internal.impl.javax.inject.@1"/>
@@ -1185,17 +1292,18 @@
<compilerarg value="-script"/>
<compilerarg value="kotlin/Metadata"/> <!-- Annotation to strip -->
<compilerarg value="kotlin/reflect/jvm/internal/impl/.*"/> <!-- Classes to strip from -->
<compilerarg value="${output}/kotlin-reflect-jarjar.jar"/>
<compilerarg value="${kotlin-home}/lib/kotlin-reflect.jar"/>
<compilerarg value="${output}/kotlin-reflect-after-jarjar.jar"/>
<compilerarg value="${output}/kotlin-reflect-before-proguard.jar"/>
<classpath>
<pathelement location="${idea.sdk}/lib/asm-all.jar"/>
</classpath>
</kotlinc>
<shrink configuration="${basedir}/core/reflection.jvm/reflection.pro"/>
</sequential>
<sequential unless:true="${obfuscate.reflect}">
<echo message="Obfuscation of kotlin-reflect is disabled"/>
<copy file="${output}/kotlin-reflect-before-jarjar.jar" tofile="${output}/kotlin-reflect-jarjar.jar" overwrite="true"/>
<copy file="${output}/kotlin-reflect-before-jarjar.jar" tofile="${kotlin-home}/lib/kotlin-reflect.jar" overwrite="true"/>
</sequential>
</target>
@@ -1228,7 +1336,7 @@
</replaceregexp>
</sequential>
<pack-runtime-jar jar-name="kotlin-runtime-sources.jar" implementation-title="${manifest.impl.title.kotlin.jvm.runtime.sources}">
<pack-runtime-jar jar-name="kotlin-stdlib-sources.jar" implementation-title="${manifest.impl.title.kotlin.jvm.runtime.sources}">
<jar-content>
<fileset dir="${basedir}/core/builtins/native" includes="**/*"/>
<fileset dir="${basedir}/core/builtins/src" includes="**/*"/>
@@ -1238,6 +1346,8 @@
<fileset dir="${output}/core.src" includes="**/*"/>
</jar-content>
</pack-runtime-jar>
<copy file="${kotlin-home}/lib/kotlin-stdlib-sources.jar" tofile="${kotlin-home}/lib/kotlin-runtime-sources.jar"/>
<pack-runtime-jar jar-dir="${output}" jar-name="kotlin-reflect-sources-for-maven.jar"
implementation-title="${manifest.impl.title.kotlin.jvm.reflect.sources}">
@@ -1274,11 +1384,11 @@
depends="builtins,stdlib,kotlin-test,core,reflection,pack-runtime,pack-runtime-sources,script-runtime,mock-runtime-for-test"/>
<target name="dist"
depends="clean,init,prepare-dist,preloader,runner,serialize-builtins,compiler,compiler-sources,ant-tools,runtime,kotlin-js-stdlib,android-extensions-compiler,allopen-compiler-plugin,noarg-compiler-plugin,sam-with-receiver-compiler-plugin,annotation-processing-under-jdk8,daemon-client,kotlin-build-common-test"
depends="clean,init,prepare-dist,preloader,runner,serialize-builtins,compiler,compiler-sources,ant-tools,runtime,kotlin-js-stdlib,android-extensions-compiler,allopen-compiler-plugin,noarg-compiler-plugin,sam-with-receiver-compiler-plugin,source-sections-compiler-plugin,annotation-processing-under-jdk8,daemon-client,kotlin-build-common-test"
description="Builds redistributables from sources"/>
<target name="dist-quick"
depends="clean,init,prepare-dist,preloader,serialize-builtins,compiler-quick,ant-tools,runtime,kotlin-js-stdlib,android-extensions-compiler,allopen-compiler-plugin,noarg-compiler-plugin,sam-with-receiver-compiler-plugin,annotation-processing-under-jdk8"
depends="clean,init,prepare-dist,preloader,serialize-builtins,compiler-quick,ant-tools,runtime,kotlin-js-stdlib,android-extensions-compiler,allopen-compiler-plugin,noarg-compiler-plugin,sam-with-receiver-compiler-plugin,source-sections-compiler-plugin,annotation-processing-under-jdk8"
description="Builds everything, but classes are reused from project out dir, doesn't run proguard and javadoc"/>
<target name="dist-quick-compiler-only"

View File

@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@@ -64,7 +64,9 @@ android {
dexOptions {
dexInProcess false
javaMaxHeapSize "600m"
javaMaxHeapSize "700m"
//default is 4 and Total Memory = maxProcessCount * javaMaxHeapSize
maxProcessCount 2
}
}

View File

@@ -16,6 +16,8 @@
package org.jetbrains.kotlin.android.tests;
import org.jetbrains.kotlin.android.tests.download.SDKDownloader;
import java.io.File;
public class PathManager {
@@ -75,7 +77,7 @@ public class PathManager {
}
public String getGradleBinFolder() {
return getDependenciesRoot() + "/gradle-2.12/bin";
return getDependenciesRoot() + "/gradle-" + SDKDownloader.GRADLE_VERSION + "/bin";
}
public String getRootForDownload() {

View File

@@ -43,6 +43,7 @@ public class SDKDownloader {
private static final String SDK_TOOLS = "25.1.1";
public static final String BUILD_TOOLS = "23.0.3";
private static final int ANDROID_VERSION = 19;
public static final String GRADLE_VERSION = "2.14.1";
public SDKDownloader(PathManager pathManager) {
@@ -78,7 +79,7 @@ public class SDKDownloader {
}
public void downloadGradle() {
download("https://services.gradle.org/distributions/gradle-2.12-bin.zip", gradleZipPath);
download("https://services.gradle.org/distributions/gradle-" + GRADLE_VERSION + "-bin.zip", gradleZipPath);
}
private static String getDownloadUrl(String prefix) {

View File

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

View File

@@ -32,8 +32,8 @@ import org.jetbrains.kotlin.config.CommonConfigurationKeys;
import org.jetbrains.kotlin.config.CompilerConfiguration;
import org.jetbrains.kotlin.config.JVMConfigurationKeys;
import org.jetbrains.kotlin.idea.KotlinFileType;
import org.jetbrains.kotlin.load.java.JvmAbi;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.name.NameUtils;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.test.*;
import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase;
@@ -244,6 +244,11 @@ public class CodegenTestsOnAndroidGenerator extends KtUsefulTestCase {
continue;
}
//TODO: support LANGUAGE_VERSION
if (InTextDirectivesUtils.isDirectiveDefined(fullFileText, "LANGUAGE_VERSION:")) {
continue;
}
//TODO: support multifile facades
//TODO: support multifile facades hierarchies
if (hasBoxMethod(fullFileText)) {
@@ -279,7 +284,7 @@ public class CodegenTestsOnAndroidGenerator extends KtUsefulTestCase {
}
private String generateTestName(String fileName) {
String result = JvmAbi.sanitizeAsJavaIdentifier(FileUtil.getNameWithoutExtension(StringUtil.capitalize(fileName)));
String result = NameUtils.sanitizeAsJavaIdentifier(FileUtil.getNameWithoutExtension(StringUtil.capitalize(fileName)));
int i = 0;
while (generatedTestNames.contains(result)) {

View File

@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.backend.common
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.backend.common.bridges.findInterfaceImplementation
import org.jetbrains.kotlin.descriptors.*
@@ -90,7 +91,7 @@ object CodegenUtil {
else if (traitMember is PropertyDescriptor) {
for (traitAccessor in traitMember.accessors) {
for (inheritedAccessor in (copy as PropertyDescriptor).accessors) {
if (inheritedAccessor.javaClass == traitAccessor.javaClass) { // same accessor kind
if (inheritedAccessor::class.java == traitAccessor::class.java) { // same accessor kind
result.put(traitAccessor, inheritedAccessor)
}
}
@@ -154,4 +155,12 @@ object CodegenUtil {
}
return this[slice, whenExpression] == true
}
@JvmStatic
fun constructFakeFunctionCall(project: Project, referencedFunction: FunctionDescriptor): KtCallExpression {
val fakeFunctionCall = StringBuilder("callableReferenceFakeCall(")
fakeFunctionCall.append(referencedFunction.valueParameters.map { "p${it.index}" }.joinToString(", "))
fakeFunctionCall.append(")")
return KtPsiFactory(project).createExpression(fakeFunctionCall.toString()) as KtCallExpression
}
}

View File

@@ -103,5 +103,5 @@ abstract class DataClassMethodGenerator(private val declaration: KtClassOrObject
.map { bindingContext.get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, it)!! }
private val primaryConstructorParameters: List<KtParameter>
get() = (declaration as? KtClass)?.getPrimaryConstructorParameters().orEmpty()
get() = (declaration as? KtClass)?.primaryConstructorParameters.orEmpty()
}

View File

@@ -19,12 +19,26 @@ package org.jetbrains.kotlin.backend.common
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
import org.jetbrains.kotlin.resolve.DescriptorEquivalenceForOverrides
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.descriptorUtil.module
val SUSPEND_WITH_CURRENT_CONTINUATION_NAME = Name.identifier("suspendWithCurrentContinuation")
val CONTINUATION_RESUME_METHOD_NAME = Name.identifier("resume")
val SUSPEND_COROUTINE_OR_RETURN_NAME = Name.identifier("suspendCoroutineOrReturn")
val COROUTINE_SUSPENDED_NAME = Name.identifier("COROUTINE_SUSPENDED")
fun FunctionDescriptor.getBuiltInSuspendWithCurrentContinuation() =
builtIns.builtInsCoroutinePackageFragment.getMemberScope()
.getContributedFunctions(SUSPEND_WITH_CURRENT_CONTINUATION_NAME, NoLookupLocation.FROM_BACKEND)
val COROUTINES_INTRINSICS_PACKAGE_FQ_NAME = DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME.child(Name.identifier("intrinsics"))
fun FunctionDescriptor.isBuiltInSuspendCoroutineOrReturn(): Boolean {
if (name != SUSPEND_COROUTINE_OR_RETURN_NAME) return false
val originalDeclaration = getBuiltInSuspendCoroutineOrReturn() ?: return false
return DescriptorEquivalenceForOverrides.areEquivalent(
originalDeclaration, this
)
}
fun FunctionDescriptor.getBuiltInSuspendCoroutineOrReturn() =
module.getPackage(COROUTINES_INTRINSICS_PACKAGE_FQ_NAME).memberScope
.getContributedFunctions(SUSPEND_COROUTINE_OR_RETURN_NAME, NoLookupLocation.FROM_BACKEND)
.singleOrNull()

View File

@@ -18,13 +18,19 @@ package org.jetbrains.kotlin.codegen;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.codegen.coroutines.CoroutineCodegenUtilKt;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.descriptors.impl.FunctionDescriptorImpl;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import java.util.LinkedHashMap;
public class AccessorForFunctionDescriptor extends AbstractAccessorForFunctionDescriptor implements AccessorForCallableDescriptor<FunctionDescriptor> {
private final FunctionDescriptor calleeDescriptor;
private final ClassDescriptor superCallTarget;
private final String nameSuffix;
public AccessorForFunctionDescriptor(
@NotNull FunctionDescriptor descriptor,
@@ -36,6 +42,7 @@ public class AccessorForFunctionDescriptor extends AbstractAccessorForFunctionDe
Name.identifier("access$" + nameSuffix));
this.calleeDescriptor = descriptor;
this.superCallTarget = superCallTarget;
this.nameSuffix = nameSuffix;
initialize(DescriptorUtils.getReceiverParameterType(descriptor.getExtensionReceiverParameter()),
descriptor instanceof ConstructorDescriptor || CodegenUtilKt.isJvmStaticInObjectOrClass(descriptor)
@@ -46,6 +53,28 @@ public class AccessorForFunctionDescriptor extends AbstractAccessorForFunctionDe
descriptor.getReturnType(),
Modality.FINAL,
Visibilities.LOCAL);
setSuspend(descriptor.isSuspend());
if (descriptor.getUserData(CoroutineCodegenUtilKt.INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION) != null) {
userDataMap = new LinkedHashMap<UserDataKey<?>, Object>();
userDataMap.put(
CoroutineCodegenUtilKt.INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION,
descriptor.getUserData(CoroutineCodegenUtilKt.INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION)
);
}
}
@NotNull
@Override
protected FunctionDescriptorImpl createSubstitutedCopy(
@NotNull DeclarationDescriptor newOwner,
@Nullable FunctionDescriptor original,
@NotNull Kind kind,
@Nullable Name newName,
@NotNull Annotations annotations,
@NotNull SourceElement source
) {
return new AccessorForFunctionDescriptor(calleeDescriptor, newOwner, superCallTarget, nameSuffix);
}
@NotNull

View File

@@ -76,9 +76,8 @@ public class AccessorForPropertyDescriptor extends PropertyDescriptorImpl implem
boolean setterAccessorRequired
) {
super(containingDeclaration, null, Annotations.Companion.getEMPTY(), Modality.FINAL, Visibilities.LOCAL,
original.isVar(), Name.identifier("access$" + nameSuffix),
Kind.DECLARATION, SourceElement.NO_SOURCE, /* lateInit = */ false, /* isConst = */ false,
/* isHeader = */ false, /* isImpl = */ false, /* isExternal = */ false);
original.isVar(), Name.identifier("access$" + nameSuffix), Kind.DECLARATION, SourceElement.NO_SOURCE,
false, false, false, false, false, false);
this.calleeDescriptor = original;
this.superCallTarget = superCallTarget;

View File

@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.codegen
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.resolve.calls.model.DefaultValueArgument
import org.jetbrains.kotlin.resolve.calls.model.ExpressionValueArgument
import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument
@@ -31,7 +32,12 @@ abstract class ArgumentGenerator {
*
* @see kotlin.reflect.jvm.internal.KCallableImpl.callBy
*/
open fun generate(valueArgumentsByIndex: List<ResolvedValueArgument>, actualArgs: List<ResolvedValueArgument>): DefaultCallArgs {
open fun generate(
valueArgumentsByIndex: List<ResolvedValueArgument>,
actualArgs: List<ResolvedValueArgument>,
// may be null for a constructor of an object literal
calleeDescriptor: CallableDescriptor?
): DefaultCallArgs {
assert(valueArgumentsByIndex.size == actualArgs.size) {
"Value arguments collection should have same size, but ${valueArgumentsByIndex.size} != ${actualArgs.size}"
}
@@ -48,7 +54,8 @@ abstract class ArgumentGenerator {
}
}
val defaultArgs = DefaultCallArgs(valueArgumentsByIndex.size)
// Use unwrapped version, because additional synthetic parameters can't have default values
val defaultArgs = DefaultCallArgs(calleeDescriptor?.unwrapFrontendVersion()?.valueParameters?.size ?: 0)
for (argumentWithDeclIndex in actualArgsWithDeclIndex) {
val argument = argumentWithDeclIndex.arg

View File

@@ -168,6 +168,11 @@ public class AsmUtil {
return Type.getType(internalName.substring(1));
}
@NotNull
public static Type getArrayType(@NotNull Type componentType) {
return Type.getType("[" + componentType.getDescriptor());
}
@Nullable
public static PrimitiveType asmPrimitiveTypeToLangPrimitiveType(Type type) {
JvmPrimitiveType jvmPrimitiveType = primitiveTypeByAsmSort.get(type.getSort());
@@ -181,7 +186,7 @@ public class AsmUtil {
public static boolean isAbstractMethod(FunctionDescriptor functionDescriptor, OwnerKind kind, GenerationState state) {
return (functionDescriptor.getModality() == Modality.ABSTRACT ||
(isJvmInterface(functionDescriptor.getContainingDeclaration()) && !state.isJvm8Target()))
(isJvmInterface(functionDescriptor.getContainingDeclaration()) && !state.isJvm8TargetWithDefaults()))
&& !isStaticMethod(kind, functionDescriptor);
}
@@ -587,6 +592,10 @@ public class AsmUtil {
v.invokestatic(IntrinsicMethods.INTRINSICS_CLASS_NAME, "areEqual", "(Ljava/lang/Object;Ljava/lang/Object;)Z", false);
}
public static void genIEEE754EqualForNullableTypesCall(InstructionAdapter v, Type left, Type right) {
v.invokestatic(IntrinsicMethods.INTRINSICS_CLASS_NAME, "areEqual", "(" + left.getDescriptor() + right.getDescriptor() + ")Z", false);
}
public static void numConst(int value, Type type, InstructionAdapter v) {
if (type == Type.FLOAT_TYPE) {
v.fconst(value);
@@ -761,6 +770,7 @@ public class AsmUtil {
if (left == Type.DOUBLE_TYPE || right == Type.DOUBLE_TYPE) return Type.DOUBLE_TYPE;
if (left == Type.FLOAT_TYPE || right == Type.FLOAT_TYPE) return Type.FLOAT_TYPE;
if (left == Type.LONG_TYPE || right == Type.LONG_TYPE) return Type.LONG_TYPE;
if (left == Type.CHAR_TYPE || right == Type.CHAR_TYPE) return Type.CHAR_TYPE;
return Type.INT_TYPE;
}

View File

@@ -210,7 +210,12 @@ class NumberCompare(
) : BranchedValue(left, right, operandType, NumberCompare.getNumberCompareOpcode(opToken)) {
override fun patchOpcode(opcode: Int, v: InstructionAdapter): Int {
when (operandType) {
// 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"
}
return when (operandType) {
Type.FLOAT_TYPE, Type.DOUBLE_TYPE -> {
if (opToken == KtTokens.GT || opToken == KtTokens.GTEQ) {
v.cmpl(operandType)
@@ -218,17 +223,19 @@ class NumberCompare(
else {
v.cmpg(operandType)
}
opcode
}
Type.LONG_TYPE -> {
v.lcmp()
opcode
}
else -> {
return opcode + (IF_ICMPEQ - IFEQ)
opcode + (IF_ICMPEQ - IFEQ)
}
}
return opcode
}
companion object {
fun getNumberCompareOpcode(opToken: IElementType): Int {
return when (opToken) {
@@ -262,4 +269,4 @@ class ObjectCompare(
}
}
}
}
}

View File

@@ -17,10 +17,13 @@
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.*;
import org.jetbrains.kotlin.types.FlexibleTypesKt;
import org.jetbrains.org.objectweb.asm.Type;
import java.util.List;
@@ -53,11 +56,12 @@ public class CallBasedArgumentGenerator extends ArgumentGenerator {
@Override
public DefaultCallArgs generate(
@NotNull List<? extends ResolvedValueArgument> valueArgumentsByIndex,
@NotNull List<? extends ResolvedValueArgument> valueArgs
@NotNull List<? extends ResolvedValueArgument> valueArgs,
@Nullable CallableDescriptor calleeDescriptor
) {
boolean shouldMarkLineNumbers = this.codegen.isShouldMarkLineNumbers();
this.codegen.setShouldMarkLineNumbers(false);
DefaultCallArgs defaultArgs = super.generate(valueArgumentsByIndex, valueArgs);
DefaultCallArgs defaultArgs = super.generate(valueArgumentsByIndex, valueArgs, calleeDescriptor);
this.codegen.setShouldMarkLineNumbers(shouldMarkLineNumbers);
return defaultArgs;
}
@@ -84,7 +88,9 @@ public class CallBasedArgumentGenerator extends ArgumentGenerator {
protected void generateVararg(int i, @NotNull VarargValueArgument argument) {
ValueParameterDescriptor parameter = valueParameters.get(i);
Type type = valueParameterTypes.get(i);
codegen.genVarargs(argument, parameter.getType());
// 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
codegen.genVarargs(argument, FlexibleTypesKt.upperIfFlexible(parameter.getType()));
callGenerator.afterParameterPut(type, null, i);
}

View File

@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.load.java.JvmAbi
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterKind
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.org.objectweb.asm.Opcodes.INVOKESPECIAL
import org.jetbrains.org.objectweb.asm.Opcodes.INVOKESTATIC
import org.jetbrains.org.objectweb.asm.Type
@@ -35,7 +36,8 @@ class CallableMethod(
private val invokeOpcode: Int,
override val dispatchReceiverType: Type?,
override val extensionReceiverType: Type?,
override val generateCalleeType: Type?
override val generateCalleeType: Type?,
private val isInterfaceMethod: Boolean = Opcodes.INVOKEINTERFACE == invokeOpcode
) : Callable {
fun getValueParameters(): List<JvmMethodParameterSignature> =
signature.valueParameters
@@ -51,7 +53,13 @@ class CallableMethod(
override fun genInvokeInstruction(v: InstructionAdapter) {
v.visitMethodInsn(invokeOpcode, owner.internalName, getAsmMethod().name, getAsmMethod().descriptor)
v.visitMethodInsn(
invokeOpcode,
owner.internalName,
getAsmMethod().name,
getAsmMethod().descriptor,
isInterfaceMethod
)
}
fun genInvokeDefaultInstruction(v: InstructionAdapter) {
@@ -61,7 +69,7 @@ class CallableMethod(
val method = getAsmMethod()
if ("<init>".equals(method.name)) {
if ("<init>" == method.name) {
v.visitMethodInsn(INVOKESPECIAL, defaultImplOwner.internalName, "<init>", defaultMethodDesc, false)
}
else {

View File

@@ -77,9 +77,13 @@ public abstract class ClassBodyCodegen extends MemberCodegen<KtPureClassOrObject
}
}
generatePrimaryConstructorProperties();
generateConstructors();
generateDefaultImplsIfNeeded();
boolean generateNonClassMembers = shouldGenerateNonClassMembers();
if (generateNonClassMembers) {
generatePrimaryConstructorProperties();
generateConstructors();
generateDefaultImplsIfNeeded();
}
// Generate _declared_ companions
for (KtObjectDeclaration companion : companions) {
@@ -92,23 +96,30 @@ public abstract class ClassBodyCodegen extends MemberCodegen<KtPureClassOrObject
genSyntheticClassOrObject((SyntheticClassOrObjectDescriptor) companionObjectDescriptor);
}
if (!DescriptorUtils.isInterface(descriptor)) {
for (DeclarationDescriptor memberDescriptor : DescriptorUtils.getAllDescriptors(descriptor.getDefaultType().getMemberScope())) {
if (memberDescriptor instanceof CallableMemberDescriptor) {
CallableMemberDescriptor member = (CallableMemberDescriptor) memberDescriptor;
if (!member.getKind().isReal() && ImplKt.findInterfaceImplementation(member) == null) {
if (member instanceof FunctionDescriptor) {
functionCodegen.generateBridges((FunctionDescriptor) member);
if (generateNonClassMembers) {
generateBridges();
}
}
private void generateBridges() {
if (DescriptorUtils.isInterface(descriptor)) {
return;
}
for (DeclarationDescriptor memberDescriptor : DescriptorUtils.getAllDescriptors(descriptor.getDefaultType().getMemberScope())) {
if (memberDescriptor instanceof CallableMemberDescriptor) {
CallableMemberDescriptor member = (CallableMemberDescriptor) memberDescriptor;
if (!member.getKind().isReal() && ImplKt.findInterfaceImplementation(member) == null) {
if (member instanceof FunctionDescriptor) {
functionCodegen.generateBridges((FunctionDescriptor) member);
}
else if (member instanceof PropertyDescriptor) {
PropertyGetterDescriptor getter = ((PropertyDescriptor) member).getGetter();
if (getter != null) {
functionCodegen.generateBridges(getter);
}
else if (member instanceof PropertyDescriptor) {
PropertyGetterDescriptor getter = ((PropertyDescriptor) member).getGetter();
if (getter != null) {
functionCodegen.generateBridges(getter);
}
PropertySetterDescriptor setter = ((PropertyDescriptor) member).getSetter();
if (setter != null) {
functionCodegen.generateBridges(setter);
}
PropertySetterDescriptor setter = ((PropertyDescriptor) member).getSetter();
if (setter != null) {
functionCodegen.generateBridges(setter);
}
}
}
@@ -116,6 +127,11 @@ public abstract class ClassBodyCodegen extends MemberCodegen<KtPureClassOrObject
}
}
private boolean shouldGenerateNonClassMembers() {
return !(myClass instanceof KtClassOrObject) ||
state.getGenerateDeclaredClassFilter().shouldGenerateClassMembers((KtClassOrObject) myClass);
}
protected void generateConstructors() {
}
@@ -130,7 +146,9 @@ public abstract class ClassBodyCodegen extends MemberCodegen<KtPureClassOrObject
protected void generateDeclaration(KtDeclaration declaration) {
if (declaration instanceof KtProperty || declaration instanceof KtNamedFunction || declaration instanceof KtTypeAlias) {
genSimpleMember(declaration);
if (shouldGenerateNonClassMembers()) {
genSimpleMember(declaration);
}
}
else if (declaration instanceof KtClassOrObject) {
if (declaration instanceof KtEnumEntry && !enumEntryNeedSubclass(bindingContext, (KtEnumEntry) declaration)) {

View File

@@ -55,20 +55,12 @@ 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);
private static class TestClassBuilderFactory implements ClassBuilderFactory {
public static class TestClassBuilderFactory implements ClassBuilderFactory {
private final boolean generateSourceRetentionAnnotations;
public TestClassBuilderFactory(boolean generateSourceRetentionAnnotations) {

View File

@@ -16,6 +16,8 @@
package org.jetbrains.kotlin.codegen;
import org.jetbrains.annotations.TestOnly;
public class ClassBuilderMode {
public final boolean generateBodies;
public final boolean generateMetadata;
@@ -73,4 +75,11 @@ 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

@@ -82,7 +82,7 @@ public class ClassFileFactory implements OutputFileCollection {
return answer;
}
void done() {
public void done() {
if (!isDone) {
isDone = true;
writeModuleMappings();

View File

@@ -26,6 +26,8 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.codegen.binding.CalculatedClosure;
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;
@@ -33,13 +35,11 @@ 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;
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader;
import org.jetbrains.kotlin.psi.KtElement;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKt;
@@ -62,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.binding.CodegenBinding.asmTypeForAnonymousClass;
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;
@@ -198,7 +197,7 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
);
}
private void generateBridges() {
protected void generateBridges() {
FunctionDescriptor erasedInterfaceFunction;
if (samType == null) {
erasedInterfaceFunction = getErasedInvokeFunction(funDescriptor);
@@ -231,9 +230,10 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
@Override
protected void generateKotlinMetadataAnnotation() {
FunctionDescriptor freeLambdaDescriptor = createFreeLambdaDescriptor(funDescriptor);
Method method = v.getSerializationBindings().get(METHOD_FOR_FUNCTION, funDescriptor);
assert method != null : "No method for " + funDescriptor;
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;
v.getSerializationBindings().put(METHOD_FOR_FUNCTION, freeLambdaDescriptor, method);
final DescriptorSerializer serializer =
@@ -396,6 +396,9 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
}
else if (container instanceof PackageFragmentDescriptor) {
iv.aconst(state.getTypeMapper().mapOwner(descriptor));
// 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
iv.aconst(state.getModuleName());
iv.invokestatic(REFLECTION, "getOrCreateKotlinPackage",
Type.getMethodDescriptor(K_DECLARATION_CONTAINER_TYPE, getType(Class.class), getType(String.class)), false);
@@ -429,7 +432,8 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
iv.load(0, superClassAsmType);
String superClassConstructorDescriptor;
if (superClassAsmType.equals(LAMBDA) || superClassAsmType.equals(FUNCTION_REFERENCE) || superClassAsmType.equals(COROUTINE_IMPL)) {
if (superClassAsmType.equals(LAMBDA) || superClassAsmType.equals(FUNCTION_REFERENCE) ||
superClassAsmType.equals(CoroutineCodegenUtilKt.COROUTINE_IMPL_ASM_TYPE)) {
int arity = calculateArity();
iv.iconst(arity);
if (shouldHaveBoundReferenceReceiver) {
@@ -466,7 +470,6 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
@NotNull CalculatedClosure closure,
@NotNull Type ownerType
) {
BindingContext bindingContext = typeMapper.getBindingContext();
List<FieldInfo> args = Lists.newArrayList();
ClassDescriptor captureThis = closure.getCaptureThis();
if (captureThis != null) {
@@ -478,23 +481,15 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
args.add(FieldInfo.createForHiddenField(ownerType, typeMapper.mapType(captureReceiverType), CAPTURED_RECEIVER_FIELD));
}
for (DeclarationDescriptor descriptor : closure.getCaptureVariables().keySet()) {
if (descriptor instanceof VariableDescriptor && !(descriptor instanceof PropertyDescriptor)) {
Type type = typeMapper.getSharedVarType(descriptor);
if (type == null && descriptor instanceof LocalVariableDescriptor) {
KotlinType delegateType = JvmCodegenUtil.getPropertyDelegateType((LocalVariableDescriptor) descriptor, bindingContext);
if (delegateType != null) {
type = typeMapper.mapType(delegateType);
}
}
if (type == null) {
type = typeMapper.mapType((VariableDescriptor) descriptor);
}
args.add(FieldInfo.createForHiddenField(ownerType, type, "$" + descriptor.getName().asString()));
}
else if (ExpressionTypingUtils.isLocalFunction(descriptor)) {
Type classType = asmTypeForAnonymousClass(bindingContext, (FunctionDescriptor) descriptor);
args.add(FieldInfo.createForHiddenField(ownerType, classType, "$" + descriptor.getName().asString()));
for (EnclosedValueDescriptor enclosedValueDescriptor : closure.getCaptureVariables().values()) {
DeclarationDescriptor descriptor = enclosedValueDescriptor.getDescriptor();
if ((descriptor instanceof VariableDescriptor && !(descriptor instanceof PropertyDescriptor)) ||
ExpressionTypingUtils.isLocalFunction(descriptor)) {
args.add(
FieldInfo.createForHiddenField(
ownerType, enclosedValueDescriptor.getType(), enclosedValueDescriptor.getFieldName()
)
);
}
else if (descriptor instanceof FunctionDescriptor) {
assert captureReceiverType != null;

View File

@@ -17,12 +17,8 @@
package org.jetbrains.kotlin.codegen
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
import org.jetbrains.kotlin.psi.KtDeclarationWithBody
import org.jetbrains.kotlin.psi.KtParameter
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
class ClosureGenerationStrategy(
state: GenerationState,
@@ -30,35 +26,8 @@ class ClosureGenerationStrategy(
) : FunctionGenerationStrategy.FunctionDefault(state, declaration) {
override fun doGenerateBody(codegen: ExpressionCodegen, signature: JvmMethodSignature) {
processDestructuringInLambdaParameters(codegen)
initializeVariablesForDestructuredLambdaParameters(codegen, codegen.context.functionDescriptor.valueParameters)
super.doGenerateBody(codegen, signature)
}
private fun processDestructuringInLambdaParameters(codegen: ExpressionCodegen) {
val savedIsShouldMarkLineNumbers = codegen.isShouldMarkLineNumbers
// Do not write line numbers until destructuring happens
// (otherwise destructuring variables will be uninitialized in the beginning of lambda)
codegen.isShouldMarkLineNumbers = false
for (parameterDescriptor in codegen.context.functionDescriptor.valueParameters) {
if (parameterDescriptor !is ValueParameterDescriptorImpl.WithDestructuringDeclaration) continue
for (entry in parameterDescriptor.destructuringVariables.filterOutDescriptorsWithSpecialNames()) {
codegen.myFrameMap.enter(entry, codegen.typeMapper.mapType(entry.type))
}
val destructuringDeclaration =
(DescriptorToSourceUtils.descriptorToDeclaration(parameterDescriptor) as? KtParameter)?.destructuringDeclaration
?: error("Destructuring declaration for descriptor $parameterDescriptor not found")
codegen.initializeDestructuringDeclarationVariables(
destructuringDeclaration,
TransientReceiver(parameterDescriptor.type),
codegen.findLocalOrCapturedValue(parameterDescriptor) ?: error("Local var not found for parameter $parameterDescriptor")
)
}
codegen.isShouldMarkLineNumbers = savedIsShouldMarkLineNumbers
}
}

View File

@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.DECLARATION
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.FAKE_OVERRIDE
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.descriptors.impl.MutableClassDescriptor
import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature.getSpecialSignatureInfo
import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature.isBuiltinWithSpecialDescriptorInJvm
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor

View File

@@ -54,7 +54,7 @@ class DefaultParameterValueSubstitutor(val state: GenerationState) {
contextKind: OwnerKind,
classOrObject: KtPureClassOrObject
) {
val methodElement = classOrObject.getPrimaryConstructor() ?: classOrObject
val methodElement = classOrObject.primaryConstructor ?: classOrObject
if (generateOverloadsIfNeeded(methodElement, constructorDescriptor, constructorDescriptor, contextKind, classBuilder, memberCodegen)) {
return
@@ -128,12 +128,14 @@ class DefaultParameterValueSubstitutor(val state: GenerationState) {
) {
val typeMapper = state.typeMapper
val isStatic = AsmUtil.isStaticMethod(contextKind, functionDescriptor)
val flags = AsmUtil.getCommonCallableFlags(functionDescriptor) or
(if (isStatic) Opcodes.ACC_STATIC else 0) or
(if (functionDescriptor.modality == Modality.FINAL && functionDescriptor !is ConstructorDescriptor) Opcodes.ACC_FINAL else 0)
val baseMethodFlags = AsmUtil.getCommonCallableFlags(functionDescriptor) and Opcodes.ACC_VARARGS.inv()
val remainingParameters = getRemainingParameters(functionDescriptor.original, substituteCount)
val signature = typeMapper.mapSignature(functionDescriptor, contextKind, remainingParameters, false)
val flags =
baseMethodFlags or
(if (isStatic) Opcodes.ACC_STATIC else 0) or
(if (functionDescriptor.modality == Modality.FINAL && functionDescriptor !is ConstructorDescriptor) Opcodes.ACC_FINAL else 0) or
(if (remainingParameters.lastOrNull()?.varargElementType != null) Opcodes.ACC_VARARGS else 0)
val signature = typeMapper.mapSignatureWithCustomParameters(functionDescriptor, contextKind, remainingParameters, false)
val mv = classBuilder.newMethod(OtherOrigin(methodElement, functionDescriptor), flags,
signature.asmMethod.name,
signature.asmMethod.descriptor,
@@ -146,10 +148,7 @@ class DefaultParameterValueSubstitutor(val state: GenerationState) {
mv.visitAnnotation(ANNOTATION_TYPE_DESCRIPTOR_FOR_JVMOVERLOADS_GENERATED_METHODS, /* visible = */ false)
}
remainingParameters.withIndex().forEach {
val annotationCodegen = AnnotationCodegen.forParameter(it.index, mv, memberCodegen, typeMapper)
annotationCodegen.genAnnotations(it.value, signature.valueParameters[it.index].asmType)
}
FunctionCodegen.generateParameterAnnotations(functionDescriptor, mv, signature, remainingParameters, memberCodegen, state)
if (!state.classBuilderMode.generateBodies) {
FunctionCodegen.generateLocalVariablesForParameters(mv, signature, null, Label(), Label(), remainingParameters, isStatic, typeMapper)
@@ -252,7 +251,7 @@ class DefaultParameterValueSubstitutor(val state: GenerationState) {
val classDescriptor = constructorDescriptor.constructedClass
if (classDescriptor.kind != ClassKind.CLASS) return false
if (classOrObject.isLocal()) return false
if (classOrObject.isLocal) return false
if (CodegenBinding.canHaveOuter(state.bindingContext, classDescriptor)) return false
@@ -266,6 +265,6 @@ class DefaultParameterValueSubstitutor(val state: GenerationState) {
}
private fun hasSecondaryConstructorsWithNoParameters(klass: KtClass) =
klass.getSecondaryConstructors().any { it.valueParameters.isEmpty() }
klass.secondaryConstructors.any { it.valueParameters.isEmpty() }
}

View File

@@ -33,10 +33,10 @@ abstract class DelegatingClassBuilderFactory(
abstract override fun newClassBuilder(origin: JvmDeclarationOrigin): DelegatingClassBuilder
override fun asBytes(builder: ClassBuilder?): ByteArray? {
return delegate.asBytes((builder as DelegatingClassBuilder).getDelegate())
return delegate.asBytes((builder as DelegatingClassBuilder).delegate)
}
override fun asText(builder: ClassBuilder?): String? {
return delegate.asText((builder as DelegatingClassBuilder).getDelegate())
return delegate.asText((builder as DelegatingClassBuilder).delegate)
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
* 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.
@@ -50,8 +50,8 @@ import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper;
import org.jetbrains.kotlin.codegen.when.SwitchCodegen;
import org.jetbrains.kotlin.codegen.when.SwitchCodegenUtil;
import org.jetbrains.kotlin.config.ApiVersion;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor;
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor;
import org.jetbrains.kotlin.descriptors.impl.SyntheticFieldDescriptor;
import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptor;
@@ -61,6 +61,7 @@ import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
import org.jetbrains.kotlin.lexer.KtTokens;
import org.jetbrains.kotlin.load.java.JvmAbi;
import org.jetbrains.kotlin.load.java.descriptors.SamConstructorDescriptor;
import org.jetbrains.kotlin.load.kotlin.TypeSignatureMappingKt;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilsKt;
@@ -157,43 +158,18 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
this.v = new InstructionAdapter(mv);
this.myFrameMap = frameMap;
this.context = context;
FunctionDescriptor originalSuspendDescriptor = getOriginalSuspendDescriptor(context);
if (originalSuspendDescriptor != null && originalSuspendDescriptor.getReturnType() != null) {
this.returnType = getBoxedReturnTypeForSuspend(originalSuspendDescriptor);
}
else {
this.returnType = returnType;
}
this.returnType = returnType;
this.parentCodegen = parentCodegen;
this.tailRecursionCodegen = new TailRecursionCodegen(context, this, this.v, state);
}
@NotNull
private Type getBoxedReturnTypeForSuspend(FunctionDescriptor descriptorForSuspend) {
assert descriptorForSuspend.getReturnType() != null : "Uninitialized suspend return type";
return AsmUtil.boxType(typeMapper.mapType(descriptorForSuspend.getReturnType()));
}
@Nullable
private static FunctionDescriptor getOriginalSuspendDescriptor(MethodContext context) {
FunctionDescriptor originalCoroutineDescriptor = getOriginalCoroutineDescriptor(context);
if (originalCoroutineDescriptor != null) return originalCoroutineDescriptor;
if (context.getFunctionDescriptor().isSuspend()) {
return (FunctionDescriptor) CoroutineCodegenUtilKt.unwrapInitialDescriptorForSuspendFunction(context.getFunctionDescriptor());
}
return null;
}
@Nullable
private static FunctionDescriptor getOriginalCoroutineDescriptor(MethodContext context) {
private static FunctionDescriptor getOriginalSuspendLambdaDescriptorFromContext(MethodContext context) {
if ((context.getParentContext() instanceof ClosureContext) &&
(context.getParentContext().closure != null) &&
context.getParentContext().closure.isCoroutine()) {
return ((ClosureContext) context.getParentContext()).getCoroutineDescriptor();
context.getParentContext().closure.isSuspend()) {
return ((ClosureContext) context.getParentContext()).getOriginalSuspendLambdaDescriptor();
}
return null;
@@ -455,6 +431,16 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
return typeMapper.mapType(type);
}
@NotNull
private Type expressionTypeForBranchingOperation(@Nullable KtExpression expression) {
if (context.getFunctionDescriptor().isSuspend() &&
!CoroutineCodegenUtilKt.isStateMachineNeeded(context.getFunctionDescriptor(), bindingContext) &&
Boolean.TRUE.equals(bindingContext.get(IS_TAIL_EXPRESSION_IN_SUSPEND_FUNCTION, expression))) {
return AsmTypes.OBJECT_TYPE;
}
return expressionType(expression);
}
@NotNull
public Type expressionType(@Nullable KtExpression expression) {
return CodegenUtilKt.asmType(expression, typeMapper, bindingContext);
@@ -495,7 +481,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
}
/* package */ StackValue generateIfExpression(@NotNull final KtIfExpression expression, final boolean isStatement) {
final Type asmType = isStatement ? Type.VOID_TYPE : expressionType(expression);
final Type asmType = isStatement ? Type.VOID_TYPE : expressionTypeForBranchingOperation(expression);
final StackValue condition = gen(expression.getCondition());
final KtExpression thenExpression = expression.getThen();
@@ -587,6 +573,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
blockStackElements.push(new LoopBlockStackElement(breakLabel, continueLabel, targetLabel(expression)));
PseudoInsnsKt.fakeAlwaysFalseIfeq(v, continueLabel);
PseudoInsnsKt.fakeAlwaysFalseIfeq(v, breakLabel);
KtExpression body = expression.getBody();
KtExpression condition = expression.getCondition();
@@ -1531,6 +1518,10 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
}
KotlinType expectedType = bindingContext.getType(expression);
if (expectedType == null) {
return null;
}
return compileTimeValue.toConstantValue(expectedType);
}
@@ -1649,7 +1640,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
declaration.getContainingFile()
);
ClosureCodegen coroutineCodegen = CoroutineCodegen.create(this, descriptor, declaration, cv);
ClosureCodegen coroutineCodegen = CoroutineCodegen.createByLambda(this, descriptor, declaration, cv);
ClosureCodegen closureCodegen = coroutineCodegen != null ? coroutineCodegen : new ClosureCodegen(
state, declaration, samType, context.intoClosure(descriptor, this, typeMapper),
functionReferenceTarget, strategy, parentCodegen, cv
@@ -1657,6 +1648,14 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
closureCodegen.generate();
return putClosureInstanceOnStack(closureCodegen, functionReferenceReceiver);
}
@NotNull
public StackValue putClosureInstanceOnStack(
@NotNull ClosureCodegen closureCodegen,
@Nullable StackValue functionReferenceReceiver
) {
if (closureCodegen.getReifiedTypeParametersUsages().wereUsedReifiedParameters()) {
ReifiedTypeInliner.putNeedClassReificationMarker(v);
propagateChildReifiedTypeParametersUsages(closureCodegen.getReifiedTypeParametersUsages());
@@ -1710,7 +1709,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
ArgumentGenerator argumentGenerator =
new CallBasedArgumentGenerator(ExpressionCodegen.this, defaultCallGenerator, valueParameters, mappedTypes);
argumentGenerator.generate(valueArguments, valueArguments);
argumentGenerator.generate(valueArguments, valueArguments, null);
}
Collection<ClassConstructorDescriptor> constructors = classDescriptor.getConstructors();
@@ -1748,7 +1747,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
if (captureReceiver != null) {
StackValue capturedReceiver =
functionReferenceReceiver != null ? functionReferenceReceiver :
generateExtensionReceiver(unwrapOriginalLambdaDescriptorForCoroutine(context));
generateExtensionReceiver(unwrapOriginalReceiverOwnerForSuspendFunction(context));
callGenerator.putCapturedValueOnStack(capturedReceiver, capturedReceiver.type, paramIndex++);
}
@@ -1769,16 +1768,36 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
);
}
if (closure.isCoroutine()) {
if (closure.isSuspend()) {
// resultContinuation
v.aconst(null);
if (closure.isSuspendLambda()) {
v.aconst(null);
}
else {
assert context.getFunctionDescriptor().isSuspend() : "Coroutines closure must be created only inside suspend functions";
ValueParameterDescriptor continuationParameter = CollectionsKt.last(context.getFunctionDescriptor().getValueParameters());
StackValue continuationValue = findLocalOrCapturedValue(continuationParameter);
assert continuationValue != null : "Couldn't find a value for continuation parameter of " + context.getFunctionDescriptor();
callGenerator.putCapturedValueOnStack(continuationValue, continuationValue.type, paramIndex++);
}
}
}
@NotNull
private static CallableDescriptor unwrapOriginalLambdaDescriptorForCoroutine(@NotNull MethodContext context) {
FunctionDescriptor coroutine = getOriginalSuspendDescriptor(context);
if (coroutine != null) return coroutine;
private static CallableDescriptor unwrapOriginalReceiverOwnerForSuspendFunction(@NotNull MethodContext context) {
FunctionDescriptor originalForDoResume =
context.getFunctionDescriptor().getUserData(CoroutineCodegenUtilKt.INITIAL_SUSPEND_DESCRIPTOR_FOR_DO_RESUME);
if (originalForDoResume != null) {
return originalForDoResume;
}
if (context.getFunctionDescriptor().isSuspend()) {
return CoroutineCodegenUtilKt.unwrapInitialDescriptorForSuspendFunction(context.getFunctionDescriptor());
}
return context.getFunctionDescriptor();
}
@@ -1869,17 +1888,17 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
@Nullable
private StackValue getCoroutineInstanceValueForSuspensionPoint(@NotNull ResolvedCall<?> resolvedCall) {
CallableDescriptor enclosingSuspendLambdaForSuspensionPoint =
bindingContext.get(ENCLOSING_SUSPEND_LAMBDA_FOR_SUSPENSION_POINT, resolvedCall.getCall());
FunctionDescriptor enclosingSuspendLambdaForSuspensionPoint =
bindingContext.get(ENCLOSING_SUSPEND_FUNCTION_FOR_SUSPEND_FUNCTION_CALL, resolvedCall.getCall());
if (enclosingSuspendLambdaForSuspensionPoint == null) return null;
return genCoroutineInstanceByLambda(enclosingSuspendLambdaForSuspensionPoint);
return genCoroutineInstanceBySuspendFunction(enclosingSuspendLambdaForSuspensionPoint);
}
@NotNull
private StackValue genCoroutineInstanceByLambda(@NotNull CallableDescriptor suspendLambda) {
ClassDescriptor suspendLambdaClassDescriptor =
bindingContext.get(CodegenBinding.CLASS_FOR_CALLABLE, suspendLambda);
@Nullable
private StackValue genCoroutineInstanceBySuspendFunction(@NotNull FunctionDescriptor suspendFunction) {
if (!CoroutineCodegenUtilKt.isStateMachineNeeded(suspendFunction, bindingContext)) return null;
ClassDescriptor suspendLambdaClassDescriptor = bindingContext.get(CodegenBinding.CLASS_FOR_CALLABLE, suspendFunction);
assert suspendLambdaClassDescriptor != null : "Coroutine class descriptor should not be null";
return StackValue.thisOrOuter(this, suspendLambdaClassDescriptor, false, false);
@@ -1900,11 +1919,6 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
return asmType(varType);
}
private static boolean isSharedVarType(@NotNull Type type) {
return type.getSort() == Type.OBJECT && type.getInternalName().startsWith(REF_TYPE_PREFIX);
}
private void putDescriptorIntoFrameMap(@NotNull KtElement statement) {
if (statement instanceof KtDestructuringDeclaration) {
KtDestructuringDeclaration multiDeclaration = (KtDestructuringDeclaration) statement;
@@ -2208,7 +2222,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
FunctionDescriptor containingFunction =
BindingContextUtils.getContainingFunctionSkipFunctionLiterals(descriptor, true).getFirst();
//FIRST_FUN_LABEL to prevent clashing with existing labels
return new NonLocalReturnInfo(getReturnTypeForNonLocalReturn(containingFunction), InlineCodegenUtil.FIRST_FUN_LABEL);
return new NonLocalReturnInfo(typeMapper.mapReturnType(containingFunction), InlineCodegenUtil.FIRST_FUN_LABEL);
} else {
//local
return null;
@@ -2220,27 +2234,18 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
DeclarationDescriptor elementDescriptor = typeMapper.getBindingContext().get(DECLARATION_TO_DESCRIPTOR, element);
assert element != null : "Expression should be not null " + expression.getText();
assert elementDescriptor != null : "Descriptor should be not null: " + element.getText();
return new NonLocalReturnInfo(getReturnTypeForNonLocalReturn(elementDescriptor), expression.getLabelName());
return new NonLocalReturnInfo(typeMapper.mapReturnType((CallableDescriptor) elementDescriptor), expression.getLabelName());
}
}
return null;
}
@NotNull
private Type getReturnTypeForNonLocalReturn(DeclarationDescriptor elementDescriptor) {
return (elementDescriptor instanceof AnonymousFunctionDescriptor
&& ((AnonymousFunctionDescriptor) elementDescriptor).isCoroutine())
|| (elementDescriptor instanceof FunctionDescriptor && ((FunctionDescriptor) elementDescriptor).isSuspend())
? getBoxedReturnTypeForSuspend((FunctionDescriptor) elementDescriptor)
: typeMapper.mapReturnType((CallableDescriptor) elementDescriptor);
}
public void returnExpression(KtExpression expr) {
boolean isBlockedNamedFunction = expr instanceof KtBlockExpression && expr.getParent() instanceof KtNamedFunction;
FunctionDescriptor originalCoroutineDescriptor = getOriginalCoroutineDescriptor(context);
FunctionDescriptor originalSuspendLambdaDescriptor = getOriginalSuspendLambdaDescriptorFromContext(context);
boolean isVoidCoroutineLambda =
originalCoroutineDescriptor != null && typeMapper.mapReturnType(originalCoroutineDescriptor).getSort() == Type.VOID;
originalSuspendLambdaDescriptor != null && TypeSignatureMappingKt.hasVoidReturnType(originalSuspendLambdaDescriptor);
// If generating body for named block-bodied function or Unit-typed coroutine lambda, generate it as sequence of statements
Type typeForExpression =
@@ -2492,14 +2497,14 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
}
public int lookupLocalIndex(DeclarationDescriptor descriptor) {
return myFrameMap.getIndex(getParameterSynonymOrThis(descriptor));
}
private DeclarationDescriptor getParameterSynonymOrThis(DeclarationDescriptor descriptor) {
if (!(descriptor instanceof ValueParameterDescriptor)) return descriptor;
int index = myFrameMap.getIndex(descriptor);
if (index != -1) return index;
if (!(descriptor instanceof ValueParameterDescriptor)) return -1;
DeclarationDescriptor synonym = bindingContext.get(CodegenBinding.PARAMETER_SYNONYM, (ValueParameterDescriptor) descriptor);
return synonym != null ? synonym : descriptor;
if (synonym == null) return -1;
return myFrameMap.getIndex(synonym);
}
@NotNull
@@ -2590,7 +2595,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
if (!skipPropertyAccessors) {
if (!couldUseDirectAccessToProperty(propertyDescriptor, true, isDelegatedProperty, context, state.getShouldInlineConstVals())) {
propertyDescriptor = context.getAccessorForSuperCallIfNeeded(propertyDescriptor, superCallTarget);
propertyDescriptor = context.getAccessorForSuperCallIfNeeded(propertyDescriptor, superCallTarget, state);
propertyDescriptor = context.accessibleDescriptor(propertyDescriptor, superCallTarget);
@@ -2727,6 +2732,9 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
if (originalIfSamAdapter != null) {
descriptor = originalIfSamAdapter;
}
descriptor = CoroutineCodegenUtilKt.unwrapInitialDescriptorForSuspendFunction(descriptor);
// $default method is not private, so you need no accessor to call it
return CallUtilKt.usesDefaultArguments(resolvedCall)
? descriptor
@@ -2757,7 +2765,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
FunctionDescriptor fd = accessibleFunctionDescriptor(resolvedCall);
ClassDescriptor superCallTarget = getSuperCallTarget(call);
fd = context.getAccessorForSuperCallIfNeeded(fd, superCallTarget);
fd = context.getAccessorForSuperCallIfNeeded(fd, superCallTarget, state);
Collection<ExpressionCodegenExtension> codegenExtensions = ExpressionCodegenExtension.Companion.getInstances(state.getProject());
if (!codegenExtensions.isEmpty()) {
@@ -2770,29 +2778,17 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
Callable callable = resolveToCallable(fd, superCallTarget != null, resolvedCall);
StackValue result = callable.invokeMethodWithArguments(resolvedCall, receiver, this);
if (bindingContext.get(BindingContext.ENCLOSING_SUSPEND_FUNCTION_FOR_SUSPEND_FUNCTION_CALL, resolvedCall.getCall()) != null) {
// Suspend function's calls inside another suspend function should behave like they leave values of correct type,
// while real methods return java/lang/Object.
// NB: They are always in return position at the moment.
// If we didn't do this, StackValue.coerce would add proper CHECKCAST that would've failed in case of callee function
// returning SUSPENDED marker, which is instance of java/lang/Object.
return new OperationStackValue(returnType, ((OperationStackValue) result).getLambda());
}
return result;
return callable.invokeMethodWithArguments(resolvedCall, receiver, this);
}
private StackValue getContinuationParameterFromEnclosingSuspendFunction(@NotNull ResolvedCall<?> resolvedCall) {
SimpleFunctionDescriptor enclosingSuspendFunction =
FunctionDescriptor enclosingSuspendFunction =
bindingContext.get(BindingContext.ENCLOSING_SUSPEND_FUNCTION_FOR_SUSPEND_FUNCTION_CALL, resolvedCall.getCall());
assert enclosingSuspendFunction != null
: "Suspend functions may be called either as suspension points or from another suspend function";
SimpleFunctionDescriptor enclosingSuspendFunctionJvmView =
FunctionDescriptor enclosingSuspendFunctionJvmView =
bindingContext.get(CodegenBinding.SUSPEND_FUNCTION_TO_JVM_VIEW, enclosingSuspendFunction);
assert enclosingSuspendFunctionJvmView != null : "No JVM view function found for " + enclosingSuspendFunction;
@@ -2856,17 +2852,9 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
@NotNull CallGenerator callGenerator,
@NotNull ArgumentGenerator argumentGenerator
) {
boolean isSuspensionPoint = CoroutineCodegenUtilKt.isSuspensionPoint(resolvedCall, bindingContext);
if (isSuspensionPoint) {
// Inline markers are used to spill the stack before coroutine suspension
addInlineMarker(v, true);
}
boolean isSuspensionPoint = CoroutineCodegenUtilKt.isSuspensionPointInStateMachine(resolvedCall, bindingContext);
boolean isConstructor = resolvedCall.getResultingDescriptor() instanceof ConstructorDescriptor;
if (!isConstructor) { // otherwise already
receiver = StackValue.receiver(resolvedCall, receiver, this, callableMethod);
receiver.put(receiver.type, v);
callableMethod.afterReceiverGeneration(v);
}
putReceiverAndInlineMarkerIfNeeded(callableMethod, resolvedCall, receiver, isSuspensionPoint, isConstructor);
callGenerator.processAndPutHiddenParameters(false);
@@ -2874,7 +2862,11 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
assert valueArguments != null : "Failed to arrange value arguments by index: " + resolvedCall.getResultingDescriptor();
DefaultCallArgs defaultArgs =
argumentGenerator.generate(valueArguments, new ArrayList<ResolvedValueArgument>(resolvedCall.getValueArguments().values()));
argumentGenerator.generate(
valueArguments,
new ArrayList<ResolvedValueArgument>(resolvedCall.getValueArguments().values()),
resolvedCall.getResultingDescriptor()
);
if (tailRecursionCodegen.isTailRecursion(resolvedCall)) {
tailRecursionCodegen.generateTailRecursion(resolvedCall);
@@ -2917,6 +2909,78 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
}
}
private void putReceiverAndInlineMarkerIfNeeded(
@NotNull Callable callableMethod,
@NotNull ResolvedCall<?> resolvedCall,
@NotNull StackValue receiver,
boolean isSuspensionPoint,
boolean isConstructor
) {
boolean isSafeCallOrOnStack = receiver instanceof StackValue.SafeCall || receiver instanceof StackValue.OnStack;
if (isSuspensionPoint && !isSafeCallOrOnStack) {
// Inline markers are used to spill the stack before coroutine suspension
addInlineMarker(v, true);
}
if (!isConstructor) { // otherwise already
receiver = StackValue.receiver(resolvedCall, receiver, this, callableMethod);
receiver.put(receiver.type, v);
// In regular cases we add an inline marker just before receiver is loaded (to spill the stack before a suspension)
// But in case of safe call things we get the following bytecode:
// ---- inlineMarkerBefore()
// LOAD $receiver
// IFNULL L1
// ---- load the rest of the arguments
// INVOKEVIRTUAL suspendCall()
// ---- inlineMarkerBefore()
// GOTO L2
// L1
// ACONST_NULL
// L2
// ...
//
// The problem is that the stack before the call is not restored in case of null receiver.
// The solution is to spill stack just after receiver is loaded (after IFNULL) in case of safe call.
// But the problem is that we should leave the receiver itself on the stack, so we store it in a temporary variable.
if (isSuspensionPoint && isSafeCallOrOnStack) {
boolean bothReceivers =
receiver instanceof StackValue.CallReceiver
&& ((StackValue.CallReceiver) receiver).getDispatchReceiver().type.getSort() != Type.VOID
&& ((StackValue.CallReceiver) receiver).getExtensionReceiver().type.getSort() != Type.VOID;
Type firstReceiverType =
bothReceivers
? ((StackValue.CallReceiver) receiver).getDispatchReceiver().type
: receiver.type;
Type secondReceiverType = bothReceivers ? receiver.type : null;
int tmpVarForFirstReceiver = myFrameMap.enterTemp(firstReceiverType);
int tmpVarForSecondReceiver = -1;
if (secondReceiverType != null) {
tmpVarForSecondReceiver = myFrameMap.enterTemp(secondReceiverType);
v.store(tmpVarForSecondReceiver, secondReceiverType);
}
v.store(tmpVarForFirstReceiver, firstReceiverType);
addInlineMarker(v, true);
v.load(tmpVarForFirstReceiver, firstReceiverType);
if (secondReceiverType != null) {
v.load(tmpVarForSecondReceiver, secondReceiverType);
myFrameMap.leaveTemp(secondReceiverType);
}
myFrameMap.leaveTemp(firstReceiverType);
}
callableMethod.afterReceiverGeneration(v);
}
}
@NotNull
private CallGenerator getOrCreateCallGenerator(
@NotNull CallableDescriptor descriptor,
@@ -2960,7 +3024,8 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
@NotNull
CallGenerator getOrCreateCallGenerator(@NotNull ResolvedCall<?> resolvedCall, @NotNull CallableDescriptor descriptor) {
Map<TypeParameterDescriptor, KotlinType> typeArguments = resolvedCall.getTypeArguments();
Map<TypeParameterDescriptor, KotlinType> typeArguments = getTypeArgumentsForResolvedCall(resolvedCall, descriptor);
TypeParameterMappings mappings = new TypeParameterMappings();
for (Map.Entry<TypeParameterDescriptor, KotlinType> entry : typeArguments.entrySet()) {
TypeParameterDescriptor key = entry.getKey();
@@ -2985,9 +3050,38 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
);
}
}
return getOrCreateCallGenerator(descriptor, resolvedCall.getCall().getCallElement(), mappings, false);
}
@NotNull
private static Map<TypeParameterDescriptor, KotlinType> getTypeArgumentsForResolvedCall(
@NotNull ResolvedCall<?> resolvedCall,
@NotNull CallableDescriptor descriptor
) {
if (!(descriptor instanceof TypeAliasConstructorDescriptor)) {
return resolvedCall.getTypeArguments();
}
TypeAliasConstructorDescriptor typeAliasConstructorDescriptor = (TypeAliasConstructorDescriptor) descriptor;
ClassConstructorDescriptor underlyingConstructorDescriptor = typeAliasConstructorDescriptor.getUnderlyingConstructorDescriptor();
KotlinType resultingType = typeAliasConstructorDescriptor.getReturnType();
List<TypeProjection> typeArgumentsForReturnType = resultingType.getArguments();
List<TypeParameterDescriptor> typeParameters = underlyingConstructorDescriptor.getTypeParameters();
assert typeParameters.size() == typeArgumentsForReturnType.size() :
"Type parameters of the underlying constructor " + underlyingConstructorDescriptor +
"should correspond to type arguments for the resulting type " + resultingType;
Map<TypeParameterDescriptor, KotlinType> typeArgumentsMap = Maps.newHashMapWithExpectedSize(typeParameters.size());
for (TypeParameterDescriptor typeParameter: typeParameters) {
KotlinType typeArgument = typeArgumentsForReturnType.get(typeParameter.getIndex()).getType();
typeArgumentsMap.put(typeParameter, typeArgument);
}
return typeArgumentsMap;
}
@Nullable
private static Pair<TypeParameterDescriptor, ReificationArgument> extractReificationArgument(@NotNull KotlinType type) {
@@ -3097,7 +3191,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
boolean isSingleton = calleeContainingClass.getKind().isSingleton();
if (isSingleton) {
if (calleeContainingClass.equals(context.getThisDescriptor()) &&
!CodegenUtilKt.isJvmStaticInObjectOrClass(context.getContextDescriptor())) {
!CodegenUtilKt.isJvmStaticInObjectOrClass(context.getFunctionDescriptor())) {
return StackValue.local(0, typeMapper.mapType(calleeContainingClass));
}
else if (isEnumEntry(calleeContainingClass)) {
@@ -3324,7 +3418,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
@Override
public Unit invoke(InstructionAdapter v) {
KotlinType type = lhs.getType();
if (lhs instanceof DoubleColonLHS.Expression && !((DoubleColonLHS.Expression) lhs).isObject()) {
if (lhs instanceof DoubleColonLHS.Expression && !((DoubleColonLHS.Expression) lhs).isObjectQualifier()) {
JavaClassProperty.INSTANCE.generateImpl(v, gen(receiverExpression));
}
else {
@@ -3566,18 +3660,43 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
/*tries to use IEEE 754 arithmetic*/
private StackValue genEqualsForExpressionsPreferIEEE754Arithmetic(
@Nullable KtExpression left,
@Nullable KtExpression right,
@NotNull IElementType opToken,
@Nullable final KtExpression left,
@Nullable final KtExpression right,
@NotNull final IElementType opToken,
@NotNull Type leftType,
@NotNull Type rightType,
@Nullable StackValue pregeneratedLeft
@Nullable final StackValue pregeneratedLeft
) {
Type left754Type = calcTypeForIEEE754ArithmeticIfNeeded(left);
Type right754Type = calcTypeForIEEE754ArithmeticIfNeeded(right);
if (left754Type != null && right754Type != null && left754Type.equals(right754Type)) {
leftType = left754Type;
rightType = right754Type;
assert (opToken == KtTokens.EQEQ || opToken == KtTokens.EXCLEQ) : "Optoken should be '==' or '!=', but: " + opToken;
final TypeAndNullability left754Type = calcTypeForIEEE754ArithmeticIfNeeded(left);
final TypeAndNullability right754Type = calcTypeForIEEE754ArithmeticIfNeeded(right);
if (left754Type != null && right754Type != null && left754Type.type.equals(right754Type.type)) {
//check nullability cause there is some optimizations in codegen for non-nullable case
if (left754Type.isNullable || right754Type.isNullable) {
if (state.getLanguageVersionSettings().getApiVersion().compareTo(ApiVersion.KOTLIN_1_1) >= 0) {
return StackValue.operation(Type.BOOLEAN_TYPE, new Function1<InstructionAdapter, Unit>() {
@Override
public Unit invoke(InstructionAdapter v) {
generate754EqualsForNullableTypesViaIntrinsic(v, opToken, pregeneratedLeft, left, left754Type, right, right754Type);
return Unit.INSTANCE;
}
});
}
else {
return StackValue.operation(Type.BOOLEAN_TYPE, new Function1<InstructionAdapter, Unit>() {
@Override
public Unit invoke(InstructionAdapter v) {
generate754EqualsForNullableTypes(v, opToken, pregeneratedLeft, left, left754Type, right, right754Type);
return Unit.INSTANCE;
}
});
}
}
else {
leftType = left754Type.type;
rightType = right754Type.type;
}
}
return genEqualsForExpressionsOnStack(
@@ -3587,6 +3706,126 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
);
}
private void generate754EqualsForNullableTypesViaIntrinsic(
@NotNull InstructionAdapter v,
@NotNull IElementType opToken,
@Nullable StackValue pregeneratedLeft,
@Nullable KtExpression left,
@NotNull TypeAndNullability left754Type,
@Nullable KtExpression right,
@NotNull TypeAndNullability right754Type
) {
Type leftType = left754Type.isNullable ? AsmUtil.boxType(left754Type.type) : left754Type.type;
if (pregeneratedLeft != null) {
StackValue.coercion(pregeneratedLeft, leftType).put(leftType, v);
}
else {
gen(left, leftType);
}
Type rightType = right754Type.isNullable ? AsmUtil.boxType(right754Type.type) : right754Type.type;
gen(right, rightType);
AsmUtil.genIEEE754EqualForNullableTypesCall(v, leftType, rightType);
if (opToken == KtTokens.EXCLEQ) {
genInvertBoolean(v);
}
}
private void generate754EqualsForNullableTypes(
@NotNull InstructionAdapter v,
@NotNull IElementType opToken,
@Nullable StackValue pregeneratedLeft,
@Nullable KtExpression left,
@NotNull TypeAndNullability left754Type,
@Nullable KtExpression right,
@NotNull TypeAndNullability right754Type
) {
int equals = opToken == KtTokens.EQEQ ? 1 : 0;
int notEquals = opToken != KtTokens.EQEQ ? 1 : 0;
Label end = new Label();
StackValue leftValue = pregeneratedLeft != null ? pregeneratedLeft : gen(left);
leftValue.put(leftValue.type, v);
leftValue = StackValue.onStack(leftValue.type);
Type leftType = left754Type.type;
Type rightType = right754Type.type;
if (left754Type.isNullable) {
leftValue.dup(v, false);
Label leftIsNull = new Label();
v.ifnull(leftIsNull);
StackValue.coercion(leftValue, leftType).put(leftType, v);
StackValue nonNullLeftValue = StackValue.onStack(leftType);
StackValue rightValue = gen(right);
rightValue.put(rightValue.type, v);
rightValue = StackValue.onStack(rightValue.type);
if (right754Type.isNullable) {
rightValue.dup(v, false);
Label rightIsNotNull = new Label();
v.ifnonnull(rightIsNotNull);
AsmUtil.pop(v, rightValue.type);
AsmUtil.pop(v, nonNullLeftValue.type);
v.iconst(notEquals);
v.goTo(end);
v.mark(rightIsNotNull);
}
StackValue.coercion(rightValue, rightType).put(rightType, v);
StackValue nonNullRightValue = StackValue.onStack(rightType);
StackValue.cmp(opToken, leftType, nonNullLeftValue, nonNullRightValue).put(Type.BOOLEAN_TYPE, v);
v.goTo(end);
//left is null case
v.mark(leftIsNull);
AsmUtil.pop(v, leftValue.type);//pop null left
rightValue = gen(right);
rightValue.put(rightValue.type, v);
rightValue = StackValue.onStack(rightValue.type);
if (right754Type.isNullable) {
Label rightIsNotNull = new Label();
v.ifnonnull(rightIsNotNull);
v.iconst(equals);
v.goTo(end);
v.mark(rightIsNotNull);
v.iconst(notEquals);
//v.goTo(end);
}
else {
AsmUtil.pop(v, rightValue.type);
v.iconst(notEquals);
//v.goTo(end);
}
v.mark(end);
return;
}
else {
StackValue.coercion(leftValue, leftType).put(leftType, v);
leftValue = StackValue.onStack(leftType);
}
//right is nullable cause left is not
StackValue rightValue = gen(right);
rightValue.put(rightValue.type, v);
rightValue = StackValue.onStack(rightValue.type);
rightValue.dup(v, false);
Label rightIsNotNull = new Label();
v.ifnonnull(rightIsNotNull);
AsmUtil.pop(v, rightValue.type);
AsmUtil.pop(v, leftValue.type);
v.iconst(notEquals);
v.goTo(end);
v.mark(rightIsNotNull);
StackValue.coercion(rightValue, rightType).put(rightType, v);
StackValue nonNullRightValue = StackValue.onStack(rightType);
StackValue.cmp(opToken, leftType, leftValue, nonNullRightValue).put(Type.BOOLEAN_TYPE, v);
v.mark(end);
}
private boolean isIntZero(KtExpression expr, Type exprType) {
ConstantValue<?> exprValue = getPrimitiveOrStringCompileTimeConstant(expr, bindingContext, state.getShouldInlineConstVals());
return isIntPrimitive(exprType) && exprValue != null && Integer.valueOf(0).equals(exprValue.getValue());
@@ -3648,12 +3887,12 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
StackValue rightValue;
Type leftType = expressionType(left);
Type rightType = expressionType(right);
Type left754Type = calcTypeForIEEE754ArithmeticIfNeeded(left);
Type right754Type = calcTypeForIEEE754ArithmeticIfNeeded(right);
TypeAndNullability left754Type = calcTypeForIEEE754ArithmeticIfNeeded(left);
TypeAndNullability right754Type = calcTypeForIEEE754ArithmeticIfNeeded(right);
Callable callable = resolveToCallable((FunctionDescriptor) resolvedCall.getResultingDescriptor(), false, resolvedCall);
boolean is754Arithmetic = left754Type != null && right754Type != null && left754Type.equals(right754Type);
boolean is754Arithmetic = left754Type != null && right754Type != null && left754Type.type.equals(right754Type.type);
if (callable instanceof IntrinsicCallable && ((isPrimitive(leftType) && isPrimitive(rightType)) || is754Arithmetic)) {
type = is754Arithmetic ? left754Type : comparisonOperandType(leftType, rightType);
type = is754Arithmetic ? left754Type.type : comparisonOperandType(leftType, rightType);
leftValue = gen(left);
rightValue = gen(right);
}
@@ -3665,7 +3904,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
return StackValue.cmp(expression.getOperationToken(), type, leftValue, rightValue);
}
private Type calcTypeForIEEE754ArithmeticIfNeeded(@Nullable KtExpression expression) {
private TypeAndNullability calcTypeForIEEE754ArithmeticIfNeeded(@Nullable KtExpression expression) {
return CodegenUtilKt.calcTypeForIEEE754ArithmeticIfNeeded(expression, bindingContext, context.getFunctionDescriptor());
}
@@ -4076,6 +4315,8 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
private static ReceiverValue getConstructorReceiver(@NotNull ResolvedCall<?> resolvedCall) {
CallableDescriptor constructor = resolvedCall.getResultingDescriptor();
if (constructor.getExtensionReceiverParameter() != null) {
// see comment on `withDispatchReceiver` parameter in
// org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptorImpl.Companion.createIfAvailable
assert constructor instanceof TypeAliasConstructorDescriptor :
"Only type alias constructor can have an extension receiver: " + constructor;
return resolvedCall.getExtensionReceiver();
@@ -4265,9 +4506,7 @@ The "returned" value of try expression with no finally is either the last expres
(or blocks).
*/
KotlinType jetType = bindingContext.getType(expression);
assert jetType != null;
final Type expectedAsmType = isStatement ? Type.VOID_TYPE : asmType(jetType);
final Type expectedAsmType = isStatement ? Type.VOID_TYPE : expressionTypeForBranchingOperation(expression);
return StackValue.operation(expectedAsmType, new Function1<InstructionAdapter, Unit>() {
@Override
@@ -4322,6 +4561,9 @@ The "returned" value of try expression with no finally is either the last expres
int index = lookupLocalIndex(descriptor);
v.store(index, descriptorType);
Label catchVariableStart = new Label();
v.mark(catchVariableStart);
gen(catchBody, expectedAsmType);
if (!isStatement) {
@@ -4333,8 +4575,8 @@ The "returned" value of try expression with no finally is either the last expres
Label clauseEnd = new Label();
v.mark(clauseEnd);
v.visitLocalVariable(descriptor.getName().asString(), descriptorType.getDescriptor(), null, clauseStart, clauseEnd,
index);
v.visitLocalVariable(descriptor.getName().asString(), descriptorType.getDescriptor(), null,
catchVariableStart, clauseEnd, index);
genFinallyBlockOrGoto(finallyBlockStackElement, i != size - 1 || finallyBlock != null ? end : null, null);
@@ -4540,7 +4782,7 @@ The "returned" value of try expression with no finally is either the last expres
final KtExpression expr = expression.getSubjectExpression();
final Type subjectType = expressionType(expr);
final Type resultType = isStatement ? Type.VOID_TYPE : expressionType(expression);
final Type resultType = isStatement ? Type.VOID_TYPE : expressionTypeForBranchingOperation(expression);
return StackValue.operation(resultType, new Function1<InstructionAdapter, Unit>() {
@Override
@@ -4666,7 +4908,8 @@ The "returned" value of try expression with no finally is either the last expres
public NameGenerator getInlineNameGenerator() {
NameGenerator nameGenerator = getParentCodegen().getInlineNameGenerator();
Name name = context.getContextDescriptor().getName();
return nameGenerator.subGenerator((name.isSpecial() ? "$special" : name.asString()) + "$$inlined" );
String inlinedName = name.isSpecial() ? InlineCodegenUtil.SPECIAL_TRANSFORMATION_NAME : name.asString();
return nameGenerator.subGenerator(inlinedName + InlineCodegenUtil.INLINE_CALL_TRANSFORMATION_SUFFIX);
}
public Type getReturnType() {

View File

@@ -31,6 +31,8 @@ import org.jetbrains.kotlin.backend.common.bridges.ImplKt;
import org.jetbrains.kotlin.codegen.annotation.AnnotatedWithOnlyTargetedAnnotations;
import org.jetbrains.kotlin.codegen.binding.CodegenBinding;
import org.jetbrains.kotlin.codegen.context.*;
import org.jetbrains.kotlin.codegen.coroutines.CoroutineCodegenUtilKt;
import org.jetbrains.kotlin.codegen.coroutines.SuspendFunctionGenerationStrategy;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper;
import org.jetbrains.kotlin.descriptors.*;
@@ -99,7 +101,7 @@ public class FunctionCodegen {
private final Function1<DeclarationDescriptor, Boolean> IS_PURE_INTERFACE_CHECKER = new Function1<DeclarationDescriptor, Boolean>() {
@Override
public Boolean invoke(DeclarationDescriptor descriptor) {
return JvmCodegenUtil.isAnnotationOrJvm6Interface(descriptor, state);
return JvmCodegenUtil.isAnnotationOrJvmInterfaceWithoutDefaults(descriptor, state);
}
};
@@ -119,17 +121,29 @@ public class FunctionCodegen {
public void gen(@NotNull KtNamedFunction function) {
SimpleFunctionDescriptor functionDescriptor = bindingContext.get(BindingContext.FUNCTION, function);
if (bindingContext.get(CodegenBinding.SUSPEND_FUNCTION_TO_JVM_VIEW, functionDescriptor) != null) {
functionDescriptor =
(SimpleFunctionDescriptor) bindingContext.get(CodegenBinding.SUSPEND_FUNCTION_TO_JVM_VIEW, functionDescriptor);
}
if (functionDescriptor == null) {
throw ExceptionLogger.logDescriptorNotFound("No descriptor for function " + function.getName(), function);
}
if (bindingContext.get(CodegenBinding.SUSPEND_FUNCTION_TO_JVM_VIEW, functionDescriptor) != null) {
functionDescriptor = bindingContext.get(CodegenBinding.SUSPEND_FUNCTION_TO_JVM_VIEW, functionDescriptor);
}
if (owner.getContextKind() != OwnerKind.DEFAULT_IMPLS || function.hasBody()) {
generateMethod(JvmDeclarationOriginKt.OtherOrigin(function, functionDescriptor), functionDescriptor,
new FunctionGenerationStrategy.FunctionDefault(state, function));
FunctionGenerationStrategy strategy;
if (functionDescriptor.isSuspend()) {
strategy = new SuspendFunctionGenerationStrategy(
state,
CoroutineCodegenUtilKt.<FunctionDescriptor>unwrapInitialDescriptorForSuspendFunction(functionDescriptor),
function
);
}
else {
strategy = new FunctionGenerationStrategy.FunctionDefault(state, function);
}
generateMethod(JvmDeclarationOriginKt.OtherOrigin(function, functionDescriptor), functionDescriptor, strategy);
}
generateDefaultIfNeeded(owner.intoFunction(functionDescriptor, true), functionDescriptor, owner.getContextKind(),
@@ -153,6 +167,11 @@ public class FunctionCodegen {
@NotNull FunctionDescriptor descriptor,
@NotNull FunctionGenerationStrategy strategy
) {
if (CoroutineCodegenUtilKt.isSuspendFunctionNotSuspensionView(descriptor)) {
generateMethod(origin, CoroutineCodegenUtilKt.getOrCreateJvmSuspendFunctionView(descriptor, bindingContext), strategy);
return;
}
generateMethod(origin, descriptor, owner.intoFunction(descriptor), strategy);
}
@@ -190,7 +209,11 @@ public class FunctionCodegen {
getThrownExceptions(functionDescriptor, typeMapper));
if (CodegenContextUtil.isImplClassOwner(owner)) {
v.getSerializationBindings().put(METHOD_FOR_FUNCTION, functionDescriptor, asmMethod);
v.getSerializationBindings().put(
METHOD_FOR_FUNCTION,
CodegenUtilKt.<FunctionDescriptor>unwrapFrontendVersion(functionDescriptor),
asmMethod
);
}
generateMethodAnnotations(functionDescriptor, asmMethod, mv);
@@ -201,14 +224,14 @@ public class FunctionCodegen {
generateBridges(functionDescriptor);
if (isJvm8InterfaceMember(functionDescriptor, state) && contextKind != OwnerKind.DEFAULT_IMPLS && state.getGenerateDefaultImplsForJvm8()) {
if (isJvm8InterfaceWithDefaultsMember(functionDescriptor, state) && contextKind != OwnerKind.DEFAULT_IMPLS && state.getGenerateDefaultImplsForJvm8()) {
generateDelegateForDefaultImpl(functionDescriptor, origin.getElement());
}
boolean staticInCompanionObject = CodegenUtilKt.isJvmStaticInCompanionObject(functionDescriptor);
if (staticInCompanionObject) {
ImplementationBodyCodegen parentBodyCodegen = (ImplementationBodyCodegen) memberCodegen.getParentCodegen();
parentBodyCodegen.addAdditionalTask(new JvmStaticGenerator(functionDescriptor, origin, state, parentBodyCodegen));
parentBodyCodegen.addAdditionalTask(new JvmStaticInCompanionObjectGenerator(functionDescriptor, origin, state, parentBodyCodegen));
}
if (!state.getClassBuilderMode().generateBodies || isAbstractMethod(functionDescriptor, contextKind, state)) {
@@ -233,7 +256,8 @@ public class FunctionCodegen {
else if (staticInCompanionObject) {
// native @JvmStatic foo() in companion object should delegate to the static native function moved to the outer class
mv.visitCode();
FunctionDescriptor staticFunctionDescriptor = JvmStaticGenerator.createStaticFunctionDescriptor(functionDescriptor);
FunctionDescriptor staticFunctionDescriptor = JvmStaticInCompanionObjectGenerator
.createStaticFunctionDescriptor(functionDescriptor);
Method accessorMethod =
typeMapper.mapAsmMethod(memberCodegen.getContext().accessibleDescriptor(staticFunctionDescriptor, null));
Type owningType = typeMapper.mapClass((ClassifierDescriptor) staticFunctionDescriptor.getContainingDeclaration());
@@ -311,9 +335,22 @@ public class FunctionCodegen {
@NotNull JvmMethodSignature jvmSignature,
@NotNull InnerClassConsumer innerClassConsumer,
@NotNull GenerationState state
) {
generateParameterAnnotations(
functionDescriptor, mv, jvmSignature, functionDescriptor.getValueParameters(), innerClassConsumer, state
);
}
public static void generateParameterAnnotations(
@NotNull FunctionDescriptor functionDescriptor,
@NotNull MethodVisitor mv,
@NotNull JvmMethodSignature jvmSignature,
@NotNull List<ValueParameterDescriptor> valueParameters,
@NotNull InnerClassConsumer innerClassConsumer,
@NotNull GenerationState state
) {
KotlinTypeMapper typeMapper = state.getTypeMapper();
Iterator<ValueParameterDescriptor> iterator = functionDescriptor.getValueParameters().iterator();
Iterator<ValueParameterDescriptor> iterator = valueParameters.iterator();
List<JvmMethodParameterSignature> kotlinParameterTypes = jvmSignature.getValueParameters();
for (int i = 0; i < kotlinParameterTypes.size(); i++) {
@@ -419,7 +456,7 @@ public class FunctionCodegen {
generateFacadeDelegateMethodBody(mv, signature.getAsmMethod(), (MultifileClassFacadeContext) context.getParentContext());
methodEnd = new Label();
}
else if (OwnerKind.DEFAULT_IMPLS == context.getContextKind() && isJvm8InterfaceMember(functionDescriptor, parentCodegen.state)) {
else if (OwnerKind.DEFAULT_IMPLS == context.getContextKind() && isJvm8InterfaceWithDefaultsMember(functionDescriptor, parentCodegen.state)) {
int flags = AsmUtil.getMethodAsmFlags(functionDescriptor, OwnerKind.DEFAULT_IMPLS, context.getState());
assert (flags & Opcodes.ACC_ABSTRACT) == 0 : "Interface method with body should be non-abstract" + functionDescriptor;
Type type = typeMapper.mapOwner(functionDescriptor);
@@ -724,7 +761,7 @@ public class FunctionCodegen {
public void generateBridges(@NotNull FunctionDescriptor descriptor) {
if (descriptor instanceof ConstructorDescriptor) return;
if (owner.getContextKind() == OwnerKind.DEFAULT_IMPLS) return;
if (isAnnotationOrJvm6Interface(descriptor.getContainingDeclaration(), state)) return;
if (isAnnotationOrJvmInterfaceWithoutDefaults(descriptor.getContainingDeclaration(), state)) return;
// equals(Any?), hashCode(), toString() never need bridges
if (isMethodOfAny(descriptor)) return;
@@ -883,17 +920,23 @@ public class FunctionCodegen {
// enum constructors have two additional synthetic parameters which somewhat complicate this task
AnnotationCodegen.forMethod(mv, memberCodegen, typeMapper).genAnnotations(functionDescriptor, defaultMethod.getReturnType());
if (state.getClassBuilderMode().generateBodies) {
if (this.owner instanceof MultifileClassFacadeContext) {
mv.visitCode();
generateFacadeDelegateMethodBody(mv, defaultMethod, (MultifileClassFacadeContext) this.owner);
if (!state.getClassBuilderMode().generateBodies) {
if (this.owner instanceof MultifileClassFacadeContext)
endVisit(mv, "default method delegation", getSourceFromDescriptor(functionDescriptor));
}
else {
mv.visitCode();
generateDefaultImplBody(owner, functionDescriptor, mv, loadStrategy, function, memberCodegen, defaultMethod);
else
endVisit(mv, "default method", getSourceFromDescriptor(functionDescriptor));
}
return;
}
if (this.owner instanceof MultifileClassFacadeContext) {
mv.visitCode();
generateFacadeDelegateMethodBody(mv, defaultMethod, (MultifileClassFacadeContext) this.owner);
endVisit(mv, "default method delegation", getSourceFromDescriptor(functionDescriptor));
}
else {
mv.visitCode();
generateDefaultImplBody(owner, functionDescriptor, mv, loadStrategy, function, memberCodegen, defaultMethod);
endVisit(mv, "default method", getSourceFromDescriptor(functionDescriptor));
}
}
@@ -919,8 +962,6 @@ public class FunctionCodegen {
InstructionAdapter iv = new InstructionAdapter(mv);
genDefaultSuperCallCheckIfNeeded(iv, functionDescriptor, defaultMethod);
loadExplicitArgumentsOnStack(OBJECT_TYPE, isStatic, signature, generator);
List<JvmMethodParameterSignature> mappedParameters = signature.getValueParameters();
int capturedArgumentsCount = 0;
while (capturedArgumentsCount < mappedParameters.size() &&
@@ -949,7 +990,15 @@ public class FunctionCodegen {
iv.mark(loadArg);
}
}
// load arguments after defaults generation to avoid redundant stack normalization operations
loadExplicitArgumentsOnStack(OBJECT_TYPE, isStatic, signature, generator);
for (int index = 0; index < valueParameters.size(); index++) {
ValueParameterDescriptor parameterDescriptor = valueParameters.get(index);
Type type = mappedParameters.get(capturedArgumentsCount + index).getAsmType();
int parameterIndex = frameMap.getIndex(parameterDescriptor);
generator.putValueIfNeeded(type, StackValue.local(parameterIndex, type));
}
@@ -1086,14 +1135,14 @@ public class FunctionCodegen {
ClassDescriptor parentClass = getSuperClassDescriptor((ClassDescriptor) descriptor.getContainingDeclaration());
assert parentClass != null;
String parentInternalName = typeMapper.mapClass(parentClass).getInternalName();
iv.invokespecial(parentInternalName, delegateTo.getName(), delegateTo.getDescriptor());
iv.invokespecial(parentInternalName, delegateTo.getName(), delegateTo.getDescriptor(), false);
}
else {
if (isJvm8InterfaceMember(descriptor, state)) {
if (isJvm8InterfaceWithDefaultsMember(descriptor, state)) {
iv.invokeinterface(v.getThisName(), delegateTo.getName(), delegateTo.getDescriptor());
}
else {
iv.invokevirtual(v.getThisName(), delegateTo.getName(), delegateTo.getDescriptor());
iv.invokevirtual(v.getThisName(), delegateTo.getName(), delegateTo.getDescriptor(), false);
}
}
@@ -1222,7 +1271,7 @@ public class FunctionCodegen {
iv.invokeinterface(internalName, delegateToMethod.getName(), delegateToMethod.getDescriptor());
}
else {
iv.invokevirtual(internalName, delegateToMethod.getName(), delegateToMethod.getDescriptor());
iv.invokevirtual(internalName, delegateToMethod.getName(), delegateToMethod.getDescriptor(), false);
}
StackValue stackValue = AsmUtil.genNotNullAssertions(
@@ -1257,6 +1306,6 @@ public class FunctionCodegen {
@NotNull GenerationState state
) {
assert isInterface(contextClass) : "'processInterface' method should be called only for interfaces, but: " + contextClass;
return isJvm8Interface(contextClass, state) ? kind != OwnerKind.DEFAULT_IMPLS : kind == OwnerKind.DEFAULT_IMPLS;
return JvmCodegenUtil.isJvm8InterfaceWithDefaults(contextClass, state) ? kind != OwnerKind.DEFAULT_IMPLS : kind == OwnerKind.DEFAULT_IMPLS;
}
}

View File

@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.codegen;
import kotlin.collections.CollectionsKt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.backend.common.CodegenUtil;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.psi.*;
@@ -36,6 +37,8 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import java.util.*;
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isObject;
public class FunctionReferenceGenerationStrategy extends FunctionGenerationStrategy.CodegenBased {
private final ResolvedCall<?> resolvedCall;
private final FunctionDescriptor referencedFunction;
@@ -74,7 +77,7 @@ public class FunctionReferenceGenerationStrategy extends FunctionGenerationStrat
every argument boils down to calling LOAD with the corresponding index
*/
KtCallExpression fakeExpression = constructFakeFunctionCall();
KtCallExpression fakeExpression = CodegenUtil.constructFakeFunctionCall(state.getProject(), referencedFunction);
final List<? extends ValueArgument> fakeArguments = fakeExpression.getValueArguments();
final ReceiverValue dispatchReceiver = computeAndSaveReceiver(signature, codegen, referencedFunction.getDispatchReceiverParameter());
@@ -140,25 +143,17 @@ public class FunctionReferenceGenerationStrategy extends FunctionGenerationStrat
v.areturn(returnType);
}
@NotNull
private KtCallExpression constructFakeFunctionCall() {
StringBuilder fakeFunctionCall = new StringBuilder("callableReferenceFakeCall(");
for (Iterator<ValueParameterDescriptor> iterator = referencedFunction.getValueParameters().iterator(); iterator.hasNext(); ) {
ValueParameterDescriptor descriptor = iterator.next();
fakeFunctionCall.append("p").append(descriptor.getIndex());
if (iterator.hasNext()) {
fakeFunctionCall.append(", ");
}
}
fakeFunctionCall.append(")");
return (KtCallExpression) KtPsiFactoryKt.KtPsiFactory(state.getProject()).createExpression(fakeFunctionCall.toString());
}
private void computeAndSaveArguments(@NotNull List<? extends ValueArgument> fakeArguments, @NotNull ExpressionCodegen codegen) {
int receivers = (referencedFunction.getDispatchReceiverParameter() != null ? 1 : 0) +
(referencedFunction.getExtensionReceiverParameter() != null ? 1 : 0) -
(receiverType != null ? 1 : 0);
if (receivers < 0 && referencedFunction instanceof ConstructorDescriptor && isObject(referencedFunction.getContainingDeclaration().getContainingDeclaration())) {
//reference to object nested class
//TODO: seems problem should be fixed on frontend side (note that object instance are captured by generated class)
receivers = 0;
}
List<ValueParameterDescriptor> parameters = CollectionsKt.drop(functionDescriptor.getValueParameters(), receivers);
for (int i = 0; i < parameters.size(); i++) {
ValueParameterDescriptor parameter = parameters.get(i);

View File

@@ -29,6 +29,7 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.backend.common.CodegenUtil;
import org.jetbrains.kotlin.backend.common.DataClassMethodGenerator;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
import org.jetbrains.kotlin.codegen.binding.CodegenBinding;
import org.jetbrains.kotlin.codegen.binding.MutableClosure;
import org.jetbrains.kotlin.codegen.context.*;
import org.jetbrains.kotlin.codegen.extensions.ExpressionCodegenExtension;
@@ -87,6 +88,7 @@ import static org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin.
import static org.jetbrains.kotlin.types.Variance.INVARIANT;
import static org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils.isLocalFunction;
import static org.jetbrains.org.objectweb.asm.Opcodes.*;
import static org.jetbrains.org.objectweb.asm.Type.getObjectType;
public class ImplementationBodyCodegen extends ClassBodyCodegen {
private static final String ENUM_VALUES_FIELD_NAME = "$VALUES";
@@ -112,7 +114,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
boolean isLocal
) {
super(aClass, context, v, state, parentCodegen);
this.classAsmType = typeMapper.mapClass(descriptor);
this.classAsmType = getObjectType(typeMapper.classInternalName(descriptor));
this.isLocal = isLocal;
delegationFieldsInfo = getDelegationFieldsInfo(myClass.getSuperTypeListEntries());
}
@@ -126,55 +128,47 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
boolean isAbstract = false;
boolean isInterface = false;
boolean isFinal = false;
boolean isStatic;
boolean isAnnotation = false;
boolean isEnum = false;
ClassKind kind = descriptor.getKind();
if (kind == ClassKind.OBJECT) {
isStatic = isCompanionObject(descriptor);
isFinal = true;
Modality modality = descriptor.getModality();
if (modality == Modality.ABSTRACT || modality == Modality.SEALED) {
isAbstract = true;
}
else {
Modality modality = descriptor.getModality();
if (modality == Modality.ABSTRACT || modality == Modality.SEALED) {
isAbstract = true;
}
if (kind == ClassKind.INTERFACE) {
isAbstract = true;
isInterface = true;
}
else if (kind == ClassKind.ANNOTATION_CLASS) {
isAbstract = true;
isInterface = true;
isAnnotation = true;
}
else if (kind == ClassKind.ENUM_CLASS) {
isAbstract = hasAbstractMembers(descriptor);
isEnum = true;
}
if (kind == ClassKind.INTERFACE) {
isAbstract = true;
isInterface = true;
}
else if (kind == ClassKind.ANNOTATION_CLASS) {
isAbstract = true;
isInterface = true;
isAnnotation = true;
}
else if (kind == ClassKind.ENUM_CLASS) {
isAbstract = hasAbstractMembers(descriptor);
isEnum = true;
}
if (modality != Modality.OPEN && !isAbstract) {
// Light-class mode: Do not make enum classes final since PsiClass corresponding to enum is expected to be inheritable from
isFinal = !(kind == ClassKind.ENUM_CLASS && !state.getClassBuilderMode().generateBodies);
}
isStatic = !descriptor.isInner();
if (modality != Modality.OPEN && !isAbstract) {
isFinal = kind == ClassKind.OBJECT ||
// Light-class mode: Do not make enum classes final since PsiClass corresponding to enum is expected to be inheritable from
!(kind == ClassKind.ENUM_CLASS && !state.getClassBuilderMode().generateBodies);
}
int access = 0;
if (!state.getClassBuilderMode().generateBodies && !DescriptorUtils.isTopLevelDeclaration(descriptor)) {
if (state.getClassBuilderMode() == ClassBuilderMode.LIGHT_CLASSES && !DescriptorUtils.isTopLevelDeclaration(descriptor)) {
// !ClassBuilderMode.generateBodies means we are generating light classes & looking at a nested or inner class
// Light class generation is implemented so that Cls-classes only read bare code of classes,
// without knowing whether these classes are inner or not (see ClassStubBuilder.EMPTY_STRATEGY)
// Thus we must write full accessibility flags on inner classes in this mode
access |= getVisibilityAccessFlag(descriptor);
// Same for STATIC
if (isStatic) {
if (!descriptor.isInner()) {
access |= ACC_STATIC;
}
}
@@ -233,7 +227,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
@Override
protected void generateDefaultImplsIfNeeded() {
if (isInterface(descriptor) && !isLocal && (!isJvm8Interface(descriptor, state) || state.getGenerateDefaultImplsForJvm8())) {
if (isInterface(descriptor) && !isLocal && (!JvmCodegenUtil.isJvm8InterfaceWithDefaults(descriptor, state) || state.getGenerateDefaultImplsForJvm8())) {
Type defaultImplsType = state.getTypeMapper().mapDefaultImpls(descriptor);
ClassBuilder defaultImplsBuilder =
state.getFactory().newVisitor(JvmDeclarationOriginKt.DefaultImpls(myClass.getPsiOrParent(), descriptor), defaultImplsType, myClass.getContainingKtFile());
@@ -331,7 +325,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
for (String kotlinMarkerInterface : kotlinMarkerInterfaces) {
sw.writeInterface();
sw.writeAsmType(Type.getObjectType(kotlinMarkerInterface));
sw.writeAsmType(getObjectType(kotlinMarkerInterface));
sw.writeInterfaceEnd();
}
@@ -1206,9 +1200,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
}
else if (descriptor instanceof VariableDescriptor) {
if (descriptor.getContainingDeclaration() instanceof ConstructorDescriptor) {
ClassDescriptor classDescriptor =
(ClassDescriptor) descriptor.getContainingDeclaration().getContainingDeclaration();
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
if (containingDeclaration instanceof ConstructorDescriptor) {
ClassDescriptor classDescriptor = ((ConstructorDescriptor) containingDeclaration).getConstructedClass();
if (classDescriptor == ImplementationBodyCodegen.this.descriptor) return;
}
lookupInContext(descriptor);
@@ -1293,14 +1287,14 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
private void generateTraitMethods() {
if (isAnnotationOrJvm6Interface(descriptor, state)) return;
if (isAnnotationOrJvmInterfaceWithoutDefaults(descriptor, state)) return;
List<FunctionDescriptor> restrictedInheritance = new ArrayList<FunctionDescriptor>();
for (Map.Entry<FunctionDescriptor, FunctionDescriptor> entry : CodegenUtil.getNonPrivateTraitMethods(descriptor).entrySet()) {
FunctionDescriptor interfaceFun = entry.getKey();
//skip java 8 default methods
if (!CodegenUtilKt.isDefinitelyNotDefaultImplsMethod(interfaceFun) && !isJvm8InterfaceMember(interfaceFun, state)) {
if (state.isJvm8Target() && !JvmCodegenUtil.isJvm8Interface(interfaceFun.getContainingDeclaration(), state)) {
if (!CodegenUtilKt.isDefinitelyNotDefaultImplsMethod(interfaceFun) && !isJvm8InterfaceWithDefaultsMember(interfaceFun, state)) {
if (state.isJvm8TargetWithDefaults() && !JvmCodegenUtil.isJvm8InterfaceWithDefaults(interfaceFun.getContainingDeclaration(), state)) {
restrictedInheritance.add(interfaceFun);
}
else {
@@ -1593,6 +1587,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
iv.iconst(ordinal);
List<KtSuperTypeListEntry> delegationSpecifiers = enumEntry.getSuperTypeListEntries();
ResolvedCall<?> defaultArgumentsConstructorCall = CallUtilKt.getResolvedCall(enumEntry, bindingContext);
boolean enumEntryHasSubclass = CodegenBinding.enumEntryNeedSubclass(bindingContext, classDescriptor);
if (delegationSpecifiers.size() == 1 && !enumEntryNeedSubclass(bindingContext, enumEntry)) {
ResolvedCall<?> resolvedCall = CallUtilKt.getResolvedCallWithAssert(delegationSpecifiers.get(0), bindingContext);
@@ -1600,6 +1596,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
codegen.invokeMethodWithArguments(method, resolvedCall, StackValue.none());
}
else if (defaultArgumentsConstructorCall != null && !enumEntryHasSubclass) {
codegen.invokeFunction(defaultArgumentsConstructorCall, StackValue.none()).put(Type.VOID_TYPE, iv);
}
else {
iv.invokespecial(implClass.getInternalName(), "<init>", "(Ljava/lang/String;I)V", false);
}

View File

@@ -30,10 +30,9 @@ import org.jetbrains.kotlin.codegen.context.MethodContext;
import org.jetbrains.kotlin.codegen.context.RootContext;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper;
import org.jetbrains.kotlin.config.LanguageFeature;
import org.jetbrains.kotlin.config.LanguageVersionSettings;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor;
import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor;
import org.jetbrains.kotlin.load.java.descriptors.JavaPropertyDescriptor;
import org.jetbrains.kotlin.load.kotlin.*;
import org.jetbrains.kotlin.psi.Call;
@@ -64,11 +63,11 @@ public class JvmCodegenUtil {
private JvmCodegenUtil() {
}
public static boolean isAnnotationOrJvm6Interface(@NotNull DeclarationDescriptor descriptor, @NotNull GenerationState state) {
return isAnnotationOrJvm6Interface(descriptor, state.isJvm8Target());
public static boolean isAnnotationOrJvmInterfaceWithoutDefaults(@NotNull DeclarationDescriptor descriptor, @NotNull GenerationState state) {
return isAnnotationOrJvmInterfaceWithoutDefaults(descriptor, state.isJvm8Target(), state.isJvm8TargetWithDefaults());
}
public static boolean isAnnotationOrJvm6Interface(@NotNull DeclarationDescriptor descriptor, boolean isJvm8Target) {
private static boolean isAnnotationOrJvmInterfaceWithoutDefaults(@NotNull DeclarationDescriptor descriptor, boolean isJvm8Target, boolean isJvm8TargetWithDefaults) {
if (!isJvmInterface(descriptor)) {
return false;
}
@@ -80,23 +79,35 @@ public class JvmCodegenUtil {
KotlinJvmBinaryClass binaryClass = ((KotlinJvmBinarySourceElement) source).getBinaryClass();
assert binaryClass instanceof FileBasedKotlinClass :
"KotlinJvmBinaryClass should be subclass of FileBasedKotlinClass, but " + binaryClass;
return ((FileBasedKotlinClass) binaryClass).getClassVersion() == Opcodes.V1_6;
/*TODO need add some flags to compiled code*/
return true || ((FileBasedKotlinClass) binaryClass).getClassVersion() == Opcodes.V1_6;
}
}
return !isJvm8Target;
return !isJvm8TargetWithDefaults;
}
public static boolean isJvm8Interface(@NotNull DeclarationDescriptor descriptor, @NotNull GenerationState state) {
return isJvm8Interface(descriptor, state.isJvm8Target());
public static boolean isJvm8InterfaceWithDefaults(@NotNull DeclarationDescriptor descriptor, @NotNull GenerationState state) {
return isJvm8InterfaceWithDefaults(descriptor, state.isJvm8Target(), state.isJvm8TargetWithDefaults());
}
public static boolean isJvm8Interface(@NotNull DeclarationDescriptor descriptor, boolean isJvm8Target) {
return DescriptorUtils.isInterface(descriptor) && !isAnnotationOrJvm6Interface(descriptor, isJvm8Target);
public static boolean isJvm8InterfaceWithDefaults(@NotNull DeclarationDescriptor descriptor, boolean isJvm8Target, boolean isJvm8TargetWithDefaults) {
return DescriptorUtils.isInterface(descriptor) && !isAnnotationOrJvmInterfaceWithoutDefaults(descriptor, isJvm8Target, isJvm8TargetWithDefaults);
}
public static boolean isJvm8InterfaceMember(@NotNull CallableMemberDescriptor descriptor, @NotNull GenerationState state) {
public static boolean isJvm8InterfaceWithDefaultsMember(@NotNull CallableMemberDescriptor descriptor, @NotNull GenerationState state) {
DeclarationDescriptor declaration = descriptor.getContainingDeclaration();
return isJvm8Interface(declaration, state);
return isJvm8InterfaceWithDefaults(declaration, state);
}
public static boolean isNonDefaultInterfaceMember(@NotNull CallableMemberDescriptor descriptor, @NotNull GenerationState state) {
if (!isJvmInterface(descriptor.getContainingDeclaration())) {
return false;
}
if (descriptor instanceof JavaCallableMemberDescriptor) {
return descriptor.getModality() == Modality.ABSTRACT;
}
return !isJvm8InterfaceWithDefaultsMember(descriptor, state);
}
public static boolean isJvmInterface(DeclarationDescriptor descriptor) {
@@ -115,7 +126,7 @@ public class JvmCodegenUtil {
return closure.getCaptureThis() == null &&
closure.getCaptureReceiverType() == null &&
closure.getCaptureVariables().isEmpty() &&
!closure.isCoroutine();
!closure.isSuspend();
}
private static boolean isCallInsideSameClassAsDeclared(@NotNull CallableMemberDescriptor descriptor, @NotNull CodegenContext context) {

View File

@@ -17,22 +17,24 @@
package org.jetbrains.kotlin.codegen
import org.jetbrains.kotlin.builtins.createFunctionType
import org.jetbrains.kotlin.builtins.isExtensionFunctionType
import org.jetbrains.kotlin.codegen.coroutines.createJvmSuspendFunctionView
import org.jetbrains.kotlin.codegen.coroutines.COROUTINES_JVM_INTERNAL_PACKAGE_FQ_NAME
import org.jetbrains.kotlin.codegen.coroutines.getOrCreateJvmSuspendFunctionView
import org.jetbrains.kotlin.coroutines.isSuspendLambda
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor
import org.jetbrains.kotlin.descriptors.impl.MutableClassDescriptor
import org.jetbrains.kotlin.descriptors.impl.MutablePackageFragmentDescriptor
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils
import org.jetbrains.kotlin.utils.addIfNotNull
class JvmRuntimeTypes(module: ModuleDescriptor) {
private val kotlinJvmInternalPackage = MutablePackageFragmentDescriptor(module, FqName("kotlin.jvm.internal"))
private val kotlinCoroutinesJvmInternalPackage =
MutablePackageFragmentDescriptor(module, COROUTINES_JVM_INTERNAL_PACKAGE_FQ_NAME)
private fun klass(name: String) = lazy { createClass(kotlinJvmInternalPackage, name) }
@@ -40,7 +42,7 @@ class JvmRuntimeTypes(module: ModuleDescriptor) {
private val functionReference: ClassDescriptor by klass("FunctionReference")
private val localVariableReference: ClassDescriptor by klass("LocalVariableReference")
private val mutableLocalVariableReference: ClassDescriptor by klass("MutableLocalVariableReference")
private val coroutineImplClass by klass("CoroutineImpl")
private val coroutineImplClass by lazy { createClass(kotlinCoroutinesJvmInternalPackage, "CoroutineImpl") }
private val propertyReferences: List<ClassDescriptor> by lazy {
(0..2).map { i -> createClass(kotlinJvmInternalPackage, "PropertyReference$i") }
@@ -50,10 +52,6 @@ class JvmRuntimeTypes(module: ModuleDescriptor) {
(0..2).map { i -> createClass(kotlinJvmInternalPackage, "MutablePropertyReference$i") }
}
private val suspendFunctions: List<ClassDescriptor> by lazy {
(0..1).map { i -> createClass(kotlinJvmInternalPackage, "SuspendFunction$i", ClassKind.INTERFACE) }
}
private fun createClass(
packageFragment: PackageFragmentDescriptor,
name: String,
@@ -70,8 +68,8 @@ class JvmRuntimeTypes(module: ModuleDescriptor) {
fun getSupertypesForClosure(descriptor: FunctionDescriptor): Collection<KotlinType> {
val actualFunctionDescriptor =
if (descriptor.isSuspendLambda)
createJvmSuspendFunctionView(descriptor)
if (descriptor.isSuspend)
getOrCreateJvmSuspendFunctionView(descriptor)
else
descriptor
@@ -84,15 +82,13 @@ class JvmRuntimeTypes(module: ModuleDescriptor) {
actualFunctionDescriptor.returnType!!
)
if (descriptor.isSuspendLambda) {
if (descriptor.isSuspend) {
return mutableListOf<KotlinType>().apply {
add(coroutineImplClass.defaultType)
add(functionType)
val parametersNumber =
descriptor.valueParameters.size + (if (functionType.isExtensionFunctionType) 1 else 0)
addIfNotNull(suspendFunctions.getOrNull(parametersNumber)?.defaultType)
if (descriptor.isSuspendLambda) {
add(functionType)
}
}
}

View File

@@ -1,101 +0,0 @@
/*
* 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.codegen
import org.jetbrains.kotlin.backend.common.CodegenUtil
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.psi.KtNamedFunction
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin
import org.jetbrains.kotlin.resolve.jvm.diagnostics.Synthetic
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
class JvmStaticGenerator(
val descriptor: FunctionDescriptor,
val declarationOrigin: JvmDeclarationOrigin,
val state: GenerationState,
parentBodyCodegen: ImplementationBodyCodegen
) : Function2<ImplementationBodyCodegen, ClassBuilder, Unit> {
private val typeMapper = state.typeMapper
init {
parentBodyCodegen.getContext().accessibleDescriptor(JvmCodegenUtil.getDirectMember(descriptor), null)
}
override fun invoke(codegen: ImplementationBodyCodegen, classBuilder: ClassBuilder) {
val staticFunctionDescriptor = createStaticFunctionDescriptor(descriptor)
val originElement = declarationOrigin.element
codegen.functionCodegen.generateMethod(
Synthetic(originElement, staticFunctionDescriptor),
staticFunctionDescriptor,
object : FunctionGenerationStrategy.CodegenBased(state) {
override fun doGenerateBody(codegen: ExpressionCodegen, signature: JvmMethodSignature) {
val iv = codegen.v
val classDescriptor = descriptor.containingDeclaration as ClassDescriptor
val singletonValue = StackValue.singleton(classDescriptor, typeMapper)
singletonValue.put(singletonValue.type, iv)
var index = 0
val asmMethod = signature.asmMethod
for (paramType in asmMethod.argumentTypes) {
iv.load(index, paramType)
index += paramType.size
}
if (descriptor is PropertyAccessorDescriptor) {
val propertyValue = codegen.intermediateValueForProperty(descriptor.correspondingProperty, false, null, StackValue.none())
if (descriptor is PropertyGetterDescriptor) {
propertyValue.put(signature.returnType, iv)
}
else {
propertyValue.store(StackValue.onStack(propertyValue.type), iv, true)
}
}
else {
val syntheticOrOriginalMethod = typeMapper.mapToCallableMethod(
codegen.context.accessibleDescriptor(descriptor, /* superCallTarget = */ null),
false
)
syntheticOrOriginalMethod.genInvokeInstruction(iv)
}
iv.areturn(asmMethod.returnType)
}
}
)
if (originElement is KtNamedFunction) {
codegen.functionCodegen.generateOverloadsWithDefaultValues(originElement, staticFunctionDescriptor, descriptor)
}
}
companion object {
@JvmStatic
fun createStaticFunctionDescriptor(descriptor: FunctionDescriptor): FunctionDescriptor {
val memberDescriptor = if (descriptor is PropertyAccessorDescriptor) descriptor.correspondingProperty else descriptor
val copies = CodegenUtil.copyFunctions(
memberDescriptor,
memberDescriptor,
descriptor.containingDeclaration.containingDeclaration!!,
descriptor.modality,
descriptor.visibility,
CallableMemberDescriptor.Kind.SYNTHESIZED,
false
)
val staticFunctionDescriptor = copies[descriptor]!!
return staticFunctionDescriptor
}
}
}

View File

@@ -0,0 +1,101 @@
/*
* 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.codegen
import org.jetbrains.kotlin.backend.common.CodegenUtil
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.psi.KtNamedFunction
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin
import org.jetbrains.kotlin.resolve.jvm.diagnostics.Synthetic
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
class JvmStaticInCompanionObjectGenerator(
val descriptor: FunctionDescriptor,
val declarationOrigin: JvmDeclarationOrigin,
val state: GenerationState,
parentBodyCodegen: ImplementationBodyCodegen
) : Function2<ImplementationBodyCodegen, ClassBuilder, Unit> {
private val typeMapper = state.typeMapper
init {
parentBodyCodegen.getContext().accessibleDescriptor(JvmCodegenUtil.getDirectMember(descriptor), null)
}
override fun invoke(codegen: ImplementationBodyCodegen, classBuilder: ClassBuilder) {
val staticFunctionDescriptor = createStaticFunctionDescriptor(descriptor)
val originElement = declarationOrigin.element
codegen.functionCodegen.generateMethod(
Synthetic(originElement, staticFunctionDescriptor),
staticFunctionDescriptor,
object : FunctionGenerationStrategy.CodegenBased(state) {
override fun doGenerateBody(codegen: ExpressionCodegen, signature: JvmMethodSignature) {
val iv = codegen.v
val classDescriptor = descriptor.containingDeclaration as ClassDescriptor
val singletonValue = StackValue.singleton(classDescriptor, typeMapper)
singletonValue.put(singletonValue.type, iv)
var index = 0
val asmMethod = signature.asmMethod
for (paramType in asmMethod.argumentTypes) {
iv.load(index, paramType)
index += paramType.size
}
if (descriptor is PropertyAccessorDescriptor) {
val propertyValue = codegen.intermediateValueForProperty(descriptor.correspondingProperty, false, null, StackValue.none())
if (descriptor is PropertyGetterDescriptor) {
propertyValue.put(signature.returnType, iv)
}
else {
propertyValue.store(StackValue.onStack(propertyValue.type), iv, true)
}
}
else {
val syntheticOrOriginalMethod = typeMapper.mapToCallableMethod(
codegen.context.accessibleDescriptor(descriptor, /* superCallTarget = */ null),
false
)
syntheticOrOriginalMethod.genInvokeInstruction(iv)
}
iv.areturn(asmMethod.returnType)
}
}
)
if (originElement is KtNamedFunction) {
codegen.functionCodegen.generateOverloadsWithDefaultValues(originElement, staticFunctionDescriptor, descriptor)
}
}
companion object {
@JvmStatic
fun createStaticFunctionDescriptor(descriptor: FunctionDescriptor): FunctionDescriptor {
val memberDescriptor = if (descriptor is PropertyAccessorDescriptor) descriptor.correspondingProperty else descriptor
val copies = CodegenUtil.copyFunctions(
memberDescriptor,
memberDescriptor,
descriptor.containingDeclaration.containingDeclaration!!,
descriptor.modality,
descriptor.visibility,
CallableMemberDescriptor.Kind.SYNTHESIZED,
false
)
val staticFunctionDescriptor = copies[descriptor]!!
return staticFunctionDescriptor
}
}
}

View File

@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.codegen.serialization.JvmSerializerExtension;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget;
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
import org.jetbrains.kotlin.fileClasses.FileClasses;
@@ -66,7 +67,8 @@ import org.jetbrains.org.objectweb.asm.commons.Method;
import java.util.*;
import static org.jetbrains.kotlin.codegen.AsmUtil.*;
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isJvm8InterfaceMember;
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isJvm8InterfaceWithDefaultsMember;
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isNonDefaultInterfaceMember;
import static org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.SYNTHESIZED;
import static org.jetbrains.kotlin.resolve.BindingContext.*;
import static org.jetbrains.kotlin.resolve.DescriptorUtils.*;
@@ -125,7 +127,10 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
generateBody();
generateSyntheticParts();
if (!(element instanceof KtClassOrObject) ||
state.getGenerateDeclaredClassFilter().shouldGenerateClassMembers((KtClassOrObject) element)) {
generateSyntheticParts();
}
if (state.getClassBuilderMode().generateMetadata) {
generateKotlinMetadataAnnotation();
@@ -236,14 +241,20 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
Annotations annotations = typeAliasDescriptor.getAnnotations();
if (!isAnnotationsMethodOwner || annotations.getAllAnnotations().isEmpty()) return;
int flags = ACC_DEPRECATED | ACC_PRIVATE | ACC_STATIC | ACC_SYNTHETIC;
String name = JvmAbi.getSyntheticMethodNameForAnnotatedTypeAlias(typeAliasDescriptor.getName());
String desc = "()V";
Method syntheticMethod = new Method(name, desc);
generateSyntheticAnnotationsMethod(typeAliasDescriptor, new Method(name, "()V"), annotations, null);
}
MethodVisitor mv = v.newMethod(JvmDeclarationOriginKt.OtherOrigin(typeAliasDescriptor), flags, syntheticMethod.getName(),
protected void generateSyntheticAnnotationsMethod(
@NotNull MemberDescriptor descriptor,
@NotNull Method syntheticMethod,
@NotNull Annotations annotations,
@Nullable AnnotationUseSiteTarget allowedTarget
) {
int flags = ACC_DEPRECATED | ACC_STATIC | ACC_SYNTHETIC | AsmUtil.getVisibilityAccessFlag(descriptor);
MethodVisitor mv = v.newMethod(JvmDeclarationOriginKt.OtherOrigin(descriptor), flags, syntheticMethod.getName(),
syntheticMethod.getDescriptor(), null, null);
AnnotationCodegen.forMethod(mv, this, typeMapper).genAnnotations(new AnnotatedSimple(annotations), Type.VOID_TYPE, null);
AnnotationCodegen.forMethod(mv, this, typeMapper).genAnnotations(new AnnotatedSimple(annotations), Type.VOID_TYPE, allowedTarget);
mv.visitCode();
mv.visitInsn(Opcodes.RETURN);
mv.visitEnd();
@@ -334,17 +345,19 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
}
private void writeInnerClass(@NotNull ClassDescriptor innerClass) {
writeInnerClass(innerClass, typeMapper, v);
if (!ErrorUtils.isError(innerClass)) {
writeInnerClass(innerClass, typeMapper, v);
}
}
public static void writeInnerClass(@NotNull ClassDescriptor innerClass, @NotNull KotlinTypeMapper typeMapper, @NotNull ClassBuilder v) {
DeclarationDescriptor containing = innerClass.getContainingDeclaration();
String outerClassInternalName = null;
if (containing instanceof ClassDescriptor) {
outerClassInternalName = typeMapper.mapClass((ClassDescriptor) containing).getInternalName();
outerClassInternalName = typeMapper.classInternalName((ClassDescriptor) containing);
}
String innerName = innerClass.getName().isSpecial() ? null : innerClass.getName().asString();
String innerClassInternalName = typeMapper.mapClass(innerClass).getInternalName();
String innerClassInternalName = typeMapper.classInternalName(innerClass);
v.visitInnerClass(innerClassInternalName, outerClassInternalName, innerName, calculateInnerClassAccessFlags(innerClass));
}
@@ -377,7 +390,7 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
ClassDescriptor classDescriptor = ((ClassContext) outermost).getContextDescriptor();
if (context instanceof MethodContext) {
FunctionDescriptor functionDescriptor = ((MethodContext) context).getFunctionDescriptor();
if (isInterface(functionDescriptor.getContainingDeclaration()) && !isJvm8InterfaceMember(functionDescriptor, state)) {
if (isInterface(functionDescriptor.getContainingDeclaration()) && !isJvm8InterfaceWithDefaultsMember(functionDescriptor, state)) {
return typeMapper.mapDefaultImpls(classDescriptor);
}
}
@@ -491,10 +504,11 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
int indexOfDelegatedProperty = PropertyCodegen.indexOfDelegatedProperty(property);
StackValue delegateValue = PropertyCodegen.invokeDelegatedPropertyConventionMethodWithReceiver(
codegen, typeMapper, provideDelegateResolvedCall, indexOfDelegatedProperty, 1, provideDelegateReceiver);
codegen, typeMapper, provideDelegateResolvedCall, indexOfDelegatedProperty, 1,
provideDelegateReceiver, propertyDescriptor
);
propValue.store(delegateValue, codegen.v);
}
protected boolean shouldInitializeProperty(@NotNull KtProperty property) {
@@ -582,7 +596,7 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
}
if (delegatedProperties.isEmpty()) return;
v.newField(NO_ORIGIN, ACC_PRIVATE | ACC_STATIC | ACC_FINAL | ACC_SYNTHETIC, JvmAbi.DELEGATED_PROPERTIES_ARRAY_NAME,
v.newField(NO_ORIGIN, ACC_STATIC | ACC_FINAL | ACC_SYNTHETIC, JvmAbi.DELEGATED_PROPERTIES_ARRAY_NAME,
"[" + K_PROPERTY_TYPE, null, null);
if (!state.getClassBuilderMode().generateBodies) return;
@@ -771,7 +785,7 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
((AccessorForCallableDescriptor) accessorDescriptor).getSuperCallTarget() != null
);
boolean hasDispatchReceiver = !isStaticDeclaration(functionDescriptor) && !isInterface(functionDescriptor.getContainingDeclaration());
boolean hasDispatchReceiver = !isStaticDeclaration(functionDescriptor) && !isNonDefaultInterfaceMember(functionDescriptor, state);
int reg = hasDispatchReceiver ? 1 : 0;
boolean accessorIsConstructor = accessorDescriptor instanceof AccessorForConstructorDescriptor;
if (!accessorIsConstructor && functionDescriptor instanceof ConstructorDescriptor) {

View File

@@ -176,7 +176,7 @@ class MultifileClassPartCodegen(
}
val serializer = DescriptorSerializer.createTopLevel(JvmSerializerExtension(v.serializationBindings, state))
val packageProto = serializer.packagePartProto(members).build()
val packageProto = serializer.packagePartProto(packageFragment.fqName, members).build()
val extraFlags = if (shouldGeneratePartHierarchy) JvmAnnotationNames.METADATA_MULTIFILE_PARTS_INHERIT_FLAG else 0

View File

@@ -129,7 +129,7 @@ public class PackagePartCodegen extends MemberCodegen<KtFile> {
final DescriptorSerializer serializer =
DescriptorSerializer.createTopLevel(new JvmSerializerExtension(v.getSerializationBindings(), state));
final ProtoBuf.Package packageProto = serializer.packagePartProto(members).build();
final ProtoBuf.Package packageProto = serializer.packagePartProto(element.getPackageFqName(), members).build();
WriteAnnotationUtilKt.writeKotlinMetadata(v, state, KotlinClassHeader.Kind.FILE_FACADE, 0, new Function1<AnnotationVisitor, Unit>() {
@Override

View File

@@ -20,7 +20,6 @@ import com.intellij.openapi.util.Pair;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.codegen.annotation.AnnotatedSimple;
import org.jetbrains.kotlin.codegen.annotation.AnnotatedWithFakeAnnotations;
import org.jetbrains.kotlin.codegen.context.*;
import org.jetbrains.kotlin.codegen.state.GenerationState;
@@ -58,7 +57,8 @@ import java.util.List;
import static org.jetbrains.kotlin.codegen.AsmUtil.getDeprecatedAccessFlag;
import static org.jetbrains.kotlin.codegen.AsmUtil.getVisibilityForBackingField;
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.*;
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isConstOrHasJvmFieldAnnotation;
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isJvmInterface;
import static org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings.FIELD_FOR_PROPERTY;
import static org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings.SYNTHETIC_METHOD_FOR_PROPERTY;
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isCompanionObject;
@@ -188,7 +188,7 @@ public class PropertyCodegen {
if (isCompanionObject(descriptor.getContainingDeclaration())) return true;
// Non-const properties from multifile classes have accessors regardless of visibility
if (!descriptor.isConst() && JvmFileClassUtilKt.isInsideJvmMultifileClassFile(declaration)) return true;
if (isNonConstTopLevelPropertyInMultifileClass(declaration, descriptor)) return true;
// Private class properties have accessors only in cases when those accessors are non-trivial
if (Visibilities.isPrivate(descriptor.getVisibility())) {
@@ -198,6 +198,15 @@ public class PropertyCodegen {
return true;
}
private static boolean isNonConstTopLevelPropertyInMultifileClass(
@NotNull KtProperty declaration,
@NotNull PropertyDescriptor descriptor
) {
return !descriptor.isConst() &&
descriptor.getContainingDeclaration() instanceof PackageFragmentDescriptor &&
JvmFileClassUtilKt.isInsideJvmMultifileClassFile(declaration);
}
private static boolean areAccessorsNeededForPrimaryConstructorProperty(
@NotNull PropertyDescriptor descriptor
) {
@@ -270,7 +279,7 @@ public class PropertyCodegen {
}
// Annotations on properties are stored in bytecode on an empty synthetic method. This way they're still
// accessible via reflection, and 'deprecated' and 'private' flags prevent this method from being called accidentally
// accessible via reflection, and 'deprecated' and 'synthetic' flags prevent this method from being called accidentally
private void generateSyntheticMethodIfNeeded(@NotNull PropertyDescriptor descriptor, @NotNull Annotations annotations) {
if (annotations.getAllAnnotations().isEmpty()) return;
@@ -278,15 +287,9 @@ public class PropertyCodegen {
if (!isInterface(contextDescriptor) ||
(FunctionCodegen.processInterface(contextDescriptor, kind, state) ||
(kind == OwnerKind.DEFAULT_IMPLS && state.getGenerateDefaultImplsForJvm8()))) {
int flags = ACC_DEPRECATED | ACC_PRIVATE | ACC_STATIC | ACC_SYNTHETIC;
Method syntheticMethod = getSyntheticMethodSignature(descriptor);
MethodVisitor mv = v.newMethod(JvmDeclarationOriginKt.OtherOrigin(descriptor), flags, syntheticMethod.getName(),
syntheticMethod.getDescriptor(), null, null);
AnnotationCodegen.forMethod(mv, memberCodegen, typeMapper)
.genAnnotations(new AnnotatedSimple(annotations), Type.VOID_TYPE, AnnotationUseSiteTarget.PROPERTY);
mv.visitCode();
mv.visitInsn(Opcodes.RETURN);
mv.visitEnd();
memberCodegen.generateSyntheticAnnotationsMethod(
descriptor, getSyntheticMethodSignature(descriptor), annotations, AnnotationUseSiteTarget.PROPERTY
);
}
}
@@ -540,7 +543,7 @@ public class PropertyCodegen {
StackValue.Property receiver = codegen.intermediateValueForProperty(propertyDescriptor, true, null, StackValue.LOCAL_0);
return invokeDelegatedPropertyConventionMethodWithReceiver(
codegen, typeMapper, resolvedCall, indexInPropertyMetadataArray, propertyMetadataArgumentIndex,
receiver
receiver, propertyDescriptor
);
}
@@ -550,9 +553,12 @@ public class PropertyCodegen {
@NotNull ResolvedCall<FunctionDescriptor> resolvedCall,
final int indexInPropertyMetadataArray,
int propertyMetadataArgumentIndex,
@Nullable StackValue receiver
@Nullable StackValue receiver,
@NotNull PropertyDescriptor propertyDescriptor
) {
final Type owner = getDelegatedPropertyMetadataOwner(codegen, typeMapper);
final Type owner = JvmAbi.isPropertyWithBackingFieldInOuterClass(propertyDescriptor) ?
codegen.getState().getTypeMapper().mapOwner(propertyDescriptor) :
getDelegatedPropertyMetadataOwner(codegen, typeMapper);
codegen.tempVariables.put(
resolvedCall.getCall().getValueArguments().get(propertyMetadataArgumentIndex).asElement(),

View File

@@ -34,7 +34,7 @@ data class SourceInfo(val source: String, val pathOrCleanFQN: String, val linesI
val isTopLevel = element is KtFile || (element is KtNamedFunction && element.getParent() is KtFile)
val cleanedClassFqName = if (!isTopLevel) internalClassName else internalClassName.substringBefore('$')
return SourceInfo(element.getContainingKtFile().name, cleanedClassFqName, lineNumbers!!)
return SourceInfo(element.containingKtFile.name, cleanedClassFqName, lineNumbers!!)
}
}

View File

@@ -48,6 +48,7 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.org.objectweb.asm.Label;
import org.jetbrains.org.objectweb.asm.Opcodes;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
@@ -281,60 +282,29 @@ public abstract class StackValue {
}
private static void box(Type type, Type toType, InstructionAdapter v) {
if (type == Type.BYTE_TYPE || toType.getInternalName().equals(NULLABLE_BYTE_TYPE_NAME) && type == Type.INT_TYPE) {
v.cast(type, Type.BYTE_TYPE);
v.invokestatic(NULLABLE_BYTE_TYPE_NAME, "valueOf", "(B)L" + NULLABLE_BYTE_TYPE_NAME + ";", false);
}
else if (type == Type.SHORT_TYPE || toType.getInternalName().equals(NULLABLE_SHORT_TYPE_NAME) && type == Type.INT_TYPE) {
v.cast(type, Type.SHORT_TYPE);
v.invokestatic(NULLABLE_SHORT_TYPE_NAME, "valueOf", "(S)L" + NULLABLE_SHORT_TYPE_NAME + ";", false);
}
else if (type == Type.LONG_TYPE || toType.getInternalName().equals(NULLABLE_LONG_TYPE_NAME) && type == Type.INT_TYPE) {
v.cast(type, Type.LONG_TYPE);
v.invokestatic(NULLABLE_LONG_TYPE_NAME, "valueOf", "(J)L" + NULLABLE_LONG_TYPE_NAME + ";", false);
}
else if (type == Type.INT_TYPE) {
v.invokestatic("java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;", false);
}
else if (type == Type.BOOLEAN_TYPE) {
v.invokestatic("java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;", false);
}
else if (type == Type.CHAR_TYPE) {
v.invokestatic("java/lang/Character", "valueOf", "(C)Ljava/lang/Character;", false);
}
else if (type == Type.FLOAT_TYPE) {
v.invokestatic("java/lang/Float", "valueOf", "(F)Ljava/lang/Float;", false);
}
else if (type == Type.DOUBLE_TYPE) {
v.invokestatic("java/lang/Double", "valueOf", "(D)Ljava/lang/Double;", false);
if (type == Type.INT_TYPE) {
if (toType.getInternalName().equals(NULLABLE_BYTE_TYPE_NAME)) {
type = Type.BYTE_TYPE;
}
else if (toType.getInternalName().equals(NULLABLE_SHORT_TYPE_NAME)) {
type = Type.SHORT_TYPE;
}
else if (toType.getInternalName().equals(NULLABLE_LONG_TYPE_NAME)) {
type = Type.LONG_TYPE;
}
v.cast(Type.INT_TYPE, type);
}
Type boxedType = AsmUtil.boxType(type);
if (boxedType == type) return;
v.invokestatic(boxedType.getInternalName(), "valueOf", Type.getMethodDescriptor(boxedType, type), false);
coerce(boxedType, toType, v);
}
private static void unbox(Type type, InstructionAdapter v) {
if (type == Type.INT_TYPE) {
v.invokevirtual("java/lang/Number", "intValue", "()I", false);
}
else if (type == Type.BOOLEAN_TYPE) {
v.invokevirtual("java/lang/Boolean", "booleanValue", "()Z", false);
}
else if (type == Type.CHAR_TYPE) {
v.invokevirtual("java/lang/Character", "charValue", "()C", false);
}
else if (type == Type.SHORT_TYPE) {
v.invokevirtual("java/lang/Number", "shortValue", "()S", false);
}
else if (type == Type.LONG_TYPE) {
v.invokevirtual("java/lang/Number", "longValue", "()J", false);
}
else if (type == Type.BYTE_TYPE) {
v.invokevirtual("java/lang/Number", "byteValue", "()B", false);
}
else if (type == Type.FLOAT_TYPE) {
v.invokevirtual("java/lang/Number", "floatValue", "()F", false);
}
else if (type == Type.DOUBLE_TYPE) {
v.invokevirtual("java/lang/Number", "doubleValue", "()D", false);
}
private static void unbox(Type methodOwner, Type type, InstructionAdapter v) {
assert isPrimitive(type) : "Unboxing should be performed to primitive type, but " + type.getClassName();
v.invokevirtual(methodOwner.getInternalName(), type.getClassName() + "Value", "()" + type.getDescriptor(), false);
}
protected void coerceTo(@NotNull Type toType, @NotNull InstructionAdapter v) {
@@ -372,23 +342,12 @@ public abstract class StackValue {
}
}
else if (toType.getSort() == Type.ARRAY) {
if (fromType.getSort() == Type.ARRAY &&
fromType.getElementType().equals(AsmTypes.JAVA_CLASS_TYPE) && toType.equals(K_CLASS_ARRAY_TYPE)) {
wrapJavaClassesIntoKClasses(v);
}
else {
v.checkcast(toType);
}
v.checkcast(toType);
}
else if (toType.getSort() == Type.OBJECT) {
if (fromType.getSort() == Type.OBJECT || fromType.getSort() == Type.ARRAY) {
if (!toType.equals(OBJECT_TYPE)) {
if (fromType.equals(AsmTypes.JAVA_CLASS_TYPE) && toType.equals(AsmTypes.K_CLASS_TYPE)) {
wrapJavaClassIntoKClass(v);
}
else {
v.checkcast(toType);
}
v.checkcast(toType);
}
}
else {
@@ -396,20 +355,29 @@ public abstract class StackValue {
}
}
else if (fromType.getSort() == Type.OBJECT) {
//toType is primitive here
Type unboxedType = unboxPrimitiveTypeOrNull(fromType);
if (unboxedType != null) {
unbox(unboxedType, v);
unbox(fromType, unboxedType, v);
coerce(unboxedType, toType, v);
}
else {
Type numberType = getType(Number.class);
if (toType.getSort() == Type.BOOLEAN || (toType.getSort() == Type.CHAR && !numberType.equals(fromType))) {
coerce(fromType, boxType(toType), v);
else if (toType.getSort() == Type.BOOLEAN) {
coerce(fromType, BOOLEAN_WRAPPER_TYPE, v);
unbox(BOOLEAN_WRAPPER_TYPE, Type.BOOLEAN_TYPE, v);
}
else if (toType.getSort() == Type.CHAR) {
if (fromType.equals(NUMBER_TYPE)) {
unbox(NUMBER_TYPE, Type.INT_TYPE, v);
v.visitInsn(Opcodes.I2C);
}
else {
coerce(fromType, numberType, v);
coerce(fromType, CHARACTER_WRAPPER_TYPE, v);
unbox(CHARACTER_WRAPPER_TYPE, Type.CHAR_TYPE, v);
}
unbox(toType, v);
}
else {
coerce(fromType, NUMBER_TYPE, v);
unbox(NUMBER_TYPE, toType, v);
}
}
else {
@@ -883,7 +851,7 @@ public abstract class StackValue {
newReceiver.put(newReceiver.type, v);
callGenerator.processAndPutHiddenParameters(false);
defaultArgs = generator.generate(valueArguments, valueArguments);
defaultArgs = generator.generate(valueArguments, valueArguments, call.getResultingDescriptor());
}
private ArgumentGenerator createArgumentGenerator() {
@@ -1211,7 +1179,20 @@ public abstract class StackValue {
else {
getter.genInvokeInstruction(v);
}
coerce(getter.getReturnType(), type, v);
Type typeOfValueOnStack = getter.getReturnType();
if (DescriptorUtils.isAnnotationClass(descriptor.getContainingDeclaration())) {
if (this.type.equals(K_CLASS_TYPE)) {
wrapJavaClassIntoKClass(v);
typeOfValueOnStack = K_CLASS_TYPE;
}
else if (this.type.equals(K_CLASS_ARRAY_TYPE)) {
wrapJavaClassesIntoKClasses(v);
typeOfValueOnStack = K_CLASS_ARRAY_TYPE;
}
}
coerce(typeOfValueOnStack, type, v);
KotlinType returnType = descriptor.getReturnType();
if (returnType != null && KotlinBuiltIns.isNothing(returnType)) {
@@ -1378,9 +1359,7 @@ public abstract class StackValue {
default:
PrimitiveType primitiveType = AsmUtil.asmPrimitiveTypeToLangPrimitiveType(type);
if (primitiveType == null) throw new UnsupportedOperationException();
String typeName = primitiveType.getTypeName().getIdentifier();
return Type.getObjectType(REF_TYPE_PREFIX + typeName + "Ref");
return sharedTypeForPrimitive(primitiveType);
}
}
@@ -1596,6 +1575,16 @@ public abstract class StackValue {
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;
}
}
public abstract static class StackValueWithSimpleReceiver extends StackValue {

View File

@@ -20,6 +20,7 @@ import com.google.common.collect.Lists;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.cfg.TailRecursionKind;
import org.jetbrains.kotlin.codegen.context.MethodContext;
import org.jetbrains.kotlin.codegen.coroutines.CoroutineCodegenUtilKt;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.descriptors.CallableDescriptor;
import org.jetbrains.kotlin.descriptors.FunctionDescriptor;
@@ -65,7 +66,7 @@ public class TailRecursionCodegen {
}
public void generateTailRecursion(ResolvedCall<?> resolvedCall) {
CallableDescriptor fd = resolvedCall.getResultingDescriptor();
CallableDescriptor fd = CoroutineCodegenUtilKt.unwrapInitialDescriptorForSuspendFunction(resolvedCall.getResultingDescriptor());
assert fd instanceof FunctionDescriptor : "Resolved call doesn't refer to the function descriptor: " + fd;
CallableMethod callable = (CallableMethod) codegen.resolveToCallable((FunctionDescriptor) fd, false, resolvedCall);
@@ -73,6 +74,11 @@ public class TailRecursionCodegen {
if (arguments == null) {
throw new IllegalStateException("Failed to arrange value arguments by index: " + fd);
}
if (((FunctionDescriptor) fd).isSuspend()) {
AsmUtil.pop(v, callable.getValueParameters().get(callable.getValueParameters().size() - 1).getAsmType());
}
assignParameterValues(fd, callable, arguments);
if (callable.getExtensionReceiverType() != null) {
if (resolvedCall.getExtensionReceiver() != fd.getExtensionReceiverParameter().getValue()) {

View File

@@ -44,5 +44,7 @@ public interface CalculatedClosure {
@NotNull
List<Pair<String, Type>> getRecordedFields();
boolean isCoroutine();
boolean isSuspend();
boolean isSuspendLambda();
}

View File

@@ -100,10 +100,21 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
@NotNull CallableDescriptor callableDescriptor,
@NotNull Collection<KotlinType> supertypes,
@NotNull String name
) {
return recordClassForCallable(element, callableDescriptor, supertypes, name, null);
}
@NotNull
private ClassDescriptor recordClassForCallable(
@NotNull KtElement element,
@NotNull CallableDescriptor callableDescriptor,
@NotNull Collection<KotlinType> supertypes,
@NotNull String name,
@Nullable DeclarationDescriptor customContainer
) {
String simpleName = name.substring(name.lastIndexOf('/') + 1);
ClassDescriptor classDescriptor = new SyntheticClassDescriptorForLambda(
correctContainerForLambda(callableDescriptor, element),
customContainer != null ? customContainer : correctContainerForLambda(callableDescriptor, element),
Name.special("<closure-" + simpleName + ">"),
supertypes,
element
@@ -289,7 +300,8 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
nameStack.push(name);
if (CoroutineUtilKt.isSuspendLambda(functionDescriptor)) {
closure.setCoroutine(true);
closure.setSuspend(true);
closure.setSuspendLambda();
}
super.visitLambdaExpression(lambdaExpression);
@@ -415,9 +427,11 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
// working around a problem with shallow analysis
if (functionDescriptor == null) return;
String nameForClassOrPackageMember = getNameForClassOrPackageMember(functionDescriptor);
if (functionDescriptor instanceof SimpleFunctionDescriptor && functionDescriptor.isSuspend()) {
SimpleFunctionDescriptor jvmSuspendFunctionView =
CoroutineCodegenUtilKt.createJvmSuspendFunctionView(
CoroutineCodegenUtilKt.getOrCreateJvmSuspendFunctionView(
(SimpleFunctionDescriptor) functionDescriptor
);
@@ -437,31 +451,53 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
bindingTrace.record(
CodegenBinding.SUSPEND_FUNCTION_TO_JVM_VIEW,
(SimpleFunctionDescriptor) functionDescriptor,
functionDescriptor,
jvmSuspendFunctionView
);
if (CoroutineCodegenUtilKt.containsNonTailSuspensionCalls(functionDescriptor, bindingContext)) {
if (nameForClassOrPackageMember != null) {
nameStack.push(nameForClassOrPackageMember);
}
processNamedFunctionWithClosure(function, functionDescriptor, functionDescriptor).setSuspend(true);
if (nameForClassOrPackageMember != null) {
nameStack.pop();
}
return;
}
}
String nameForClassOrPackageMember = getNameForClassOrPackageMember(functionDescriptor);
if (nameForClassOrPackageMember != null) {
nameStack.push(nameForClassOrPackageMember);
super.visitNamedFunction(function);
nameStack.pop();
}
else {
String name = inventAnonymousClassName();
Collection<KotlinType> supertypes = runtimeTypes.getSupertypesForClosure(functionDescriptor);
ClassDescriptor classDescriptor = recordClassForCallable(function, functionDescriptor, supertypes, name);
recordClosure(classDescriptor, name);
classStack.push(classDescriptor);
nameStack.push(name);
super.visitNamedFunction(function);
nameStack.pop();
classStack.pop();
processNamedFunctionWithClosure(function, functionDescriptor, null);
}
}
private MutableClosure processNamedFunctionWithClosure(
@NotNull KtNamedFunction function,
@NotNull FunctionDescriptor functionDescriptor,
@Nullable DeclarationDescriptor customContainer
) {
String name = inventAnonymousClassName();
Collection<KotlinType> supertypes = runtimeTypes.getSupertypesForClosure(functionDescriptor);
ClassDescriptor classDescriptor = recordClassForCallable(function, functionDescriptor, supertypes, name, customContainer);
MutableClosure closure = recordClosure(classDescriptor, name);
classStack.push(classDescriptor);
nameStack.push(name);
super.visitNamedFunction(function);
nameStack.pop();
classStack.pop();
return closure;
}
@Nullable
private String getNameForClassOrPackageMember(@NotNull DeclarationDescriptor descriptor) {
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
@@ -612,8 +648,10 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
int fieldNumber = mappings.size();
assert expression.getSubjectExpression() != null : "subject expression should be not null in a valid when by enums";
KotlinType type = bindingContext.getType(expression.getSubjectExpression());
KotlinType type = WhenChecker.whenSubjectType(expression, bindingContext);
assert type != null : "should not be null in a valid when by enums";
ClassDescriptor classDescriptor = (ClassDescriptor) type.getConstructor().getDeclarationDescriptor();
assert classDescriptor != null : "because it's enum";

View File

@@ -66,7 +66,7 @@ public class CodegenBinding {
public static final WritableSlice<VariableDescriptor, VariableDescriptor> LOCAL_VARIABLE_PROPERTY_METADATA =
Slices.createSimpleSlice();
public static final WritableSlice<SimpleFunctionDescriptor, SimpleFunctionDescriptor> SUSPEND_FUNCTION_TO_JVM_VIEW =
public static final WritableSlice<FunctionDescriptor, FunctionDescriptor> SUSPEND_FUNCTION_TO_JVM_VIEW =
Slices.createSimpleSlice();
public static final WritableSlice<ValueParameterDescriptor, ValueParameterDescriptor> PARAMETER_SYNONYM =

View File

@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.codegen.binding;
import com.intellij.openapi.util.Pair;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.codegen.StackValue;
import org.jetbrains.kotlin.codegen.context.EnclosedValueDescriptor;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.types.KotlinType;
@@ -40,7 +41,8 @@ public final class MutableClosure implements CalculatedClosure {
private Map<DeclarationDescriptor, Integer> parameterOffsetInConstructor;
private List<Pair<String, Type>> recordedFields;
private KotlinType captureReceiverType;
private boolean isCoroutine;
private boolean isSuspend;
private boolean isSuspendLambda;
MutableClosure(@NotNull ClassDescriptor classDescriptor, @Nullable ClassDescriptor enclosingClass) {
this.closureClass = classDescriptor;
@@ -119,15 +121,24 @@ public final class MutableClosure implements CalculatedClosure {
}
@Override
public boolean isCoroutine() {
return isCoroutine;
public boolean isSuspend() {
return isSuspend;
}
public void setCoroutine(boolean coroutine) {
this.isCoroutine = coroutine;
public void setSuspend(boolean suspend) {
this.isSuspend = suspend;
}
public void recordField(String name, Type type) {
@Override
public boolean isSuspendLambda() {
return isSuspendLambda;
}
public void setSuspendLambda() {
isSuspendLambda = true;
}
private void recordField(String name, Type type) {
if (recordedFields == null) {
recordedFields = new LinkedList<Pair<String, Type>>();
}
@@ -135,6 +146,8 @@ public final class MutableClosure implements CalculatedClosure {
}
public void captureVariable(EnclosedValueDescriptor value) {
recordField(value.getFieldName(), value.getType());
if (captureVariables == null) {
captureVariables = new LinkedHashMap<DeclarationDescriptor, EnclosedValueDescriptor>();
}

View File

@@ -35,7 +35,6 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getParentCall
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
import org.jetbrains.kotlin.resolve.descriptorUtil.overriddenTreeAsSequence
import org.jetbrains.kotlin.utils.addIfNotNull
import org.jetbrains.kotlin.utils.singletonOrEmptyList
import java.util.*
class BridgeForBuiltinSpecial<out Signature : Any>(
@@ -76,7 +75,7 @@ object BuiltinSpecialBridgesUtil {
else null
val commonBridges = reachableDeclarations.mapTo(LinkedHashSet<Signature>(), signatureByDescriptor)
commonBridges.removeAll(specialBridgesSignaturesInSuperClass + specialBridge?.from.singletonOrEmptyList())
commonBridges.removeAll(specialBridgesSignaturesInSuperClass + listOfNotNull(specialBridge?.from))
if (fake) {
for (overridden in function.overriddenDescriptors.map { it.original }) {

View File

@@ -40,7 +40,7 @@ private fun Iterable<PackageParts>.addCompiledParts(state: GenerationState): Lis
val incrementalCache = state.incrementalCacheForThisTarget ?: return this.toList()
val moduleMappingData = incrementalCache.getModuleMappingData() ?: return this.toList()
val mapping = ModuleMapping.create(moduleMappingData, "<incremental>")
val mapping = ModuleMapping.create(moduleMappingData, "<incremental>", state.deserializationConfiguration)
incrementalCache.getObsoletePackageParts().forEach { internalName ->
val qualifier = internalName.substringBeforeLast('/', "").replace('/', '.')

View File

@@ -21,30 +21,34 @@ import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.codegen.context.FieldOwnerContext
import org.jetbrains.kotlin.codegen.context.PackageContext
import org.jetbrains.kotlin.codegen.coroutines.unwrapInitialDescriptorForSuspendFunction
import org.jetbrains.kotlin.codegen.intrinsics.TypeIntrinsics
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.ValueParameterDescriptorImpl
import org.jetbrains.kotlin.diagnostics.rendering.Renderers
import org.jetbrains.kotlin.diagnostics.rendering.RenderingContext
import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature.SpecialSignatureInfo
import org.jetbrains.kotlin.load.java.JvmAbi
import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor
import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtObjectDeclaration
import org.jetbrains.kotlin.psi.KtProperty
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.renderer.DescriptorRenderer
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.DescriptorUtils.isSubclass
import org.jetbrains.kotlin.resolve.annotations.hasJvmStaticAnnotation
import org.jetbrains.kotlin.resolve.bindingContextUtil.getDataFlowInfoBefore
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
import org.jetbrains.kotlin.serialization.deserialization.PLATFORM_DEPENDENT_ANNOTATION_FQ_NAME
import org.jetbrains.kotlin.types.ErrorUtils
import org.jetbrains.kotlin.types.KotlinType
@@ -267,25 +271,27 @@ private fun CallableDescriptor.isJvmStaticIn(predicate: (DeclarationDescriptor)
fun Collection<VariableDescriptor>.filterOutDescriptorsWithSpecialNames() = filterNot { it.name.isSpecial }
fun calcTypeForIEEE754ArithmeticIfNeeded(expression: KtExpression?, bindingContext: BindingContext, descriptor: DeclarationDescriptor): Type? {
class TypeAndNullability(@JvmField val type: Type, @JvmField val isNullable: Boolean)
fun calcTypeForIEEE754ArithmeticIfNeeded(expression: KtExpression?, bindingContext: BindingContext, descriptor: DeclarationDescriptor): TypeAndNullability? {
val ktType = expression.kotlinType(bindingContext) ?: return null
if (KotlinBuiltIns.isDoubleOrNullableDouble(ktType)) {
return Type.DOUBLE_TYPE
return TypeAndNullability(Type.DOUBLE_TYPE, TypeUtils.isNullableType(ktType))
}
if (KotlinBuiltIns.isFloatOrNullableFloat(ktType)) {
return Type.FLOAT_TYPE
return TypeAndNullability(Type.FLOAT_TYPE, TypeUtils.isNullableType(ktType))
}
val dataFlow = DataFlowValueFactory.createDataFlowValue(expression!!, ktType, bindingContext, descriptor)
val stableTypes = bindingContext.getDataFlowInfoBefore(expression).getStableTypes(dataFlow)
return stableTypes.firstNotNullResult {
if (KotlinBuiltIns.isDoubleOrNullableDouble(it)) {
Type.DOUBLE_TYPE
TypeAndNullability(Type.DOUBLE_TYPE, TypeUtils.isNullableType(it))
}
else if (KotlinBuiltIns.isFloatOrNullableFloat(it)) {
Type.FLOAT_TYPE
TypeAndNullability(Type.FLOAT_TYPE, TypeUtils.isNullableType(it))
}
else {
null
@@ -339,3 +345,35 @@ fun MemberDescriptor.isToArrayFromCollection(): Boolean {
return isGenericToArray() || isNonGenericToArray()
}
fun FqName.topLevelClassInternalName() = JvmClassName.byClassId(ClassId(parent(), shortName())).internalName
fun FqName.topLevelClassAsmType(): Type = Type.getObjectType(topLevelClassInternalName())
fun initializeVariablesForDestructuredLambdaParameters(codegen: ExpressionCodegen, valueParameters: List<ValueParameterDescriptor>) {
val savedIsShouldMarkLineNumbers = codegen.isShouldMarkLineNumbers
// Do not write line numbers until destructuring happens
// (otherwise destructuring variables will be uninitialized in the beginning of lambda)
codegen.isShouldMarkLineNumbers = false
for (parameterDescriptor in valueParameters) {
if (parameterDescriptor !is ValueParameterDescriptorImpl.WithDestructuringDeclaration) continue
for (entry in parameterDescriptor.destructuringVariables.filterOutDescriptorsWithSpecialNames()) {
codegen.myFrameMap.enter(entry, codegen.typeMapper.mapType(entry.type))
}
val destructuringDeclaration =
(DescriptorToSourceUtils.descriptorToDeclaration(parameterDescriptor) as? KtParameter)?.destructuringDeclaration
?: error("Destructuring declaration for descriptor $parameterDescriptor not found")
codegen.initializeDestructuringDeclarationVariables(
destructuringDeclaration,
TransientReceiver(parameterDescriptor.type),
codegen.findLocalOrCapturedValue(parameterDescriptor) ?: error("Local var not found for parameter $parameterDescriptor")
)
}
codegen.isShouldMarkLineNumbers = savedIsShouldMarkLineNumbers
}
fun <D : CallableDescriptor> D.unwrapFrontendVersion() = unwrapInitialDescriptorForSuspendFunction()

View File

@@ -26,23 +26,23 @@ import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.anonymousClass
public class ClosureContext extends ClassContext {
private final FunctionDescriptor functionDescriptor;
private final FunctionDescriptor coroutineDescriptor;
private final FunctionDescriptor originalSuspendLambdaDescriptor;
public ClosureContext(
@NotNull KotlinTypeMapper typeMapper,
@NotNull FunctionDescriptor functionDescriptor,
@Nullable CodegenContext parentContext,
@NotNull LocalLookup localLookup,
// original coroutine lambda descriptor having return type T (the type that can be returned within lambda)
@Nullable FunctionDescriptor coroutineDescriptor
// original suspend lambda descriptor
@Nullable FunctionDescriptor originalSuspendLambdaDescriptor
) {
super(typeMapper,
anonymousClassForCallable(
typeMapper.getBindingContext(), coroutineDescriptor != null ? coroutineDescriptor : functionDescriptor),
typeMapper.getBindingContext(), originalSuspendLambdaDescriptor != null ? originalSuspendLambdaDescriptor : functionDescriptor),
OwnerKind.IMPLEMENTATION, parentContext, localLookup);
this.functionDescriptor = functionDescriptor;
this.coroutineDescriptor = coroutineDescriptor;
this.originalSuspendLambdaDescriptor = originalSuspendLambdaDescriptor;
}
public ClosureContext(
@@ -65,7 +65,7 @@ public class ClosureContext extends ClassContext {
}
@Nullable
public FunctionDescriptor getCoroutineDescriptor() {
return coroutineDescriptor;
public FunctionDescriptor getOriginalSuspendLambdaDescriptor() {
return originalSuspendLambdaDescriptor;
}
}

View File

@@ -37,7 +37,7 @@ import org.jetbrains.org.objectweb.asm.Type;
import java.util.*;
import static org.jetbrains.kotlin.codegen.AsmUtil.getVisibilityAccessFlag;
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isJvmInterface;
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isNonDefaultInterfaceMember;
import static org.jetbrains.kotlin.descriptors.annotations.AnnotationUtilKt.isInlineOnlyOrReifiable;
import static org.jetbrains.org.objectweb.asm.Opcodes.ACC_PRIVATE;
import static org.jetbrains.org.objectweb.asm.Opcodes.ACC_PROTECTED;
@@ -340,14 +340,14 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
@NotNull
public ClosureContext intoCoroutineClosure(
// copy of lambda descriptor that have Continuation<Unit> return type (as it's ep)
@NotNull FunctionDescriptor funDescriptorReturningContinuation,
// original coroutine lambda descriptor having return type T (the type that can be returned within lambda)
@NotNull FunctionDescriptor coroutineLambdaDescriptor,
// copy of lambda descriptor that has an additional value parameter Continuation<T>
@NotNull FunctionDescriptor jvmViewOfSuspendLambda,
// original coroutine lambda descriptor
@NotNull FunctionDescriptor originalSuspendLambdaDescriptor,
@NotNull LocalLookup localLookup,
@NotNull KotlinTypeMapper typeMapper
) {
return new ClosureContext(typeMapper, funDescriptorReturningContinuation, this, localLookup, coroutineLambdaDescriptor);
return new ClosureContext(typeMapper, jvmViewOfSuspendLambda, this, localLookup, originalSuspendLambdaDescriptor);
}
@Nullable
@@ -391,8 +391,11 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
@SuppressWarnings("unchecked")
@NotNull
public <D extends CallableMemberDescriptor> D getAccessorForSuperCallIfNeeded(@NotNull D descriptor, @Nullable ClassDescriptor superCallTarget) {
if (superCallTarget != null && !isJvmInterface(descriptor.getContainingDeclaration())) {
public <D extends CallableMemberDescriptor> D getAccessorForSuperCallIfNeeded(
@NotNull D descriptor,
@Nullable ClassDescriptor superCallTarget,
@NotNull GenerationState state) {
if (superCallTarget != null && !isNonDefaultInterfaceMember(descriptor, state)) {
CodegenContext afterInline = getFirstCrossInlineOrNonInlineContext();
CodegenContext c = afterInline.findParentContextWithDescriptor(superCallTarget);
assert c != null : "Couldn't find a context for a super-call: " + descriptor;

View File

@@ -75,7 +75,6 @@ public interface LocalLookup {
enclosedValueDescriptor = new EnclosedValueDescriptor(fieldName, d, innerValue, type);
}
closure.recordField(fieldName, type);
closure.captureVariable(enclosedValueDescriptor);
return innerValue;
@@ -115,7 +114,6 @@ public interface LocalLookup {
StackValue.StackValueWithSimpleReceiver innerValue = StackValue.field(localType, classType, fieldName, false,
StackValue.LOCAL_0, vd);
closure.recordField(fieldName, localType);
closure.captureVariable(new EnclosedValueDescriptor(fieldName, d, innerValue, localType));
return innerValue;

View File

@@ -17,18 +17,21 @@
package org.jetbrains.kotlin.codegen.coroutines
import com.intellij.util.ArrayUtil
import org.jetbrains.kotlin.backend.common.CONTINUATION_RESUME_METHOD_NAME
import org.jetbrains.kotlin.codegen.*
import org.jetbrains.kotlin.codegen.binding.CodegenBinding
import org.jetbrains.kotlin.codegen.context.ClosureContext
import org.jetbrains.kotlin.codegen.context.MethodContext
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.coroutines.isSuspendLambda
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.KtDeclarationWithBody
import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.psi.KtFunction
import org.jetbrains.kotlin.psi.KtFunctionLiteral
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
import org.jetbrains.kotlin.resolve.descriptorUtil.module
@@ -37,35 +40,38 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin
import org.jetbrains.kotlin.resolve.jvm.diagnostics.OtherOrigin
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.KotlinTypeFactory
import org.jetbrains.kotlin.types.typeUtil.asTypeProjection
import org.jetbrains.kotlin.types.typeUtil.makeNullable
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
import org.jetbrains.kotlin.utils.singletonOrEmptyList
import org.jetbrains.org.objectweb.asm.Label
import org.jetbrains.org.objectweb.asm.MethodVisitor
import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
import org.jetbrains.org.objectweb.asm.commons.Method
class CoroutineCodegen(
state: GenerationState,
class CoroutineCodegen private constructor(
outerExpressionCodegen: ExpressionCodegen,
element: KtElement,
private val closureContext: ClosureContext,
strategy: FunctionGenerationStrategy,
parentCodegen: MemberCodegen<*>,
classBuilder: ClassBuilder,
private val coroutineLambdaDescriptor: FunctionDescriptor
) : ClosureCodegen(state, element, null, closureContext, null, strategy, parentCodegen, classBuilder) {
private val originalSuspendFunctionDescriptor: FunctionDescriptor,
private val isSuspendLambda: Boolean
) : ClosureCodegen(
outerExpressionCodegen.state,
element, null, closureContext, null,
FailingFunctionGenerationStrategy,
outerExpressionCodegen.parentCodegen, classBuilder
) {
private val classDescriptor = closureContext.contextDescriptor
private val builtIns = funDescriptor.builtIns
private lateinit var constructorToUseFromInvoke: Method
// protected fun doResume(result, throwable)
private val doResumeDescriptor =
SimpleFunctionDescriptorImpl.create(
classDescriptor, Annotations.EMPTY, Name.identifier("doResume"), CallableMemberDescriptor.Kind.DECLARATION,
classDescriptor, Annotations.EMPTY, Name.identifier(DO_RESUME_METHOD_NAME), CallableMemberDescriptor.Kind.DECLARATION,
funDescriptor.source
).apply doResume@{
initialize(
@@ -75,40 +81,39 @@ class CoroutineCodegen(
listOf(
ValueParameterDescriptorImpl(
this@doResume, null, 0, Annotations.EMPTY, Name.identifier("data"),
module.builtIns.nullableAnyType,
builtIns.nullableAnyType,
/* isDefault = */ false, /* isCrossinline = */ false,
/* isNoinline = */ false,
/* varargElementType = */ null, SourceElement.NO_SOURCE
),
ValueParameterDescriptorImpl(
this@doResume, null, 1, Annotations.EMPTY, Name.identifier("throwable"),
module.builtIns.throwable.defaultType.makeNullable(),
builtIns.throwable.defaultType.makeNullable(),
/* isDefault = */ false, /* isCrossinline = */ false,
/* isNoinline = */ false,
/* varargElementType = */ null, SourceElement.NO_SOURCE
)
),
funDescriptor.builtIns.nullableAnyType,
builtIns.nullableAnyType,
Modality.FINAL,
Visibilities.PROTECTED
Visibilities.PUBLIC,
mapOf(INITIAL_SUSPEND_DESCRIPTOR_FOR_DO_RESUME to originalSuspendFunctionDescriptor)
)
}
private val createCoroutineDescriptor =
funDescriptor.createCustomCopy {
setName(Name.identifier("create"))
setName(Name.identifier(SUSPEND_FUNCTION_CREATE_METHOD_NAME))
setReturnType(
KotlinTypeFactory.simpleNotNullType(
Annotations.EMPTY,
funDescriptor.builtIns.continuationClassDescriptor,
listOf(funDescriptor.builtIns.unitType.asTypeProjection())
)
funDescriptor.module.getContinuationOfTypeOrAny(builtIns.unitType)
)
// 'create' method should not inherit initial descriptor for suspend function from original descriptor
putUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION, null)
setVisibility(Visibilities.PUBLIC)
}
override fun generateClosureBody() {
for (parameter in allLambdaParameters()) {
for (parameter in allFunctionParameters()) {
val fieldInfo = parameter.getFieldInfoForCoroutineLambdaParameter()
v.newField(
OtherOrigin(parameter),
@@ -121,9 +126,17 @@ class CoroutineCodegen(
generateDoResume()
}
override fun generateBridges() {
if (!isSuspendLambda) return
super.generateBridges()
}
override fun generateBody() {
super.generateBody()
if (!isSuspendLambda) return
// create() = ...
functionCodegen.generateMethod(JvmDeclarationOrigin.NO_ORIGIN, createCoroutineDescriptor,
object : FunctionGenerationStrategy.CodegenBased(state) {
override fun doGenerateBody(codegen: ExpressionCodegen, signature: JvmMethodSignature) {
@@ -139,7 +152,7 @@ class CoroutineCodegen(
}
})
if (allLambdaParameters().size <= 1) {
if (allFunctionParameters().size <= 1) {
val delegate = typeMapper.mapSignatureSkipGeneric(createCoroutineDescriptor).asmMethod
val bridgeParameters = (1..delegate.argumentTypes.size - 1).map { AsmTypes.OBJECT_TYPE } + delegate.argumentTypes.last()
@@ -162,30 +175,21 @@ class CoroutineCodegen(
v.thisName,
createCoroutineDescriptor.name.identifier,
Type.getMethodDescriptor(
AsmTypes.CONTINUATION,
CONTINUATION_ASM_TYPE,
*parameterTypes.toTypedArray()
),
false
)
checkcast(Type.getObjectType(v.thisName))
// .resume(Unit)
StackValue.putUnitInstance(this)
invokevirtual(
AsmTypes.RESTRICTED_COROUTINE_IMPL.internalName,
CONTINUATION_RESUME_METHOD_NAME.identifier,
Type.getMethodDescriptor(Type.VOID_TYPE, AsmTypes.OBJECT_TYPE),
false
)
loadSuspendMarker()
// .doResume(Unit)
invokeDoResumeWithUnit(v.thisName)
areturn(AsmTypes.OBJECT_TYPE)
}
override fun generateConstructor(): Method {
val args = calculateConstructorParameters(typeMapper, closure, asmType)
val argTypes = args.map { it.fieldType }.plus(AsmTypes.CONTINUATION).toTypedArray()
val argTypes = args.map { it.fieldType }.plus(CONTINUATION_ASM_TYPE).toTypedArray()
val constructor = Method("<init>", Type.VOID_TYPE, argTypes)
val mv = v.newMethod(
@@ -205,7 +209,7 @@ class CoroutineCodegen(
iv.iconst(calculateArity())
iv.load(argTypes.map { it.size }.sum(), AsmTypes.OBJECT_TYPE)
val superClassConstructorDescriptor = Type.getMethodDescriptor(Type.VOID_TYPE, Type.INT_TYPE, AsmTypes.CONTINUATION)
val superClassConstructorDescriptor = Type.getMethodDescriptor(Type.VOID_TYPE, Type.INT_TYPE, CONTINUATION_ASM_TYPE)
iv.invokespecial(superClassAsmType.internalName, "<init>", superClassConstructorDescriptor, false)
iv.visitInsn(Opcodes.RETURN)
@@ -217,6 +221,7 @@ class CoroutineCodegen(
}
private fun generateCreateCoroutineMethod(codegen: ExpressionCodegen) {
assert(isSuspendLambda) { "create method should only be generated for suspend lambdas" }
val classDescriptor = closureContext.contextDescriptor
val owner = typeMapper.mapClass(classDescriptor)
@@ -233,7 +238,7 @@ class CoroutineCodegen(
}
// load resultContinuation
load(allLambdaParameters().map { typeMapper.mapType(it.type).size }.sum() + 1, AsmTypes.OBJECT_TYPE)
load(allFunctionParameters().map { typeMapper.mapType(it.type).size }.sum() + 1, AsmTypes.OBJECT_TYPE)
invokespecial(owner.internalName, constructorToUseFromInvoke.name, constructorToUseFromInvoke.descriptor, false)
@@ -242,7 +247,7 @@ class CoroutineCodegen(
// Pass lambda parameters to 'invoke' call on newly constructed object
var index = 1
for (parameter in allLambdaParameters()) {
for (parameter in allFunctionParameters()) {
val fieldInfoForCoroutineLambdaParameter = parameter.getFieldInfoForCoroutineLambdaParameter()
load(index, fieldInfoForCoroutineLambdaParameter.fieldType)
AsmUtil.genAssignInstanceFieldFromParam(fieldInfoForCoroutineLambdaParameter, index, this, cloneIndex)
@@ -255,21 +260,36 @@ class CoroutineCodegen(
}
private fun ExpressionCodegen.initializeCoroutineParameters() {
for (parameter in allLambdaParameters()) {
val mappedType = typeMapper.mapType(parameter.type)
val newIndex = myFrameMap.enter(parameter, mappedType)
if (!isSuspendLambda && !originalSuspendFunctionDescriptor.isTailrec) return
for (parameter in allFunctionParameters()) {
val fieldStackValue =
if (isSuspendLambda)
StackValue.field(
parameter.getFieldInfoForCoroutineLambdaParameter(), generateThisOrOuter(context.thisDescriptor, false)
)
else
closureContext.lookupInContext(parameter, null, state, /* ignoreNoOuter = */ false)
generateLoadField(parameter.getFieldInfoForCoroutineLambdaParameter())
val mappedType = typeMapper.mapType(parameter.type)
fieldStackValue.put(mappedType, v)
val newIndex = myFrameMap.enter(parameter, mappedType)
v.store(newIndex, mappedType)
}
// necessary for proper tailrec codegen
val actualMethodStartLabel = Label()
v.visitLabel(actualMethodStartLabel)
context.setMethodStartLabel(actualMethodStartLabel)
if (isSuspendLambda) {
initializeVariablesForDestructuredLambdaParameters(this, originalSuspendFunctionDescriptor.valueParameters)
}
}
private fun allLambdaParameters() =
coroutineLambdaDescriptor.extensionReceiverParameter.singletonOrEmptyList() + coroutineLambdaDescriptor.valueParameters
private fun ExpressionCodegen.generateLoadField(fieldInfo: FieldInfo) {
StackValue.field(fieldInfo, generateThisOrOuter(context.thisDescriptor, false)).put(fieldInfo.fieldType, v)
}
private fun allFunctionParameters() =
listOfNotNull(originalSuspendFunctionDescriptor.extensionReceiverParameter) +
originalSuspendFunctionDescriptor.valueParameters.orEmpty()
private fun ParameterDescriptor.getFieldInfoForCoroutineLambdaParameter() =
createHiddenFieldInfo(type, COROUTINE_LAMBDA_PARAMETER_PREFIX + (this.safeAs<ValueParameterDescriptor>()?.index ?: ""))
@@ -295,33 +315,81 @@ class CoroutineCodegen(
)
}
override fun generateKotlinMetadataAnnotation() {
if (isSuspendLambda) {
super.generateKotlinMetadataAnnotation()
}
else {
writeKotlinMetadata(v, state, KotlinClassHeader.Kind.SYNTHETIC_CLASS, 0) {
// Do not write method metadata for raw coroutine state machines
}
}
}
companion object {
fun shouldCreateByLambda(
originalSuspendLambdaDescriptor: CallableDescriptor,
declaration: KtElement): Boolean {
return (declaration is KtFunctionLiteral && originalSuspendLambdaDescriptor.isSuspendLambda)
}
@JvmStatic
fun create(
fun createByLambda(
expressionCodegen: ExpressionCodegen,
originalCoroutineLambdaDescriptor: FunctionDescriptor,
originalSuspendLambdaDescriptor: FunctionDescriptor,
declaration: KtElement,
classBuilder: ClassBuilder
): ClosureCodegen? {
if (declaration !is KtFunctionLiteral) return null
if (!originalCoroutineLambdaDescriptor.isSuspendLambda) return null
if (!shouldCreateByLambda(originalSuspendLambdaDescriptor, declaration)) return null
val descriptorWithContinuationReturnType = createJvmSuspendFunctionView(originalCoroutineLambdaDescriptor)
val state = expressionCodegen.state
return CoroutineCodegen(
state,
expressionCodegen,
declaration,
expressionCodegen.context.intoCoroutineClosure(
descriptorWithContinuationReturnType, originalCoroutineLambdaDescriptor, expressionCodegen, state.typeMapper
getOrCreateJvmSuspendFunctionView(originalSuspendLambdaDescriptor, expressionCodegen.state.bindingContext),
originalSuspendLambdaDescriptor, expressionCodegen, expressionCodegen.state.typeMapper
),
FunctionGenerationStrategy.FunctionDefault(state, declaration),
expressionCodegen.parentCodegen, classBuilder,
originalCoroutineLambdaDescriptor
classBuilder,
originalSuspendLambdaDescriptor,
isSuspendLambda = true
)
}
fun create(
expressionCodegen: ExpressionCodegen,
originalSuspendDescriptor: FunctionDescriptor,
declaration: KtFunction,
state: GenerationState
): CoroutineCodegen {
val cv = state.factory.newVisitor(
OtherOrigin(declaration, originalSuspendDescriptor),
CodegenBinding.asmTypeForAnonymousClass(state.bindingContext, originalSuspendDescriptor),
declaration.containingFile
)
return CoroutineCodegen(
expressionCodegen, declaration,
expressionCodegen.context.intoClosure(
originalSuspendDescriptor, expressionCodegen, expressionCodegen.state.typeMapper
),
cv,
originalSuspendDescriptor,
isSuspendLambda = false
)
}
}
}
private const val COROUTINE_LAMBDA_PARAMETER_PREFIX = "p$"
private object FailingFunctionGenerationStrategy : FunctionGenerationStrategy() {
override fun generateBody(
mv: MethodVisitor,
frameMap: FrameMap,
signature: JvmMethodSignature,
context: MethodContext,
parentCodegen: MemberCodegen<*>
) {
error("This functions must not be called")
}
}

View File

@@ -83,10 +83,7 @@ class CoroutineTransformerMethodVisitor(
// Remove unreachable suspension points
// If we don't do this, then relevant frames will not be analyzed, that is unexpected from point of view of next steps (e.g. variable spilling)
DeadCodeEliminationMethodTransformer().transform(classBuilder.thisName, methodNode)
suspensionPoints.removeAll {
it.suspensionCallBegin.next == null && it.suspensionCallBegin.previous == null
}
removeUnreachableSuspensionPointsAndExitPoints(methodNode, suspensionPoints)
processUninitializedStores(methodNode)
@@ -105,12 +102,12 @@ class CoroutineTransformerMethodVisitor(
// tableswitch(this.label)
insertBefore(firstToInsertBefore,
insnListOf(
*withInstructionAdapter { loadSuspendMarker() }.toArray(),
*withInstructionAdapter { loadCoroutineSuspendedMarker() }.toArray(),
VarInsnNode(Opcodes.ASTORE, suspendMarkerVarIndex),
VarInsnNode(Opcodes.ALOAD, 0),
FieldInsnNode(
Opcodes.GETFIELD,
AsmTypes.RESTRICTED_COROUTINE_IMPL.internalName,
COROUTINE_IMPL_ASM_TYPE.internalName,
COROUTINE_LABEL_FIELD_NAME, Type.INT_TYPE.descriptor
),
TableSwitchInsnNode(0,
@@ -136,6 +133,22 @@ class CoroutineTransformerMethodVisitor(
}
private fun removeUnreachableSuspensionPointsAndExitPoints(methodNode: MethodNode, suspensionPoints: MutableList<SuspensionPoint>) {
val dceResult = DeadCodeEliminationMethodTransformer().transformWithResult(classBuilder.thisName, methodNode)
// If the suspension call begin is alive and suspension call end is dead
// (e.g., an inlined suspend function call ends with throwing a exception -- see KT-15017),
// this is an exit point for the corresponding coroutine.
// It doesn't introduce an additional state to the corresponding coroutine's FSM.
suspensionPoints.forEach {
if (dceResult.isAlive(it.suspensionCallBegin) && dceResult.isRemoved(it.suspensionCallEnd)) {
methodNode.instructions.remove(it.suspensionCallBegin)
}
}
suspensionPoints.removeAll { dceResult.isRemoved(it.suspensionCallBegin) || dceResult.isRemoved(it.suspensionCallEnd) }
}
private fun collectSuspensionPoints(methodNode: MethodNode): MutableList<SuspensionPoint> {
val suspensionPoints = mutableListOf<SuspensionPoint>()
val beforeSuspensionPointMarkerStack = Stack<MethodInsnNode>()
@@ -149,12 +162,7 @@ class CoroutineTransformerMethodVisitor(
}
AFTER_SUSPENSION_POINT_MARKER_NAME -> {
suspensionPoints.add(
SuspensionPoint(
suspensionCallBegin = beforeSuspensionPointMarkerStack.pop(),
suspensionCallEnd = methodInsn
)
)
suspensionPoints.add(SuspensionPoint(beforeSuspensionPointMarkerStack.pop(), methodInsn))
}
}
}
@@ -186,8 +194,8 @@ class CoroutineTransformerMethodVisitor(
for (suspension in suspensionPoints) {
val suspensionCallBegin = suspension.suspensionCallBegin
val suspensionCallEnd = suspension.suspensionCallEnd
assert(frames[suspensionCallEnd.next.index()]?.stackSize == 1) {
assert(frames[suspension.suspensionCallEnd.next.index()]?.stackSize == 1) {
"Stack should be spilled before suspension call"
}
@@ -221,6 +229,18 @@ class CoroutineTransformerMethodVisitor(
}
for ((index, basicValue) in variablesToSpill) {
if (basicValue === StrictBasicValue.NULL_VALUE) {
postponedActions.add {
with(instructions) {
insert(suspension.tryCatchBlockEndLabelAfterSuspensionCall, withInstructionAdapter {
aconst(null)
store(index, AsmTypes.OBJECT_TYPE)
})
}
}
continue
}
val type = basicValue.type
val normalizedType = type.normalize()
@@ -274,7 +294,7 @@ class CoroutineTransformerMethodVisitor(
get() {
assert(suspensionCallEnd.next is LabelNode) {
"Next instruction after ${this} should be a label, but " +
"${suspensionCallEnd.next.javaClass}/${suspensionCallEnd.next.opcode} was found"
"${suspensionCallEnd.next::class.java}/${suspensionCallEnd.next.opcode} was found"
}
return suspensionCallEnd.next as LabelNode
@@ -295,7 +315,7 @@ class CoroutineTransformerMethodVisitor(
VarInsnNode(Opcodes.ALOAD, 0),
*withInstructionAdapter { iconst(id) }.toArray(),
FieldInsnNode(
Opcodes.PUTFIELD, AsmTypes.RESTRICTED_COROUTINE_IMPL.internalName, COROUTINE_LABEL_FIELD_NAME,
Opcodes.PUTFIELD, COROUTINE_IMPL_ASM_TYPE.internalName, COROUTINE_LABEL_FIELD_NAME,
Type.INT_TYPE.descriptor
)
)
@@ -401,7 +421,7 @@ private fun InstructionAdapter.generateResumeWithExceptionCheck() {
private fun Type.fieldNameForVar(index: Int) = descriptor.first() + "$" + index
private fun withInstructionAdapter(block: InstructionAdapter.() -> Unit): InsnList {
inline fun withInstructionAdapter(block: InstructionAdapter.() -> Unit): InsnList {
val tmpMethodNode = MethodNode()
InstructionAdapter(tmpMethodNode).apply(block)
@@ -430,9 +450,3 @@ private class SuspensionPoint(
) {
lateinit var tryCatchBlocksContinuationLabel: LabelNode
}
private val DEFAULT_VALUE_OPCODES =
setOf(Opcodes.ICONST_0, Opcodes.LCONST_0, Opcodes.FCONST_0, Opcodes.DCONST_0, Opcodes.ACONST_NULL,
// GETSTATIC Unit.Instance
Opcodes.GETSTATIC)

View File

@@ -0,0 +1,52 @@
/*
* Copyright 2010-2016 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.coroutines
import org.jetbrains.kotlin.codegen.ExpressionCodegen
import org.jetbrains.kotlin.codegen.FunctionGenerationStrategy
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.psi.KtFunction
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
import org.jetbrains.org.objectweb.asm.Type
class SuspendFunctionGenerationStrategy(
state: GenerationState,
private val originalSuspendDescriptor: FunctionDescriptor,
private val declaration: KtFunction
) : FunctionGenerationStrategy.CodegenBased(state) {
override fun doGenerateBody(codegen: ExpressionCodegen, signature: JvmMethodSignature) {
if (!originalSuspendDescriptor.containsNonTailSuspensionCalls(state.bindingContext)) {
return codegen.returnExpression(declaration.bodyExpression)
}
val coroutineCodegen = CoroutineCodegen.create(codegen, originalSuspendDescriptor, declaration, state)
coroutineCodegen.generate()
codegen.putClosureInstanceOnStack(coroutineCodegen, null).put(Type.getObjectType(coroutineCodegen.className), codegen.v)
with(codegen.v) {
invokeDoResumeWithUnit(coroutineCodegen.v.thisName)
codegen.markLineNumber(declaration, true)
areturn(AsmTypes.OBJECT_TYPE)
}
}
}

View File

@@ -17,27 +17,31 @@
package org.jetbrains.kotlin.codegen.coroutines
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.backend.common.SUSPEND_WITH_CURRENT_CONTINUATION_NAME
import org.jetbrains.kotlin.backend.common.getBuiltInSuspendWithCurrentContinuation
import org.jetbrains.kotlin.backend.common.COROUTINES_INTRINSICS_PACKAGE_FQ_NAME
import org.jetbrains.kotlin.backend.common.COROUTINE_SUSPENDED_NAME
import org.jetbrains.kotlin.backend.common.isBuiltInSuspendCoroutineOrReturn
import org.jetbrains.kotlin.builtins.isBuiltinFunctionalType
import org.jetbrains.kotlin.codegen.StackValue
import org.jetbrains.kotlin.codegen.binding.CodegenBinding
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
import org.jetbrains.kotlin.codegen.topLevelClassAsmType
import org.jetbrains.kotlin.codegen.topLevelClassInternalName
import org.jetbrains.kotlin.coroutines.isSuspendLambda
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
import org.jetbrains.kotlin.load.java.JvmAbi
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtPsiFactory
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.BindingTraceContext
import org.jetbrains.kotlin.resolve.DelegatingBindingTrace
import org.jetbrains.kotlin.resolve.DescriptorEquivalenceForOverrides
import org.jetbrains.kotlin.resolve.*
import org.jetbrains.kotlin.resolve.calls.model.*
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
import org.jetbrains.kotlin.resolve.descriptorUtil.module
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.KotlinTypeFactory
import org.jetbrains.kotlin.types.TypeConstructorSubstitution
import org.jetbrains.kotlin.types.typeUtil.asTypeProjection
@@ -57,11 +61,35 @@ const val AFTER_SUSPENSION_POINT_MARKER_NAME = "afterSuspensionPoint"
const val ACTUAL_COROUTINE_START_MARKER_NAME = "actualCoroutineStart"
const val COROUTINE_LABEL_FIELD_NAME = "label"
const val SUSPEND_FUNCTION_CREATE_METHOD_NAME = "create"
const val DO_RESUME_METHOD_NAME = "doResume"
@JvmField
val COROUTINES_JVM_INTERNAL_PACKAGE_FQ_NAME =
DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME.child(Name.identifier("jvm")).child(Name.identifier("internal"))
@JvmField
val CONTINUATION_ASM_TYPE = DescriptorUtils.CONTINUATION_INTERFACE_FQ_NAME.topLevelClassAsmType()
@JvmField
val COROUTINE_IMPL_ASM_TYPE = COROUTINES_JVM_INTERNAL_PACKAGE_FQ_NAME.child(Name.identifier("CoroutineImpl")).topLevelClassAsmType()
private val COROUTINES_INTRINSICS_FILE_FACADE_INTERNAL_NAME =
COROUTINES_INTRINSICS_PACKAGE_FQ_NAME.child(Name.identifier("IntrinsicsKt")).topLevelClassAsmType()
private val INTERNAL_COROUTINE_INTRINSICS_OWNER_INTERNAL_NAME =
COROUTINES_JVM_INTERNAL_PACKAGE_FQ_NAME.child(Name.identifier("CoroutineIntrinsics")).topLevelClassInternalName()
private val NORMALIZE_CONTINUATION_METHOD_NAME = "normalizeContinuation"
data class ResolvedCallWithRealDescriptor(val resolvedCall: ResolvedCall<*>, val fakeContinuationExpression: KtExpression)
@JvmField
val INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION = object : FunctionDescriptor.UserDataKey<FunctionDescriptor> {}
@JvmField
val INITIAL_SUSPEND_DESCRIPTOR_FOR_DO_RESUME = object : FunctionDescriptor.UserDataKey<FunctionDescriptor> {}
// Resolved calls to suspension function contain descriptors as they visible within coroutines:
// E.g. `fun <V> await(f: CompletableFuture<V>): V` instead of `fun <V> await(f: CompletableFuture<V>, machine: Continuation<V>): Unit`
// See `createJvmSuspendFunctionView` and it's usages for clarification
@@ -85,12 +113,18 @@ fun ResolvedCall<*>.replaceSuspensionFunctionWithRealDescriptor(
)
)
}
val function = candidateDescriptor as? SimpleFunctionDescriptor ?: return null
val function = candidateDescriptor as? FunctionDescriptor ?: return null
if (!function.isSuspend || function.getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION) != null) return null
val newCandidateDescriptor =
bindingContext.get(CodegenBinding.SUSPEND_FUNCTION_TO_JVM_VIEW, function)
?: createJvmSuspendFunctionView(function)
when (function) {
is FunctionImportedFromObject ->
getOrCreateJvmSuspendFunctionView(function.callableFromObject, bindingContext).asImportedFromObject()
is SimpleFunctionDescriptor ->
getOrCreateJvmSuspendFunctionView(function, bindingContext)
else ->
throw AssertionError("Unexpected suspend function descriptor: $function")
}
val newCall = ResolvedCallImpl(
call,
@@ -120,13 +154,36 @@ fun ResolvedCall<*>.replaceSuspensionFunctionWithRealDescriptor(
return ResolvedCallWithRealDescriptor(newCall, thisExpression)
}
fun ResolvedCall<*>.isSuspensionPoint(bindingContext: BindingContext) =
bindingContext[BindingContext.ENCLOSING_SUSPEND_LAMBDA_FOR_SUSPENSION_POINT, call] != null
fun ResolvedCall<*>.isSuspensionPointInStateMachine(bindingContext: BindingContext): Boolean {
if (resultingDescriptor.safeAs<FunctionDescriptor>()?.isSuspend != true) return false
val enclosingSuspendFunction = bindingContext[BindingContext.ENCLOSING_SUSPEND_FUNCTION_FOR_SUSPEND_FUNCTION_CALL, call] ?: return false
return enclosingSuspendFunction.isStateMachineNeeded(bindingContext)
}
fun FunctionDescriptor.isStateMachineNeeded(bindingContext: BindingContext) =
isSuspendLambda || containsNonTailSuspensionCalls(bindingContext)
fun FunctionDescriptor.containsNonTailSuspensionCalls(bindingContext: BindingContext) =
bindingContext[BindingContext.CONTAINS_NON_TAIL_SUSPEND_CALLS, original] == true
fun CallableDescriptor.isSuspendFunctionNotSuspensionView(): Boolean {
if (this !is FunctionDescriptor) return false
return this.isSuspend && this.getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION) == null
}
// Suspend functions have irregular signatures on JVM, containing an additional last parameter with type `Continuation<return-type>`,
// and return type Any?
// This function returns a function descriptor reflecting how the suspend function looks from point of view of JVM
fun <D : FunctionDescriptor> createJvmSuspendFunctionView(function: D): D {
@JvmOverloads
fun <D : FunctionDescriptor> getOrCreateJvmSuspendFunctionView(function: D, bindingContext: BindingContext? = null): D {
assert(function.isSuspend) {
"Suspended function is expected, but $function was found"
}
@Suppress("UNCHECKED_CAST")
bindingContext?.get(CodegenBinding.SUSPEND_FUNCTION_TO_JVM_VIEW, function)?.let { return it as D }
val continuationParameter = ValueParameterDescriptorImpl(
function, null, function.valueParameters.size, Annotations.EMPTY, Name.identifier("\$continuation"),
// Add j.l.Object to invoke(), because that is the type of parameters we have in FunctionN+1
@@ -170,27 +227,26 @@ fun <D : FunctionDescriptor> D.createCustomCopy(
}
private fun FunctionDescriptor.getContinuationParameterTypeOfSuspendFunction() =
KotlinTypeFactory.simpleType(
builtIns.continuationClassDescriptor.defaultType,
arguments = listOf(returnType!!.asTypeProjection())
)
module.getContinuationOfTypeOrAny(returnType!!)
fun FunctionDescriptor.isBuiltInSuspendWithCurrentContinuation(): Boolean {
if (name != SUSPEND_WITH_CURRENT_CONTINUATION_NAME) return false
fun ModuleDescriptor.getContinuationOfTypeOrAny(kotlinType: KotlinType) =
module.findContinuationClassDescriptorOrNull(NoLookupLocation.FROM_BACKEND)?.defaultType?.let {
KotlinTypeFactory.simpleType(
it,
arguments = listOf(kotlinType.asTypeProjection())
)
} ?: module.builtIns.nullableAnyType
val originalDeclaration = getBuiltInSuspendWithCurrentContinuation() ?: return false
return DescriptorEquivalenceForOverrides.areEquivalent(
originalDeclaration, this.getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION)
)
}
fun FunctionDescriptor.isBuiltInSuspendCoroutineOrReturnInJvm() =
getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION)?.isBuiltInSuspendCoroutineOrReturn() == true
fun createMethodNodeForSuspendWithCurrentContinuation(
fun createMethodNodeForSuspendCoroutineOrReturn(
functionDescriptor: FunctionDescriptor,
typeMapper: KotlinTypeMapper
): MethodNode {
assert(functionDescriptor.isBuiltInSuspendWithCurrentContinuation()) {
"functionDescriptor must be kotlin.coroutines.suspendWithCurrentContinuation"
assert(functionDescriptor.isBuiltInSuspendCoroutineOrReturnInJvm()) {
"functionDescriptor must be kotlin.coroutines.intrinsics.suspendOrReturn"
}
val node =
@@ -203,6 +259,15 @@ fun createMethodNodeForSuspendWithCurrentContinuation(
node.visitVarInsn(Opcodes.ALOAD, 0)
node.visitVarInsn(Opcodes.ALOAD, 1)
node.visitMethodInsn(
Opcodes.INVOKESTATIC,
INTERNAL_COROUTINE_INTRINSICS_OWNER_INTERNAL_NAME,
NORMALIZE_CONTINUATION_METHOD_NAME,
Type.getMethodDescriptor(CONTINUATION_ASM_TYPE, CONTINUATION_ASM_TYPE),
false
)
node.visitMethodInsn(
Opcodes.INVOKEINTERFACE,
typeMapper.mapType(functionDescriptor.valueParameters[0]).internalName,
@@ -216,17 +281,29 @@ fun createMethodNodeForSuspendWithCurrentContinuation(
return node
}
fun CallableDescriptor?.unwrapInitialDescriptorForSuspendFunction() =
(this as? SimpleFunctionDescriptor)?.getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION) ?: this
@Suppress("UNCHECKED_CAST")
fun <D : CallableDescriptor?> D.unwrapInitialDescriptorForSuspendFunction(): D =
this.safeAs<SimpleFunctionDescriptor>()?.getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION) as D ?: this
fun InstructionAdapter.loadSuspendMarker() {
getstatic(
AsmTypes.COROUTINES_INTRINSICS.internalName, JvmAbi.INSTANCE_FIELD, AsmTypes.COROUTINES_INTRINSICS.descriptor
)
invokevirtual(
AsmTypes.COROUTINES_INTRINSICS.internalName,
"getSUSPENDED",
fun InstructionAdapter.loadCoroutineSuspendedMarker() {
invokestatic(
COROUTINES_INTRINSICS_FILE_FACADE_INTERNAL_NAME.internalName,
"get$COROUTINE_SUSPENDED_NAME",
Type.getMethodDescriptor(AsmTypes.OBJECT_TYPE),
false
)
}
fun InstructionAdapter.invokeDoResumeWithUnit(thisName: String) {
// .doResume(Unit, null)
StackValue.putUnitInstance(this)
aconst(null)
invokevirtual(
thisName,
DO_RESUME_METHOD_NAME,
Type.getMethodDescriptor(AsmTypes.OBJECT_TYPE, AsmTypes.OBJECT_TYPE, AsmTypes.JAVA_THROWABLE_TYPE),
false
)
}

View File

@@ -160,7 +160,7 @@ private class UninitializedNewValueMarkerInterpreter : OptimizationBasicInterpre
val uninitializedValuesToCopyUsages = hashMapOf<AbstractInsnNode, MutableSet<AbstractInsnNode>>()
override fun newOperation(insn: AbstractInsnNode): BasicValue? {
if (insn.opcode == Opcodes.NEW) {
uninitializedValuesToCopyUsages[insn] = mutableSetOf()
uninitializedValuesToCopyUsages.getOrPut(insn) { mutableSetOf() }
return UninitializedNewValue(insn as TypeInsnNode, insn.desc)
}
return super.newOperation(insn)

View File

@@ -217,7 +217,7 @@ private class VarExpectedTypeFrame(maxLocals: Int) : VarFrame<VarExpectedTypeFra
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other?.javaClass != javaClass) return false
if (other == null || other::class.java != this::class.java) return false
other as VarExpectedTypeFrame

View File

@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.codegen.AsmUtil;
import org.jetbrains.kotlin.codegen.ClassBuilder;
import org.jetbrains.kotlin.codegen.FieldInfo;
import org.jetbrains.kotlin.codegen.StackValue;
import org.jetbrains.kotlin.resolve.jvm.AsmTypes;
import org.jetbrains.kotlin.codegen.coroutines.CoroutineCodegenUtilKt;
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
import org.jetbrains.org.objectweb.asm.*;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
@@ -66,9 +66,8 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
createClassReader().accept(new ClassVisitor(InlineCodegenUtil.API, classBuilder.getVisitor()) {
@Override
public void visit(int version, int access, @NotNull String name, String signature, String superName, String[] interfaces) {
InlineCodegenUtil.assertVersionNotGreaterThanGeneratedOne(version, name, inliningContext.state);
classBuilder.defineClass(null, version, access, name, signature, superName, interfaces);
if(AsmTypes.COROUTINE_IMPL.getInternalName().equals(superName)) {
if(CoroutineCodegenUtilKt.COROUTINE_IMPL_ASM_TYPE.getInternalName().equals(superName)) {
inliningContext.setContinuation(true);
}
}
@@ -141,12 +140,12 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
List<CapturedParamInfo> additionalFakeParams =
extractParametersMappingAndPatchConstructor(constructor, allCapturedParamBuilder, constructorParamBuilder,
transformationInfo, parentRemapper);
List<MethodVisitor> deferringMethods = new ArrayList<MethodVisitor>();
List<DeferredMethodVisitor> deferringMethods = new ArrayList<DeferredMethodVisitor>();
generateConstructorAndFields(classBuilder, allCapturedParamBuilder, constructorParamBuilder, parentRemapper, additionalFakeParams);
for (MethodNode next : methodsToTransform) {
MethodVisitor deferringVisitor = newMethod(classBuilder, next);
DeferredMethodVisitor deferringVisitor = newMethod(classBuilder, next);
InlineResult funResult =
inlineMethodAndUpdateGlobalResult(parentRemapper, deferringVisitor, next, allCapturedParamBuilder, false);
@@ -161,7 +160,8 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
deferringMethods.add(deferringVisitor);
}
for (MethodVisitor method : deferringMethods) {
for (DeferredMethodVisitor method : deferringMethods) {
InlineCodegenUtil.removeFinallyMarkers(method.getIntermediate());
method.visitEnd();
}
@@ -270,7 +270,7 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
//TODO for inline method make public class
transformationInfo.setNewConstructorDescriptor(constructorDescriptor);
MethodVisitor constructorVisitor = classBuilder.newMethod(
NO_ORIGIN, AsmUtil.NO_FLAG_PACKAGE_PRIVATE, "<init>", constructorDescriptor, null, ArrayUtil.EMPTY_STRING_ARRAY
NO_ORIGIN, constructor.access, "<init>", constructorDescriptor, null, ArrayUtil.EMPTY_STRING_ARRAY
);
final Label newBodyStartLabel = new Label();
@@ -311,8 +311,9 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
}
MethodNode intermediateMethodNode =
new MethodNode(AsmUtil.NO_FLAG_PACKAGE_PRIVATE, "<init>", constructorDescriptor, null, ArrayUtil.EMPTY_STRING_ARRAY);
new MethodNode(constructor.access, "<init>", constructorDescriptor, null, ArrayUtil.EMPTY_STRING_ARRAY);
inlineMethodAndUpdateGlobalResult(parentRemapper, intermediateMethodNode, constructor, constructorInlineBuilder, true);
InlineCodegenUtil.removeFinallyMarkers(intermediateMethodNode);
AbstractInsnNode first = intermediateMethodNode.instructions.getFirst();
final Label oldStartLabel = first instanceof LabelNode ? ((LabelNode) first).getLabel() : null;

View File

@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.builtins.BuiltInsPackageFragment;
import org.jetbrains.kotlin.codegen.*;
import org.jetbrains.kotlin.codegen.context.*;
import org.jetbrains.kotlin.codegen.coroutines.CoroutineCodegenUtilKt;
import org.jetbrains.kotlin.codegen.coroutines.SuspendFunctionGenerationStrategy;
import org.jetbrains.kotlin.codegen.intrinsics.IntrinsicArrayConstructorsKt;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper;
@@ -37,6 +38,7 @@ import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache;
import org.jetbrains.kotlin.name.ClassId;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
@@ -201,7 +203,7 @@ public class InlineCodegen extends CallGenerator {
MethodNode node = nodeAndSmap != null ? nodeAndSmap.getNode() : null;
throw new CompilationException(
"Couldn't inline method call '" + functionDescriptor.getName() + "' into\n" +
contextDescriptor + "\n" +
DescriptorRenderer.DEBUG_TEXT.render(contextDescriptor) + "\n" +
(element != null ? element.getText() : "<no source>") +
(generateNodeText ? ("\nCause: " + InlineCodegenUtil.getNodeText(node)) : ""),
e, callElement
@@ -238,19 +240,19 @@ public class InlineCodegen extends CallGenerator {
assert resolvedCall != null : "Resolved call for " + functionDescriptor + " should be not null";
Map<TypeParameterDescriptor, KotlinType> arguments = resolvedCall.getTypeArguments();
assert arguments.size() == 1 : "Resolved call for " + functionDescriptor + " should have 1 type argument";
KotlinType type = arguments.values().iterator().next();
MethodNode node =
InlineCodegenUtil.createSpecialEnumMethodBody(
codegen,
functionDescriptor.getName().asString(),
type,
arguments.keySet().iterator().next().getDefaultType(),
codegen.getState().getTypeMapper()
);
return new SMAPAndMethodNode(node, SMAPParser.parseOrCreateDefault(null, null, "fake", -1, -1));
}
else if (CoroutineCodegenUtilKt.isBuiltInSuspendWithCurrentContinuation(functionDescriptor)) {
else if (CoroutineCodegenUtilKt.isBuiltInSuspendCoroutineOrReturnInJvm(functionDescriptor)) {
return new SMAPAndMethodNode(
CoroutineCodegenUtilKt.createMethodNodeForSuspendWithCurrentContinuation(
CoroutineCodegenUtilKt.createMethodNodeForSuspendCoroutineOrReturn(
functionDescriptor, codegen.getState().getTypeMapper()
),
SMAPParser.parseOrCreateDefault(null, null, "fake", -1, -1)
@@ -320,7 +322,7 @@ public class InlineCodegen extends CallGenerator {
}
});
return InlineCodegenUtil.getMethodNode(bytes, asmMethod.getName(), asmMethod.getDescriptor(), classId, state);
return InlineCodegenUtil.getMethodNode(bytes, asmMethod.getName(), asmMethod.getDescriptor(), classId);
}
assert callableDescriptor instanceof DeserializedCallableMemberDescriptor : "Not a deserialized function or proper: " + callableDescriptor;
@@ -347,7 +349,7 @@ public class InlineCodegen extends CallGenerator {
});
return InlineCodegenUtil.getMethodNode(bytes, asmMethod.getName(), asmMethod.getDescriptor(), containerId, state);
return InlineCodegenUtil.getMethodNode(bytes, asmMethod.getName(), asmMethod.getDescriptor(), containerId);
}
@NotNull
@@ -465,7 +467,9 @@ public class InlineCodegen extends CallGenerator {
adapter, infos, ((StackValue.Local) remapper.remap(parameters.getArgsSizeOnStack() + 1).value).index
);
removeStaticInitializationTrigger(adapter);
removeFinallyMarkers(adapter);
if (!InlineCodegenUtil.isFinallyMarkerRequired(codegen.getContext())) {
InlineCodegenUtil.removeFinallyMarkers(adapter);
}
adapter.accept(new MethodBodyVisitor(codegen.v));
@@ -479,9 +483,9 @@ public class InlineCodegen extends CallGenerator {
@NotNull
private static CallableMemberDescriptor getLabelOwnerDescriptor(@NotNull MethodContext context) {
if (context.getParentContext() instanceof ClosureContext &&
((ClosureContext) context.getParentContext()).getCoroutineDescriptor() != null) {
((ClosureContext) context.getParentContext()).getOriginalSuspendLambdaDescriptor() != null) {
//noinspection ConstantConditions
return ((ClosureContext) context.getParentContext()).getCoroutineDescriptor();
return ((ClosureContext) context.getParentContext()).getOriginalSuspendLambdaDescriptor();
}
return context.getContextDescriptor();
@@ -601,6 +605,14 @@ public class InlineCodegen extends CallGenerator {
else if (expression instanceof KtFunctionLiteral) {
strategy = new ClosureGenerationStrategy(state, (KtDeclarationWithBody) expression);
}
else if (descriptor.isSuspend() && expression instanceof KtFunction) {
strategy =
new SuspendFunctionGenerationStrategy(
state,
CoroutineCodegenUtilKt.<FunctionDescriptor>unwrapInitialDescriptorForSuspendFunction(descriptor),
(KtFunction) expression
);
}
else {
strategy = new FunctionGenerationStrategy.FunctionDefault(state, (KtDeclarationWithBody) expression);
}
@@ -1015,25 +1027,6 @@ public class InlineCodegen extends CallGenerator {
//processor.substituteLocalVarTable(intoNode);
}
private void removeFinallyMarkers(@NotNull MethodNode intoNode) {
if (InlineCodegenUtil.isFinallyMarkerRequired(codegen.getContext())) return;
InsnList instructions = intoNode.instructions;
AbstractInsnNode curInstr = instructions.getFirst();
while (curInstr != null) {
if (InlineCodegenUtil.isFinallyMarker(curInstr)) {
AbstractInsnNode marker = curInstr;
//just to assert
getConstant(marker.getPrevious());
curInstr = curInstr.getNext();
instructions.remove(marker.getPrevious());
instructions.remove(marker);
continue;
}
curInstr = curInstr.getNext();
}
}
@NotNull
public static SourceMapper createNestedSourceMapper(@NotNull SMAPAndMethodNode nodeAndSmap, @NotNull SourceMapper parent) {
return new NestedSourceMapper(parent, nodeAndSmap.getSortedRanges(), nodeAndSmap.getClassSMAP().getSourceInfo());

View File

@@ -23,6 +23,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.backend.common.output.OutputFile;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
import org.jetbrains.kotlin.codegen.AsmUtil;
import org.jetbrains.kotlin.codegen.ExpressionCodegen;
import org.jetbrains.kotlin.codegen.MemberCodegen;
import org.jetbrains.kotlin.codegen.binding.CodegenBinding;
@@ -38,7 +39,7 @@ import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.fileClasses.FileClasses;
import org.jetbrains.kotlin.fileClasses.JvmFileClassesProvider;
import org.jetbrains.kotlin.load.java.JvmAbi;
import org.jetbrains.kotlin.load.kotlin.JvmVirtualFileFinder;
import org.jetbrains.kotlin.load.kotlin.VirtualFileFinder;
import org.jetbrains.kotlin.name.ClassId;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.name.Name;
@@ -51,6 +52,7 @@ import org.jetbrains.kotlin.util.OperatorNameConventions;
import org.jetbrains.org.objectweb.asm.*;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import org.jetbrains.org.objectweb.asm.tree.*;
import org.jetbrains.org.objectweb.asm.util.Printer;
import org.jetbrains.org.objectweb.asm.util.Textifier;
import org.jetbrains.org.objectweb.asm.util.TraceMethodVisitor;
@@ -60,6 +62,9 @@ import java.io.StringWriter;
import java.util.List;
import java.util.ListIterator;
import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.ENUM_TYPE;
import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.JAVA_CLASS_TYPE;
public class InlineCodegenUtil {
public static final boolean GENERATE_SMAP = true;
public static final int API = Opcodes.ASM5;
@@ -77,7 +82,9 @@ public class InlineCodegenUtil {
private static final String INLINE_MARKER_AFTER_METHOD_NAME = "afterInlineCall";
private static final String INLINE_MARKER_FINALLY_START = "finallyStart";
private static final String INLINE_MARKER_FINALLY_END = "finallyEnd";
public static final String SPECIAL_TRANSFORMATION_NAME = "$special";
public static final String INLINE_TRANSFORMATION_SUFFIX = "$inlined";
public static final String INLINE_CALL_TRANSFORMATION_SUFFIX = "$" + INLINE_TRANSFORMATION_SUFFIX;
public static final String INLINE_FUN_THIS_0_SUFFIX = "$inline_fun";
public static final String INLINE_FUN_VAR_SUFFIX = "$iv";
@@ -86,8 +93,7 @@ public class InlineCodegenUtil {
byte[] classData,
final String methodName,
final String methodDescriptor,
ClassId classId,
final @NotNull GenerationState state
ClassId classId
) {
ClassReader cr = new ClassReader(classData);
final MethodNode[] node = new MethodNode[1];
@@ -97,10 +103,6 @@ public class InlineCodegenUtil {
lines[1] = Integer.MIN_VALUE;
//noinspection PointlessBitwiseExpression
cr.accept(new ClassVisitor(API) {
@Override
public void visit(int version, int access, @NotNull String name, String signature, String superName, String[] interfaces) {
assertVersionNotGreaterThanGeneratedOne(version, name, state);
}
@Override
public void visitSource(String source, String debug) {
@@ -145,16 +147,6 @@ public class InlineCodegenUtil {
return new SMAPAndMethodNode(node[0], smap);
}
public static void assertVersionNotGreaterThanGeneratedOne(int version, String internalName, @NotNull GenerationState state) {
// TODO: report a proper diagnostic
if (version > state.getClassFileVersion() && !"true".equals(System.getProperty("kotlin.skip.bytecode.version.check"))) {
throw new UnsupportedOperationException(
"Cannot inline bytecode of class " + internalName + " which has version " + version + ". " +
"This compiler can only inline Java 1.6 bytecode (version " + Opcodes.V1_6 + ")"
);
}
}
public static void initDefaultSourceMappingIfNeeded(
@NotNull CodegenContext context, @NotNull MemberCodegen codegen, @NotNull GenerationState state
) {
@@ -173,7 +165,7 @@ public class InlineCodegenUtil {
@Nullable
public static VirtualFile findVirtualFile(@NotNull GenerationState state, @NotNull ClassId classId) {
return JvmVirtualFileFinder.SERVICE.getInstance(state.getProject()).findVirtualFileWithHeader(classId);
return VirtualFileFinder.SERVICE.getInstance(state.getProject()).findVirtualFileWithHeader(classId);
}
@Nullable
@@ -399,6 +391,11 @@ public class InlineCodegenUtil {
return sw.toString().trim();
}
@NotNull
public static String getInsnOpcodeText(@Nullable AbstractInsnNode node) {
return node == null ? "null" : Printer.OPCODES[node.getOpcode()];
}
@NotNull
/* package */ static ClassReader buildClassReaderByInternalName(@NotNull GenerationState state, @NotNull String internalName) {
//try to find just compiled classes then in dependencies
@@ -460,6 +457,23 @@ public class InlineCodegenUtil {
}
}
public static void removeFinallyMarkers(@NotNull MethodNode intoNode) {
InsnList instructions = intoNode.instructions;
AbstractInsnNode curInstr = instructions.getFirst();
while (curInstr != null) {
if (isFinallyMarker(curInstr)) {
AbstractInsnNode marker = curInstr;
//just to assert
getConstant(marker.getPrevious());
curInstr = curInstr.getNext();
instructions.remove(marker.getPrevious());
instructions.remove(marker);
continue;
}
curInstr = curInstr.getNext();
}
}
public static void addInlineMarker(@NotNull InstructionAdapter v, boolean isStartNotEnd) {
v.visitMethodInsn(
Opcodes.INVOKESTATIC, INLINE_MARKER_CLASS_NAME,
@@ -530,7 +544,7 @@ public class InlineCodegenUtil {
if (!(containingDeclaration instanceof PackageFragmentDescriptor)) {
return false;
}
if (!containingDeclaration.getName().equals(KotlinBuiltIns.BUILT_INS_PACKAGE_NAME)) {
if (!((PackageFragmentDescriptor) containingDeclaration).getFqName().equals(KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME)) {
return false;
}
if (functionDescriptor.getTypeParameters().size() != 1) {
@@ -548,23 +562,30 @@ public class InlineCodegenUtil {
@NotNull KotlinType type,
@NotNull KotlinTypeMapper typeMapper
) {
boolean isEnumValues = "enumValues".equals(name);
boolean isValueOf = "enumValueOf".equals(name);
Type invokeType = typeMapper.mapType(type);
String desc = getSpecialEnumFunDescriptor(invokeType, isEnumValues);
String desc = getSpecialEnumFunDescriptor(invokeType, isValueOf);
MethodNode node = new MethodNode(API, Opcodes.ACC_STATIC, "fake", desc, null, null);
if (!isEnumValues) {
node.visitVarInsn(Opcodes.ALOAD, 0);
}
codegen.putReifiedOperationMarkerIfTypeIsReifiedParameter(type, ReifiedTypeInliner.OperationKind.ENUM_REIFIED, new InstructionAdapter(node));
node.visitMethodInsn(Opcodes.INVOKESTATIC, invokeType.getInternalName(), isEnumValues ? "values" : "valueOf", desc, false);
if (isValueOf) {
node.visitInsn(Opcodes.ACONST_NULL);
node.visitVarInsn(Opcodes.ALOAD, 0);
node.visitMethodInsn(Opcodes.INVOKESTATIC, ENUM_TYPE.getInternalName(), "valueOf",
Type.getMethodDescriptor(ENUM_TYPE, JAVA_CLASS_TYPE, AsmTypes.JAVA_STRING_TYPE), false);
}
else {
node.visitInsn(Opcodes.ICONST_0);
node.visitTypeInsn(Opcodes.ANEWARRAY, ENUM_TYPE.getInternalName());
}
node.visitInsn(Opcodes.ARETURN);
node.visitMaxs(isEnumValues ? 2 : 3, isEnumValues ? 0 : 1);
node.visitMaxs(isValueOf ? 3 : 2, isValueOf ? 1 : 0);
return node;
}
public static String getSpecialEnumFunDescriptor(@NotNull Type type, boolean isEnumValues) {
return (isEnumValues ? "()[" : "(Ljava/lang/String;)") + "L" + type.getInternalName() + ";";
@NotNull
public static String getSpecialEnumFunDescriptor(@NotNull Type type, boolean isValueOf) {
return isValueOf ? Type.getMethodDescriptor(type, AsmTypes.JAVA_STRING_TYPE) : Type.getMethodDescriptor(AsmUtil.getArrayType(type));
}
}

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