Compare commits

...

773 Commits

Author SHA1 Message Date
Pavel V. Talanov
804a251e5f ~ 2014-11-07 18:59:04 +03:00
Pavel V. Talanov
f4a4bd203d ~ tests 2014-11-07 18:58:40 +03:00
Pavel V. Talanov
1d5836f60a ~ 2014-11-07 18:08:26 +03:00
Pavel V. Talanov
69303d638f ~ test 2014-11-07 18:08:03 +03:00
Pavel V. Talanov
a445e8b289 Convert to Kotlin: KotlinParameterStubImpl 2014-11-07 18:07:51 +03:00
Pavel V. Talanov
2c5b11ed97 ~ 2014-11-07 17:44:21 +03:00
Pavel V. Talanov
6166afb911 Convert to Kotlin: KotlinUserTypeStubImpl 2014-11-07 17:44:01 +03:00
Pavel V. Talanov
8d7b2a83f7 Determine stub interface more accurately 2014-11-06 20:17:50 +03:00
Pavel V. Talanov
1806b09809 ++ KotlinModifierListStubImpl + ModifierMaskUtils.kt 2014-11-06 20:16:27 +03:00
Pavel V. Talanov
7ba16f8a4e ++ KotlinClassStubImpl.kt 2014-11-06 20:15:48 +03:00
Pavel V. Talanov
d6d642be52 tests ++ 2014-11-06 19:57:51 +03:00
Pavel V. Talanov
c3b232cb2f ++ 2014-11-06 19:43:41 +03:00
Pavel V. Talanov
a49a44dee3 ++ 2014-11-06 19:39:26 +03:00
Pavel V. Talanov
17451c13f0 Convert to Kotlin: KotlinFunctionStubImpl and KotlinPropertyStubImpl 2014-11-06 19:39:07 +03:00
Pavel V. Talanov
d886066102 ++ 2014-11-06 19:17:21 +03:00
Pavel V. Talanov
a4dc6946b8 ++ 2014-11-06 19:13:24 +03:00
Pavel V. Talanov
b7ae06f1f5 ++ 2014-11-06 19:12:57 +03:00
Pavel V. Talanov
a37144612f ++ 2014-11-06 19:11:40 +03:00
Pavel V. Talanov
cbbacd0043 ++ 2014-11-06 19:11:16 +03:00
Pavel V. Talanov
7d77005567 ++ 2014-11-06 19:08:50 +03:00
Pavel V. Talanov
eea79c6fca Convert to Kotlin: Stub interfaces and place them in one file 2014-11-06 18:19:21 +03:00
Pavel V. Talanov
7b1fd591c2 Convert to Kotlin: KotlinObjectStubImpl 2014-11-06 18:18:57 +03:00
Pavel V. Talanov
7f8b7fb35c ++ 2014-11-06 17:42:11 +03:00
Pavel V. Talanov
a52f6a849b Convert to Kotlin: KotlinObjectStubImpl 2014-11-06 17:38:59 +03:00
Pavel V. Talanov
3bd3c69bc1 ++ 2014-11-06 17:31:07 +03:00
Pavel V. Talanov
483de4d1db NAME 2014-11-06 14:39:55 +03:00
Pavel V. Talanov
0c0f400604 Move logic dealing with mask from KotlinModifierListStubImpl
To a separate kotlin file
2014-11-06 14:37:32 +03:00
Pavel V. Talanov
1abae94a03 Minor 2014-11-06 14:22:41 +03:00
Pavel V. Talanov
06c3494aa5 ++ draft 2014-11-06 14:21:13 +03:00
Pavel V. Talanov
81c7d82804 revert converting KotlinModifierListStubImpl 2014-11-06 14:21:02 +03:00
Pavel Talanov
630ac58520 -- draft 2014-11-04 19:48:36 +04:00
Pavel Talanov
1f08fef0a2 REVIEW: Convert KotlinModifierListStubImpl to Kotlin 2014-11-04 19:32:13 +04:00
Pavel Talanov
3406d030e5 ++ 2014-11-02 17:07:40 +04:00
Pavel Talanov
aabe67869b DRAFT: ClsStubBuilderTest 2014-11-02 17:04:31 +04:00
Pavel Talanov
6328700ee8 ++ 2014-11-01 20:27:10 +04:00
Pavel V. Talanov
009a0d3418 DRAFT: building stubs for kotlin cls 2014-10-31 20:24:54 +03:00
Pavel V. Talanov
c617b73424 Rename stub classes: PsiJet*Stub(Impl) -> Kotlin*Stub(Impl) 2014-10-31 18:26:09 +03:00
Pavel V. Talanov
5fb4f41030 Rename test data folder: libraries -> decompiler 2014-10-31 18:12:20 +03:00
Pavel V. Talanov
d2d9813e12 Rename and restructure plugin.libraries package
Rename: libraries -> decompiler
New subpackages: textBuilder, navigation
2014-10-31 16:49:11 +03:00
Pavel V. Talanov
f47d8239c4 Convert and rename JetClsStubBuilder 2014-10-31 16:48:26 +03:00
Pavel V. Talanov
97cbadef61 Decompiler tests: check decompiled text was parsed correctly 2014-10-31 15:04:47 +03:00
Pavel V. Talanov
602be6303c Minor: JetPsiUtil#getElementTextWithContext() accepts PsiElement 2014-10-31 15:04:46 +03:00
Pavel V. Talanov
3b59a513b0 Approximating flexible types in decompiled text 2014-10-31 15:04:46 +03:00
Pavel V. Talanov
b728ba2b1e Test function types in decompiler 2014-10-31 15:04:45 +03:00
Pavel V. Talanov
c0416255c4 DescriptorRenderer: fix rendering of functional types in receivers 2014-10-31 15:04:45 +03:00
Nikolay Krasko
8cbda20ef2 Relay artifact to internal folder 2014-10-31 00:39:47 +03:00
Nikolay Krasko
b6d0539795 Prepare additional artifact with test data to reuse it from eclipse 2014-10-31 00:39:47 +03:00
Nikolay Krasko
4622b6dd8f Move IdeDescriptorRenderer to ide-common 2014-10-31 00:39:46 +03:00
Nikolay Krasko
3a10416192 Rename module: ide-lazy-resolve -> ide-common 2014-10-31 00:39:45 +03:00
Nikolay Krasko
4e99572dbc Update to EAP 139.222.5 2014-10-31 00:39:45 +03:00
Michael Bogdanov
b8c13b851c Move to proguard 5.1
#KT-5931 Fixed
2014-10-30 19:02:03 +03:00
Michael Bogdanov
59917f3727 Fix for KT-6154: Inlining a private class function accessing a private val member throws exception at runtime in accessing the val getter
#KT-6154 Fixed
2014-10-30 19:02:03 +03:00
Pavel V. Talanov
951ce827a6 Parser: allow function types as receiver type for function 2014-10-30 16:47:03 +03:00
Pavel V. Talanov
632bceef26 Minor: fix parser error message 2014-10-30 16:47:03 +03:00
Natalia Ukhorskaya
c36fc42014 Exception analyzer doesn't show multiple attachments 2014-10-30 15:39:39 +03:00
Natalia Ukhorskaya
7bb4e538a6 Use resolveAnnotations instead of getResolvedAnnotations for typeReference 2014-10-30 15:39:38 +03:00
valentin
3aadd6f880 Corrected test data bacause return inside "use { }" is now allowed 2014-10-30 12:55:54 +03:00
Valentin Kipyatkov
245e70100d Renamed parameter 2014-10-30 12:55:54 +03:00
Valentin Kipyatkov
0b4c7588da Java to Kotlin action: no infinite recursion for symlinks + more efficient update() 2014-10-30 12:55:53 +03:00
Valentin Kipyatkov
448d444b2d J2K: replaced IntermediateResult with function 2014-10-30 12:55:53 +03:00
Valentin Kipyatkov
2e0ccf6984 J2K: fixed usage processing scheme to cover exotic case with anonymous class 2014-10-30 12:55:52 +03:00
Valentin Kipyatkov
7de15ec2a8 J2K: singletons are back 2014-10-30 12:55:52 +03:00
Valentin Kipyatkov
567bb6fd1a Renamed LazyElement -> DeferredElement 2014-10-30 12:55:51 +03:00
Valentin Kipyatkov
17622f8259 J2K: correct mutable/non-mutable types for overrides of Kotlin methods 2014-10-30 12:55:51 +03:00
Valentin Kipyatkov
0092c952ef Minor 2014-10-30 12:55:51 +03:00
Valentin Kipyatkov
899a051a8f J2K: fixed assertion 2014-10-30 12:55:50 +03:00
Valentin Kipyatkov
7e147d28c2 J2K converter: automatic generation of 'open' modifier for classes and methods 2014-10-30 12:55:50 +03:00
Valentin Kipyatkov
39cea5999c J2K: renamed Field to Property 2014-10-30 12:55:49 +03:00
Valentin Kipyatkov
3f6cebbc28 J2K converter testing: added dumping of errors into multifile tests too 2014-10-30 12:55:49 +03:00
Valentin Kipyatkov
82fc0ee394 Java to Kotlin converter tests: added check for errors in result file 2014-10-30 12:55:48 +03:00
Valentin Kipyatkov
389b14f44f KT-6120 Java to Kotlin converter can generate mutable collection types in case if collection write methods used
#KT-6120 Fixed
2014-10-30 12:55:48 +03:00
Valentin Kipyatkov
1af63cb3be Java to Kotlin converter: preparing to support Mutability 2014-10-30 12:55:47 +03:00
Valentin Kipyatkov
3217981a62 Disable Java To Kotlin action when not java file selected 2014-10-30 12:55:47 +03:00
Valentin Kipyatkov
d67e99d40a Fixed KT-6110 J2K converter: do not replace accessors implementing interface with property
#KT-6110
2014-10-30 12:55:47 +03:00
Valentin Kipyatkov
927fe9d2cb JavaToKotlinAction converts all files at once with cross usage processing 2014-10-30 12:55:46 +03:00
Valentin Kipyatkov
f100015e58 JavaToKotlinAction refactorings + minor fixes in the logic 2014-10-30 12:55:46 +03:00
Valentin Kipyatkov
41cb97ac61 Converted JavaToKotlinAction and JavaToKotlinActionUtil into Kotlin and merged into one class 2014-10-30 12:55:45 +03:00
Valentin Kipyatkov
3d6da9104c J2K: memory optimization 2014-10-30 12:55:45 +03:00
Valentin Kipyatkov
abf537e348 J2K: conversion with usage processing across multiple converted files works in tests (but not in real life yet) 2014-10-30 12:55:45 +03:00
Valentin Kipyatkov
41c7ec8285 J2K: processing usages of get/set methods in the code being converted when converting them into property 2014-10-30 12:55:43 +03:00
Valentin Kipyatkov
3b51858ed9 Removed workaround for compiler bug which has been fixed 2014-10-30 12:55:43 +03:00
Valentin Kipyatkov
e81631a3af J2K: refactored code to make createDefaultCodeConverter() private 2014-10-30 12:55:42 +03:00
Valentin Kipyatkov
7941314c60 J2K: fixed conversion of default parameter values and annotation arguments 2014-10-30 12:55:42 +03:00
Valentin Kipyatkov
7762d4e7c6 J2K: fixed conversion of base class constructor arguments 2014-10-30 12:55:42 +03:00
Valentin Kipyatkov
9ac23cd657 J2K: checked that field name change is correctly handled for usages in other converted classes as well 2014-10-30 12:55:41 +03:00
Valentin Kipyatkov
030faa4630 Big refactoring in j2k converter to support java&kotlin code updating to reflect changes in declarations produced by conversion (work in progress but all tests pass) 2014-10-30 12:55:41 +03:00
Valentin Kipyatkov
16f117571f Minor 2014-10-30 12:55:40 +03:00
Valentin Kipyatkov
95bf9e3c1c Repackaging 2014-10-30 12:55:40 +03:00
Valentin Kipyatkov
f5e9230a04 Renamed ReferenceSearcherImpl to IdeaReferenceSearcher 2014-10-30 12:55:39 +03:00
Zalim Bashorov
9e11b40fe1 Add the support suppressWarnings, verbose and version in build tools. 2014-10-29 23:09:07 +03:00
Andrey Breslav
70db76b219 Typo fixed in a diagnostic message 2014-10-29 18:43:48 +03:00
Natalia Ukhorskaya
8deef10292 Fix android tests 2014-10-29 17:31:14 +03:00
Natalia Ukhorskaya
75a8699467 Minor: fix warnings 2014-10-29 17:10:27 +03:00
Natalia Ukhorskaya
c4ba32a8cc Can't use a qualified name of an annotation class in an annotation parameter
#KT-6151 Fixed
2014-10-29 17:10:25 +03:00
Michael Bogdanov
8e93719e9d Fix test data for android tests 2014-10-29 17:04:10 +03:00
Alexey Sedunov
cede5ac58b Create From Usage: Fix type substitution for no-receiver calls 2014-10-28 19:15:06 +03:00
Alexey Sedunov
abbbd198fd Create From Usage: Use supplied type arguments to infer function type parameters 2014-10-28 19:15:05 +03:00
Alexey Sedunov
a13f334df2 Find Usages: Restrict search scope for private class members
#KT-6124 Fixed
2014-10-28 19:15:03 +03:00
Alexey Sedunov
a2930a581f Additional Resolve: Use descriptor of constructor instead of class when resolving primary constructor annotations
#KT-6099
2014-10-28 19:15:02 +03:00
Michael Bogdanov
d0f6f03380 Fixes for call site finally generation before non-local returns 2014-10-28 19:15:00 +03:00
Michael Bogdanov
dd8c3f0e49 Fixes for inline fun finally block generation before lambda non-local returns 2014-10-28 19:14:52 +03:00
Michael Bogdanov
25d7c9f20a Enabled disabled non-local returns in stdlib 2014-10-28 19:14:14 +03:00
Valentin Kipyatkov
11fd8fe392 Convert to expression body: fixed type selection for public override 2014-10-28 15:40:11 +03:00
Nikolay Krasko
d1fe9b71ef Make line break before '}' optional
#KT-6142 Fixed
2014-10-28 01:50:51 +04:00
Nikolay Krasko
0cd95b5514 Formatter: empty lines between declarations 2014-10-28 01:50:50 +04:00
Nikolay Krasko
6090eb5563 Refactoring: move method to rules 2014-10-28 01:50:50 +04:00
Nikolay Krasko
5d094415ce Allow access to home kotlin project dir in convert tests 2014-10-28 01:50:49 +04:00
Alexander Udalov
35e956609a Rewrite mutable collection stub method generation
The main problem of the previous approach was that we were only generating
erased method signatures, which was incorrect in case a class also had a member
from another supertype with the same signature as the substituted one from the
collection. Javac issues compilation errors when compiling Java code against
such classes.

Also all the needed method stub signatures were hardcoded in
generateBuiltInMethodStubs() and the case of MutableListIterator was missing
2014-10-27 17:17:31 +03:00
Alexander Udalov
1fc9c58b24 Minor, update outdated deprecation comment 2014-10-27 17:17:27 +03:00
Alexander Udalov
685a1c38e2 Fix indent in built-in sources 2014-10-27 17:17:26 +03:00
Alexey Tsvetkov
fb8918bbe6 JS backend: removed adding '$' to label suffix 2014-10-27 15:58:49 +03:00
Alexey Tsvetkov
78e12f7cfa JS backend minor: removed license from test cases 2014-10-27 15:58:49 +03:00
Nikolay Krasko
8d86951a3b Refactoring: junit.framework.Assert -> org.junit.Assert 2014-10-27 12:47:43 +04:00
Nikolay Krasko
863ef64c61 Replace http://teamcity.jetbrains.com to https 2014-10-24 16:24:53 +04:00
Natalia Ukhorskaya
7d106ee8b5 Debugger tests: do not create breakpoints for FakeLightClassForFileOfPackage because we create them for KotlinLightClassForPackage 2014-10-24 15:59:40 +04:00
Natalia Ukhorskaya
d9ac8155da Debugger: wrong stepping through the loop with continue label
#KT-5776 Fixed
 #KT-5664 Fixed
2014-10-24 15:59:39 +04:00
Natalia Ukhorskaya
ffba1b6fa0 Debugger tests: render line properly 2014-10-24 15:59:38 +04:00
Natalia Ukhorskaya
3900ee34ae Debugger tests: move stepping tests 2014-10-24 15:59:37 +04:00
Natalia Ukhorskaya
cce22c0df9 Debugger: implement getSourcePosition for fields 2014-10-24 15:59:36 +04:00
Nikolay Krasko
29d73b9302 Don't activate getPresentation() method from parser tests
Calling this method from frontend tests caches empty presenters
in KeyedExtensionCollector that makes plugins tests fail.
2014-10-24 15:54:00 +04:00
Valentin Kipyatkov
304c826b47 Fixed KT-6128 Code completion does not work inside function literal if it's dependant on declarations below
#KT-6128 Fixed
2014-10-24 15:14:26 +04:00
Valentin Kipyatkov
357ea7a995 Added JetCallableDeclaration.getColon() 2014-10-24 14:19:41 +04:00
Valentin Kipyatkov
d13fd19a63 Added feature to "Convert to expression body" intention: selection for easier explicit type removal 2014-10-24 14:19:41 +04:00
Nikolay Krasko
ea69f5a9a6 Fix for KT-6106: Using platformStatic crashes intellisense (but not Compiler)
#KT-6106 Fixed
2014-10-24 10:04:43 +04:00
Alexander Udalov
c50ca3ab86 Fix empty stack trace in assertion for platform typed expression 2014-10-23 18:32:47 +04:00
Alexey Sedunov
27977cda23 Move: Test data addendum 2014-10-22 21:07:10 +04:00
Alexey Sedunov
07dfde4d2d Add comment 2014-10-22 21:07:09 +04:00
Alexey Sedunov
f7ef1c8d4d Add alternative constructor 2014-10-22 21:07:08 +04:00
Alexey Sedunov
c0901ec8a6 Improve assertion message 2014-10-22 21:07:07 +04:00
Alexey Sedunov
d5e80cae1b Remove unused property 2014-10-22 21:07:06 +04:00
Alexey Sedunov
5b3a4ed7e0 Make JetOperationExpression an inheritor of JetExpression 2014-10-22 21:07:05 +04:00
Alexander Udalov
8c87b242b3 Regenerate tests 2014-10-22 20:49:35 +04:00
Pavel V. Talanov
a65f0d3b2a Use PsiElement#getResolveScope() instead of custom helper
Fix extensions and types completion completion in code fragments in context of library source files
Also affects completion in files not in our project (not tested)
2014-10-22 18:56:33 +04:00
Pavel V. Talanov
db8d1b58b8 Debugger: log error on evaluating fragment with non-kotlin context 2014-10-22 18:56:32 +04:00
Pavel V. Talanov
c3efe1b9b7 Extract attachment helper to a separate file
Improve logic for a nonphysical file
2014-10-22 18:56:32 +04:00
Pavel V. Talanov
5806a66cf9 JetPositionManager: restrict scope of type mapper 2014-10-22 18:56:31 +04:00
Pavel V. Talanov
f2018a8764 Minor: extract function 2014-10-22 18:56:31 +04:00
Pavel V. Talanov
11b18c2817 Minor: rename 2014-10-22 18:56:30 +04:00
Pavel V. Talanov
0070377f2a KotlinCacheService: Correctly deal with code fragments in getLazyResolveSession()
Fix completion in code fragments in context of library source
2014-10-22 18:56:30 +04:00
Pavel V. Talanov
e88db57214 Test completion for code fragments in context of library source 2014-10-22 18:56:29 +04:00
Pavel V. Talanov
a0ad05983a KotlinCacheService: Correctly deal with code fragments in getAnalysisResults()
Fix evaluate expression for breakpoints in library source
2014-10-22 18:56:29 +04:00
Pavel V. Talanov
8d9f17d09d Reconfigure KotlinDebuggerTestCase
It is hiding a problem: evaluate expression fails in libraries
2014-10-22 18:56:28 +04:00
Pavel V. Talanov
e9fe66b8e4 Assert that extra files passed to analysis are in the same module 2014-10-22 18:56:28 +04:00
Andrey Breslav
d4d909de5f Flexible types supported in Extract Function when used from debugger/evaluate expression 2014-10-22 18:56:27 +04:00
Alexey Sedunov
925177f3d8 Move: Fix rebinding of references to singleton members and Java statics
#KT-6082 Fixed
2014-10-22 18:43:14 +04:00
Alexey Sedunov
bc7ae4186b Move: Do not rebind references to the declaration under move 2014-10-22 18:42:59 +04:00
Alexey Sedunov
b2588f610a Create From Usage ("set" operation): Support expressions of the form a[i]++ 2014-10-22 18:42:58 +04:00
Alexey Sedunov
b5e1fe613c Extract Function: Take duplicates into account when choosing placement of extracted function
#KT-5916 Fixed
2014-10-22 18:42:57 +04:00
Alexey Sedunov
c492ffee08 PSI Pattern Matching: Prefer strongly matched children over weakly matched parents 2014-10-22 18:42:55 +04:00
Alexey Sedunov
40da4bd423 Extract Function: Do not allow property extraction if return type is Unit
#KT-6017 Fixed
2014-10-22 18:42:55 +04:00
Alexey Sedunov
f5f1aec47b Create From Usage: Add support of get/set functions in property delegates
#KT-5977 Fixed
2014-10-22 18:42:54 +04:00
Alexey Sedunov
d4a9b922e5 Create From Usage: Fix template insertion when target container is not empty 2014-10-22 18:42:52 +04:00
Alexey Sedunov
07a2a16232 Type-related quick fixes: Render types using fully qualified names 2014-10-22 18:42:51 +04:00
Michael Bogdanov
b212fbd0b5 Remove empty try catch nodes from inlined code 2014-10-22 18:31:11 +04:00
Nikolay Krasko
f50d8c0731 Add explicit type to prevent compile error 2014-10-22 18:18:10 +04:00
Nikolay Krasko
1a7fd756e5 Check that removing open brace is out-of-block change 2014-10-22 18:18:10 +04:00
Nikolay Krasko
798a6bf689 Temp workaround: force out-of-block modification for properties with nullable types
Initializers for properties with nullable types are analyzed with binding context common for all declarations.
This can cause invalid elements are left in the cache guarded with out-of-block  modification tracker. This workaround forces increment for such cases.
2014-10-22 18:18:09 +04:00
Nikolay Krasko
5cdd5f580d Rewrite out-of-block modifier increment algorithm
1. Search the top-level function or property (only they can produce blocks that won't affect other declarations)
    2. Check if current position is hidden by this declaration

    O^2 behaviour is removed
2014-10-22 18:18:09 +04:00
Nikolay Krasko
40bd9fbdf3 Refactoring: move functions 2014-10-22 18:18:08 +04:00
Nikolay Krasko
0862eead00 Rename file: JetCodeBlockModificationListener -> KotlinCodeBlockModificationListener 2014-10-22 18:18:07 +04:00
Nikolay Krasko
474bc536d6 Rewrite to Kotlin: JetCodeBlockModificationListener 2014-10-22 18:18:07 +04:00
Nikolay Krasko
7b3d96e9e9 Rewrite to Kotlin: rename file 2014-10-22 18:18:06 +04:00
Nikolay Krasko
6b605ec4f9 Rewrite to kotlin: JetModifiableBlockHelper 2014-10-22 18:18:05 +04:00
Nikolay Krasko
565612bc19 Take all responsibility for updating trackers, stop delegating it to Java-plugin code 2014-10-22 18:18:05 +04:00
Nikolay Krasko
a988415e22 Add file text to assert message 2014-10-22 18:18:04 +04:00
Nikolay Krasko
0844a11549 Make out-of-block test functional 2014-10-22 18:18:03 +04:00
Nikolay Krasko
b58c5f7df4 Don't spam warning when file is empty
IDEA produces such files when class file had been removed from jar but indexes haven't been not fully reconstructed yet.
2014-10-22 18:18:03 +04:00
Natalia Ukhorskaya
40bb8968cc Run J2KConverter tests in webDemo mode 2014-10-22 17:30:48 +04:00
Natalia Ukhorskaya
9e19546ba8 J2K: add default implementation for NullableNotNullManager 2014-10-22 17:30:47 +04:00
Valentin Kipyatkov
82d5e044c7 Corrected test 2014-10-22 17:08:43 +04:00
Valentin Kipyatkov
34d4477a12 Dropped test that cannot work anymore 2014-10-22 17:05:49 +04:00
Valentin Kipyatkov
23c5ad78b5 Regenerated tests 2014-10-22 15:51:28 +04:00
Valentin Kipyatkov
dcfeb5829a Minor 2014-10-22 15:49:13 +04:00
Valentin Kipyatkov
0384e3d323 No filtering by visibility filter twice 2014-10-22 15:49:13 +04:00
Valentin Kipyatkov
1f548875c6 Hopefully fixed KT-4339 Auto-import suggestion doesn't go away for a long time
#KT-4339 Fixed
2014-10-22 15:49:13 +04:00
Valentin Kipyatkov
762dc31e98 More consistent API in psi 2014-10-22 15:49:13 +04:00
Valentin Kipyatkov
4fd417d419 Fixing code completion in function literal parameters
#KT-4047 Fixed
 #KT-5877 Fixed
2014-10-22 15:49:12 +04:00
Valentin Kipyatkov
59b66e7579 Fixed KT-6074 Package facade classes are shown in completion in kotlin files
#KT-6074 Fixed
2014-10-22 15:48:53 +04:00
Valentin Kipyatkov
d8dbc46867 Fixed KT-6075 Qualified name inserted when completing class with class object
#KT-6075 Fixed
2014-10-22 15:48:35 +04:00
Valentin Kipyatkov
3a2a7427e7 Fixed caret position for KT-5906 Smart completion of anonymous object should preselect single method body
#KT-5906 Fixed
2014-10-22 15:48:34 +04:00
Valentin Kipyatkov
7f55c0626f Fixed KT-6033 Smart completion: wrong replacement range by Tab for item with all arguments at once
#KT-6033 Fixed
2014-10-22 15:48:34 +04:00
Valentin Kipyatkov
a84488f59a Fixed KT-5985 Smart completion does not insert comma for constructor of nested data class
#KT-5985 Fixed
2014-10-22 15:48:17 +04:00
Valentin Kipyatkov
f64f08c9b6 Checked that KT-5984 has been fixed already 2014-10-22 15:48:00 +04:00
Valentin Kipyatkov
af883d9165 Ordering items in smart completion for 'it' 2014-10-22 15:47:47 +04:00
Valentin Kipyatkov
f5f5b514d4 Ordering items in smart completion for nullable 2014-10-22 15:47:33 +04:00
Valentin Kipyatkov
4068879d84 Ordering items in smart completion for boolean 2014-10-22 15:47:17 +04:00
Valentin Kipyatkov
9cf50154d2 Ordering items in smart completion for function type 2014-10-22 15:46:56 +04:00
Valentin Kipyatkov
65c30902e7 KT-6028 Smart completion items priority
#KT-6028 Fixed
2014-10-22 15:45:16 +04:00
Valentin Kipyatkov
e6dbfac232 Fixed smart completion of functions with "::"
#KT-6073 Fixed
2014-10-22 15:42:36 +04:00
Valentin Kipyatkov
f2a83cdf29 No need to filter by visibility in LookupElementsCollector anymore 2014-10-22 15:40:21 +04:00
Valentin Kipyatkov
042e446694 Refactored TipsManager to filter by visibility 2014-10-22 15:40:21 +04:00
Valentin Kipyatkov
13d9fd083c Auto-import fix also honors visibility 2014-10-22 15:40:20 +04:00
Valentin Kipyatkov
0a24dca821 Minor refactoring of KotlinIndicesHelper 2014-10-22 15:40:20 +04:00
Valentin Kipyatkov
1f632daf85 Code completion to filter out non-imported declarations by visibility 2014-10-22 15:40:20 +04:00
Valentin Kipyatkov
b6d4de7046 Optimization in smart completion 2014-10-22 15:40:20 +04:00
Valentin Kipyatkov
86a9f47f6c Fixed KT-6056 Smart completion does not filter out inaccessible declarations
#KT-6056
2014-10-22 15:40:20 +04:00
Alexander Udalov
fb5806f5fb Fix inheritance from mutable Java collections
Don't use CodegenUtil#getDeclaredFunctionByRawSignature because it's incorrect
in case of platform types. Instead use JetTypeMapper to find JVM signatures of
methods which are callable on the current class

 #KT-6042 Fixed
2014-10-22 10:51:14 +04:00
Alexander Udalov
07374b5638 Drop temporary hack, enums are comparable now 2014-10-22 10:49:33 +04:00
Alexander Udalov
23c1eea7d8 Disable codegen test on Android
Can't import from enum there because a package directive is appended to the
beginning of the file in Android tests, invalidating import statements
2014-10-22 10:42:24 +04:00
Natalia Ukhorskaya
7200f3cf31 Merge pull request #521 from ronshapiro/patch-1
Correct Android variant compile task name
2014-10-22 10:30:22 +04:00
Andrey Breslav
7ed7f020d3 Generation of ++ and += fixed for platform types 2014-10-22 00:41:20 +04:00
Andrey Breslav
d28c96837e Compilation errors fixed 2014-10-22 00:41:20 +04:00
Andrey Breslav
a14eefcea3 KT-6077 Compiler does not issue error on unsafe access to ArrayList with nullable values
#KT-6077 Fixed
2014-10-22 00:41:20 +04:00
Andrey Breslav
7b89771953 KT-6059 Regression: irrelevant compiler error on trait inheritance (worked in M8)
#KT-6059 Fixed
2014-10-22 00:41:19 +04:00
Andrey Breslav
d9f5bd013b Clean up declarations of runReadAction() etc 2014-10-22 00:41:19 +04:00
Andrey Breslav
9bd3ac26e3 toString() for easier debugging 2014-10-22 00:41:19 +04:00
Andrey Breslav
b5f89c661a DescriptorRenderer can now render flexible types for code (i.e. ft<L, U>) 2014-10-22 00:41:19 +04:00
Andrey Breslav
0e42de4e99 CHECK_TYPES injected through imports 2014-10-22 00:41:19 +04:00
Andrey Breslav
71d9ad5e8b Removing the static import that caused exception on compilation 2014-10-22 00:41:18 +04:00
Andrey Breslav
f06e5581aa Support creating flexible types in tests
Flexible types can not be created in normal user code, but if there's a special classifier `kotlin.internal.flexible.ft` with two type parameters,
its occurrences are replaced by flexible types, e.g. `ft<Int, Int?>` becomes `Int!`
2014-10-22 00:41:18 +04:00
Ron Shapiro
1ab0edb84c Correct Android variant compile task name
Corrects 'compiledebugKotlin' to 'compileDebugKotlin'
2014-10-21 16:40:06 -04:00
Zalim Bashorov
8067a9ad56 Added regression tests for KT-2474 Range lacks reverse() in JavaScript backend
#KT-2474 Fixed
2014-10-21 22:46:09 +04:00
Zalim Bashorov
66519d9973 Added regression tests for KT-1906 Support invoke() convention is js-backend (including classes implementing Function trait)
#KT-1906 Fixed
2014-10-21 22:46:09 +04:00
Zalim Bashorov
f3d9d21757 Added regression tests for KT-3518 Null pointer during null comparison in JS Backend. 2014-10-21 22:46:09 +04:00
Nikolay Krasko
2e3c0505cd Update to EAP 139.144.2 2014-10-21 19:45:27 +04:00
Zalim Bashorov
b3e34cc2b4 Minor: added regression tests for downTo.
Adopted tests from patch attached to KT-2586.
2014-10-21 18:25:17 +04:00
Zalim Bashorov
fedbe26480 Minor: added regression tests for KT-4235
#KT-4235 Obsolete
2014-10-21 18:25:16 +04:00
Zalim Bashorov
335771d580 JS lib: provide Kotlin object as parameter of IIFE. 2014-10-21 14:49:00 +04:00
Zalim Bashorov
98d62283c7 JS lib: simplify DefaultPrimitiveHashSet. 2014-10-21 14:49:00 +04:00
Michael Bogdanov
6eaa6201f0 Test for obsolete KT-6020: Type inference failed on property reference of generic class
#KT-6020 Can't Reproduce
2014-10-21 09:47:17 +04:00
Michael Bogdanov
da20845e9c Support non standart java source root configuration in gradle plugin
#KT-6051 Fixed
2014-10-21 09:46:59 +04:00
Alexander Udalov
3a8ad45dec Append newline to EOF for .txt test data files
Reverts and fixes 102f0d3
2014-10-21 03:18:27 +04:00
Alexander Udalov
6e5647bb67 Append newline at EOF when creating file in JetTestUtils 2014-10-21 03:17:44 +04:00
Alexander Udalov
102f0d3470 Regenerate .txt testData
Add newline to EOF, trim trailing spaces
2014-10-21 00:16:08 +04:00
Alexander Udalov
51fd654802 Regenerate injectors and keyword strings
After recent changes to Printer
2014-10-21 00:16:08 +04:00
Alexander Udalov
f8be39b26b Regenerate tests
After recent changes to Printer and TestGenerator
2014-10-21 00:16:08 +04:00
Alexander Udalov
b9836afb49 Reorder imports in test generator
To make IDEA's Optimize Imports action a no-op on most of the generated tests
2014-10-21 00:16:07 +04:00
Alexander Udalov
bc9aa9e34f Don't output trailing spaces in Printer
Also don't output trailing empty lines in TestGenerator
2014-10-21 00:16:07 +04:00
Alexander Udalov
4d9ef1042d Prohibit 'override' on classes and all modality on objects
#KT-3464 Fixed
2014-10-21 00:16:07 +04:00
Alexander Udalov
093dedcd85 Minor, don't call Type.getObjectType on array 2014-10-21 00:16:07 +04:00
Alexander Udalov
ae401cac0f Prohibit type parameters for enum classes
#KT-5696 Fixed
2014-10-21 00:16:07 +04:00
Alexander Udalov
63366042ed Fix incorrect "senseless null in when" on nullable type 2014-10-21 00:16:07 +04:00
Alexander Udalov
fe59dc27b3 Make 'when' on nullable enums exhaustive if 'null' entry is present
#KT-2902 Fixed
2014-10-21 00:16:06 +04:00
Alexander Udalov
91105b8183 Minor, fix some warnings in DeclarationsChecker 2014-10-21 00:16:06 +04:00
Alexander Udalov
c071ac854e Prohibit all modifiers for enum entries
#KT-2679 Fixed
2014-10-21 00:16:06 +04:00
Alexey Tsvetkov
1f87bea78f JS backend: added support for nested labels with the same name
#KT-5891 fixed
2014-10-20 19:51:35 +04:00
Alexey Tsvetkov
09c98226c8 JS backend: added tests for labels 2014-10-20 19:51:35 +04:00
Alexey Tsvetkov
0bc05135d8 JS test minor: renamed InlineTestUtils to DirectiveTestUtils 2014-10-20 19:51:35 +04:00
Alexey Tsvetkov
6d16d06120 JS test: extracted test with ast access and directives 2014-10-20 19:51:34 +04:00
Valentin Kipyatkov
f00823c7bf Fixed NPE 2014-10-20 18:50:37 +04:00
Evgeny Gerashchenko
b9a4ea80c5 Optimized imports. Fixed build. 2014-10-20 17:57:44 +04:00
Valentin Kipyatkov
cb00e729ad Optimization to not optimize imports on completion of class name if we do not insert any import 2014-10-20 14:49:49 +04:00
Svetlana Isakova
68e2e21fb9 Refactoring: inlined 'collectSmartCastReceiverValues' 2014-10-18 11:06:53 +04:00
Svetlana Isakova
4a1a95ea36 Rename: casted -> cast 2014-10-18 11:06:53 +04:00
Svetlana Isakova
595b3ffe23 KT-6026 Exception on instantiating a nested class in an anonymous object
#KT-6026 Fixed
2014-10-18 11:06:53 +04:00
Svetlana Isakova
c0c9552f4c KT-5971 Missing error when fun argument is safe call
#KT-5971 Fixed
2014-10-18 11:06:53 +04:00
Svetlana Isakova
c339df65a9 Small refactoring in CandidateResolver 2014-10-18 11:06:52 +04:00
Svetlana Isakova
a47729c626 KT-5455 Need warning about redundant type cast
#KT-5455 Fixed
2014-10-18 11:06:52 +04:00
Svetlana Isakova
b20327770b KT-5854 Incorrect 'Nested class should be qualified'
#KT-5854 Fixed
2014-10-18 11:06:52 +04:00
Svetlana Isakova
29fa87ee7c Slightly reduce number of candidates in task prioritizer
return only extensions (functions) when we expecting extensions (not all functions);
  for properties it's not that easy: they may have extension function types, and we want to avoid early computing of deferred types
  rename: getNonMembersByName -> getExtensionsByName

Report NO_RECEIVER_ALLOWED for '42.(f)()' where f: () -> Unit in TracingStrategyForInvoke
(we don't store candidates for such 'invoke' functions any more)
2014-10-18 11:06:52 +04:00
Svetlana Isakova
c0eb894bd9 Rename: NO_RECEIVER_ADMITTED -> NO_RECEIVER_ALLOWED 2014-10-18 11:06:51 +04:00
Svetlana Isakova
cd3dc5998f Rewrote CallableDescriptorCollectors to Kotlin 2014-10-18 11:06:51 +04:00
Svetlana Isakova
dfd88b8f24 Rename CallableDescriptorCollectors.java to CallableDescriptorCollectors.kt 2014-10-18 11:06:51 +04:00
Alexander Udalov
6ddc063a76 Regenerate test data on enums
Now they have final equals, hashCode and compareTo
2014-10-17 21:27:24 +04:00
Alexander Udalov
624e507ec2 Make enum classes comparable
#KT-3727 Fixed
2014-10-17 21:27:23 +04:00
Alexander Udalov
02861308bc Add toString() to kotlin.Enum
Overridable because it is in java.lang.Enum
2014-10-17 21:27:23 +04:00
Alexander Udalov
66a7a58313 Prohibit to override equals/hashCode in enums
#KT-5721 Fixed
2014-10-17 21:27:22 +04:00
Alexander Udalov
6ec71b3fd1 Generate lambdas in enum entry super calls
#KT-4423 Fixed
2014-10-17 21:27:22 +04:00
Alexander Udalov
1edaf43051 Fix Double and Float equality/hashCode in data classes
#KT-5818 Fixed
2014-10-17 21:27:22 +04:00
Alexander Udalov
f632a34959 Delete unused JavaSignatureFormatter 2014-10-17 21:27:21 +04:00
Alexander Udalov
d3e3039eb2 Add tests for obsolete "nested class is inaccessible"
#KT-3535 Obsolete
 #KT-3647 Obsolete
 #KT-3731 Obsolete
2014-10-17 21:27:21 +04:00
Alexey Sedunov
0def7d4b4e JetFileReferenceResolver: Stabilize reference order 2014-10-17 17:34:04 +04:00
Alexey Sedunov
80321b610a Use QUALIFIER info in JetFileReferenceResolver 2014-10-17 17:34:02 +04:00
Alexey Sedunov
f3a219f062 Shorten References: Extract common superclass for type- and expression-processing visitors 2014-10-17 17:33:48 +04:00
Alexey Sedunov
f7e947e912 Shorten References: Simplify shortening of qualified expressions 2014-10-17 13:30:19 +04:00
Natalia Ukhorskaya
be73ec2cc9 KotlinEvaluateExpressionTestGenerated:testSimple: add comment 2014-10-17 11:46:25 +04:00
Natalia Ukhorskaya
6bf0152f6d Fix KotlinEvaluateExpressionTestGenerated:testSimple 2014-10-17 10:37:54 +04:00
Denis Zharkov
ec63394121 Check that boxing instruction is simple call
like T.valueOf(unboxType(T))

 #KT-6047 fixed
2014-10-17 01:22:25 +04:00
Michael Nedzelsky
34269e1a3e JS backend: fix KT-6037 (default arguments in simple function with expression as body)
#KT-6037 Fixed
2014-10-17 00:46:05 +04:00
Evgeny Gerashchenko
954a011721 Added incremental cache format versioning. 2014-10-16 22:01:45 +04:00
Evgeny Gerashchenko
0eda00e2df Rearranged code in abstract incremental compilation test. 2014-10-16 22:01:44 +04:00
Evgeny Gerashchenko
f63f1274cd Changed shortcuts for "Show expression type".
Using same shortcuts as in Scala.
2014-10-16 19:17:09 +04:00
Alexey Tsvetkov
5fb5cea4a3 JS inline: fixed bug with simple return inline function, when result is not used.
When function body can be expression
(contains only one statement, and it's return),
 result was saved to resultExpr, not body.

 But when result was not used, resultExpr was not
 used then.

 Fixed by checking, that result is used in first place.
2014-10-16 17:16:10 +04:00
Alexey Tsvetkov
be82d4c661 JS backend: increment counter for fresh names 2014-10-16 17:16:10 +04:00
Alexander Udalov
f0169f4181 Regenerate tests 2014-10-16 17:10:33 +04:00
Alexander Udalov
6698e0ecc9 Add test for outdated smart cast with elvis issue
#KT-5335 Obsolete
2014-10-16 16:38:11 +04:00
Alexander Udalov
6387076efe Uncomment previously failing code in J2K after fixing KT-5343 2014-10-16 16:38:04 +04:00
Alexander Udalov
159878e09d Pass correct outer instance in complex case of inheritance
#KT-5343 Fixed
2014-10-16 16:16:55 +04:00
Alexander Udalov
61674fb3d9 Don't put outer instance twice for anonymous object extending inner
#KT-5343 In Progress
2014-10-16 16:16:54 +04:00
Alexander Udalov
7315146753 Fix and refactor ExpressionCodegen#pushClosureOnStack
- change Closure parameter to ClassDescriptor, load closure in the beginning
- invert and rename boolean parameter, also use it only to prevent pushing
  dispatch receiver (not the extension receiver) onto the stack because the
  only non-trivial usage of it is preceded by manual handling of the dispatch
  (not extension) receiver. This fixes innerOfLocalCaptureExtensionReceiver.kt
2014-10-16 16:16:54 +04:00
Valentin Kipyatkov
79123d6bb6 Minor 2014-10-16 15:14:23 +04:00
Valentin Kipyatkov
6b163bca8a Keyword completion uses simple prefix matching only 2014-10-16 15:14:23 +04:00
Valentin Kipyatkov
1e5ea703b5 Added a test 2014-10-16 15:14:23 +04:00
Valentin Kipyatkov
0da62a8815 Keyword completion: added missing 'out' keyword 2014-10-16 15:14:23 +04:00
Valentin Kipyatkov
6dc17e5a03 Minor refactoring in keyword completion 2014-10-16 15:14:22 +04:00
Valentin Kipyatkov
96a5e573c3 Fix in keyword completion 2014-10-16 15:14:22 +04:00
Valentin Kipyatkov
8e1a89230e Keyword correction: smaller file text 2014-10-16 15:14:22 +04:00
Valentin Kipyatkov
f7dc0fca74 Keyword correction: more correct behavior + smaller file text 2014-10-16 15:14:22 +04:00
Valentin Kipyatkov
525a1cc3c6 Fixed tests 2014-10-16 15:14:22 +04:00
Valentin Kipyatkov
d65d3b9068 Checked that KT-2795 has been fixed
#KT-2795 Fixed
2014-10-16 15:14:21 +04:00
Valentin Kipyatkov
9663fac5b1 Checked that KT-2832 has been fixed
#KT-2832 Fixed
2014-10-16 15:14:21 +04:00
Valentin Kipyatkov
50e1ec9c4f Fixed KT-5809 Code completion after "?." should not include keywords
#KT-5809 Fixed
2014-10-16 15:14:21 +04:00
Valentin Kipyatkov
549171d043 Completely rewritten keyword completion implementation using another approach
#KT-2816 Fixed
2014-10-16 15:14:21 +04:00
Natalia Ukhorskaya
6a4fe52e51 Fix Android tests 2014-10-16 14:31:57 +04:00
Andrey Breslav
a128b94e2e Typo fixed: "cast", not "casted" 2014-10-16 14:10:14 +04:00
Andrey Breslav
9feebb1dc6 "typedef" replaced with "typeAlias" in the grammar 2014-10-16 14:10:02 +04:00
Nikolay Krasko
4cb276c47f More information about context for assert 2014-10-16 13:01:37 +04:00
Nikolay Krasko
501bb398d4 Update to Idea 139.69.2 2014-10-16 13:01:36 +04:00
Evgeny Gerashchenko
1a3750f31b Stabilized order of static accessors. 2014-10-15 20:38:16 +04:00
Evgeny Gerashchenko
84c7b05781 Stabilized order of methods inherited by delegation. 2014-10-15 20:38:16 +04:00
Evgeny Gerashchenko
db45f4a062 Fixed hot swap when closure captures variables
Stabilized order of synthetic constructor parameters in anonymous class.

 #KT-5440 fixed
2014-10-15 20:33:17 +04:00
Valentin Kipyatkov
afa59a616c More tests 2014-10-15 17:30:33 +04:00
Valentin Kipyatkov
2365db1367 Fixed KT-6011 Smart completion works for argument of wrong method
#KT-6011 Fixed
2014-10-15 17:30:33 +04:00
Alexey Sedunov
b18b888161 PSI Pattern Matching: Fix matching of !!
#KT-6021 Fixed
2014-10-15 15:41:47 +04:00
Alexey Kudravtsev
6f5a2172ac moved more find usages-related stuff to idea-analysis for upsource 2014-10-15 15:11:49 +04:00
Natalia Ukhorskaya
fff8bfff5f Debugger: do not throw exception on getting source position for Kotlin object 2014-10-15 14:09:55 +04:00
Andrey Breslav
3453809b4b Defining flexible type semantic equality through subtyping 2014-10-15 14:07:55 +04:00
Andrey Breslav
f41a8d2c00 Render "<" properly in HTML 2014-10-15 14:07:54 +04:00
Andrey Breslav
2bf6db003a Error message corrected: packages can't be nested any more 2014-10-15 12:22:35 +04:00
Andrey Breslav
391b57077b KT-5976 Parser recovery is poor on object with parameters
#KT-5976 Fixed
2014-10-15 12:22:35 +04:00
Andrey Breslav
d25a858214 "typealias" escaped in DOM API generator 2014-10-15 12:22:33 +04:00
Evgeny Gerashchenko
cb9a55b375 Minor. Storing valOrVar in constructor to avoid bad action text for outdated quick fix. 2014-10-15 11:51:02 +04:00
Evgeny Gerashchenko
fbcfed6757 Fixed EA-57220. 2014-10-15 11:51:01 +04:00
Evgeny Gerashchenko
b653598df2 Fixed EA-61504. 2014-10-15 11:51:01 +04:00
Evgeny Gerashchenko
0d17a71ffa Minor. Renamed class. 2014-10-15 11:51:01 +04:00
Evgeny Gerashchenko
ef93a71e78 Made "Remove val/var from parameter" quick fix local. 2014-10-15 11:51:01 +04:00
Evgeny Gerashchenko
7a6429e35e Removed live templates completion contributor.
LT are added to completion on IDEA side.

Fixed EA-52890.
2014-10-15 11:51:01 +04:00
Evgeny Gerashchenko
745a7333b1 Fixed EA-50672. 2014-10-15 11:51:00 +04:00
Evgeny Gerashchenko
05677e26a4 Fixed EA-54056. 2014-10-15 11:51:00 +04:00
Evgeny Gerashchenko
4fe11f0998 Clarified assertion. Just in case. 2014-10-15 11:51:00 +04:00
Evgeny Gerashchenko
e1cf002c30 Clarified assertion which should be fixed on IDEA side. 2014-10-15 11:51:00 +04:00
Evgeny Gerashchenko
e9880e6787 Clarified assertion for EA-50536. 2014-10-15 11:50:59 +04:00
Evgeny Gerashchenko
a759fc2454 Added test for EA-53340. 2014-10-15 11:50:59 +04:00
Evgeny Gerashchenko
7229df26ab Project settings: navigation to EA problems. 2014-10-15 11:50:59 +04:00
Evgeny Gerashchenko
73f3db5cf8 Clarified assertion for EA-50657. 2014-10-15 11:50:59 +04:00
Natalia Ukhorskaya
a0e518870d Fix Android tests 2014-10-15 09:54:29 +04:00
Natalia Ukhorskaya
0a9adbb777 Do not try to use index in JetPositionManager in dumpMode
EA-58536 Fixed
2014-10-15 09:54:28 +04:00
Valentin Kipyatkov
3b85839bf3 Refactored StatementVisitor to StatementConverter (similar to ExpressionConverter before) + renamed ExpressionVisitor 2014-10-14 21:23:24 +04:00
Valentin Kipyatkov
a84b32af98 KT-5492 J2K: convert field with getter/setter to property
#KT-5492 Fixed
2014-10-14 21:23:24 +04:00
Valentin Kipyatkov
129c592581 J2K converter: refactored code moving code for converting class body into separate class 2014-10-14 21:19:48 +04:00
Valentin Kipyatkov
a7a1227390 Converter should not fail completely if some error occured in the after conversion pass 2014-10-14 21:19:48 +04:00
Valentin Kipyatkov
5008682bef Better diagnostic for Element has no prototype error 2014-10-14 21:19:10 +04:00
Valentin Kipyatkov
0213d37d82 More correct line breaks counting in converter 2014-10-14 21:19:10 +04:00
Valentin Kipyatkov
c8da4d90e9 J2K: minor fix 2014-10-14 21:19:10 +04:00
Valentin Kipyatkov
a08373fec6 Minor code corrections after review 2014-10-14 21:19:10 +04:00
Zalim Bashorov
f0078b5e0f JS lib: export Kotlin object when it possible.
It allows use kotlin.js on node.js without modifications.
2014-10-14 18:02:28 +04:00
Zalim Bashorov
55c19a632a JS lib: introduced different output strategies, and chose them depending of environment.
#KT-2994 Fixed
2014-10-14 18:02:28 +04:00
Pavel V. Talanov
40e1292e9a Do not create junit configuration in dumb mode 2014-10-14 17:39:42 +04:00
Pavel V. Talanov
f3b9ab9329 Minor: Log and create attachment on AssertionError in KotlinSignature line markers 2014-10-14 17:37:12 +04:00
Michael Nedzelsky
e73866040d JS backend: correct hierarchy for collections in kotlin_lib.js, maps.js 2014-10-14 16:46:01 +04:00
Michael Nedzelsky
229c92e6b8 JS backend: add files to jslib_files.xml 2014-10-14 16:45:59 +04:00
Michael Nedzelsky
aa13a67371 JS backend: remove Iterable from FAKE_CLASS list, remove Iterator from StandardClasses 2014-10-14 16:45:57 +04:00
Michael Nedzelsky
edac2dd3bd JS backend: tests for KT-2468 2014-10-14 16:45:54 +04:00
Valentin Kipyatkov
cff0c35987 Checked that KT-3596 is not reproducible 2014-10-14 16:08:17 +04:00
Valentin Kipyatkov
e1a84802f2 Minor 2014-10-14 16:08:17 +04:00
Valentin Kipyatkov
c61ee18c03 Removed some more stuff from ImportInsertHelper 2014-10-14 16:08:17 +04:00
Valentin Kipyatkov
6d69608feb Refactored completion tests to not set/restore auto-complete settings in 2 different places 2014-10-14 16:08:17 +04:00
Valentin Kipyatkov
043c65b1d4 Removed method which is not needed anymore 2014-10-14 16:08:17 +04:00
Valentin Kipyatkov
503a8deef1 Fixed bug in reference shortening + fixed test data for completion tests 2014-10-14 16:08:16 +04:00
Valentin Kipyatkov
d8b962c7f3 Completion: the same universal insertion handler is used for java classes too 2014-10-14 16:08:16 +04:00
Valentin Kipyatkov
38a5b988f0 One more class rename 2014-10-14 16:08:16 +04:00
Valentin Kipyatkov
a5223d8a38 Class renames 2014-10-14 16:08:16 +04:00
Valentin Kipyatkov
f9bf214526 Code completion: avoid duplication of elements for java classes 2014-10-14 15:47:45 +04:00
Valentin Kipyatkov
eabcbb00ab KT-5876 Code completion should never auto-insert item which requires adding import
#KT-5876 Fixed
2014-10-14 15:47:45 +04:00
Valentin Kipyatkov
a124827c4e Fixed KT-5611 Completion doesn't include not imported extensions for implicit receiver
#KT-5611 Fixed
2014-10-14 15:47:44 +04:00
Alexey Kudravtsev
22c80d2694 moved structure view to to idea-analysis to make available in upsource 2014-10-14 15:42:50 +04:00
Nikolay Krasko
c5852152b2 Don't ruin highlighting if there's no descriptor in resolve session
#EA-61683 Fixed
2014-10-14 15:38:27 +04:00
Andrey Breslav
b1e452b568 type unescaped in *.kt files 2014-10-14 13:02:13 +04:00
Andrey Breslav
56d1979d9b File names fixed according to f202ad9f98 2014-10-14 13:02:06 +04:00
Alexey Sedunov
2b43aad4f9 Create From Usage: Fix rendering of nullable types 2014-10-14 01:59:54 +04:00
Alexey Sedunov
ff082be524 File Move: Fix update of extension references. Reuse MoveKotlinTopLevelDeclarationsProcessor 2014-10-14 01:59:53 +04:00
Alexey Sedunov
dc62d167ad Add user-data delegate for non-nullable properties 2014-10-14 01:59:52 +04:00
Alexey Sedunov
0d220c68ea Find Usages: Fix reference check for the case of multiple resolve results 2014-10-14 01:59:51 +04:00
Alexey Sedunov
f0a0df94b5 Create From Usage: Add support of property delegates 2014-10-14 01:59:50 +04:00
Alexey Sedunov
2e6d4b3501 Create From Usage: Support EXPRESSION_EXPECTED_PACKAGE_FOUND diagnostic 2014-10-14 01:59:49 +04:00
Alexey Sedunov
c73c581b11 Call Resolver: Report UNRESOLVED_REFERENCE instead of EXPRESSION_EXPECTED_PACKAGE_FOUND when callee expession is resolved to package 2014-10-14 01:59:48 +04:00
Alexey Sedunov
77a5ddbcd0 Create From Usage: Do not suggest Java classes as receiver type candidates (for now) 2014-10-14 01:59:47 +04:00
Alexey Sedunov
0dafcb6728 Create From Usage: Generate type parameters (if any) for all callable declarations 2014-10-14 01:59:46 +04:00
Alexey Sedunov
9206b571f4 Create From Usage: Always try to shorten return type reference if there is one 2014-10-14 01:59:45 +04:00
Alexey Sedunov
497e4fab79 Create From Usage: Generate Unit-typed declaration if result is unused
#KT-5903 Fixed
2014-10-14 01:59:44 +04:00
Alexey Sedunov
a3a0edca58 Pseudocode: Drop CompilationErrorInstruction 2014-10-14 01:59:43 +04:00
Alexey Sedunov
a56c54371e Pseudocode: Generate instructions for unresolved array assignments 2014-10-14 01:59:42 +04:00
Nikolay Krasko
b06b3ab4c4 Insert empty lines after functions and properties (KT-4002)
#KT-4002 Fixed
2014-10-14 00:39:23 +04:00
Nikolay Krasko
22d33a5afa Data class copy method invocation gives errors in IDE when some optional parameters specified (KT-5975)
#KT-5975 Fixed
2014-10-14 00:39:22 +04:00
Zalim Bashorov
f202ad9f98 Stdlib: run all stdlib tests with JS backend(as possible). 2014-10-13 21:25:56 +04:00
Zalim Bashorov
f20ee6df4b JS backend: fixes in ranges:
* map all number ranges and progressions;
* add missed hashCode and static EMPTY to Range implementations;
* add missed hashCode and equals to Progression implementations;
* fix type of start and end in CharRange and CharProgression.
2014-10-13 21:25:56 +04:00
Zalim Bashorov
8bd6acec5d JS stdlib: drop wrong annotations in javautilCollectionsCode.kt and fix Collections.reverse. 2014-10-13 21:25:56 +04:00
Zalim Bashorov
e54c838482 JS backend: temporary fix for CharSequence.get 2014-10-13 21:25:56 +04:00
Zalim Bashorov
64044800c9 JS stdlib: fix bug with using "__proto__" as element of DefaultPrimitiveHashSet. 2014-10-13 21:25:56 +04:00
Zalim Bashorov
49e2262ca7 JS tests: fixed waiting to finish qunit tests in SeleniumTest. 2014-10-13 21:25:56 +04:00
Zalim Bashorov
2d634931f6 JS backend: use 0 as init value when calculating hashCode in data classes as in JVM backend. 2014-10-13 21:25:56 +04:00
Zalim Bashorov
ae39524a95 JS backend: compile primitive iterators from builtins as part of stdlib. 2014-10-13 21:25:55 +04:00
Zalim Bashorov
ecb955f5b3 Stdlib: split OrderingJVM.kt to common and jvm parts 2014-10-13 21:25:55 +04:00
Zalim Bashorov
88f9621b45 Minor: update junit to 4.11 2014-10-13 21:25:55 +04:00
Zalim Bashorov
1b2aa205ec Introduce assertNotEquals 2014-10-13 21:25:55 +04:00
Zalim Bashorov
b086a2b7a5 Extract some closure-compiler arguments to separate property and change warning level to "default" 2014-10-13 21:25:55 +04:00
Pavel V. Talanov
c1f8db5962 Fix MutableDiagnosticsTest#testCaching()
Sadly relying on implementation details
2014-10-13 19:48:57 +04:00
Michael Nedzelsky
df8232c555 JS backend: minor: refactor ClassTranslator 2014-10-13 19:25:06 +04:00
Michael Nedzelsky
ab6eff5a5b JS backend: minor: remove ArrayList(Collection) from bridges/_commonFiles/javautil.kt 2014-10-13 19:25:02 +04:00
Michael Nedzelsky
aa3d0fe1d7 minor: rename TargetBackend enum values 2014-10-13 19:24:59 +04:00
Alexey Kudravtsev
869487ac82 moved to idea-analysis to make available in upsource 2014-10-13 18:33:37 +04:00
Alexey Kudravtsev
ef34875061 added sources to kotlin-upsource 2014-10-13 18:30:47 +04:00
Michael Nedzelsky
a63bbf317d JS backend: translate 0L, 1L and -1L to Kotlin.Long constants 2014-10-13 17:51:48 +04:00
Michael Nedzelsky
e5c77d1242 JS backend: minor: move constant to Namer 2014-10-13 17:51:45 +04:00
Pavel V. Talanov
ee33c09714 Android: navigate to resource
Implementation mostly copied from android plugin
 #KT-5596 Fixed
2014-10-13 16:46:55 +04:00
Andrey Breslav
838ef11f1c Test data fixed: after "type" is no longer a keyword 2014-10-13 16:42:03 +04:00
Andrey Breslav
34a98f2563 Minor. Compilation fixed 2014-10-13 16:02:39 +04:00
Andrey Breslav
f202a5c31d KT-4524 Generate implementations fails on functions with default values
#KT-4524 Fixed
2014-10-13 15:43:03 +04:00
Andrey Breslav
cc68ed894b "type" is not a keyword anymore ("typealias" reserved instead) 2014-10-13 15:41:13 +04:00
Andrey Breslav
b20439027c Advancing ABI version
Related changes:
 - serialization of flexible types supported
 - Intrinsics.checkExpressionValueIsNotNull() added
2014-10-13 15:38:23 +04:00
Andrey Breslav
4a132599fd getAllOverriddenDescriptors() moved to DescriptorUtils 2014-10-13 15:38:22 +04:00
Andrey Breslav
f7ccfafd1c Minor. [platformStatic] used 2014-10-13 15:38:21 +04:00
Andrey Breslav
f1675a9162 Minor. Getters replaced by properties 2014-10-13 15:38:21 +04:00
Andrey Breslav
8e8f41e228 Minor. Improved usability of CustomTypeVariable API 2014-10-13 15:38:20 +04:00
Andrey Breslav
070a7d4d72 Serialization of flexible types supported 2014-10-13 15:38:20 +04:00
Andrey Breslav
e76df4db11 Rendering fixed across the idea module 2014-10-13 15:38:19 +04:00
Andrey Breslav
9fb09e62af toString() on nullables fixed 2014-10-13 15:38:19 +04:00
Andrey Breslav
619df3a53e Use semantic equality in Create From Usage 2014-10-13 15:38:18 +04:00
Andrey Breslav
8eb57f5a75 Parser recovers on platform types notation:
- Foo!
- Array<(out) Foo>!
- (Mutable)List<Foo>!
2014-10-13 15:38:18 +04:00
Andrey Breslav
21d31a1a4f An option to enable assertions in the Bytecode toolwindow 2014-10-13 15:38:17 +04:00
Andrey Breslav
1214bef3e8 Always create a missing txt file, even if the test itself fails before 2014-10-13 15:38:17 +04:00
Andrey Breslav
890ef7a8ae Choosing a best fit when getting multiple exact bounds for a type variable 2014-10-13 15:38:16 +04:00
Andrey Breslav
d74b27335e RemoveExplicitTypeArguments fixed: platform types approximated before comparison 2014-10-13 15:38:16 +04:00
Andrey Breslav
94f4ddb762 IDE TypeUtils moved to idea-analysis 2014-10-13 15:38:15 +04:00
Andrey Breslav
e418a763db Fix JetType.equals(): flexible types are not equal to non-flexible ones, when we store them in a HashSet 2014-10-13 15:38:15 +04:00
Andrey Breslav
5be4dda58b Unit obtained through a generic substitution should not be mapped to VOID 2014-10-13 15:38:14 +04:00
Andrey Breslav
f5aed51fd0 TypeUtils.containsSpecialType() fixed to account for flexible types 2014-10-13 15:38:14 +04:00
Andrey Breslav
a737352b5d Assertions when approximating platform types in delegation by expression 2014-10-13 15:38:13 +04:00
Andrey Breslav
f1c66fa6b0 Assertions on approximation of platform types to non-null types
- for most expressions (ExpressionCodegen.genQualified)
2014-10-13 15:38:13 +04:00
Andrey Breslav
3d5d3e00e3 Minor. @TestDataFlie added for naviagtion 2014-10-13 15:38:12 +04:00
Andrey Breslav
57bffaf8fa All JetType subinterfaces migrated to capabilities 2014-10-13 15:38:12 +04:00
Andrey Breslav
013dd7261e Extensible specificity expressed as a type capability 2014-10-13 15:38:11 +04:00
Andrey Breslav
4b24c96cca Type capabilities introduced to facilitate extensibility of the type representation
This approach: returning adapter objects by class is crucial, because it is delegation-proof.
Simply extending interfaces in particular implementations fails when we wrap types in DelegatedType subclasses
2014-10-13 15:38:11 +04:00
Andrey Breslav
6564231040 Descriptor test data for diagnostic tests fixed 2014-10-13 15:38:10 +04:00
Andrey Breslav
25efd6684f Missing test data generated 2014-10-13 15:38:10 +04:00
Andrey Breslav
52ed640a2b Visibility fixed 2014-10-13 15:38:09 +04:00
Andrey Breslav
aea978cf90 Do not render type arguments as outermost 2014-10-13 15:38:09 +04:00
Andrey Breslav
fd3f929a11 Guessing class ids for external annotations 2014-10-13 15:38:08 +04:00
Andrey Breslav
fe2fb60daf Approximating flexible types in descriptor renderer 2014-10-13 15:38:07 +04:00
Andrey Breslav
40932f84c8 isFlexible() turned into a method in JetType
Otherwise delegated types were never recognized as flexible
2014-10-13 15:38:07 +04:00
Andrey Breslav
91b0b83ec3 Java declaration annotations are treated as type annotations
This is needed, for example, to approximate flexible types correctly when rendering them in the code
2014-10-13 15:38:06 +04:00
Andrey Breslav
bd21e487fc Unused class removed 2014-10-13 15:38:06 +04:00
Andrey Breslav
d25a76e044 Disabling @KotlinSignature checks in PLATFORM_TYPES mode 2014-10-13 15:38:05 +04:00
Andrey Breslav
ea3215b361 Massive test data update for compiledJava 2014-10-13 15:38:05 +04:00
Andrey Breslav
0b6a4df4f4 The case of Integer.getInteger("1", 2) fixed (was: OVERLOAD_RESOLUTION_AMBIGUITY) 2014-10-13 15:38:04 +04:00
Andrey Breslav
837353d9fd Skip alternative signatures in PLATFORM_TYPES mode, but use parameter names 2014-10-13 15:38:03 +04:00
Andrey Breslav
50aa918791 Failing test for type inference 2014-10-13 15:38:02 +04:00
Andrey Breslav
f5cc3e1a92 Use TypeUtils.isNullableType() in codegen 2014-10-13 15:38:02 +04:00
Andrey Breslav
1dbfe5483a Fix isNullableType() to always consider flexible types, even if they contain type parameters 2014-10-13 15:38:01 +04:00
Andrey Breslav
107480657a Spec document added 2014-10-13 15:38:00 +04:00
Andrey Breslav
d1214d2368 Another TypeUtils.isNullableType() introduced 2014-10-13 15:38:00 +04:00
Andrey Breslav
12d18533e8 Recursion depth in CommonSupertypes is bounded by maxDepth + 3 2014-10-13 15:37:59 +04:00
Andrey Breslav
364a7a6574 Do not overuse makeNullableAsSpecified in TypeSubstitutor 2014-10-13 15:37:59 +04:00
Andrey Breslav
920769d36d Fold standard flexible types in shortNames mode 2014-10-13 15:37:58 +04:00
Andrey Breslav
220c360081 Null-aware types introduced
Flexible types should drive their own conversions to nullable/not-null
2014-10-13 15:37:58 +04:00
Andrey Breslav
969beb7898 Account for substitutions of one variable for another (it must remain a variable) 2014-10-13 15:37:57 +04:00
Andrey Breslav
bdbd469aad Do not wrap flexible types into Nullable/NotNull types 2014-10-13 15:37:57 +04:00
Andrey Breslav
141e731f39 Constraint Foo on T! should be turned into Foo! on T 2014-10-13 15:37:56 +04:00
Andrey Breslav
6cb1d2e3f7 Lower bound must be a subtype of the upper bound.
The change in CommonSupertypes:

 We used to say that commonSupertype(Inv<A>, Inv<B>) = Inv<in Intersect(A, B)). This is counter-intuitive, should be Inv<out commonSupertype(A, B)>
2014-10-13 15:37:56 +04:00
Andrey Breslav
e232697da1 CommonSupertypes support for flexible types 2014-10-13 15:37:55 +04:00
Andrey Breslav
583694a450 Flexible types for primitive arrays 2014-10-13 15:37:54 +04:00
Andrey Breslav
8134d097e3 Another portion of test data fixed 2014-10-13 15:37:54 +04:00
Andrey Breslav
a3d9ff65aa Wrong "USELESS_ELVIS" fixed 2014-10-13 15:37:54 +04:00
Andrey Breslav
c3c72fc528 Switching off propagation of types and KotlinSignatures for platform types 2014-10-13 15:37:53 +04:00
Andrey Breslav
fefadaa171 Rendering platform type for java.util.Map.Entry as kotlin.(Mutable)Map.(Mutable)Entry 2014-10-13 15:37:53 +04:00
Andrey Breslav
dd2e95b3bc Substitution implemented for flexible occurrences of Java type parameters 2014-10-13 15:37:52 +04:00
Andrey Breslav
bf53222bd9 Flexible types in SAM conversions 2014-10-13 15:37:51 +04:00
Andrey Breslav
2529bb24d1 Don't create flexible types for ".class" expressions in annotation arguments 2014-10-13 15:37:51 +04:00
Andrey Breslav
c699fa96d9 Make not-null compile-time constants non-flexible 2014-10-13 15:37:51 +04:00
Andrey Breslav
867956729b Don't create platform types for annotation members 2014-10-13 15:37:50 +04:00
Andrey Breslav
bdf7e924b5 Rendering flexible types with "!" and optional parts 2014-10-13 15:37:50 +04:00
Andrey Breslav
c2a03d60f0 Better support for forced resolve while debugging 2014-10-13 15:37:49 +04:00
Andrey Breslav
b4f26bde44 Support forced resolve for lazy flexible types 2014-10-13 15:37:49 +04:00
Andrey Breslav
549df3c0eb Equality for flexible types 2014-10-13 15:37:48 +04:00
Andrey Breslav
a39d2bc24f Failing test isolated 2014-10-13 15:37:48 +04:00
Andrey Breslav
b665a1998b Supertypes should not be flexible 2014-10-13 15:37:47 +04:00
Andrey Breslav
0cbbb6a0db Test data fixed 2014-10-13 15:37:47 +04:00
Andrey Breslav
195274370f Fix the case of safe call and elvis operators: flexible types may be nullable 2014-10-13 15:37:46 +04:00
Andrey Breslav
45c1fa3741 Support flexible types in DataFlowValues 2014-10-13 15:37:46 +04:00
Andrey Breslav
f7de0e274c TypeSubstitutor respects flexible types 2014-10-13 15:37:45 +04:00
Andrey Breslav
f11095b1d0 Minor. DelegatingFlexibleType moved to top level 2014-10-13 15:37:45 +04:00
Andrey Breslav
687fdce30a Support flexible types in TypeCheckingProcedure 2014-10-13 15:37:44 +04:00
Andrey Breslav
a2f8def1e8 Tests for Java method calls 2014-10-13 15:37:44 +04:00
Andrey Breslav
6c50e1b237 Render flexible types in debug mode 2014-10-13 15:37:43 +04:00
Andrey Breslav
90e4b09272 Fix compilation errors 2014-10-13 15:37:43 +04:00
Andrey Breslav
e268e74fa3 Flexible types added to JDR
So far they act exactly like inflexible ones
2014-10-13 15:37:42 +04:00
Andrey Breslav
ad8de070fa A flag in the JDR to govern usage of platform types 2014-10-13 15:37:42 +04:00
Michael Bogdanov
a88e9666e4 As designed KT-5930: Wrong execution order in case of extension function
#KT-5930 As Designed
2014-10-13 11:31:15 +04:00
Michael Bogdanov
5abc2dac4e Generate labeled statements as statements 2014-10-13 11:31:15 +04:00
Michael Bogdanov
9d72036ba5 Fix for KT-5995: Labeled val causes an exception from the back-end
#KT-5995 Fixed
2014-10-13 11:30:28 +04:00
Michael Bogdanov
860544d299 Obsolete KT-5685: VerifyError: Bad local variable type for class with inline method and optional parameters
#KT-5685 Obsolete
2014-10-11 13:53:43 +04:00
Michael Bogdanov
605c9f48b4 Added inline annotation check on local funs 2014-10-11 13:53:43 +04:00
Michael Bogdanov
2a1520228e Support inheritance from java 8 interfaces
#KT-5969 In Progress
2014-10-11 13:53:43 +04:00
Andrey Breslav
3613fb746c Readme.md: Broken links fixed 2014-10-10 23:03:38 +04:00
Pavel V. Talanov
ebbd08a546 Respect resolve scope when adapting java types completion
Do not suggest classes from unrelated modules
2014-10-10 21:14:30 +04:00
Pavel V. Talanov
b6d76157c4 Respect source/test roots when building scope in CompletionSession 2014-10-10 21:14:29 +04:00
Pavel V. Talanov
2ded7bae73 Test abstract override in enum class 2014-10-10 18:19:57 +04:00
Pavel V. Talanov
b2c288b62a Test super calls in enum literals 2014-10-10 18:12:56 +04:00
Pavel V. Talanov
8e6618920d Minor: rename test data file 2014-10-10 18:05:36 +04:00
Pavel V. Talanov
bb5998048f Test code generation for enum deriving from a trait 2014-10-10 17:43:33 +04:00
Pavel V. Talanov
c04b52561e "abstract" modifier on enum class is an error
#KT-3454 Fixed
2014-10-10 17:43:32 +04:00
Pavel V. Talanov
6eae62c235 Do not report NON_FINAL_MEMBER_IN_FINAL_CLASS on open members in enum classes 2014-10-10 17:43:32 +04:00
Pavel V. Talanov
4136c80358 Do not report ABSTRACT_MEMBER_NOT_IMPLEMENTED on enum classes
Partial fix of KT-3454
2014-10-10 17:43:31 +04:00
Pavel V. Talanov
e703de5796 Minor: add diagnostic test for entries in enum with abstract members 2014-10-10 17:43:31 +04:00
Michael Nedzelsky
12e76f3d04 JS backend: test for KT-2901: nullable type in string template 2014-10-10 17:04:18 +04:00
Pavel V. Talanov
e7cd4bf6cf Implement modificationTracker for CompositeDiagnostics
#KT-5981 Fixed
2014-10-10 16:46:05 +04:00
Evgeny Gerashchenko
75853e3aad Saving only class files into incremental cache.
Fixed exception for JS modules.
2014-10-10 16:24:03 +04:00
Evgeny Gerashchenko
fa70192f75 Added test for EA-49318. 2014-10-10 16:00:27 +04:00
Evgeny Gerashchenko
ad1b460bea Clarified assert for EA-45243. 2014-10-10 16:00:26 +04:00
Evgeny Gerashchenko
27238a470a Minor. Removed redundant cast. 2014-10-10 16:00:26 +04:00
Evgeny Gerashchenko
9829fd83a0 Fixed EA-45529. 2014-10-10 16:00:26 +04:00
Evgeny Gerashchenko
0137b7ec3c Clarified assertion for EA-45529. 2014-10-10 16:00:25 +04:00
Evgeny Gerashchenko
38514673bf Clarified assertion for EA-53060. 2014-10-10 16:00:25 +04:00
Evgeny Gerashchenko
556b76d9a4 Made it possible to patch IDEA by adding class to idea_runner module.
See confluence page for details: http://confluence.jetbrains.com/display/JET/How+to+patch+IDEA+for+Kotlin
2014-10-10 16:00:24 +04:00
Nikolay Krasko
9cdea0479c Update to IDEA 139.1.20 2014-10-10 12:56:53 +04:00
Pavel V. Talanov
2fc2c73374 Test mutable diagnostics 2014-10-09 20:32:56 +04:00
Pavel V. Talanov
19ec9f9eda Introduce MutableDiagnosticsWithSuppression and use it in BindingTrace implementations
Exposes the fact that Diagnostics is in fact a mutable entity with readonly API
Update readonly view when diagnostics are modified
Allows to avoid recreating DiagnosticsWithSuppression every time getDiagnostics() is called in DelegatingBindingTrace
  which led to severe performance issues for large files with lots of diagnostics
2014-10-09 20:32:55 +04:00
Pavel V. Talanov
d7c06f0527 Default implementations for some functions in Diagnostics 2014-10-09 20:32:54 +04:00
Pavel V. Talanov
b98f000c29 Prevent external change in SimpleDiagnostics and convert to Kotlin 2014-10-09 20:32:54 +04:00
Pavel V. Talanov
ec077d5f8f Minor: rename DiagnosticHolder -> DiagnosticSink 2014-10-09 20:32:53 +04:00
Michael Nedzelsky
e5bbc2a0d8 JS backend: support for Throwable.getMessage 2014-10-09 19:32:00 +04:00
Alexey Tsvetkov
5649797461 JS backend: catch fix refactoring 2014-10-09 19:31:57 +04:00
Michael Nedzelsky
787b8f72c5 JS backend: fix KT-5603 (Multiple catch): support for multiply catch clauses 2014-10-09 19:31:54 +04:00
Michael Nedzelsky
b15963d3fb JS backend: fix KT-5603 (Multiple catch): add tests 2014-10-09 19:31:51 +04:00
Natalia Ukhorskaya
1ce3ddaa82 Minor add message for class cast
EA-59672
2014-10-09 19:18:25 +04:00
Natalia Ukhorskaya
da96385f00 J2K: initialize NotNullManager 2014-10-09 19:18:23 +04:00
Natalia Ukhorskaya
141c88aaa9 Make ReferenceSearcher a parameter for JavaToKotlinConverter 2014-10-09 19:18:21 +04:00
Natalia Ukhorskaya
db86ade5fb Evaluate expression: add readAction during file analysis 2014-10-09 19:17:24 +04:00
Natalia Ukhorskaya
1055aa86aa Debugger tests: do not check breakpoint line and file extension for JDK classes 2014-10-09 19:17:23 +04:00
Michael Bogdanov
1944f75802 Skip default methods on single abstract method search
Fix for KT-4886: SAM conversion doesn't work for interfaces with default methods

  #KT-4886 Fixed
2014-10-09 17:15:46 +04:00
Nikolay Krasko
062dda89ea Add dumb mode for building run configuration
#EA-61442
2014-10-09 15:21:15 +04:00
Natalia Ukhorskaya
f9f4aefb2a Evaluate expression: check for errors before running extract function for code fragment 2014-10-09 13:48:39 +04:00
Natalia Ukhorskaya
410d5deb1c Evaluate expression: add runAction EA-61399 Fixed 2014-10-09 13:48:37 +04:00
Natalia Ukhorskaya
e613e3523e Minor: fix warnings 2014-10-09 13:46:23 +04:00
Natalia Ukhorskaya
e125375654 Evaluate expression: change message when extracted function is null 2014-10-09 13:46:22 +04:00
Natalia Ukhorskaya
f5c08c4868 Evaluate expression: add message for multiple output error from extract function 2014-10-09 13:46:21 +04:00
Natalia Ukhorskaya
f45baa9dbe Fix EA-60953 - NPE: CodeInsightUtils.findElementsOfClassInRange 2014-10-09 13:46:20 +04:00
Michael Bogdanov
d4307c69d2 Fix for KT-4301: Too many StringBuilders on string concatenations
#KT-4301 Fixed
2014-10-09 12:23:06 +04:00
Michael Bogdanov
4a078c1143 Temporary disable local fun inlining (it's not supported now) 2014-10-09 10:38:14 +04:00
Nikolay Krasko
ecb293bd6c Add context information about assert (EA-60850) 2014-10-09 02:28:48 +04:00
Nikolay Krasko
4b197aafa4 Abandon storing BindingContext in JetFunctionPsiElementCellRenderer
#EA-61357 Fixed
2014-10-09 02:28:47 +04:00
Nikolay Krasko
1143db85f1 Refactoring: move method to utility and don't create intermediate kotlin scope 2014-10-09 02:28:47 +04:00
Nikolay Krasko
3ea2d420b2 Refactoring: rename methods 2014-10-09 02:28:46 +04:00
Nikolay Krasko
6c9538b040 Share check "is file under source roots" 2014-10-09 02:28:45 +04:00
Nikolay Krasko
3e4888afa7 Refactoring: remove usages with default value from overload 2014-10-09 02:28:45 +04:00
Nikolay Krasko
7bf84ec84c Refactoring: rename method and hide information about gradle 2014-10-09 02:28:44 +04:00
Nikolay Krasko
a7fbc1bc6c Always check kotlin file is in correct source root for gradle modules 2014-10-09 02:28:44 +04:00
Nikolay Krasko
a29773597e Convert to Kotlin 2014-10-09 02:28:43 +04:00
Nikolay Krasko
b172709008 Refactoring: move file 2014-10-09 02:28:42 +04:00
Nikolay Krasko
e85b36cdff Store resolution context for light classes to prevent back-end fail 2014-10-09 02:28:41 +04:00
Nikolay Krasko
ad6a0c4b72 Add information about declaration 2014-10-09 02:28:41 +04:00
Nikolay Krasko
50265c311e Don't do resolve for files not under sorce roots 2014-10-09 02:28:40 +04:00
Evgeny Gerashchenko
181b10103f Incremental compilation checkbox in settings.
Old setting via VM option is automatically migrated to "new style".
2014-10-08 20:09:18 +04:00
Evgeny Gerashchenko
514a41ac77 Minor. Moved dialog title from code to GUI settings. 2014-10-08 17:22:31 +04:00
Evgeny Gerashchenko
e554c9f53d Converted CompilerSettings to Kotlin. 2014-10-08 17:22:31 +04:00
Zalim Bashorov
c7e0e3d391 Replace js.translator with js.frontend in dependencies of idea module and remove js.translator from KotlinPlugin artifact. 2014-10-08 15:55:06 +04:00
Zalim Bashorov
401d9ac831 Minor: add js.inliner sources to kotlin-for-upsource-sources.jar 2014-10-08 15:54:49 +04:00
Valentin Kipyatkov
05aaea48e9 Added API in PSI to add/remove modifiers and refactored quickfixes to use it 2014-10-08 15:41:48 +04:00
Valentin Kipyatkov
12b7d218b7 Simplified quickfix code 2014-10-08 15:41:48 +04:00
Valentin Kipyatkov
93efcd637e JetParameter made JetCallableDeclaration 2014-10-08 15:41:47 +04:00
Valentin Kipyatkov
852fc8bc5d More renames of TypeRef to TypeReference 2014-10-08 15:41:47 +04:00
Valentin Kipyatkov
31ebee81f0 JetVariableDeclaration made JetCallableDeclaration and renamed getTypeRef/setTypeRef, getReturnTypeRef/setReturnTypeRef to getTypeReference/setTypeReference 2014-10-08 15:41:47 +04:00
Valentin Kipyatkov
c42b7b1780 Minor refactorings in ChangeMemberFunctionSignatureFix 2014-10-08 15:41:47 +04:00
Valentin Kipyatkov
b26e6665b0 JetChangeFunctionSignatureAction made nested class of quickfix class (and it does not need to be QuestionAction!) 2014-10-08 15:41:47 +04:00
Valentin Kipyatkov
61221382b5 Inlined CodeInsightUtils.createFunctionSignatureStringFromDescriptor() 2014-10-08 15:41:46 +04:00
Valentin Kipyatkov
b5722c9470 More correct code for adding type specification to function declaration with no parameter list 2014-10-08 15:41:46 +04:00
Valentin Kipyatkov
cc3ca57b75 Minor code editings 2014-10-08 15:41:46 +04:00
Michael Bogdanov
41c4c3befd Fix test data for KT-3285 2014-10-08 09:34:50 +04:00
nik
11d02e5485 use standard UnsupportedOperationException instead of NotImplementedException from internal packages 2014-10-07 20:57:47 +04:00
Evgeny Gerashchenko
b80f82dffd Fixed filename case. 2014-10-07 20:57:05 +04:00
Pavel V. Talanov
33cdefffe3 Do not log ProcessCanceledException in copy paste reference processor
It is rethrown and leads to inability to copy code

 #KT-5426
2014-10-07 19:28:49 +04:00
Michael Bogdanov
f8052817a8 Rollback some changes in MutableClosure 2014-10-07 18:43:29 +04:00
Ilya Ryzhenkov
759e42188b Update TeamCity links to https, replace link to confluence with link to kotlinlang.org. 2014-10-07 17:59:02 +04:00
Evgeny Gerashchenko
b062548392 Expanded and simplified test for generating bridges in sam conversions. 2014-10-07 17:48:17 +04:00
Ilya Ryzhenkov
72f96cd55c Generate bridges when creating SAM wrapper not from closure. 2014-10-07 17:48:17 +04:00
Michael Bogdanov
6bcb2e9001 Temporary fix for KT-5912
#KT-5912 Fixed
2014-10-07 17:48:17 +04:00
Michael Bogdanov
6b336be10c Obsolete KT-1776: Can't resolve members of auto-casted "this" in extension without typing "this" explicitly
#KT-1776 Obsolete
2014-10-07 17:21:11 +04:00
Michael Bogdanov
278e682595 Obsolete KT-3285: "A receiver of type ... is required" when using extension functions
#KT-5467 Obsolete
2014-10-07 17:21:11 +04:00
Michael Bogdanov
bb3f1f1fb7 Fix for KT-5467: JVM codegen doesn't support capture of many extension receivers
#KT-5467 Fixed
2014-10-07 17:21:10 +04:00
Michael Bogdanov
c3cfe33b64 Fix for KT-5495: Support method implementations in local traits
#KT-5495 Fixed
2014-10-07 17:21:10 +04:00
Michael Bogdanov
212d3da950 Fix for KT-5937: Receiver of javaClass-property hasn't been generated
#KT-5937 Fixed
2014-10-07 17:21:10 +04:00
Pavel V. Talanov
1e9718f55b Do not try to copy references in dumb mode
#KT-4766 Fixed
2014-10-07 16:43:32 +04:00
Zalim Bashorov
23fa0ba6ab Refactoring kotlin-maven-plugin:
* cleanup KotlinCompileMojoBase moved JVM specific things to KotlinCompileMojo;
* add support noInline in JS.
2014-10-07 16:32:07 +04:00
Zalim Bashorov
d986b0e565 Ant buildtools: added base class for Kotlin compiler ant tasks.
As side effect:
 - used cli compiler in both ant tasks.
 - got the ability to use custom args in JS ant task too.
2014-10-07 16:32:07 +04:00
Nikolay Krasko
dc97cdb51c Fix test 2014-10-07 13:34:55 +04:00
Natalia Ukhorskaya
1904955c82 Android support: implement extension for OutputParser 2014-10-07 12:15:52 +04:00
Natalia Ukhorskaya
824d79c934 Android-support: implement OutputParser 2014-10-07 12:15:52 +04:00
Natalia Ukhorskaya
ffe8ae3840 kotlin-gradle-plugin: change output format 2014-10-07 12:15:51 +04:00
Natalia Ukhorskaya
dd0642e0fc Add module for kotlin-android-plugin and optional dependency on android plugin 2014-10-07 12:15:50 +04:00
Michael Bogdanov
d0d207f387 Fix for KT-3584: Wrong bytecode generated for local class with default parameters and captured local val
#KT-3584 Fixed
2014-10-07 10:13:53 +04:00
Michael Bogdanov
989cae9f1f Fix for KT-4357: Compiler error with infix call to Array.get
#KT-4357 Fixed
2014-10-07 10:13:53 +04:00
Michael Bogdanov
7be48c7336 Support move on depth 2 2014-10-07 10:13:52 +04:00
Michael Bogdanov
e6c98078b3 Fixes for KT-4733 UnsupportedOperationException: don't know how to move type J to top of stack; KT-3430 VerifyError on a safe call to a primitive value
#KT-4733 Fixed
  #KT-3430 Fixed
2014-10-07 10:13:52 +04:00
Michael Nedzelsky
8cafea9f5a JS backend: add generateTraitMethods into ClassTranslator 2014-10-07 08:37:35 +04:00
Michael Nedzelsky
6d1b89bba3 JS backend: support for bridge methods 2014-10-07 08:37:27 +04:00
Michael Nedzelsky
541786a4db JS backend: extract generateDelegateCall from DelegationTranslator into utils 2014-10-07 08:37:23 +04:00
Michael Nedzelsky
df15e4767b extract getTraitMethods from ImplementationBodyGen to CodegenUtil 2014-10-07 08:37:20 +04:00
Michael Nedzelsky
0c3a7a9d99 add more tests for bridge methods (fake override) 2014-10-07 08:37:18 +04:00
Michael Nedzelsky
2db1d128a0 JS backend: add ArrayList(Collection) into javautilCode.kt 2014-10-07 08:37:01 +04:00
Michael Nedzelsky
1e02064a5b JS backend: add javauitl.kt to bridges/_commonFiles 2014-10-07 08:36:54 +04:00
Michael Nedzelsky
04d8960a3d JS backend: add BridgeTestGenerated 2014-10-07 08:36:50 +04:00
Michael Nedzelsky
0dd17535d6 JS backend: add TARGET_BACKEND: ONLY_JVM for some tests for bridge methods 2014-10-07 08:36:46 +04:00
Michael Nedzelsky
bdc4d14f33 JS backend: improve test generator, support for backend header in test files 2014-10-07 08:36:43 +04:00
Michael Nedzelsky
03f673d6cf JS backend: add NotNull and Nullable annotations 2014-10-07 08:36:27 +04:00
Michael Nedzelsky
6f1d362917 JS backend: add getPackageName to BasicTest, checkBlackBox to SingleFileTranslationTest 2014-10-07 08:36:22 +04:00
Michael Nedzelsky
b84e5969e2 JS backend: fix get mangling name for generic methods with multiply upper bounds 2014-10-07 08:36:18 +04:00
Zalim Bashorov
9fabdf4587 JS backend: mangling functions for extension properties. 2014-10-06 23:18:54 +04:00
Zalim Bashorov
9b04e3e3fe JS backend: use all generic parameters in mangling 2014-10-06 23:18:54 +04:00
Zalim Bashorov
10a9c0a434 JS backend: move mangling functions to separate util class. 2014-10-06 23:18:53 +04:00
Zalim Bashorov
b5ee5877ce JS backend: kotlin_lib_compiled -> stdlib. 2014-10-06 23:18:53 +04:00
Zalim Bashorov
eec4bc7e04 Minor: fix compilation in IDEA 2014-10-06 23:18:53 +04:00
Zalim Bashorov
8f6b12d296 Fixed maven build 2014-10-06 23:18:53 +04:00
Zalim Bashorov
5a63e34c19 JS tests: fix testData files 2014-10-06 23:18:53 +04:00
Zalim Bashorov
9ac193407b Fixed JS test runner: save only stdlib module from run to run. 2014-10-06 23:18:53 +04:00
Zalim Bashorov
25172d797e JS tests: disable Rhino optimization by default. 2014-10-06 23:18:52 +04:00
Zalim Bashorov
20f20f9441 JS tests: refactored StdLibTestBase and derived classes. 2014-10-06 23:18:52 +04:00
Zalim Bashorov
b72b036bdb JS tests: refactored BasicTest class. 2014-10-06 23:18:52 +04:00
Zalim Bashorov
c8278fd887 JS backend: refactor Configs. 2014-10-06 23:18:52 +04:00
Zalim Bashorov
dd1fffae40 Minor in JS tests: load and cache kotlin_lib_compiled.js 2014-10-06 23:18:52 +04:00
Zalim Bashorov
ce4bbb906b JS tests: disabled linter. 2014-10-06 23:18:51 +04:00
Zalim Bashorov
36bad02e67 Minor in JS tests: cleanup RhinoFunctionResultChecker and dependent classes. 2014-10-06 23:18:51 +04:00
Zalim Bashorov
9290c3aad7 JS tests: HACK for use JsTestsAsserter in JS tests 2014-10-06 23:18:51 +04:00
Zalim Bashorov
7a51ef5723 Stdlib: fix build -- use named object instead of instance of Any because Any not mapped yet in JS backend. 2014-10-06 23:18:51 +04:00
Zalim Bashorov
c142253fb9 JS stdlib: droped unnecessary jutilCode.kt 2014-10-06 23:18:51 +04:00
Zalim Bashorov
9827a5a21d Minor in JS stdlib: fix annotations.kt 2014-10-06 23:18:51 +04:00
Zalim Bashorov
23151936b6 JS stdlib: added volatile and synchronized. 2014-10-06 23:18:50 +04:00
Zalim Bashorov
80294f53ad JS stdlib: drop TuplesCode.kt -- switch to use tuples from stdlib. 2014-10-06 23:18:50 +04:00
Zalim Bashorov
0cac7c32b6 Stdlib: Deprecated.kt splitted to common and jvm parts. 2014-10-06 23:18:50 +04:00
Zalim Bashorov
3bc80a6d05 Stdlib: Char.kt splitted to common and jvm parts. 2014-10-06 23:18:50 +04:00
Zalim Bashorov
d7dfbe40a4 Stdlib: moved CharSequence.size and String.size to StringJVM.kt because they are intrinsic in JS. 2014-10-06 23:18:50 +04:00
Zalim Bashorov
4ba4484683 Stdlib: moved setOf and linkedListOf from JUtilJVM.kt to JUtil.kt. 2014-10-06 23:18:49 +04:00
Zalim Bashorov
5b80eef381 Added ant step for compilation Kotlin stdlib to JS. 2014-10-06 23:18:49 +04:00
Valentin Kipyatkov
5ae756addb Quickfix to correct signature of method with 'override' to not include 'override' in signature text 2014-10-06 21:26:55 +04:00
Valentin Kipyatkov
317607db70 Corrected quickfix to correct signature of method with 'override' to:
- not loose annotations and other stuff
  - not include visibility modifiers into the name and into the code generated
2014-10-06 21:26:55 +04:00
Valentin Kipyatkov
89ea4d5a85 More quickfixes to use API for setting type ref 2014-10-06 21:26:55 +04:00
Valentin Kipyatkov
d876e85eb2 Added API for changing type ref for function/variable and refactored code in some quickfixes to use it 2014-10-06 21:26:55 +04:00
Valentin Kipyatkov
2036b87ccf Deleted strange unused method 2014-10-06 21:26:55 +04:00
Evgeny Gerashchenko
6e8002138e Made Kotlin available for IDEA 140.* (trunk after 14.0) 2014-10-06 20:03:58 +04:00
Evgeny Gerashchenko
dd0436cd3a Updated base URL for jb_update_continuous_local.
It wasn't updated on time when Kotlin was transferred from IDEA 13 to 14.
2014-10-06 19:17:31 +04:00
Nikolay Krasko
44b8e22bef More tests for generating methods from different caret positions 2014-10-06 17:53:10 +04:00
Nikolay Krasko
3c6566c1b1 Auto generate "after"-file if it's not present 2014-10-06 17:53:08 +04:00
Nikolay Krasko
60a7a57e65 Auto insert caret and selection to "after" file 2014-10-06 17:53:07 +04:00
Nikolay Krasko
27b654cc50 Refactoring: rename and make public 2014-10-06 17:53:05 +04:00
Nikolay Krasko
c05d30de38 Refactoring: extract method 2014-10-06 17:53:03 +04:00
Nikolay Krasko
774af134fa Move caret to generated element and add selection 2014-10-06 17:53:02 +04:00
Nikolay Krasko
a50720d74d Remove rest of whitespace on override or implement to insert generated at caret offset 2014-10-06 17:53:00 +04:00
Nikolay Krasko
03d1c64d27 KT-5103 No delegated members in Override/Implement
#KT-5103 Fixed
2014-10-06 17:52:41 +04:00
Nikolay Krasko
a0404b11b0 Refactoring: use resolve session instead of binding context 2014-10-06 17:52:33 +04:00
Nikolay Krasko
c80cdb4790 getContainingFile() and getProject() have to be executed under read lock 2014-10-06 15:27:01 +04:00
Alexey Sedunov
74242a5fd9 Move: Updated test data (functions/properties are not imported by default) 2014-10-06 14:23:50 +04:00
Alexey Sedunov
1353e7f56b Find Usages: Disable by-convention search of invoke(). Improve scanner
accuracy when indexing possible references to component functions
2014-10-06 14:23:49 +04:00
Pavel V. Talanov
5e6619e368 Increase LibraryModificationTracker when external annotations are changed
Library cache is dropped when there are changes to external annotations
2014-10-03 21:35:11 +04:00
Pavel V. Talanov
95302fd540 Fix not generating KotlinLightField for OBJECT$ and INSTANCE$ fields
Fix navigation from Java to such fields
Fix TODO in converter
2014-10-03 21:35:06 +04:00
Pavel V. Talanov
b2ec5e1ec4 Test reference resolve from Java to Kotlin
Cases cover the most basic features
Sadly it was missing before
2014-10-03 21:35:00 +04:00
Pavel V. Talanov
af963ea244 Fix being unable to find declaration for substituted callable from library
#KT-5900 Fixed
#KT-5901 Fixed
2014-10-03 21:33:18 +04:00
Pavel V. Talanov
8f52f71378 Remove warn on performing analysis from dispatch thread
This is outdated since lazy resolve can be called from dispatch thread (Intentions do it)
2014-10-03 21:33:18 +04:00
Pavel V. Talanov
8db599c68a Convert Java file to Kotlin: do not ask whether to backup files
Do not backup files

 #KT-5530 Fixed
2014-10-03 21:33:17 +04:00
Alexey Sedunov
be2713b59c Minor: Rename CreateFunctionFromUsageFix -> CreateCallableFromUsageFix 2014-10-03 20:18:45 +04:00
Alexey Sedunov
ae7c5e1323 Create From Usage: Do not fail on qualifier receiver when it doesn't have type 2014-10-03 20:18:44 +04:00
Alexey Sedunov
b680b74ecb Create From Usage: Do not suggest list of type candidates when there is at most one 2014-10-03 20:18:43 +04:00
Alexey Sedunov
5ade563902 Create From Usage: Join local "vars" with their initializers 2014-10-03 20:18:43 +04:00
Alexey Sedunov
865c793561 Create From Usage: Do not suggest "val" for references used as assignment left-hand side 2014-10-03 20:18:42 +04:00
Alexey Sedunov
58126b28ca Create From Usage: Quick-fix for properties 2014-10-03 20:18:41 +04:00
Alexey Sedunov
8386bcd4e0 Create Local Variable From Usage: Support lambdas 2014-10-03 20:18:39 +04:00
Alexey Sedunov
6ad2157806 Create From Usage: Quick-fix for value parameters 2014-10-03 20:18:39 +04:00
Alexey Sedunov
73fc984c4c Change Signature: Fix detection of conflicts in generic classes 2014-10-03 20:18:37 +04:00
Michael Bogdanov
609caa8159 Clean 2014-10-03 17:24:15 +04:00
Michael Bogdanov
15043b3c6d Fixes for KT-4991: Prefix/postfix expressions resolved to local extensions are not supported in codegen;
KT-4989: Verify error on local functions and extensions;
KT-4987: NegativeArraySizeException on local extension convention function on nullable Int

  #KT-4991 Fixed
  #KT-4989 Fixed
  #KT-4987 Fixed
2014-10-03 17:24:14 +04:00
Michael Bogdanov
0c11ca680e Fix for KT-3969: Codegen fails on unary calls with default arguments
#KT-3969 Fixed
2014-10-03 17:24:14 +04:00
Alexey Tsvetkov
d61352c8f3 JS inline: assignment binary operation is not side-effect free 2014-10-03 14:23:57 +04:00
Alexey Tsvetkov
a795ee6218 JS backend minor: added @NotNull annotation to JsBinaryOperation's getOp() 2014-10-03 14:23:57 +04:00
Alexey Tsvetkov
8a607ce9be Minor test: added config argument 2014-10-03 14:23:57 +04:00
Alexey Tsvetkov
436fc33e84 Minor testData: fixed -Xno-inline option at extraHelp.out 2014-10-03 14:23:57 +04:00
Alexey Tsvetkov
48bd71e0b6 JS inline minor: removed unused parameter 2014-10-03 14:23:57 +04:00
Alexey Tsvetkov
f022cd6281 JS backend: restored old label naming strategy 2014-10-03 14:23:57 +04:00
Alexey Tsvetkov
886ae36e1f JS backend: removed nullable parameters
Since JsScope declareName() parameter became NotNull
2014-10-03 14:23:57 +04:00
Alexey Tsvetkov
0eedb0dc6b JS backend: added @NotNull annotation to JsNameRef's getIdent() and constructor parameters 2014-10-03 14:23:56 +04:00
Alexey Tsvetkov
89d74d94c9 JS backend: added @NotNull annotation to JsName's getIdent() 2014-10-03 14:23:56 +04:00
Zalim Bashorov
3b9232e8d4 Drop extra fields which covered by metadata: hasDefaultValue from JsParameter. 2014-10-03 14:23:56 +04:00
Zalim Bashorov
aa6ab1ffee Drop extra fields which covered by metadata: isLocal from JsFunction. 2014-10-03 14:23:56 +04:00
Zalim Bashorov
afdec6ecc4 Drop extra fields which covered by metadata: inlineStrategy from JsInvocation. 2014-10-03 14:23:56 +04:00
Zalim Bashorov
b5ab6cbad0 Drop extra fields which covered by metadata: staticRef from JsName. 2014-10-03 14:23:56 +04:00
Zalim Bashorov
d16ddd081a JS backend: copy metdata when copy node. 2014-10-03 14:23:56 +04:00
Zalim Bashorov
1c5338ccf7 JS backend: added the ability to add metadata to js nodes. 2014-10-03 14:23:55 +04:00
Zalim Bashorov
03539c1945 Minor: removed unused ChameleonJsExpression. 2014-10-03 14:23:55 +04:00
Zalim Bashorov
4816e391ff Minor in JS backend: moved js.inliner to "compiler/js" group and added descriptors to its dependencies. 2014-10-03 14:23:55 +04:00
Alexey Tsvetkov
d3fce0d0ec JS inline return statements after top return 2014-10-03 14:23:55 +04:00
Alexey Tsvetkov
7a8ba9c733 JS backend refactor: refactored LiteralFunctionTranslator after code review 2014-10-03 14:23:55 +04:00
Alexey Tsvetkov
c47732e7eb JS inline minor: optimized imports 2014-10-03 14:23:55 +04:00
Alexey Tsvetkov
64982aa72e JS backend minor: made CALL_FUNCTION constant public 2014-10-03 14:23:54 +04:00
Alexey Tsvetkov
d6f8aa6f03 JS backend minor: made undefined expression static field 2014-10-03 14:23:54 +04:00
Alexey Tsvetkov
fb475775c9 JS inline minor: inlined doDirectInline() 2014-10-03 14:23:54 +04:00
Alexey Tsvetkov
6018b103cc JS inline refactor: splitted Renaming.kt 2014-10-03 14:23:54 +04:00
Alexey Tsvetkov
17a78dd522 JS inline refactor: moved invocation and function utils to separate files 2014-10-03 14:23:54 +04:00
Alexey Tsvetkov
7fbed5ee86 JS inline refactor: extracted flattenStatement() function 2014-10-03 14:23:54 +04:00
Alexey Tsvetkov
80eca3e49e JS inline refactor: refactored clean utils after code review 2014-10-03 14:23:53 +04:00
Alexey Tsvetkov
1ad090e3a7 JS inline refactor: moved contexts to 'context' package 2014-10-03 14:23:53 +04:00
Alexey Tsvetkov
cd9349deb7 JS inline refactor: moved JS AST collecting utils to 'collectors' package 2014-10-03 14:23:53 +04:00
Alexey Tsvetkov
86c253ef6d JS inline refactor: moved JS AST modifying utils to 'rewriters' package 2014-10-03 14:23:53 +04:00
Alexey Tsvetkov
d3a8f78a88 JS inline minor: moved JsInliningContext definition to the bottom of JsInliner 2014-10-03 14:23:53 +04:00
Zalim Bashorov
0e075c7d5f JS backend: added the ability to turn off the inline optimization. 2014-10-03 14:23:53 +04:00
Alexey Tsvetkov
338789664c JS inline: use inlined function name for inline labels 2014-10-03 14:23:53 +04:00
Alexey Tsvetkov
cbb9e9c40e JS inline: inline simple-return functions directly 2014-10-03 14:23:52 +04:00
Alexey Tsvetkov
da817e7ed2 JS inline: use dfs processing order, as it is independent of declaration order 2014-10-03 14:23:52 +04:00
Alexey Tsvetkov
a5688440a1 JS inline: added inline recursion exception 2014-10-03 14:23:52 +04:00
Alexey Tsvetkov
5aaa186180 JS inline: remove unused function literals and local functions 2014-10-03 14:23:52 +04:00
Alexey Tsvetkov
ec6108ee05 JS inline: remove unused local function instances 2014-10-03 14:23:52 +04:00
Alexey Tsvetkov
7f98ceb427 JS inline: common reference utilities for cleaning up after inline 2014-10-03 14:23:52 +04:00
Alexey Tsvetkov
ddb3157a58 JS inline: added collections utils 2014-10-03 14:23:52 +04:00
Alexey Tsvetkov
c78169d236 JS inline: support inline local functions 2014-10-03 14:23:51 +04:00
Alexey Tsvetkov
1dafa79eaf JS inline: prevent inliner from inlining multiple subexpressions at once 2014-10-03 14:23:51 +04:00
Alexey Tsvetkov
87d108e75e JS inline: default parameter processing for inlined functions
When function is inlined initializers
for default parameters can be:
1. removed  if argument is not `void 0`
2. expanded otherwise
2014-10-03 14:23:51 +04:00
Alexey Tsvetkov
1f68b43558 JS inline: support inline extension functions 2014-10-03 14:23:51 +04:00
Alexey Tsvetkov
78e7b9c32b JS inline: replace returns with result variable assignment and break 2014-10-03 14:23:51 +04:00
Alexey Tsvetkov
667a22f84e JS inline: alias arguments and local variables 2014-10-03 14:23:51 +04:00
Alexey Tsvetkov
49718f143b JS inline: create JsInliningContext per function processed by JsInliner 2014-10-03 14:23:51 +04:00
Alexey Tsvetkov
0151b7a2d1 JS inline: added inlining context utilities 2014-10-03 14:23:50 +04:00
Alexey Tsvetkov
f29816f19c JS inline: added invocation utils 2014-10-03 14:23:50 +04:00
Alexey Tsvetkov
1aa55f3e54 JS inline: run JsInliner after AST is built 2014-10-03 14:23:50 +04:00
Alexey Tsvetkov
3c4125c233 JS inline: inline function calls 2014-10-03 14:23:50 +04:00
Alexey Tsvetkov
3c7677e73e JS inline: collect defined functions 2014-10-03 14:23:50 +04:00
Alexey Tsvetkov
2e38833367 JS inline: save static ref to JsFunction in JsName 2014-10-03 14:23:50 +04:00
Alexey Tsvetkov
e4cd733879 JS inline: added JsInliner 2014-10-03 14:23:50 +04:00
Alexey Tsvetkov
60271201fc JS inline: added FunctionInlineMutator 2014-10-03 14:23:49 +04:00
Alexey Tsvetkov
2c443532c5 JS inline: added InlineableResult 2014-10-03 14:23:49 +04:00
Alexey Tsvetkov
3cdae252ef JS inline: save inline status during translation 2014-10-03 14:23:49 +04:00
Alexey Tsvetkov
efac671ae6 JS inline: removed legacy inline logic 2014-10-03 14:23:49 +04:00
Alexey Tsvetkov
f076ab8f54 JS backend: added deepCopy() method to JS AST nodes 2014-10-03 14:23:49 +04:00
Alexey Tsvetkov
b880775de5 JS backend: removed JsBlock toString() truncation
Truncation complicates debugging.
Some inline tests depend on functions strings  comparison.
2014-10-03 14:23:49 +04:00
Alexey Tsvetkov
28b3ed67c1 JS backend: made JsScope hasOwnName method public 2014-10-03 14:23:48 +04:00
Alexey Tsvetkov
2b6045af0f JS backend: made JsBlock statements list modifieable
Inliner should be able to add statements of inline function to JsBlock
2014-10-03 14:23:48 +04:00
Alexey Tsvetkov
53fe237499 JS backend: made JsInvocation arguments modifieable 2014-10-03 14:23:48 +04:00
Alexey Tsvetkov
96e5985ca9 JS backend: added NotNull annotation 2014-10-03 14:23:48 +04:00
Alexey Tsvetkov
d27b7b793f JS backend: break label should be JsNameRef, not String
The reason is to make it easier to distinguish
between different break labels (that's valid on same level).
JsNameRefs can be distinguished by their JsName.
2014-10-03 14:23:48 +04:00
Alexey Tsvetkov
915f8734c5 JS backend: added visitors with context 2014-10-03 14:23:48 +04:00
Alexey Tsvetkov
15e963de25 JS test: turn rhino optimization off for stdlib tests 2014-10-03 14:23:48 +04:00
Alexey Tsvetkov
3f2d4b31be JS test: added inline tests 2014-10-03 14:23:47 +04:00
Alexey Tsvetkov
987708680f JS test: JS AST access from tests 2014-10-03 14:23:47 +04:00
Alexey Tsvetkov
1dcc096753 JS test: removed legacy inline tests 2014-10-03 14:23:47 +04:00
Alexey Tsvetkov
0484df00c3 JS test: added test utils 2014-10-03 14:23:47 +04:00
Alexey Tsvetkov
a26e77fd93 JS inline: new module 2014-10-03 14:23:47 +04:00
Nikolay Krasko
555119f59a Exceptions during 'compute' in storage manager must be processed with exception strategy
#KT-5134 Fixed
2014-10-02 23:37:49 +04:00
Valentin Kipyatkov
bbc2d30f60 KT-4849 'Join lines' should remove braces from single-statement block
#KT-4849 Fixed
2014-10-02 18:26:07 +04:00
Valentin Kipyatkov
53983774d0 Moved and renamed class + added check for JetFile 2014-10-02 18:26:07 +04:00
Valentin Kipyatkov
593e93b88b Moved code from DeclarationUtils and refactored code 2014-10-02 18:26:07 +04:00
Valentin Kipyatkov
d71c481606 Moved test data 2014-10-02 18:26:06 +04:00
Valentin Kipyatkov
8cb631d6f8 Better way of changing property intiailizer used 2014-10-02 18:26:06 +04:00
Valentin Kipyatkov
c0db84331e Fixed bug in join lines 2014-10-02 18:26:06 +04:00
Valentin Kipyatkov
c6f10ea219 Moved some code from DeclarationUtils to JetDeclarationJoinLinesHandler and refactored it 2014-10-02 18:26:06 +04:00
Valentin Kipyatkov
879f0d201e Converted JetDeclarationJoinLinesHandler to Kotlin 2014-10-02 18:26:06 +04:00
Evgeny Gerashchenko
c7633a5266 Added workaround for auto-ungzipping when downloading in Ant 1.9.4. 2014-10-02 11:48:09 +04:00
Evgeny Gerashchenko
498d1d5cf8 Updating regexp for finding URL of IDEA EAP. 2014-10-02 11:48:09 +04:00
Svetlana Isakova
ce01c61811 Rename: auto cast -> smart cast 2014-10-01 18:52:52 +04:00
Svetlana Isakova
20f3403c80 Rename: this object, receiver argument -> dispatch receiver, extension receiver 2014-10-01 18:52:51 +04:00
Svetlana Isakova
1d2d2f4845 KT-5873 Exception in ArgumentMatchImpl on smart completion
#KT-5873 Fixed
2014-10-01 18:52:51 +04:00
Nikolay Krasko
f0e7435254 A better heuristics is declaration implemented or overriden 2014-10-01 18:05:46 +04:00
Nikolay Krasko
bb7b4daef6 Drop isOverridableHeuristic and use isOverridable from utils instead 2014-10-01 18:05:45 +04:00
Nikolay Krasko
f76025710e Rewrite to Kotlin: overridden properties markers tooltip and navigation 2014-10-01 18:05:43 +04:00
Nikolay Krasko
bc5f28d9fd Refactoring: rename KotlinLightMethodFromTrait -> KotlinLightMethodForTraitFakeOverride 2014-10-01 18:05:38 +04:00
Nikolay Krasko
5c6d74af7d Test for "Incorrect override icon shown for overloaded methods" (KT-4428)
#KT-4428 Fixed
2014-10-01 18:03:02 +04:00
Nikolay Krasko
9de0e8c9fd Refactoring: rename file 2014-10-01 18:03:01 +04:00
Nikolay Krasko
54b2e994e1 Refactoring: move utils methods 2014-10-01 18:02:59 +04:00
Nikolay Krasko
260f9fb634 Rewrite to Kotlin: rewrite methods for markers on overridden declarations 2014-10-01 18:02:58 +04:00
Nikolay Krasko
7bf622dd26 Rewrite to Kotlin: super navigation markers methods 2014-10-01 18:02:57 +04:00
Nikolay Krasko
f7edd5abe7 Show all line markers in slow pass as they all require resolve 2014-10-01 18:02:55 +04:00
Nikolay Krasko
236cdc7d82 Filter synthetic trait overrides for "overriding" markers too 2014-10-01 18:02:54 +04:00
Nikolay Krasko
897ebd0347 Linemarker tests 2014-10-01 18:02:52 +04:00
Nikolay Krasko
8ada9b68b0 Add special class for getting methods from traits 2014-10-01 18:02:31 +04:00
Nikolay Krasko
35c67734d3 Force function render use short qualified names 2014-10-01 17:58:58 +04:00
Nikolay Krasko
6aa5e53a00 Fix navigate to super declaration line marker tooltip
Don't show overridden function signature each time, show only where it's declared
2014-10-01 17:58:56 +04:00
Nikolay Krasko
6a714436f2 Make testable navigation from line markers for super declarations 2014-10-01 17:58:55 +04:00
Nikolay Krasko
7c0acd9da5 Navigate to sources from markers not to decompiled classes 2014-10-01 17:58:53 +04:00
Nikolay Krasko
dfe3062340 Auto insert acual line markers for failed tests 2014-10-01 17:58:52 +04:00
Nikolay Krasko
2d54139018 Refactoring: move method to utils 2014-10-01 17:58:51 +04:00
Nikolay Krasko
72c7d22d5f Rewrite to Kotlin: DescriptorToDeclarationUtil 2014-10-01 17:58:49 +04:00
Zalim Bashorov
9eb1a38a25 Don't rewrite testData file if content not changed, it's for windows family.
And improved some error messages.
2014-10-01 15:35:40 +04:00
Pavel V. Talanov
92faee3fd7 Do not reuse other caches when analyzing synthetic files inside libraries classes
This is no longer correct since libraries have dependencies
2014-09-30 21:59:02 +04:00
Pavel V. Talanov
b7dbd7a68d Minor: readable toString for LibraryInfo and LibrarySourceInfo 2014-09-30 21:59:01 +04:00
Pavel V. Talanov
a8d77887af Introduce HighlightingWithDependentLibrariesTest
This tests that LibraryInfo dependencies affect source files highlighting
2014-09-30 21:59:01 +04:00
Pavel V. Talanov
e25cbcd961 Test for LibraryInfo dependencies 2014-09-30 21:59:00 +04:00
Pavel V. Talanov
23a45ae689 Provide heuristic dependencies for LibraryInfo
This is not and cannot be (with current IDEA model) accurate
For now we use the following approximation:
    If a module dependends on library 'a' and among module's dependencies (including this module)
	there is a module that depends on library 'b' then
	we assume that library 'a' depends on library 'b'
2014-09-30 21:59:00 +04:00
Pavel V. Talanov
691068c0c2 Implement LibraryDependenciesCache 2014-09-30 21:58:59 +04:00
Nikolay Krasko
f7c1802fb7 Can't call Kotlin built-in Throwable 2014-09-30 20:44:57 +04:00
6227 changed files with 96173 additions and 55278 deletions

View File

@@ -1,9 +1,9 @@
<component name="ArtifactManager">
<artifact type="jar" name="IdeLazyResolver">
<output-path>$PROJECT_DIR$/out/artifacts/IdeLazyResolver</output-path>
<root id="archive" name="ide-lazy-resolver.jar">
<element id="module-output" name="ide-lazy-resolve" />
<element id="dir-copy" path="$PROJECT_DIR$/idea/ide-lazy-resolve" />
<output-path>$PROJECT_DIR$/out/artifacts/internal/</output-path>
<root id="archive" name="kotlin-ide-common.jar">
<element id="module-output" name="ide-common" />
<element id="dir-copy" path="$PROJECT_DIR$/idea/ide-common" />
</root>
</artifact>
</component>

View File

@@ -1,6 +1,6 @@
<component name="ArtifactManager">
<artifact type="jar" name="InjectorGenerator">
<output-path>$PROJECT_DIR$/out/artifacts/InjectorGenerator</output-path>
<output-path>$PROJECT_DIR$/out/artifacts/internal/</output-path>
<root id="archive" name="injector-generator.jar">
<element id="module-output" name="injector-generator" />
<element id="dir-copy" path="$PROJECT_DIR$/injector-generator" />

View File

@@ -14,7 +14,6 @@
<element id="module-output" name="util" />
<element id="module-output" name="util.runtime" />
<element id="module-output" name="j2k" />
<element id="module-output" name="js.translator" />
<element id="module-output" name="js.frontend" />
<element id="module-output" name="cli-common" />
<element id="module-output" name="ide-compiler-runner" />
@@ -30,7 +29,9 @@
</element>
<element id="module-output" name="eval4j" />
<element id="module-output" name="idea-analysis" />
<element id="module-output" name="ide-lazy-resolve" />
<element id="module-output" name="ide-common" />
<element id="file-copy" path="$PROJECT_DIR$/resources/manifest.properties" />
<element id="module-output" name="kotlin-android-plugin" />
</element>
<element id="library" level="project" name="javax.inject" />
<element id="directory" name="jps">

View File

@@ -2,7 +2,9 @@
<dictionary name="valentin">
<words>
<w>initializers</w>
<w>inserter</w>
<w>pparent</w>
<w>processings</w>
<w>rparenth</w>
</words>
</dictionary>

19
.idea/libraries/android_plugin.xml generated Normal file
View File

@@ -0,0 +1,19 @@
<component name="libraryTable">
<library name="android-plugin">
<ANNOTATIONS>
<root url="file://$PROJECT_DIR$/annotations" />
</ANNOTATIONS>
<CLASSES>
<root url="file://$PROJECT_DIR$/ideaSDK/plugins/android/lib" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.zip!/android/android/src" />
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.zip!/android/android/common/src" />
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.zip!/android/android/rt/src" />
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.zip!/android/android/jps-plugin/src" />
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.zip!/android/android/ultimate/src" />
</SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/ideaSDK/plugins/android/lib" recursive="false" />
</library>
</component>

7
.idea/modules.xml generated
View File

@@ -22,8 +22,8 @@
<module fileurl="file://$PROJECT_DIR$/compiler/frontend.java/frontend.java.iml" filepath="$PROJECT_DIR$/compiler/frontend.java/frontend.java.iml" group="compiler/java" />
<module fileurl="file://$PROJECT_DIR$/generators/generators.iml" filepath="$PROJECT_DIR$/generators/generators.iml" group="infrastructure" />
<module fileurl="file://$PROJECT_DIR$/grammar/grammar.iml" filepath="$PROJECT_DIR$/grammar/grammar.iml" group="compiler" />
<module fileurl="file://$PROJECT_DIR$/idea/ide-common/ide-common.iml" filepath="$PROJECT_DIR$/idea/ide-common/ide-common.iml" group="ide" />
<module fileurl="file://$PROJECT_DIR$/ide-compiler-runner/ide-compiler-runner.iml" filepath="$PROJECT_DIR$/ide-compiler-runner/ide-compiler-runner.iml" group="ide" />
<module fileurl="file://$PROJECT_DIR$/idea/ide-lazy-resolve/ide-lazy-resolve.iml" filepath="$PROJECT_DIR$/idea/ide-lazy-resolve/ide-lazy-resolve.iml" group="ide" />
<module fileurl="file://$PROJECT_DIR$/idea/idea.iml" filepath="$PROJECT_DIR$/idea/idea.iml" group="ide" />
<module fileurl="file://$PROJECT_DIR$/idea/idea-analysis/idea-analysis.iml" filepath="$PROJECT_DIR$/idea/idea-analysis/idea-analysis.iml" group="ide" />
<module fileurl="file://$PROJECT_DIR$/idea_runner/idea_runner.iml" filepath="$PROJECT_DIR$/idea_runner/idea_runner.iml" group="ide" />
@@ -34,9 +34,11 @@
<module fileurl="file://$PROJECT_DIR$/jps-plugin/jps-plugin.iml" filepath="$PROJECT_DIR$/jps-plugin/jps-plugin.iml" group="ide/jps" />
<module fileurl="file://$PROJECT_DIR$/js/js.dart-ast/js.dart-ast.iml" filepath="$PROJECT_DIR$/js/js.dart-ast/js.dart-ast.iml" group="compiler/js" />
<module fileurl="file://$PROJECT_DIR$/js/js.frontend/js.frontend.iml" filepath="$PROJECT_DIR$/js/js.frontend/js.frontend.iml" group="compiler/js" />
<module fileurl="file://$PROJECT_DIR$/js/js.inliner/js.inliner.iml" filepath="$PROJECT_DIR$/js/js.inliner/js.inliner.iml" group="compiler/js" />
<module fileurl="file://$PROJECT_DIR$/js/js.tests/js.tests.iml" filepath="$PROJECT_DIR$/js/js.tests/js.tests.iml" group="compiler/js" />
<module fileurl="file://$PROJECT_DIR$/js/js.translator/js.translator.iml" filepath="$PROJECT_DIR$/js/js.translator/js.translator.iml" group="compiler/js" />
<module fileurl="file://$PROJECT_DIR$/jps-plugin/kannotator-jps-plugin-test/kannotator-jps-plugin-test.iml" filepath="$PROJECT_DIR$/jps-plugin/kannotator-jps-plugin-test/kannotator-jps-plugin-test.iml" group="ide/jps" />
<module fileurl="file://$PROJECT_DIR$/idea/kotlin-android-plugin/kotlin-android-plugin.iml" filepath="$PROJECT_DIR$/idea/kotlin-android-plugin/kotlin-android-plugin.iml" group="ide" />
<module fileurl="file://$PROJECT_DIR$/compiler/preloader/preloader.iml" filepath="$PROJECT_DIR$/compiler/preloader/preloader.iml" group="compiler/cli" />
<module fileurl="file://$PROJECT_DIR$/core/reflection/reflection.iml" filepath="$PROJECT_DIR$/core/reflection/reflection.iml" group="core" />
<module fileurl="file://$PROJECT_DIR$/core/runtime.jvm/runtime.jvm.iml" filepath="$PROJECT_DIR$/core/runtime.jvm/runtime.jvm.iml" group="core" />
@@ -46,5 +48,4 @@
<module fileurl="file://$PROJECT_DIR$/core/util.runtime/util.runtime.iml" filepath="$PROJECT_DIR$/core/util.runtime/util.runtime.iml" group="core" />
</modules>
</component>
</project>
</project>

View File

@@ -10,7 +10,13 @@
<option name="PASS_PARENT_ENVS" value="true" />
<module name="generators" />
<envs />
<RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value="" />
<option name="TRANSPORT" value="0" />
<option name="LOCAL" value="true" />
</RunnerSettings>
<RunnerSettings RunnerId="Run" />
<ConfigurationWrapper RunnerId="Debug" />
<ConfigurationWrapper RunnerId="Run" />
<method />
</configuration>

View File

@@ -5,9 +5,9 @@
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" value="" />
<option name="PACKAGE_NAME" value="org.jetbrains.jet.jps.build" />
<option name="MAIN_CLASS_NAME" value="org.jetbrains.jet.jps.build.IncrementalJpsTestGenerated" />
<option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="class" />
<option name="TEST_OBJECT" value="pattern" />
<option name="VM_PARAMETERS" value="-ea -Xmx512m -XX:MaxPermSize=320m -Dkotlin.incremental.compilation=true" />
<option name="PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
@@ -19,7 +19,10 @@
<envs>
<env name="kotlin.tests.actually.compile" value="false" />
</envs>
<patterns />
<patterns>
<pattern testClass="org.jetbrains.jet.jps.build.IncrementalJpsTestGenerated" />
<pattern testClass="org.jetbrains.jet.jps.build.IncrementalCacheVersionChangedTest" />
</patterns>
<RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value="" />
<option name="TRANSPORT" value="0" />

4
.idea/vcs.xml generated
View File

@@ -7,6 +7,10 @@
<option name="issueRegexp" value="[A-Z]+\-\d+" />
<option name="linkRegexp" value="http://youtrack.jetbrains.com/issue/$0" />
</IssueNavigationLink>
<IssueNavigationLink>
<option name="issueRegexp" value="EA\-(\d+)" />
<option name="linkRegexp" value="http://ea.jetbrains.com/browser/ea_problems/$1" />
</IssueNavigationLink>
</list>
</option>
</component>

View File

@@ -2,7 +2,7 @@
Welcome to [Kotlin](http://kotlinlang.org/)! Some handy links:
* [Getting Started Guide](http://confluence.jetbrains.net/display/Kotlin/Getting+Started)
* [Getting Started Guide](http://kotlinlang.org/docs/tutorials/getting-started.html)
* [Web Demo](http://kotlin-demo.jetbrains.com/)
* [Kotlin Site](http://jetbrains.github.com/kotlin/)
* [API](http://jetbrains.github.com/kotlin/versions/snapshot/apidocs/index.html)
@@ -10,7 +10,7 @@ Welcome to [Kotlin](http://kotlinlang.org/)! Some handy links:
* [Forum](http://devnet.jetbrains.net/community/kotlin?view=discussions)
* [Kotlin Blog](http://blog.jetbrains.com/kotlin/)
* [follow Kotlin on twitter](http://twitter.com/#!/project_kotlin)
* [TeamCity CI build](http://teamcity.jetbrains.com/project.html?projectId=project67&tab=projectOverview)
* [TeamCity CI build](https://teamcity.jetbrains.com/project.html?tab=projectOverview&projectId=Kotlin)
## Editing Kotlin
@@ -52,7 +52,7 @@ then choose the `tools.jar` in the JDK's `lib` directory.
If you are not dealing with Android, you may need to disable the Android Plugin in order to compile the project.
Since Kotlin project contains code written in Kotlin itself, you will also need a Kotlin plugin to build the project in IntelliJ IDEA.
To keep the plugin version in sync with the rest of the team and our [Continuous Integration server](http://teamcity.jetbrains.com/project.html?projectId=Kotlin&tab=projectOverview)
To keep the plugin version in sync with the rest of the team and our [Continuous Integration server](https://teamcity.jetbrains.com/project.html?projectId=Kotlin&tab=projectOverview)
you should install the according to the [instructions below](#plugin-for-contributors).
If you want to have an IDEA installation without the Kotlin plugin which is separate to your default IDEA installation which has the Kotlin
@@ -72,7 +72,7 @@ There are several options for getting Kotlin plugin. A stable version can be obt
Preferences -> Plugins -> Browse Repositories -> Search with "Kotlin" string
The most recent version of the plugin can be downloaded from the
[IDEA Plugin and Tests CI build](http://teamcity.jetbrains.com/project.html?projectId=project67&tab=projectOverview). When downloading is
[IDEA Plugin and Tests CI build](https://teamcity.jetbrains.com/project.html?projectId=project67&tab=projectOverview). When downloading is
finished you can install it with "Install plugin from disk...":
Preferences -> Plugins -> Install plugin from disk...
@@ -89,15 +89,15 @@ Open
and add the following URL to your repositories:
http://teamcity.jetbrains.com/guestAuth/repository/download/bt345/bootstrap.tcbuildtag/updatePlugins.xml
https://teamcity.jetbrains.com/guestAuth/repository/download/bt345/bootstrap.tcbuildtag/updatePlugins.xml
Then update the list of plugins in "Browse Repositories", you'll see two versions of Kotlin there, install the one with the higher version number.
# Contributing
We love contributions! There's [lots to do on kotlin](http://youtrack.jetbrains.com/issues/KT) and on the [standard library](http://youtrack.jetbrains.com/issues/KT?q=%23%7BStandard+Library%7D+-Resolved) so why not chat with us on the [forum](http://devnet.jetbrains.net/community/kotlin?view=discussions) about what you're interested in doing?
We love contributions! There's [lots to do on kotlin](http://youtrack.jetbrains.com/issues/KT) and on the [standard library](https://youtrack.jetbrains.com/issues/KT?q=Subtask+of%3A+KT-2554+%23Unresolved) so why not chat with us on the [forum](http://devnet.jetbrains.net/community/kotlin?view=discussions) about what you're interested in doing?
If you want to find some issues to start off with, try [this query](http://youtrack.jetbrains.com/issues?q=tag%3A+%7BUp+For+Grabs%7D) which should find all issues that marked as "up-for-grabs".
If you want to find some issues to start off with, try [this query](https://youtrack.jetbrains.com/issues?q=tag%3A+%7BUp+For+Grabs%7D+%23Unresolved) which should find all issues that marked as "up-for-grabs".
Currently only committers can assign issues to themselves so just add a comment if you're starting work on it.

View File

@@ -0,0 +1,9 @@
<root>
<item
name='com.android.tools.idea.gradle.output.parser.PatternAwareOutputParser boolean parse(java.lang.String, com.android.tools.idea.gradle.output.parser.OutputLineReader, java.util.List&lt;com.android.tools.idea.gradle.output.GradleMessage&gt;)'>
<annotation name='kotlin.jvm.KotlinSignature'>
<val name="value"
val="&quot;fun parse(line: String, reader: OutputLineReader, messages: MutableList&lt;GradleMessage&gt;): Boolean&quot;"/>
</annotation>
</item>
</root>

View File

@@ -168,4 +168,20 @@
name='com.intellij.codeInsight.editorActions.CopyPasteReferenceProcessor void restoreReferences(com.intellij.codeInsight.editorActions.ReferenceData[], TRef[]) 1'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.codeInsight.editorActions.JoinLinesHandlerDelegate int tryJoinLines(com.intellij.openapi.editor.Document, com.intellij.psi.PsiFile, int, int) 0'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.codeInsight.editorActions.JoinLinesHandlerDelegate int tryJoinLines(com.intellij.openapi.editor.Document, com.intellij.psi.PsiFile, int, int) 1'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.codeInsight.editorActions.JoinRawLinesHandlerDelegate int tryJoinRawLines(com.intellij.openapi.editor.Document, com.intellij.psi.PsiFile, int, int) 0'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.codeInsight.editorActions.JoinRawLinesHandlerDelegate int tryJoinRawLines(com.intellij.openapi.editor.Document, com.intellij.psi.PsiFile, int, int) 1'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
</root>

View File

@@ -1,117 +1,121 @@
<root>
<item name='com.intellij.formatting.Spacing com.intellij.formatting.Spacing createKeepingFirstColumnSpacing(int, int, boolean, int)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.Spacing com.intellij.formatting.Spacing createSpacing(int, int, int, boolean, int)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder append(com.intellij.formatting.SpacingBuilder)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder after(com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder afterInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder afterInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.TokenSet)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder afterInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder around(com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder around(com.intellij.psi.tree.TokenSet)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder aroundInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder aroundInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.TokenSet)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder aroundInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder aroundInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.TokenSet)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder before(com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder beforeInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder beforeInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder between(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder between(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.TokenSet)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder between(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder between(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.TokenSet)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder betweenInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder betweenInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder withinPair(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder withinPairInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder blankLines(int)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder lineBreakInCode()'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder lineBreakInCodeIf(boolean)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder none()'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder spaceIf(boolean)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder spaces(int)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder spacing(int, int, int, boolean, int)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.DependentSpacingRule com.intellij.formatting.DependentSpacingRule registerData(com.intellij.formatting.DependentSpacingRule.Anchor, int)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.Spacing com.intellij.formatting.Spacing createKeepingFirstColumnSpacing(int, int, boolean, int)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.Spacing com.intellij.formatting.Spacing createSpacing(int, int, int, boolean, int)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder append(com.intellij.formatting.SpacingBuilder)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder after(com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder afterInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder afterInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.TokenSet)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder afterInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder around(com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder around(com.intellij.psi.tree.TokenSet)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder aroundInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder aroundInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.TokenSet)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder aroundInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder aroundInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.TokenSet)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder before(com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder beforeInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder beforeInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder between(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder between(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.TokenSet)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder between(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder between(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.TokenSet)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder betweenInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder betweenInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder withinPair(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder withinPairInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder blankLines(int)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder lineBreakInCode()'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder lineBreakInCodeIf(boolean)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder none()'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder spaceIf(boolean)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder spaces(int)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder spacing(int, int, int, boolean, int)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
</root>

View File

@@ -8,4 +8,7 @@
<item name='com.intellij.ide.util.PsiElementListCellRenderer java.lang.String getElementText(T) 0'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.ide.util.PsiElementListCellRenderer java.util.Comparator&lt;T&gt; getComparator()'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
</root>

View File

@@ -0,0 +1,6 @@
<root>
<item
name='com.intellij.openapi.project.DumbService com.intellij.openapi.project.DumbService getInstance(com.intellij.openapi.project.Project)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
</root>

View File

@@ -22,7 +22,11 @@
<item name='com.intellij.openapi.roots.OrderEnumerator com.intellij.openapi.roots.OrderEnumerator recursively()'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
<item
name='com.intellij.openapi.roots.OrderEnumerator com.intellij.openapi.roots.OrderEnumerator satisfying(com.intellij.openapi.util.Condition&lt;com.intellij.openapi.roots.OrderEntry&gt;)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.openapi.roots.ProjectFileIndex.SERVICE com.intellij.openapi.roots.ProjectFileIndex getInstance(com.intellij.openapi.project.Project)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>

View File

@@ -0,0 +1,5 @@
<root>
<item name='com.intellij.openapi.util.text.StringUtil java.lang.String decapitalize(java.lang.String)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
</root>

View File

@@ -21,4 +21,8 @@
<item name='com.intellij.refactoring.move.moveFilesOrDirectories.MoveFileHandler void updateMovedFile(com.intellij.psi.PsiFile) 0'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.refactoring.move.moveFilesOrDirectories.MoveFileHandler$1 void retargetUsages(java.util.List&lt;com.intellij.usageView.UsageInfo&gt;, java.util.Map&lt;com.intellij.psi.PsiElement,com.intellij.psi.PsiElement&gt;) 0'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
</root>

View File

@@ -1,5 +1,8 @@
<root>
<item name='org.apache.tools.ant.types.Path java.lang.String[] list()'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='org.apache.tools.ant.types.Path org.apache.tools.ant.types.Path createPath()'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
</root>
</root>

View File

@@ -1,151 +0,0 @@
/*
* Copyright 2010-2013 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.jet.buildtools.ant;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Reference;
import org.jetbrains.jet.buildtools.core.BytecodeCompiler;
import org.jetbrains.jet.buildtools.core.Util;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static org.jetbrains.jet.buildtools.core.Util.getPath;
/**
* Kotlin bytecode compiler Ant task.
* <p/>
* See
* http://evgeny-goldin.org/javadoc/ant/tutorial-writing-tasks.html
* http://evgeny-goldin.org/javadoc/ant/develop.html
* http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java?view=markup.
*/
public class BytecodeCompilerTask extends Task {
private File output;
private File stdlib;
private Path src;
private Path externalAnnotations;
private Path compileClasspath;
private boolean includeRuntime = true;
private final List<Commandline.Argument> additionalArguments = new ArrayList<Commandline.Argument>();
public void setOutput(File output) {
this.output = output;
}
public void setStdlib(File stdlib) {
this.stdlib = stdlib;
}
public void setSrc(Path src) {
this.src = src;
}
public Path createSrc() {
if (src == null) {
src = new Path(getProject());
}
return src.createPath();
}
public void setExternalAnnotations(Path externalAnnotations) {
this.externalAnnotations = externalAnnotations;
}
public Path createExternalAnnotations() {
if (externalAnnotations == null) {
externalAnnotations = new Path(getProject());
}
return externalAnnotations.createPath();
}
public void setIncludeRuntime(boolean includeRuntime) {
this.includeRuntime = includeRuntime;
}
public Commandline.Argument createCompilerArg() {
Commandline.Argument argument = new Commandline.Argument();
additionalArguments.add(argument);
return argument;
}
/**
* Set the classpath to be used for this compilation.
*
* @param classpath an Ant Path object containing the compilation classpath.
*/
public void setClasspath(Path classpath) {
if (this.compileClasspath == null) {
this.compileClasspath = classpath;
}
else {
this.compileClasspath.append(classpath);
}
}
/**
* Adds a reference to a classpath defined elsewhere.
*
* @param ref a reference to a classpath.
*/
public void setClasspathRef(Reference ref) {
if (this.compileClasspath == null) {
this.compileClasspath = new Path(getProject());
}
this.compileClasspath.createPath().setRefid(ref);
}
/**
* Set the nested {@code <classpath>} to be used for this compilation.
*
* @param classpath an Ant Path object containing the compilation classpath.
*/
public void addConfiguredClasspath(Path classpath) {
setClasspath(classpath);
}
@Override
public void execute() {
String stdlibPath = stdlib != null ? getPath(stdlib) : null;
String[] classpath = compileClasspath != null ? compileClasspath.list() : null;
String[] externalAnnotationsPath = externalAnnotations != null ? externalAnnotations.list() : null;
List<String> args = new ArrayList<String>();
for (Commandline.Argument argument : additionalArguments) {
args.addAll(Arrays.asList(argument.getParts()));
}
if (src == null) {
throw new BuildException("\"src\" should be specified");
}
if (output == null) {
throw new BuildException("\"output\" should be specified");
}
String[] source = Util.getPaths(src.list());
String destination = getPath(output);
log(String.format("Compiling [%s] => [%s]", Arrays.toString(source), destination));
BytecodeCompiler.compileSources(source, destination, includeRuntime, stdlibPath, classpath, externalAnnotationsPath, args);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2013 JetBrains s.r.o.
* Copyright 2010-2014 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.
@@ -16,10 +16,7 @@
package org.jetbrains.jet.buildtools.ant
import org.apache.tools.ant.Task
import org.apache.tools.ant.types.Path
import org.apache.tools.ant.types.Reference
import org.jetbrains.jet.buildtools.core.Util
import org.jetbrains.jet.cli.common.arguments.K2JSCompilerArguments
import org.jetbrains.jet.cli.common.messages.MessageCollectorPlainTextToStream
import org.jetbrains.jet.cli.js.K2JSCompiler
@@ -32,9 +29,10 @@ import org.jetbrains.jet.config.Services
* Kotlin JavaScript compiler Ant task.
* http://evgeny-goldin.org/javadoc/ant/tutorial-writing-tasks.html
*/
public class Kotlin2JsCompilerTask : Task() {
public var src: Path? = null
public var output: File? = null
public class Kotlin2JsTask : KotlinCompilerBaseTask<K2JSCompilerArguments>() {
override val arguments = K2JSCompilerArguments()
override val compiler = K2JSCompiler()
public var library: Path? = null
public var outputPrefix: File? = null
public var outputPostfix: File? = null
@@ -46,21 +44,6 @@ public class Kotlin2JsCompilerTask : Task() {
*/
public var main: String? = null
public fun createSrc(): Path {
val srcPath = src
if (srcPath == null) {
val t = Path(getProject())
src = t
return t
}
return srcPath.createPath()
}
public fun setSrcRef(ref: Reference) {
createSrc().setRefid(ref)
}
public fun createLibrary(): Path {
val libraryPath = library
if (libraryPath == null) {
@@ -72,28 +55,13 @@ public class Kotlin2JsCompilerTask : Task() {
return libraryPath.createPath()
}
override fun execute(): Unit {
val arguments = K2JSCompilerArguments()
val sourcePaths = src ?: throw BuildException("\"src\" should be specified")
arguments.freeArgs = Util.getPaths(sourcePaths.list()).toList()
val outputFile = output ?: throw BuildException("\"output\" should be specified")
arguments.outputFile = outputFile.canonicalPath
override fun fillSpecificArguments() {
arguments.outputFile = getPath(output!!)
arguments.outputPrefix = outputPrefix?.canonicalPath
arguments.outputPostfix = outputPostfix?.canonicalPath
arguments.main = main
arguments.sourceMap = sourceMap
log("Compiling ${arguments.freeArgs} => [${arguments.outputFile}]");
val compiler = K2JSCompiler()
val exitCode = compiler.exec(MessageCollectorPlainTextToStream.PLAIN_TEXT_TO_SYSTEM_ERR, Services.EMPTY, arguments)
if (exitCode != ExitCode.OK) {
throw BuildException("Compilation finished with exit code $exitCode")
}
}
}

View File

@@ -0,0 +1,108 @@
/*
* Copyright 2010-2014 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.jet.buildtools.ant
import org.apache.tools.ant.types.Path
import org.apache.tools.ant.types.Reference
import java.io.File
import java.io.File.pathSeparator
import org.jetbrains.jet.cli.jvm.K2JVMCompiler
import org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments
import com.intellij.openapi.util.io.FileUtilRt
/**
* Kotlin bytecode compiler Ant task.
* <p/>
* See
* http://evgeny-goldin.org/javadoc/ant/tutorial-writing-tasks.html
* http://evgeny-goldin.org/javadoc/ant/develop.html
* http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java?view=markup.
*/
public class Kotlin2JvmTask : KotlinCompilerBaseTask<K2JVMCompilerArguments>() {
override val arguments = K2JVMCompilerArguments()
override val compiler = K2JVMCompiler()
public var noStdlib: Boolean = false
public var externalAnnotations: Path? = null
public var includeRuntime: Boolean = true
private var compileClasspath: Path? = null
public fun createExternalAnnotations(): Path {
if (externalAnnotations == null) {
externalAnnotations = Path(getProject())
}
return externalAnnotations!!.createPath()
}
/**
* Set the classpath to be used for this compilation.
*
* @param classpath an Ant Path object containing the compilation classpath.
*/
public fun setClasspath(classpath: Path) {
if (this.compileClasspath == null) {
this.compileClasspath = classpath
}
else {
this.compileClasspath!!.append(classpath)
}
}
/**
* Adds a reference to a classpath defined elsewhere.
*
* @param ref a reference to a classpath.
*/
public fun setClasspathRef(ref: Reference) {
if (this.compileClasspath == null) {
this.compileClasspath = Path(getProject())
}
this.compileClasspath!!.createPath().setRefid(ref)
}
/**
* Set the nested {@code <classpath>} to be used for this compilation.
*
* @param classpath an Ant Path object containing the compilation classpath.
*/
public fun addConfiguredClasspath(classpath: Path) {
setClasspath(classpath)
}
override fun fillSpecificArguments() {
arguments.destination = getPath(output!!)
val classpath = arrayListOf<String>()
compileClasspath?.let { classpath.addAll(it.list()) }
arguments.freeArgs?.forEach {
val file = File(it)
if (file.isDirectory() || file.extension != "kt") {
classpath.add(it)
}
}
arguments.classpath = classpath.join(pathSeparator)
arguments.annotations = externalAnnotations?.list()?.join(pathSeparator)
arguments.noStdlib = noStdlib
arguments.includeRuntime = includeRuntime
}
}

View File

@@ -40,7 +40,7 @@ public class KotlinCompilerAdapter extends DefaultCompilerAdapter {
public boolean execute() throws BuildException {
Javac javac = getJavac();
BytecodeCompilerTask kotlinTask = new BytecodeCompilerTask();
Kotlin2JvmTask kotlinTask = new Kotlin2JvmTask();
kotlinTask.setOutput(javac.getDestdir());
kotlinTask.setClasspath(javac.getClasspath());
kotlinTask.setSrc(javac.getSrcdir());

View File

@@ -0,0 +1,124 @@
/*
* Copyright 2010-2014 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.jet.buildtools.ant
import org.apache.tools.ant.Task
import org.apache.tools.ant.types.Path
import org.apache.tools.ant.types.Reference
import org.jetbrains.jet.cli.common.messages.MessageCollectorPlainTextToStream
import java.io.File
import org.apache.tools.ant.BuildException
import org.jetbrains.jet.cli.common.ExitCode
import org.jetbrains.jet.cli.common.arguments.CommonCompilerArguments
import org.jetbrains.jet.cli.common.CLICompiler
import org.apache.tools.ant.types.Commandline
import com.sampullara.cli.Args
import java.io.IOException
import org.jetbrains.jet.config
import org.jetbrains.jet.cli.common.messages.PrintingMessageCollector
import org.jetbrains.jet.cli.common.messages.MessageRenderer
/**
* {@code file.getCanonicalPath()} convenience wrapper.
*
* @param file - file to get its canonical path.
* @return file's canonical path
*/
fun getPath(file: File): String {
try {
return file.getCanonicalPath()
}
catch (e: IOException) {
throw RuntimeException("Failed to resolve canonical file of [$file]: $e", e)
}
}
/**
* Base class for Kotlin compiler Ant tasks.
* http://evgeny-goldin.org/javadoc/ant/tutorial-writing-tasks.html
*/
public abstract class KotlinCompilerBaseTask<T : CommonCompilerArguments> : Task() {
protected abstract val arguments: T
protected abstract val compiler: CLICompiler<T>
public var src: Path? = null
public var output: File? = null
public var nowarn: Boolean = false
public var verbose: Boolean = false
public var printVersion: Boolean = false
public val additionalArguments: MutableList<Commandline.Argument> = arrayListOf()
public fun createSrc(): Path {
val srcPath = src
if (srcPath == null) {
val t = Path(getProject())
src = t
return t
}
return srcPath.createPath()
}
public fun setSrcRef(ref: Reference) {
createSrc().setRefid(ref)
}
public fun createCompilerArg(): Commandline.Argument {
val argument = Commandline.Argument()
additionalArguments.add(argument)
return argument
}
abstract fun fillSpecificArguments()
private fun fillArguments() {
val sourcePaths = src ?: throw BuildException("\"src\" should be specified")
arguments.freeArgs = sourcePaths.list().map { getPath(File(it)) }
output ?: throw BuildException("\"output\" should be specified")
arguments.suppressWarnings = nowarn
arguments.verbose = verbose
arguments.version = printVersion
val args = additionalArguments.flatMap { it.getParts()!!.toList() }
try {
Args.parse(arguments, args.copyToArray())
}
catch (e: IllegalArgumentException) {
throw BuildException(e.getMessage())
}
fillSpecificArguments()
}
final override fun execute(): Unit {
fillArguments()
val outputPath = getPath(output!!)
log("Compiling ${arguments.freeArgs} => [${outputPath}]");
val collector = PrintingMessageCollector(System.err, MessageRenderer.PLAIN, arguments.verbose)
val exitCode = compiler.exec(collector, config.Services.EMPTY, arguments)
if (exitCode != ExitCode.OK) {
throw BuildException("Compilation finished with exit code $exitCode")
}
}
}

View File

@@ -5,10 +5,10 @@
<antlib>
<taskdef
name = "kotlinc"
classname = "org.jetbrains.jet.buildtools.ant.BytecodeCompilerTask"/>
classname = "org.jetbrains.jet.buildtools.ant.Kotlin2JvmTask"/>
<taskdef
name = "kotlin2js"
classname = "org.jetbrains.jet.buildtools.ant.Kotlin2JsCompilerTask"/>
classname = "org.jetbrains.jet.buildtools.ant.Kotlin2JsTask"/>
<typedef
name = "withKotlin"
classname = "org.jetbrains.jet.buildtools.ant.KotlinCompilerAdapter"/>

View File

@@ -1,177 +0,0 @@
/*
* Copyright 2010-2013 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.jet.buildtools.core;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Function;
import com.sampullara.cli.Args;
import org.apache.tools.ant.BuildException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.cli.common.CLIConfigurationKeys;
import org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments;
import org.jetbrains.jet.cli.common.messages.MessageCollectorPlainTextToStream;
import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys;
import org.jetbrains.jet.cli.jvm.K2JVMCompiler;
import org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentException;
import org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentUtil;
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
import org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler;
import org.jetbrains.jet.config.CompilerConfiguration;
import org.jetbrains.jet.utils.KotlinPaths;
import org.jetbrains.jet.utils.KotlinPathsFromHomeDir;
import org.jetbrains.jet.utils.PathUtil;
import java.io.File;
import java.util.Arrays;
import java.util.List;
import static org.jetbrains.jet.cli.jvm.JVMConfigurationKeys.ANNOTATIONS_PATH_KEY;
import static org.jetbrains.jet.cli.jvm.JVMConfigurationKeys.CLASSPATH_KEY;
public class BytecodeCompiler {
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
@NotNull
private static CompilerConfiguration createConfiguration(
@Nullable String stdlib,
@Nullable String[] classpath,
@Nullable String[] externalAnnotationsPath,
@NotNull String[] sourceRoots,
@NotNull List<String> args
) {
KotlinPaths paths = getKotlinPathsForAntTask();
CompilerConfiguration configuration = new CompilerConfiguration();
configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollectorPlainTextToStream.PLAIN_TEXT_TO_SYSTEM_ERR);
configuration.addAll(CLASSPATH_KEY, PathUtil.getJdkClassesRoots());
if ((stdlib != null) && (stdlib.trim().length() > 0)) {
configuration.add(CLASSPATH_KEY, new File(stdlib));
}
else {
File path = paths.getRuntimePath();
if (path.exists()) {
configuration.add(CLASSPATH_KEY, path);
}
}
if ((classpath != null) && (classpath.length > 0)) {
for (String path : classpath) {
configuration.add(CLASSPATH_KEY, new File(path));
}
}
if ((externalAnnotationsPath != null) && (externalAnnotationsPath.length > 0)) {
for (String path : externalAnnotationsPath) {
configuration.add(ANNOTATIONS_PATH_KEY, new File(path));
}
}
File jdkAnnotationsPath = paths.getJdkAnnotationsPath();
if (jdkAnnotationsPath.exists()) {
configuration.add(ANNOTATIONS_PATH_KEY, jdkAnnotationsPath);
}
CompileEnvironmentUtil.addSourceFilesCheckingForDuplicates(configuration, Arrays.asList(sourceRoots));
for (String sourceRoot : sourceRoots) {
File file = new File(sourceRoot);
if (!file.isFile() || !"kt".equals(FileUtilRt.getExtension(file.getName()))) {
configuration.add(JVMConfigurationKeys.CLASSPATH_KEY, file);
}
}
// TODO: use K2JVMCompiler directly, don't duplicate this code here
K2JVMCompilerArguments arguments = new K2JVMCompilerArguments();
try {
Args.parse(arguments, ArrayUtil.toStringArray(args));
}
catch (IllegalArgumentException e) {
throw new BuildException(e.getMessage());
}
K2JVMCompiler.putAdvancedOptions(configuration, arguments);
return configuration;
}
private static String errorMessage(@NotNull String[] source, boolean exceptionThrown) {
return String.format("Compilation of the following source roots failed:" + LINE_SEPARATOR +
getAbsolutePaths(source) +
(exceptionThrown ? "" : LINE_SEPARATOR + "see \"ERROR:\" messages above for more details."));
}
private static String getAbsolutePaths(String[] source) {
return StringUtil.join(
source,
new Function<String, String>() {
@Override
public String fun(String s) {
return " * " + new File(s).getAbsolutePath();
}
},
LINE_SEPARATOR
);
}
/**
* {@code KotlinToJVMBytecodeCompiler#compileBunchOfSources} wrapper.
* @param src compilation source (directory or file)
* @param destination compilation destination (directory or jar)
* @param includeRuntime whether Kotlin runtime library is included in destination jar
* @param stdlib "kotlin-runtime.jar" path
* @param args additional command line arguments to Kotlin compiler
*/
public static void compileSources(
@NotNull String[] src,
@NotNull String destination,
boolean includeRuntime,
@Nullable String stdlib,
@Nullable String[] classpath,
@Nullable String[] externalAnnotationsPath,
@NotNull List<String> args
) {
try {
JetCoreEnvironment environment = JetCoreEnvironment.createForProduction(
Disposer.newDisposable(),
createConfiguration(stdlib, classpath, externalAnnotationsPath, src, args)
);
// TODO: use K2JVMCompiler directly, don't duplicate this code here
boolean isJar = destination.endsWith(".jar");
File jar = isJar ? new File(destination) : null;
File outputDir = isJar ? null : new File(destination);
boolean success = KotlinToJVMBytecodeCompiler.compileBunchOfSources(environment, jar, outputDir, includeRuntime);
if (!success) {
throw new CompileEnvironmentException(errorMessage(src, false));
}
}
catch (BuildException e) {
throw e;
}
catch (CompileEnvironmentException e) {
throw e;
}
catch (Exception e) {
throw new CompileEnvironmentException(errorMessage(src, true), e);
}
}
private static KotlinPaths getKotlinPathsForAntTask() {
return new KotlinPathsFromHomeDir(PathUtil.getJarPathForClass(BytecodeCompiler.class).getParentFile().getParentFile());
}
}

View File

@@ -1,53 +0,0 @@
/*
* Copyright 2010-2013 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.jet.buildtools.core;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;
public final class Util {
private Util() {
}
/**
* {@code file.getCanonicalPath()} convenience wrapper.
*
* @param f file to get its canonical path.
* @return file's canonical path
*/
@NotNull
public static String getPath(@NotNull File f) {
try {
return f.getCanonicalPath();
}
catch (IOException e) {
throw new RuntimeException(String.format("Failed to resolve canonical file of [%s]: %s", f, e), e);
}
}
@NotNull
public static String[] getPaths(String[] paths) {
String[] result = new String[paths.length];
for (int i = 0; i < paths.length; i++) {
String path = paths[i];
result[i] = getPath(new File(path));
}
return result;
}
}

View File

@@ -1,4 +1,6 @@
<project name="Kotlin" default="dist">
<include file="jslib_files.xml" />
<property file="resources/manifest.properties"/>
<!-- Set to false to disable proguard run on kotlin-compiler.jar. Speeds up the build -->
@@ -77,6 +79,7 @@
<include name="js/js.dart-ast/src"/>
<include name="js/js.translator/src"/>
<include name="js/js.frontend/src"/>
<include name="js/js.inliner/src"/>
</dirset>
<property name="idea.out" value="${basedir}/out/production"/>
@@ -99,6 +102,7 @@
<include name="js.dart-ast/**"/>
<include name="js.translator/**"/>
<include name="js.frontend/**"/>
<include name="js.inliner/**"/>
</patternset>
<path id="compilerSources.path">
@@ -163,6 +167,7 @@
<fileset dir="js/js.dart-ast/src"/>
<fileset dir="js/js.translator/src"/>
<fileset dir="js/js.frontend/src"/>
<fileset dir="js/js.inliner/src"/>
<zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/>
<manifest>
@@ -213,17 +218,18 @@
</target>
<target name="jslib">
<property name="compiled.stdlib.js" value="stdlib.js" />
<property name="stdlib.js.dir" value="${basedir}/js/js.translator/testData" />
<kotlin2js output="${output}/${compiled.stdlib.js}" main="noCall">
<src>
<fileset refid="kotlin.builtin.files" />
<resources refid="js.lib.files" />
</src>
</kotlin2js>
<jar jarfile="${kotlin-home}/lib/kotlin-jslib.jar">
<fileset dir="${basedir}/js/js.libraries/src">
<include name="core/**"/>
<include name="jquery/**"/>
<include name="dom/**"/>
<include name="html5/**"/>
<include name="stdlib/TuplesCode.kt"/>
</fileset>
<fileset dir="${basedir}/core/reflection/src">
<include name="kotlin/**"/>
</fileset>
<resources refid="js.lib.files" />
<zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/>
<manifest>
@@ -239,21 +245,36 @@
classname="com.google.javascript.jscomp.ant.CompileTask"
classpath="${dependencies.dir}/closure-compiler.jar"/>
<!-- value should be one of: whitespace, simple, advanced -->
<property name="compilationLevel" value="simple" />
<!-- value should be one of: default, quiet, verbose -->
<property name="warningLevel" value="default" />
<closure-compiler
compilationLevel="simple"
compilationLevel="${compilationLevel}"
prettyprint="true"
languagein="ECMASCRIPT5_STRICT"
warning="verbose"
debug="false"
output="${kotlin-home}/lib/kotlin.js">
warning="${warningLevel}"
output="${kotlin-home}/lib/kotlin.js" >
<sources dir="${basedir}/js/js.translator/testData">
<sources dir="${stdlib.js.dir}">
<file name="kotlin_lib_ecma5.js"/>
<file name="kotlin_lib.js"/>
<file name="maps.js"/>
<file name="long.js"/>
</sources>
<sources dir="${output}">
<file name="${compiled.stdlib.js}"/>
</sources>
<sources dir="${stdlib.js.dir}">
<file name="export_Kotlin_if_possible.js"/>
</sources>
<externs dir="${stdlib.js.dir}">
<file name="externs.js"/>
</externs>
</closure-compiler>
</target>
@@ -330,6 +351,7 @@
</fileset>
<fileset dir="${basedir}/compiler/frontend.java/src" includes="META-INF/services/**"/>
<fileset dir="${basedir}/compiler/backend/src" includes="META-INF/services/**"/>
<fileset dir="${basedir}/resources" includes="manifest.properties"/>
<zipgroupfileset dir="${basedir}/lib" includes="*.jar"/>
<zipgroupfileset dir="${basedir}/ideaSDK/core" includes="*.jar" excludes="util.jar"/>
@@ -655,7 +677,7 @@
depends="init,prepareDist,preloader,builtins,compiler_quick"
description="Builds compiler jar from project out dir"/>
<target name="zip" depends="dist">
<target name="zip-compiler" depends="dist">
<zip destfile="${output}/${output.name}.zip">
<zipfileset prefix="kotlinc" dir="${kotlin-home}" excludes="bin/*"/>
<zipfileset prefix="kotlinc/bin" dir="${kotlin-home}/bin" includes="*.bat" filemode="644"/>
@@ -670,7 +692,7 @@
source="${java.target}" target="${java.target}">
<withKotlin externalannotations="${external.annotations.path}"/>
<src>
<dirset dir="${basedir}/idea/ide-lazy-resolve">
<dirset dir="${basedir}/idea/ide-common">
<include name="src"/>
</dirset>
<dirset dir="${basedir}/idea/idea-analysis">
@@ -744,7 +766,9 @@
<fileset dir="js/js.dart-ast/src"/>
<fileset dir="js/js.translator/src"/>
<fileset dir="js/js.frontend/src"/>
<fileset dir="js/js.inliner/src"/>
<fileset dir="idea/idea-analysis/src"/>
<fileset dir="idea/ide-common/src"/>
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
@@ -756,5 +780,12 @@
</target>
<target name="build-artifacts" depends="zip,kotlin-for-upsource"/>
<target name="zip-test-data">
<zip destfile="${output}/kotlin-test-data.zip">
<zipfileset dir="compiler/testData" prefix="compiler"/>
<zipfileset dir="idea/testData" prefix="ide"/>
</zip>
</target>
<target name="build-artifacts" depends="zip-compiler,kotlin-for-upsource,zip-test-data"/>
</project>

View File

@@ -16,6 +16,7 @@
package org.jetbrains.jet.compiler;
import com.intellij.util.PlatformUtils;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.jetbrains.annotations.NotNull;
@@ -179,11 +180,13 @@ public class CodegenTestsOnAndroidRunner {
downloader.downloadAll();
downloader.unzipAll();
PermissionManager.setPermissions(pathManager);
antRunner.packLibraries();
String platformPrefixProperty = System.setProperty(PlatformUtils.PLATFORM_PREFIX_KEY, "Idea");
try {
PermissionManager.setPermissions(pathManager);
antRunner.packLibraries();
emulator.createEmulator();
emulator.startEmulator();
@@ -207,6 +210,12 @@ public class CodegenTestsOnAndroidRunner {
throw e;
}
finally {
if (platformPrefixProperty != null) {
System.setProperty(PlatformUtils.PLATFORM_PREFIX_KEY, platformPrefixProperty);
}
else {
System.clearProperty(PlatformUtils.PLATFORM_PREFIX_KEY);
}
emulator.finishEmulatorProcesses();
}
}

View File

@@ -73,6 +73,8 @@ public class SpecialFiles {
excludedFiles.add("invokeOnClassObjectOfNestedClass2.kt"); // Cannot change package name
excludedFiles.add("invokeOnImportedEnum1.kt"); // Cannot change package name
excludedFiles.add("invokeOnImportedEnum2.kt"); // Cannot change package name
excludedFiles.add("sortEnumEntries.kt"); // Cannot change package name
excludedFiles.add("assertionStackTrace.kt"); // Cannot change package name
excludedFiles.add("kt326.kt"); // Commented
excludedFiles.add("kt1213.kt"); // Commented

View File

@@ -87,7 +87,7 @@ public fun findTraitImplementation(descriptor: CallableMemberDescriptor): Callab
// If this implementation is already generated into one of the superclasses, we need not generate it again, it'll be inherited
val containingClass = descriptor.getContainingDeclaration() as ClassDescriptor
val implClassType = implementation!!.getExpectedThisObject()!!.getType()
val implClassType = implementation!!.getDispatchReceiverParameter()!!.getType()
for (supertype in containingClass.getDefaultType().getConstructor().getSupertypes()) {
if (!DescriptorUtils.isTrait(supertype.getConstructor().getDeclarationDescriptor()!!) &&
TypeUtils.getAllSupertypes(supertype).contains(implClassType)) {

View File

@@ -18,6 +18,7 @@ package org.jetbrains.jet.backend.common;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.codegen.bridges.BridgesPackage;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.psi.JetDelegationSpecifier;
import org.jetbrains.jet.lang.psi.JetExpression;
@@ -125,18 +126,32 @@ public class CodegenUtil {
Boolean.TRUE.equals(bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor));
}
public static Map<CallableMemberDescriptor, CallableMemberDescriptor> getDelegates(ClassDescriptor descriptor, ClassDescriptor toClass) {
Map<CallableMemberDescriptor, CallableMemberDescriptor> result = new LinkedHashMap<CallableMemberDescriptor, CallableMemberDescriptor>();
@NotNull
public static Map<FunctionDescriptor, FunctionDescriptor> getTraitMethods(ClassDescriptor descriptor) {
Map<FunctionDescriptor, FunctionDescriptor> result = new LinkedHashMap<FunctionDescriptor, FunctionDescriptor>();
for (DeclarationDescriptor declaration : descriptor.getDefaultType().getMemberScope().getAllDescriptors()) {
if (declaration instanceof CallableMemberDescriptor) {
CallableMemberDescriptor callableMemberDescriptor = (CallableMemberDescriptor) declaration;
if (callableMemberDescriptor.getKind() == CallableMemberDescriptor.Kind.DELEGATION) {
Set<? extends CallableMemberDescriptor> overriddenDescriptors = callableMemberDescriptor.getOverriddenDescriptors();
for (CallableMemberDescriptor overriddenDescriptor : overriddenDescriptors) {
if (overriddenDescriptor.getContainingDeclaration() == toClass) {
assert !result.containsKey(callableMemberDescriptor) :
"overridden is already set for " + callableMemberDescriptor;
result.put(callableMemberDescriptor, overriddenDescriptor);
if (!(declaration instanceof CallableMemberDescriptor)) continue;
CallableMemberDescriptor inheritedMember = (CallableMemberDescriptor) declaration;
CallableMemberDescriptor traitMember = BridgesPackage.findTraitImplementation(inheritedMember);
if (traitMember == null) continue;
assert traitMember.getModality() != Modality.ABSTRACT : "Cannot delegate to abstract trait method: " + inheritedMember;
// inheritedMember can be abstract here. In order for FunctionCodegen to generate the method body, we're creating a copy here
// with traitMember's modality
CallableMemberDescriptor copy =
inheritedMember.copy(inheritedMember.getContainingDeclaration(), traitMember.getModality(), Visibilities.PUBLIC,
CallableMemberDescriptor.Kind.DECLARATION, true);
if (traitMember instanceof SimpleFunctionDescriptor) {
result.put((FunctionDescriptor) traitMember, (FunctionDescriptor) copy);
}
else if (traitMember instanceof PropertyDescriptor) {
for (PropertyAccessorDescriptor traitAccessor : ((PropertyDescriptor) traitMember).getAccessors()) {
for (PropertyAccessorDescriptor inheritedAccessor : ((PropertyDescriptor) copy).getAccessors()) {
if (inheritedAccessor.getClass() == traitAccessor.getClass()) { // same accessor kind
result.put(traitAccessor, inheritedAccessor);
}
}
}

View File

@@ -0,0 +1,68 @@
/*
* Copyright 2010-2014 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.jet.backend.common
import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor
import org.jetbrains.jet.lang.descriptors.ClassDescriptor
import org.jetbrains.jet.lang.types.JetType
import kotlin.platform.platformStatic
import org.jetbrains.jet.lang.descriptors.CallableDescriptor
import org.jetbrains.jet.utils.keysToMapExceptNulls
import org.jetbrains.jet.lang.resolve.DescriptorUtils
import org.jetbrains.jet.lang.resolve.MemberComparator
import java.util.Comparator
public object CodegenUtilKt {
// class Foo : Bar by baz
// descriptor = Foo
// toTrait = Bar
// delegateExpressionType = typeof(baz)
// return Map<member of Foo, corresponding member of typeOf(baz)>
public [platformStatic] fun getDelegates(
descriptor: ClassDescriptor,
toTrait: ClassDescriptor,
delegateExpressionType: JetType? = null
): Map<CallableMemberDescriptor, CallableDescriptor> {
return descriptor.getDefaultType().getMemberScope().getAllDescriptors().stream()
.filterIsInstance(javaClass<CallableMemberDescriptor>())
.filter { it.getKind() == CallableMemberDescriptor.Kind.DELEGATION }
.toList()
.sortBy(MemberComparator.INSTANCE as Comparator<CallableMemberDescriptor>) // Workaround for KT-6030
.keysToMapExceptNulls {
delegatingMember ->
val actualDelegates = DescriptorUtils.getAllOverriddenDescriptors(delegatingMember)
.filter { it.getContainingDeclaration() == toTrait }
.map {
overriddenDescriptor ->
val scope = (delegateExpressionType ?: toTrait.getDefaultType()).getMemberScope()
val name = overriddenDescriptor.getName()
// this is the actual member of delegateExpressionType that we are delegating to
(scope.getFunctions(name) + scope.getProperties(name))
.first {
(listOf(it) + DescriptorUtils.getAllOverriddenDescriptors(it)).map { it.getOriginal() }.contains(overriddenDescriptor.getOriginal())
}
}
assert(actualDelegates.size <= 1) { "Meny delegates found for $delegatingMember: $actualDelegates" }
actualDelegates.firstOrNull()
}
}
}

View File

@@ -44,8 +44,8 @@ public class AccessorForFunctionDescriptor extends SimpleFunctionDescriptorImpl
Kind.DECLARATION, SourceElement.NO_SOURCE);
this.calleeDescriptor = descriptor;
initialize(DescriptorUtils.getReceiverParameterType(descriptor.getReceiverParameter()),
descriptor instanceof ConstructorDescriptor ? NO_RECEIVER_PARAMETER : descriptor.getExpectedThisObject(),
initialize(DescriptorUtils.getReceiverParameterType(descriptor.getExtensionReceiverParameter()),
descriptor instanceof ConstructorDescriptor ? NO_RECEIVER_PARAMETER : descriptor.getDispatchReceiverParameter(),
copyTypeParameters(descriptor),
copyValueParameters(descriptor),
descriptor.getReturnType(),

View File

@@ -34,14 +34,14 @@ public class AccessorForPropertyDescriptor extends PropertyDescriptorImpl implem
private final PropertyDescriptor calleeDescriptor;
public AccessorForPropertyDescriptor(@NotNull PropertyDescriptor pd, @NotNull DeclarationDescriptor containingDeclaration, int index) {
this(pd, pd.getType(), DescriptorUtils.getReceiverParameterType(pd.getReceiverParameter()), pd.getExpectedThisObject(), containingDeclaration, index);
this(pd, pd.getType(), DescriptorUtils.getReceiverParameterType(pd.getExtensionReceiverParameter()), pd.getDispatchReceiverParameter(), containingDeclaration, index);
}
protected AccessorForPropertyDescriptor(
@NotNull PropertyDescriptor original,
@NotNull JetType propertyType,
@Nullable JetType receiverType,
@Nullable ReceiverParameterDescriptor expectedThisObject,
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
@NotNull DeclarationDescriptor containingDeclaration,
int index
) {
@@ -50,7 +50,7 @@ public class AccessorForPropertyDescriptor extends PropertyDescriptorImpl implem
Kind.DECLARATION, SourceElement.NO_SOURCE);
this.calleeDescriptor = original;
setType(propertyType, Collections.<TypeParameterDescriptorImpl>emptyList(), expectedThisObject, receiverType);
setType(propertyType, Collections.<TypeParameterDescriptorImpl>emptyList(), dispatchReceiverParameter, receiverType);
initialize(new Getter(this), new Setter(this));
}

View File

@@ -37,7 +37,9 @@ import org.jetbrains.jet.lang.resolve.java.*;
import org.jetbrains.jet.lang.resolve.java.descriptor.JavaCallableMemberDescriptor;
import org.jetbrains.jet.lang.resolve.kotlin.PackagePartClassUtils;
import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.types.Approximation;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.TypesPackage;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lexer.JetTokens;
import org.jetbrains.org.objectweb.asm.*;
@@ -484,29 +486,28 @@ public class AsmUtil {
v.xor(Type.INT_TYPE);
}
@NotNull
public static StackValue genEqualsForExpressionsOnStack(
InstructionAdapter v,
IElementType opToken,
Type leftType,
Type rightType
@NotNull InstructionAdapter v,
@NotNull IElementType opToken,
@NotNull Type leftType,
@NotNull Type rightType
) {
if ((isNumberPrimitive(leftType) || leftType.getSort() == Type.BOOLEAN) && leftType == rightType) {
if (isPrimitive(leftType) && leftType == rightType) {
return StackValue.cmp(opToken, leftType);
}
else {
if (opToken == JetTokens.EQEQEQ || opToken == JetTokens.EXCLEQEQEQ) {
return StackValue.cmp(opToken, leftType);
}
else {
v.invokestatic("kotlin/jvm/internal/Intrinsics", "areEqual", "(Ljava/lang/Object;Ljava/lang/Object;)Z", false);
if (opToken == JetTokens.EXCLEQ || opToken == JetTokens.EXCLEQEQEQ) {
genInvertBoolean(v);
}
return StackValue.onStack(Type.BOOLEAN_TYPE);
}
if (opToken == JetTokens.EQEQEQ || opToken == JetTokens.EXCLEQEQEQ) {
return StackValue.cmp(opToken, leftType);
}
v.invokestatic("kotlin/jvm/internal/Intrinsics", "areEqual", "(Ljava/lang/Object;Ljava/lang/Object;)Z", false);
if (opToken == JetTokens.EXCLEQ || opToken == JetTokens.EXCLEQEQEQ) {
genInvertBoolean(v);
}
return StackValue.onStack(Type.BOOLEAN_TYPE);
}
public static void genIncrement(Type expectedType, int myDelta, InstructionAdapter v) {
@@ -608,12 +609,15 @@ public class AsmUtil {
@NotNull CallableDescriptor descriptor,
@NotNull String assertMethodToCall
) {
// Assertions are generated elsewhere for platform types
if (JavaPackage.getPLATFORM_TYPES()) return;
if (!state.isCallAssertionsEnabled()) return;
if (!isDeclaredInJava(descriptor)) return;
JetType type = descriptor.getReturnType();
if (type == null || isNullableType(type)) return;
if (type == null || isNullableType(TypesPackage.lowerIfFlexible(type))) return;
Type asmType = state.getTypeMapper().mapReturnType(descriptor);
if (asmType.getSort() == Type.OBJECT || asmType.getSort() == Type.ARRAY) {
@@ -625,6 +629,30 @@ public class AsmUtil {
}
}
@NotNull
public static StackValue genNotNullAssertions(
@NotNull GenerationState state,
@NotNull final StackValue stackValue,
@Nullable final Approximation.Info approximationInfo
) {
if (!state.isCallAssertionsEnabled()) return stackValue;
if (approximationInfo == null || !TypesPackage.assertNotNull(approximationInfo)) return stackValue;
return new StackValue(stackValue.type) {
@Override
public void put(Type type, InstructionAdapter v) {
stackValue.put(type, v);
if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) {
v.dup();
v.visitLdcInsn(approximationInfo.getMessage());
v.invokestatic("kotlin/jvm/internal/Intrinsics", "checkExpressionValueIsNotNull",
"(Ljava/lang/Object;Ljava/lang/String;)V", false);
}
}
};
}
private static boolean isDeclaredInJava(@NotNull CallableDescriptor callableDescriptor) {
CallableDescriptor descriptor = callableDescriptor;
while (true) {
@@ -667,7 +695,7 @@ public class AsmUtil {
}
public static int getVisibilityForSpecialPropertyBackingField(@NotNull PropertyDescriptor propertyDescriptor, boolean isDelegate) {
boolean isExtensionProperty = propertyDescriptor.getReceiverParameter() != null;
boolean isExtensionProperty = propertyDescriptor.getExtensionReceiverParameter() != null;
if (isDelegate || isExtensionProperty) {
return ACC_PRIVATE;
}
@@ -688,7 +716,7 @@ public class AsmUtil {
}
public static boolean isPropertyWithBackingFieldCopyInOuterClass(@NotNull PropertyDescriptor propertyDescriptor) {
boolean isExtensionProperty = propertyDescriptor.getReceiverParameter() != null;
boolean isExtensionProperty = propertyDescriptor.getExtensionReceiverParameter() != null;
DeclarationDescriptor propertyContainer = propertyDescriptor.getContainingDeclaration();
return !propertyDescriptor.isVar()
&& !isExtensionProperty

View File

@@ -28,6 +28,7 @@ import org.jetbrains.jet.codegen.signature.BothSignatureWriter;
import org.jetbrains.jet.codegen.state.GenerationState;
import org.jetbrains.jet.codegen.state.JetTypeMapper;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
@@ -54,6 +55,7 @@ import static org.jetbrains.org.objectweb.asm.Opcodes.*;
public class ClosureCodegen extends ParentCodegenAware {
private final PsiElement fun;
private final FunctionDescriptor funDescriptor;
private final ClassDescriptor classDescriptor;
private final SamType samType;
private final JetType superClassType;
private final List<JetType> superInterfaceTypes;
@@ -86,7 +88,7 @@ public class ClosureCodegen extends ParentCodegenAware {
this.syntheticClassKind = syntheticClassKind;
this.strategy = strategy;
ClassDescriptor classDescriptor = anonymousClassForFunction(bindingContext, funDescriptor);
this.classDescriptor = anonymousClassForFunction(bindingContext, funDescriptor);
if (samType == null) {
this.superInterfaceTypes = new ArrayList<JetType>();
@@ -164,6 +166,21 @@ public class ClosureCodegen extends ParentCodegenAware {
FunctionCodegen fc = new FunctionCodegen(context, cv, state, getParentCodegen());
fc.generateMethod(OtherOrigin(fun, funDescriptor), jvmMethodSignature, funDescriptor, strategy);
//TODO: rewrite cause ugly hack
if (samType != null) {
SimpleFunctionDescriptorImpl descriptorForBridges = SimpleFunctionDescriptorImpl
.create(funDescriptor.getContainingDeclaration(), funDescriptor.getAnnotations(), erasedInterfaceFunction.getName(),
CallableMemberDescriptor.Kind.DECLARATION, funDescriptor.getSource());
descriptorForBridges
.initialize(null, erasedInterfaceFunction.getDispatchReceiverParameter(), erasedInterfaceFunction.getTypeParameters(),
erasedInterfaceFunction.getValueParameters(), erasedInterfaceFunction.getReturnType(), Modality.OPEN,
erasedInterfaceFunction.getVisibility());
descriptorForBridges.addOverriddenDescriptor(erasedInterfaceFunction);
fc.generateBridges(descriptorForBridges);
}
this.constructor = generateConstructor(cv, superClassAsmType);
if (isConst(closure)) {
@@ -180,7 +197,7 @@ public class ClosureCodegen extends ParentCodegenAware {
null);
AsmUtil.writeOuterClassAndEnclosingMethod(anonymousClassForFunction(bindingContext, funDescriptor), funDescriptor, typeMapper, cv);
AsmUtil.writeOuterClassAndEnclosingMethod(classDescriptor, funDescriptor, typeMapper, cv);
cv.done();
}
@@ -193,7 +210,7 @@ public class ClosureCodegen extends ParentCodegenAware {
v.anew(asmType);
v.dup();
codegen.pushClosureOnStack(closure, false, codegen.defaultCallGenerator);
codegen.pushClosureOnStack(classDescriptor, true, codegen.defaultCallGenerator);
v.invokespecial(asmType.getInternalName(), "<init>", constructor.getDescriptor(), false);
}
return StackValue.onStack(asmType);
@@ -230,7 +247,7 @@ public class ClosureCodegen extends ParentCodegenAware {
InstructionAdapter iv = new InstructionAdapter(mv);
iv.load(0, asmType);
ReceiverParameterDescriptor receiver = funDescriptor.getReceiverParameter();
ReceiverParameterDescriptor receiver = funDescriptor.getExtensionReceiverParameter();
int count = 1;
if (receiver != null) {
StackValue.local(count, bridge.getArgumentTypes()[count - 1]).put(typeMapper.mapType(receiver.getType()), iv);
@@ -328,7 +345,7 @@ public class ClosureCodegen extends ParentCodegenAware {
@NotNull
public static FunctionDescriptor getErasedInvokeFunction(@NotNull FunctionDescriptor funDescriptor) {
int arity = funDescriptor.getValueParameters().size();
ClassDescriptor funClass = funDescriptor.getReceiverParameter() == null
ClassDescriptor funClass = funDescriptor.getExtensionReceiverParameter() == null
? KotlinBuiltIns.getInstance().getFunction(arity)
: KotlinBuiltIns.getInstance().getExtensionFunction(arity);
return funClass.getDefaultType().getMemberScope().getFunctions(Name.identifier("invoke")).iterator().next();

View File

@@ -50,4 +50,11 @@ public class CodegenStatementVisitor extends JetVisitor<StackValue, StackValue>
public StackValue visitBlockExpression(@NotNull JetBlockExpression expression, StackValue data) {
return codegen.generateBlock(expression, true);
}
@Override
public StackValue visitLabeledExpression(@NotNull JetLabeledExpression expression, StackValue receiver) {
JetExpression baseExpression = expression.getBaseExpression();
assert baseExpression != null : "Label expression should have base one: " + expression.getText();
return baseExpression.accept(this, receiver);
}
}

View File

@@ -0,0 +1,232 @@
/*
* Copyright 2010-2014 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.jet.codegen
import org.jetbrains.jet.codegen.state.GenerationState
import org.jetbrains.jet.lang.descriptors.*
import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor.Kind.*
import org.jetbrains.jet.lang.descriptors.impl.*
import org.jetbrains.org.objectweb.asm.Opcodes.*
import org.jetbrains.jet.lang.resolve.java.diagnostics.JvmDeclarationOrigin
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
import org.jetbrains.jet.lang.types.*
import org.jetbrains.jet.lang.resolve.scopes.JetScope
import org.jetbrains.jet.lang.descriptors.annotations.Annotations
import org.jetbrains.jet.lang.resolve.OverrideResolver
import org.jetbrains.jet.lang.resolve.OverridingUtil
import java.util.LinkedHashSet
import org.jetbrains.jet.lang.resolve.name.Name
import java.util.ArrayList
import org.jetbrains.jet.lang.types.checker.JetTypeChecker
import java.util.HashSet
/**
* Generates exception-throwing stubs for methods from mutable collection classes not implemented in Kotlin classes which inherit only from
* Kotlin's read-only collections. This is required on JVM because Kotlin's read-only collections are mapped to mutable JDK collections
*/
class CollectionStubMethodGenerator(
state: GenerationState,
private val descriptor: ClassDescriptor,
private val functionCodegen: FunctionCodegen,
private val v: ClassBuilder
) {
private val typeMapper = state.getTypeMapper()
fun generate() {
val superCollectionClasses = findRelevantSuperCollectionClasses()
if (superCollectionClasses.isEmpty()) return
val methodStubsToGenerate = LinkedHashSet<String>()
val syntheticStubsToGenerate = LinkedHashSet<String>()
for ((readOnlyClass, mutableClass) in superCollectionClasses) {
// To determine which method stubs we need to generate, we create a synthetic class (named 'child' here) which inherits from
// our class ('descriptor') and the corresponding MutableCollection class (for example; the process is the same for every
// built-in read-only/mutable class pair). We then construct and bind fake overrides in this synthetic class with the usual
// override resolution process. Resulting fake overrides with originals in MutableCollection are considered as candidates for
// method stubs or bridges to the actual implementation that happened to be present in the class
val (child, typeParameters) = createSyntheticSubclass()
// If the original class has any type parameters, we copied them and now we need to substitute types of the newly created type
// parameters as arguments for the type parameters of the original class
val parentType = newType(descriptor, typeParameters.map { TypeProjectionImpl(it.getDefaultType()) })
// Now we need to determine the arguments which should be substituted for the MutableCollection super class. To do that,
// we look for type arguments which were substituted in the inheritance of the original class from Collection and use them
// to construct the needed MutableCollection type. Since getAllSupertypes() may return several types which correspond to the
// Collection class descriptor, we find the most specific one (which is guaranteed to exist by front-end)
val readOnlyCollectionType = TypeUtils.getAllSupertypes(parentType).findMostSpecificTypeForClass(readOnlyClass)
val mutableCollectionType = newType(mutableClass, readOnlyCollectionType.getArguments())
child.addSupertype(parentType)
child.addSupertype(mutableCollectionType)
child.createTypeConstructor()
// Bind fake overrides and for each fake override originated from the MutableCollection, save its signature to generate a stub
// or save its descriptor to generate all the needed bridges
for (method in findFakeOverridesForMethodsFromMutableCollection(child, mutableClass)) {
if (method.getModality() == Modality.ABSTRACT) {
// If the fake override is abstract and it's _declared_ as abstract in the class, skip it because the method is already
// present in the bytecode (abstract) and we don't want a duplicate signature error
if (method.findOverriddenFromDirectSuperClass(descriptor)?.getKind() == DECLARATION) continue
// Otherwise we can safely generate the stub with the substituted signature
val signature = method.signature()
methodStubsToGenerate.add(signature)
// If the substituted signature differs from the original one in MutableCollection, we should also generate a stub with
// the original (erased) signature. It doesn't really matter if this is a bridge method delegating to the first stub or
// a method with its own exception-throwing code, for simplicity we do the latter here.
// What _does_ matter though, is that these two methods can't be both non-synthetic at once: javac issues compilation
// errors when compiling Java against such classes because one of them doesn't seem to override the generic method
// declared in the Java Collection interface (can't override generic with erased). So we maintain an additional set of
// methods which need to be generated with the ACC_SYNTHETIC flag
val originalSignature = method.findOverriddenFromDirectSuperClass(mutableClass)!!.getOriginal().signature()
if (originalSignature != signature) {
syntheticStubsToGenerate.add(originalSignature)
}
}
else {
// If the fake override is non-abstract, its implementation is already present in the class or inherited from one of its
// super classes, but is not related to the MutableCollection hierarchy. So maybe it uses more specific return types
// and we may need to generate some bridges
functionCodegen.generateBridges(method)
}
}
}
for (signature in methodStubsToGenerate) {
generateMethodStub(signature, synthetic = false)
}
for (signature in syntheticStubsToGenerate) {
generateMethodStub(signature, synthetic = true)
}
}
private data class CollectionClassPair(
val readOnlyClass: ClassDescriptor,
val mutableClass: ClassDescriptor
)
private fun findRelevantSuperCollectionClasses(): Collection<CollectionClassPair> {
fun pair(readOnlyClass: ClassDescriptor, mutableClass: ClassDescriptor) = CollectionClassPair(readOnlyClass, mutableClass)
val collectionClasses = with(KotlinBuiltIns.getInstance()) {
listOf(
pair(getCollection(), getMutableCollection()),
pair(getSet(), getMutableSet()),
pair(getList(), getMutableList()),
pair(getMap(), getMutableMap()),
pair(getMapEntry(), getMutableMapEntry()),
pair(getIterable(), getMutableIterable()),
pair(getIterator(), getMutableIterator()),
pair(getListIterator(), getMutableListIterator())
)
}
val allSuperClasses = TypeUtils.getAllSupertypes(descriptor.getDefaultType()).classes().toHashSet()
val ourSuperCollectionClasses = collectionClasses.filter { pair ->
pair.readOnlyClass in allSuperClasses && pair.mutableClass !in allSuperClasses
}
if (ourSuperCollectionClasses.isEmpty()) return listOf()
// Filter out built-in classes which are overridden by other built-in classes in the list, to avoid duplicating methods.
val redundantClasses = ourSuperCollectionClasses.flatMapTo(HashSet<ClassDescriptor>()) { pair ->
pair.readOnlyClass.getTypeConstructor().getSupertypes().classes()
}
return ourSuperCollectionClasses.filter { klass -> klass.readOnlyClass !in redundantClasses }
}
private fun Collection<JetType>.classes(): Collection<ClassDescriptor> =
this.map { it.getConstructor().getDeclarationDescriptor() as ClassDescriptor }
private fun findFakeOverridesForMethodsFromMutableCollection(
klass: ClassDescriptor,
mutableCollectionClass: ClassDescriptor
): List<FunctionDescriptor> {
val result = ArrayList<FunctionDescriptor>()
OverrideResolver.generateOverridesInAClass(klass, listOf(), object : OverridingUtil.DescriptorSink {
override fun addToScope(fakeOverride: CallableMemberDescriptor) {
if (fakeOverride !is FunctionDescriptor) return
if (fakeOverride.findOverriddenFromDirectSuperClass(mutableCollectionClass) != null) {
result.add(fakeOverride)
}
}
override fun conflict(fromSuper: CallableMemberDescriptor, fromCurrent: CallableMemberDescriptor) {
// Ignore conflicts here
// TODO: report a warning that javac will prohibit use/inheritance from such class
}
})
return result
}
private fun Collection<JetType>.findMostSpecificTypeForClass(klass: ClassDescriptor): JetType {
val types = this.filter { it.getConstructor().getDeclarationDescriptor() == klass }
if (types.isEmpty()) error("No supertype of $klass in $this")
if (types.size == 1) return types.first()
// Find the first type in the list such that it's a subtype of every other type in that list
return types.first { type ->
types.all { other -> JetTypeChecker.DEFAULT.isSubtypeOf(type, other) }
}
}
private fun createSyntheticSubclass(): Pair<MutableClassDescriptor, List<TypeParameterDescriptor>> {
val child = MutableClassDescriptor(descriptor.getContainingDeclaration(), JetScope.EMPTY, ClassKind.CLASS, false,
Name.special("<synthetic inheritor of ${descriptor.getName()}>"), descriptor.getSource())
child.setModality(Modality.FINAL)
child.setVisibility(Visibilities.PUBLIC)
val typeParameters = descriptor.getTypeConstructor().getParameters()
val newTypeParameters = ArrayList<TypeParameterDescriptor>(typeParameters.size())
DescriptorSubstitutor.substituteTypeParameters(typeParameters, TypeSubstitutor.EMPTY, child, newTypeParameters)
child.setTypeParameterDescriptors(typeParameters)
return Pair(child, newTypeParameters)
}
private fun FunctionDescriptor.findOverriddenFromDirectSuperClass(classDescriptor: ClassDescriptor): FunctionDescriptor? {
return this.getOverriddenDescriptors().firstOrNull { it.getContainingDeclaration() == classDescriptor }
}
private fun newType(classDescriptor: ClassDescriptor, typeArguments: List<TypeProjection>): JetType {
return JetTypeImpl(Annotations.EMPTY, classDescriptor.getTypeConstructor(), false, typeArguments,
classDescriptor.getMemberScope(typeArguments))
}
private fun FunctionDescriptor.signature(): String {
val method = typeMapper.mapSignature(this).getAsmMethod()
return method.getName() + method.getDescriptor()
}
private fun generateMethodStub(signature: String, synthetic: Boolean) {
// TODO: investigate if it makes sense to generate abstract stubs in traits
var access = ACC_PUBLIC
if (descriptor.getKind() == ClassKind.TRAIT) access = access or ACC_ABSTRACT
if (synthetic) access = access or ACC_SYNTHETIC
val paren = signature.indexOf('(')
val mv = v.newMethod(JvmDeclarationOrigin.NO_ORIGIN, access, signature.substring(0, paren), signature.substring(paren), null, null)
if (descriptor.getKind() != ClassKind.TRAIT) {
mv.visitCode()
AsmUtil.genThrow(InstructionAdapter(mv), "java/lang/UnsupportedOperationException", "Mutating immutable collection")
FunctionCodegen.endVisit(mv, "built-in stub for $signature", null)
}
}
}

View File

@@ -29,7 +29,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.codegen.binding.CalculatedClosure;
import org.jetbrains.jet.codegen.binding.CodegenBinding;
import org.jetbrains.jet.codegen.binding.MutableClosure;
import org.jetbrains.jet.codegen.context.*;
import org.jetbrains.jet.codegen.inline.InlineCodegen;
import org.jetbrains.jet.codegen.inline.InlineCodegenUtil;
@@ -61,6 +60,7 @@ import org.jetbrains.jet.lang.resolve.java.descriptor.SamConstructorDescriptor;
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodSignature;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.resolve.scopes.receivers.*;
import org.jetbrains.jet.lang.types.Approximation;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.TypeUtils;
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
@@ -88,6 +88,7 @@ import static org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage.getR
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.*;
import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.KotlinSyntheticClass;
import static org.jetbrains.jet.lang.resolve.java.diagnostics.DiagnosticsPackage.OtherOrigin;
import static org.jetbrains.jet.lang.resolve.java.diagnostics.DiagnosticsPackage.TraitImpl;
import static org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue.NO_RECEIVER;
import static org.jetbrains.org.objectweb.asm.Opcodes.ACC_PRIVATE;
import static org.jetbrains.org.objectweb.asm.Opcodes.GETFIELD;
@@ -183,7 +184,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
@NotNull
public CalculatedClosure generateObjectLiteral(@NotNull JetObjectLiteralExpression literal) {
public ClassDescriptor generateObjectLiteral(@NotNull JetObjectLiteralExpression literal) {
JetObjectDeclaration objectDeclaration = literal.getObjectDeclaration();
ClassDescriptor classDescriptor = bindingContext.get(CLASS, objectDeclaration);
@@ -196,13 +197,10 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
literal.getContainingFile()
);
ClassContext objectContext = context.intoAnonymousClass(classDescriptor, this);
ClassContext objectContext = context.intoAnonymousClass(classDescriptor, this, OwnerKind.IMPLEMENTATION);
new ImplementationBodyCodegen(objectDeclaration, objectContext, classBuilder, state, getParentCodegen()).generate();
//noinspection ConstantConditions
return bindingContext.get(CLOSURE, classDescriptor);
return classDescriptor;
}
@NotNull
@@ -241,7 +239,14 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
}
return selector.accept(visitor, receiver);
StackValue stackValue = selector.accept(visitor, receiver);
Approximation.Info approximationInfo = null;
if (selector instanceof JetExpression) {
approximationInfo = bindingContext.get(BindingContext.EXPRESSION_RESULT_APPROXIMATION, (JetExpression) selector);
}
return genNotNullAssertions(state, stackValue, approximationInfo);
}
catch (ProcessCanceledException e) {
throw e;
@@ -285,9 +290,16 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
Type asmType = asmTypeForAnonymousClass(bindingContext, declaration);
ClassBuilder classBuilder = state.getFactory().newVisitor(OtherOrigin(declaration, descriptor), asmType, declaration.getContainingFile());
ClassContext objectContext = context.intoAnonymousClass(descriptor, this);
ClassContext objectContext = context.intoAnonymousClass(descriptor, this, OwnerKind.IMPLEMENTATION);
new ImplementationBodyCodegen(declaration, objectContext, classBuilder, state, getParentCodegen()).generate();
if (declaration instanceof JetClass && ((JetClass) declaration).isTrait()) {
Type traitImplType = state.getTypeMapper().mapTraitImpl(descriptor);
ClassBuilder traitImplBuilder = state.getFactory().newVisitor(TraitImpl(declaration, descriptor), traitImplType, declaration.getContainingFile());
ClassContext traitImplContext = context.intoAnonymousClass(descriptor, this, OwnerKind.TRAIT_IMPL);
new TraitImplBodyCodegen(declaration, traitImplContext, traitImplBuilder, state, parentCodegen).generate();
}
return StackValue.none();
}
@@ -649,6 +661,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
public void afterBody(@NotNull Label loopExit) {
markLineNumber(forExpression);
increment(loopExit);
v.mark(bodyEnd);
@@ -1326,20 +1340,16 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
@Override
public StackValue visitObjectLiteralExpression(@NotNull JetObjectLiteralExpression expression, StackValue receiver) {
CalculatedClosure closure = generateObjectLiteral(expression);
ConstructorDescriptor constructorDescriptor = bindingContext.get(CONSTRUCTOR, expression.getObjectDeclaration());
assert constructorDescriptor != null : "Unresolved constructor: " + expression.getText();
JvmMethodSignature constructor = typeMapper.mapSignature(constructorDescriptor);
Type type = typeMapper.mapType(constructorDescriptor.getContainingDeclaration());
ClassDescriptor classDescriptor = generateObjectLiteral(expression);
Type type = typeMapper.mapType(classDescriptor);
v.anew(type);
v.dup();
pushClosureOnStack(closure, false, defaultCallGenerator);
pushClosureOnStack(classDescriptor, true, defaultCallGenerator);
ResolvedCall<ConstructorDescriptor> superCall = closure.getSuperCall();
//noinspection ConstantConditions
ResolvedCall<ConstructorDescriptor> superCall = bindingContext.get(CLOSURE, classDescriptor).getSuperCall();
if (superCall != null) {
// For an anonymous object, we should also generate all non-default arguments that it captures for its super call
ConstructorDescriptor superConstructor = superCall.getResultingDescriptor();
@@ -1347,7 +1357,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
int params = superValueParameters.size();
List<Type> superMappedTypes = typeMapper.mapToCallableMethod(superConstructor).getValueParameterTypes();
assert superMappedTypes.size() >= params : String.format("Incorrect number of mapped parameters vs arguments: %d < %d for %s",
superMappedTypes.size(), params, constructorDescriptor);
superMappedTypes.size(), params, classDescriptor);
List<ResolvedValueArgument> valueArguments = new ArrayList<ResolvedValueArgument>(params);
List<ValueParameterDescriptor> valueParameters = new ArrayList<ValueParameterDescriptor>(params);
@@ -1365,33 +1375,33 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
argumentGenerator.generate(valueArguments);
}
ConstructorDescriptor constructorDescriptor = bindingContext.get(CONSTRUCTOR, expression.getObjectDeclaration());
assert constructorDescriptor != null : "Unresolved constructor: " + expression.getText();
JvmMethodSignature constructor = typeMapper.mapSignature(constructorDescriptor);
v.invokespecial(type.getInternalName(), "<init>", constructor.getAsmMethod().getDescriptor(), false);
return StackValue.onStack(type);
}
public void pushClosureOnStack(
@Nullable CalculatedClosure closure,
boolean ignoreThisAndReceiver,
@NotNull CallGenerator callGenerator
) {
public void pushClosureOnStack(@NotNull ClassDescriptor classDescriptor, boolean putThis, @NotNull CallGenerator callGenerator) {
CalculatedClosure closure = bindingContext.get(CLOSURE, classDescriptor);
if (closure == null) return;
int paramIndex = 0;
if (!ignoreThisAndReceiver) {
if (putThis) {
ClassDescriptor captureThis = closure.getCaptureThis();
if (captureThis != null) {
StackValue thisOrOuter = generateThisOrOuter(captureThis, false);
assert !isPrimitive(thisOrOuter.type) : "This or outer should be non primitive: " + thisOrOuter.type;
callGenerator.putCapturedValueOnStack(thisOrOuter, thisOrOuter.type, paramIndex++);
}
}
JetType captureReceiver = closure.getCaptureReceiverType();
if (captureReceiver != null) {
Type asmType = typeMapper.mapType(captureReceiver);
StackValue.Local capturedReceiver = StackValue.local(AsmUtil.getReceiverIndex(context, context.getContextDescriptor()), asmType);
callGenerator.putCapturedValueOnStack(capturedReceiver, capturedReceiver.type, paramIndex++);
}
JetType captureReceiver = closure.getCaptureReceiverType();
if (captureReceiver != null) {
Type asmType = typeMapper.mapType(captureReceiver);
StackValue.Local capturedReceiver = StackValue.local(AsmUtil.getReceiverIndex(context, context.getContextDescriptor()), asmType);
callGenerator.putCapturedValueOnStack(capturedReceiver, capturedReceiver.type, paramIndex++);
}
for (Map.Entry<DeclarationDescriptor, EnclosedValueDescriptor> entry : closure.getCaptureVariables().entrySet()) {
@@ -1405,8 +1415,11 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
ResolvedCall<ConstructorDescriptor> superCall = closure.getSuperCall();
if (superCall != null) {
MutableClosure superClosure = bindingContext.get(CLOSURE, superCall.getResultingDescriptor().getContainingDeclaration());
pushClosureOnStack(superClosure, ignoreThisAndReceiver, callGenerator);
pushClosureOnStack(
superCall.getResultingDescriptor().getContainingDeclaration(),
putThis && closure.getCaptureThis() == null,
callGenerator
);
}
}
@@ -1422,7 +1435,12 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
StackValue answer = StackValue.none();
for (Iterator<JetElement> iterator = statements.iterator(); iterator.hasNext(); ) {
JetElement statement = iterator.next();
JetElement possiblyLabeledStatement = iterator.next();
JetElement statement = possiblyLabeledStatement instanceof JetExpression
? JetPsiUtil.safeDeparenthesize((JetExpression) possiblyLabeledStatement, true)
: possiblyLabeledStatement;
if (statement instanceof JetNamedDeclaration) {
JetNamedDeclaration declaration = (JetNamedDeclaration) statement;
@@ -1451,7 +1469,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
v.mark(labelBeforeLastExpression);
}
StackValue result = isExpression ? gen(statement) : genStatement(statement);
StackValue result = isExpression ? gen(possiblyLabeledStatement) : genStatement(possiblyLabeledStatement);
if (!iterator.hasNext()) {
answer = result;
@@ -1880,7 +1898,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
boolean isBackingFieldInAnotherClass = AsmUtil.isPropertyWithBackingFieldInOuterClass(propertyDescriptor);
boolean isStatic = DescriptorUtils.isStaticDeclaration(propertyDescriptor);
boolean isSuper = superExpression != null;
boolean isExtensionProperty = propertyDescriptor.getReceiverParameter() != null;
boolean isExtensionProperty = propertyDescriptor.getExtensionReceiverParameter() != null;
JetType delegateType = getPropertyDelegateType(propertyDescriptor, bindingContext);
boolean isDelegatedProperty = delegateType != null;
@@ -2214,6 +2232,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
boolean isInline = state.isInlineEnabled() &&
descriptor instanceof SimpleFunctionDescriptor &&
((SimpleFunctionDescriptor) descriptor).getInlineStrategy().isInline();
if (!isInline) return defaultCallGenerator;
SimpleFunctionDescriptor original = DescriptorUtils.unwrapFakeOverride((SimpleFunctionDescriptor) descriptor.getOriginal());
@@ -2264,11 +2283,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
@NotNull
private StackValue generateReceiver(@NotNull CallableDescriptor descriptor) {
if (context.getCallableDescriptorWithReceiver() == descriptor) {
return context.getReceiverExpression(typeMapper);
}
return context.lookupInContext(descriptor, StackValue.local(0, OBJECT_TYPE), state, false);
return context.generateReceiver(descriptor, state, false);
}
// SCRIPT: generate script, move to ScriptingUtil
@@ -2479,7 +2494,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
PackageFragmentDescriptor containingPackage = (PackageFragmentDescriptor) descriptor.getContainingDeclaration();
String packageClassInternalName = PackageClassUtils.getPackageClassInternalName(containingPackage.getFqName());
ReceiverParameterDescriptor receiverParameter = descriptor.getReceiverParameter();
ReceiverParameterDescriptor receiverParameter = descriptor.getExtensionReceiverParameter();
Method factoryMethod;
if (receiverParameter != null) {
Type[] parameterTypes = new Type[] {JAVA_STRING_TYPE, K_PACKAGE_IMPL_TYPE, getType(Class.class)};
@@ -2556,21 +2571,21 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
JetCallExpression fakeExpression = constructFakeFunctionCall();
final List<? extends ValueArgument> fakeArguments = fakeExpression.getValueArguments();
final ReceiverValue thisObject = computeAndSaveReceiver(signature, codegen, referencedFunction.getExpectedThisObject());
final ReceiverValue extensionReceiver = computeAndSaveReceiver(signature, codegen, referencedFunction.getReceiverParameter());
final ReceiverValue dispatchReceiver = computeAndSaveReceiver(signature, codegen, referencedFunction.getDispatchReceiverParameter());
final ReceiverValue extensionReceiver = computeAndSaveReceiver(signature, codegen, referencedFunction.getExtensionReceiverParameter());
computeAndSaveArguments(fakeArguments, codegen);
ResolvedCall<CallableDescriptor> fakeResolvedCall = new DelegatingResolvedCall<CallableDescriptor>(resolvedCall) {
@NotNull
@Override
public ReceiverValue getReceiverArgument() {
public ReceiverValue getExtensionReceiver() {
return extensionReceiver;
}
@NotNull
@Override
public ReceiverValue getThisObject() {
return thisObject;
public ReceiverValue getDispatchReceiver() {
return dispatchReceiver;
}
@NotNull
@@ -2992,9 +3007,10 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
StackValue value = gen(lhs); // receiver
value.dupReceiver(v); // receiver receiver
value.put(lhsType, v); // receiver lhs
((IntrinsicMethod) callable).generate(this, v, typeMapper.mapType(descriptor), expression,
Type returnType = typeMapper.mapType(descriptor);
((IntrinsicMethod) callable).generate(this, v, returnType, expression,
Collections.singletonList(expression.getRight()), StackValue.onStack(lhsType));
value.store(lhsType, v);
value.store(returnType, v);
return StackValue.none();
}
else {
@@ -3038,9 +3054,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
JetExpression left = binaryExpression.getLeft();
JetExpression right = binaryExpression.getRight();
Type leftType = expressionType(left);
Type rightType = expressionType(right);
if (leftType.equals(JAVA_STRING_TYPE) && rightType.equals(JAVA_STRING_TYPE)) {
if (leftType.equals(JAVA_STRING_TYPE)) {
invokeAppend(left);
invokeAppend(right);
return;
@@ -3069,24 +3084,25 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
@Override
public StackValue visitPrefixExpression(@NotNull JetPrefixExpression expression, StackValue receiver) {
DeclarationDescriptor op = bindingContext.get(REFERENCE_TARGET, expression.getOperationReference());
assert op instanceof FunctionDescriptor : String.valueOf(op);
DeclarationDescriptor originalOperation = bindingContext.get(REFERENCE_TARGET, expression.getOperationReference());
ResolvedCall<?> resolvedCall = getResolvedCallWithAssert(expression, bindingContext);
CallableDescriptor op = resolvedCall.getResultingDescriptor();
assert op instanceof FunctionDescriptor || originalOperation == null : String.valueOf(op);
Callable callable = resolveToCallable((FunctionDescriptor) op, false);
if (callable instanceof IntrinsicMethod) {
Type returnType = typeMapper.mapType((FunctionDescriptor) op);
Type returnType = typeMapper.mapType(op);
((IntrinsicMethod) callable).generate(this, v, returnType, expression,
Collections.singletonList(expression.getBaseExpression()), receiver);
return StackValue.onStack(returnType);
}
DeclarationDescriptor cls = op.getContainingDeclaration();
ResolvedCall<?> resolvedCall = getResolvedCallWithAssert(expression, bindingContext);
if (isPrimitiveNumberClassDescriptor(cls) || !(op.getName().asString().equals("inc") || op.getName().asString().equals("dec"))) {
if (isPrimitiveNumberClassDescriptor(cls) || !(originalOperation.getName().asString().equals("inc") || originalOperation.getName().asString().equals("dec"))) {
return invokeFunction(resolvedCall, receiver);
}
CallableMethod callableMethod = (CallableMethod) callable;
StackValue value = gen(expression.getBaseExpression());
value.dupReceiver(v);
@@ -3094,9 +3110,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
Type type = expressionType(expression.getBaseExpression());
value.put(type, v);
callableMethod.invokeWithNotNullAssertion(v, state, resolvedCall);
value.store(callableMethod.getReturnType(), v);
StackValue result = invokeFunction(resolvedCall, StackValue.onStack(type));
value.store(result.type, v);
value.put(type, v);
return StackValue.onStack(type);
}
@@ -3117,29 +3132,33 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
return StackValue.onStack(base.type);
}
DeclarationDescriptor op = bindingContext.get(REFERENCE_TARGET, expression.getOperationReference());
if (!(op instanceof FunctionDescriptor)) {
throw new UnsupportedOperationException("Don't know how to generate this postfix expression: " + op);
DeclarationDescriptor originalOperation = bindingContext.get(REFERENCE_TARGET, expression.getOperationReference());
String originalOperationName = originalOperation != null ? originalOperation.getName().asString() : null;
ResolvedCall<?> resolvedCall = getResolvedCallWithAssert(expression, bindingContext);
DeclarationDescriptor op = resolvedCall.getResultingDescriptor();
if (!(op instanceof FunctionDescriptor) || originalOperation == null) {
throw new UnsupportedOperationException("Don't know how to generate this postfix expression: " + originalOperationName + " " + op);
}
Type asmType = expressionType(expression);
Type asmResultType = expressionType(expression);
Type asmBaseType = expressionType(expression.getBaseExpression());
DeclarationDescriptor cls = op.getContainingDeclaration();
int increment;
if (op.getName().asString().equals("inc")) {
if (originalOperationName.equals("inc")) {
increment = 1;
}
else if (op.getName().asString().equals("dec")) {
else if (originalOperationName.equals("dec")) {
increment = -1;
}
else {
throw new UnsupportedOperationException("Unsupported postfix operation: " + op);
throw new UnsupportedOperationException("Unsupported postfix operation: " + originalOperationName + " " + op);
}
boolean isPrimitiveNumberClassDescriptor = isPrimitiveNumberClassDescriptor(cls);
if (isPrimitiveNumberClassDescriptor) {
if (isPrimitiveNumberClassDescriptor && AsmUtil.isPrimitive(asmBaseType)) {
JetExpression operand = expression.getBaseExpression();
if (operand instanceof JetReferenceExpression && asmType == Type.INT_TYPE) {
if (operand instanceof JetReferenceExpression && asmResultType == Type.INT_TYPE) {
int index = indexOfLocal((JetReferenceExpression) operand);
if (index >= 0) {
return StackValue.postIncrement(index, increment);
@@ -3156,20 +3175,17 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
pushReceiverAndValueViaDup(value, type); // receiver and new value
Type storeType;
if (isPrimitiveNumberClassDescriptor) {
genIncrement(asmType, increment, v);
if (isPrimitiveNumberClassDescriptor && AsmUtil.isPrimitive(asmBaseType)) {
genIncrement(asmResultType, increment, v);
storeType = type;
}
else {
ResolvedCall<?> resolvedCall = getResolvedCallWithAssert(expression, bindingContext);
Callable callable = resolveToCallable((FunctionDescriptor) op, false);
CallableMethod callableMethod = (CallableMethod) callable;
callableMethod.invokeWithNotNullAssertion(v, state, resolvedCall);
storeType = callableMethod.getReturnType();
StackValue result = invokeFunction(resolvedCall, StackValue.onStack(type));
storeType = result.type;
}
value.store(storeType, v);
return StackValue.onStack(asmType); // old value
return StackValue.onStack(asmResultType); // old value
}
private void pushReceiverAndValueViaDup(StackValue value, Type type) {
@@ -3316,17 +3332,15 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
ConstructorDescriptor constructor = (ConstructorDescriptor) resolvedCall.getResultingDescriptor();
ReceiverParameterDescriptor expectedThisObject = constructor.getExpectedThisObject();
if (expectedThisObject != null) {
Type receiverType = typeMapper.mapType(expectedThisObject.getType());
generateReceiverValue(resolvedCall.getThisObject(), receiverType);
ReceiverParameterDescriptor dispatchReceiver = constructor.getDispatchReceiverParameter();
if (dispatchReceiver != null) {
Type receiverType = typeMapper.mapType(dispatchReceiver.getType());
generateReceiverValue(resolvedCall.getDispatchReceiver(), receiverType);
}
MutableClosure closure = bindingContext.get(CLOSURE, constructor.getContainingDeclaration());
// Resolved call to local class constructor doesn't have expectedThisObject, so we need to generate closure on stack
// Resolved call to local class constructor doesn't have dispatchReceiver, so we need to generate closure on stack
// See StackValue.receiver for more info
pushClosureOnStack(closure, expectedThisObject != null, defaultCallGenerator);
pushClosureOnStack(constructor.getContainingDeclaration(), dispatchReceiver == null, defaultCallGenerator);
ConstructorDescriptor originalOfSamAdapter = (ConstructorDescriptor) SamCodegenUtil.getOriginalIfSamAdapter(constructor);
CallableMethod method = typeMapper.mapToCallableMethod(originalOfSamAdapter == null ? constructor : originalOfSamAdapter);
@@ -3463,7 +3477,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
else {
gen(array, arrayType); // intrinsic method
int index = operationDescriptor.getReceiverParameter() != null ? 1 : 0;
int index = operationDescriptor.getExtensionReceiverParameter() != null ? 1 : 0;
for (JetExpression jetExpression : expression.getIndexExpressions()) {
gen(jetExpression, argumentTypes[index]);
@@ -3487,6 +3501,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
public StackValue visitThisExpression(@NotNull JetThisExpression expression, StackValue receiver) {
DeclarationDescriptor descriptor = bindingContext.get(REFERENCE_TARGET, expression.getInstanceReference());
if (descriptor instanceof ClassDescriptor) {
//TODO rewrite with context.lookupInContext()
return StackValue.thisOrOuter(this, (ClassDescriptor) descriptor, false, true);
}
if (descriptor instanceof CallableDescriptor) {
@@ -3687,7 +3702,7 @@ The "returned" value of try expression with no finally is either the last expres
@Override
public StackValue visitIsExpression(@NotNull JetIsExpression expression, StackValue receiver) {
StackValue match = StackValue.expression(OBJECT_TYPE, expression.getLeftHandSide(), this);
return generateIsCheck(match, expression.getTypeRef(), expression.isNegated());
return generateIsCheck(match, expression.getTypeReference(), expression.isNegated());
}
private StackValue generateExpressionMatch(StackValue expressionToMatch, JetExpression patternExpression) {
@@ -3839,7 +3854,7 @@ The "returned" value of try expression with no finally is either the last expres
StackValue.Local match = subjectLocal == -1 ? null : StackValue.local(subjectLocal, subjectType);
if (condition instanceof JetWhenConditionIsPattern) {
JetWhenConditionIsPattern patternCondition = (JetWhenConditionIsPattern) condition;
return generateIsCheck(match, patternCondition.getTypeRef(), patternCondition.isNegated());
return generateIsCheck(match, patternCondition.getTypeReference(), patternCondition.isNegated());
}
else if (condition instanceof JetWhenConditionWithExpression) {
JetExpression patternExpression = ((JetWhenConditionWithExpression) condition).getExpression();

View File

@@ -36,10 +36,10 @@ import org.jetbrains.jet.codegen.state.GenerationState;
import org.jetbrains.jet.codegen.state.JetTypeMapper;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.psi.JetClassOrObject;
import org.jetbrains.jet.lang.psi.JetNamedFunction;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.ResolvePackage;
import org.jetbrains.jet.lang.resolve.annotations.AnnotationsPackage;
import org.jetbrains.jet.lang.resolve.calls.CallResolverUtil;
import org.jetbrains.jet.lang.resolve.constants.ArrayValue;
@@ -50,6 +50,8 @@ import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodParameterKind;
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodParameterSignature;
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodSignature;
import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.types.Approximation;
import org.jetbrains.jet.lang.types.TypesPackage;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.org.objectweb.asm.AnnotationVisitor;
import org.jetbrains.org.objectweb.asm.Label;
@@ -236,7 +238,7 @@ public class FunctionCodegen extends ParentCodegenAware {
}
if (kind == JvmMethodParameterKind.RECEIVER) {
ReceiverParameterDescriptor receiver = functionDescriptor.getReceiverParameter();
ReceiverParameterDescriptor receiver = functionDescriptor.getExtensionReceiverParameter();
nullableType = receiver == null || receiver.getType().isNullable();
}
else {
@@ -271,12 +273,12 @@ public class FunctionCodegen extends ParentCodegenAware {
@Nullable
private static Type getThisTypeForFunction(@NotNull FunctionDescriptor functionDescriptor, @NotNull MethodContext context, @NotNull JetTypeMapper typeMapper) {
ReceiverParameterDescriptor expectedThisObject = functionDescriptor.getExpectedThisObject();
ReceiverParameterDescriptor dispatchReceiver = functionDescriptor.getDispatchReceiverParameter();
if (functionDescriptor instanceof ConstructorDescriptor) {
return typeMapper.mapType(functionDescriptor);
}
else if (expectedThisObject != null) {
return typeMapper.mapType(expectedThisObject.getType());
else if (dispatchReceiver != null) {
return typeMapper.mapType(dispatchReceiver.getType());
}
else if (isFunctionLiteral(functionDescriptor) || isLocalNamedFun(functionDescriptor)) {
return typeMapper.mapType(context.getThisDescriptor());
@@ -483,7 +485,7 @@ public class FunctionCodegen extends ParentCodegenAware {
}
@NotNull
private static String[] getThrownExceptions(@NotNull FunctionDescriptor function, @NotNull final JetTypeMapper mapper) {
public static String[] getThrownExceptions(@NotNull FunctionDescriptor function, @NotNull final JetTypeMapper mapper) {
AnnotationDescriptor annotation = function.getAnnotations().findAnnotation(new FqName("kotlin.throws"));
if (annotation == null) return ArrayUtil.EMPTY_STRING_ARRAY;
@@ -515,9 +517,10 @@ public class FunctionCodegen extends ParentCodegenAware {
@NotNull GenerationState state,
@NotNull CallableMethod method,
@NotNull ConstructorDescriptor constructorDescriptor,
@NotNull ClassBuilder classBuilder
@NotNull ClassBuilder classBuilder,
@NotNull JetClassOrObject classOrObject
) {
if (!isDefaultConstructorNeeded(state.getBindingContext(), constructorDescriptor)) {
if (!isEmptyConstructorNeeded(state.getBindingContext(), constructorDescriptor, classOrObject)) {
return;
}
int flags = getVisibilityAccessFlag(constructorDescriptor);
@@ -551,7 +554,7 @@ public class FunctionCodegen extends ParentCodegenAware {
String desc = JetTypeMapper.getDefaultDescriptor(method.getAsmMethod(), false);
v.invokespecial(methodOwner.getInternalName(), "<init>", desc, false);
v.areturn(Type.VOID_TYPE);
endVisit(mv, "default constructor for " + methodOwner.getInternalName(), null);
endVisit(mv, "default constructor for " + methodOwner.getInternalName(), classOrObject);
}
void generateDefaultIfNeeded(
@@ -740,9 +743,15 @@ public class FunctionCodegen extends ParentCodegenAware {
return needed;
}
private static boolean isDefaultConstructorNeeded(@NotNull BindingContext context, @NotNull ConstructorDescriptor constructorDescriptor) {
private static boolean isEmptyConstructorNeeded(
@NotNull BindingContext context,
@NotNull ConstructorDescriptor constructorDescriptor,
@NotNull JetClassOrObject classOrObject
) {
ClassDescriptor classDescriptor = constructorDescriptor.getContainingDeclaration();
if (classOrObject.isLocal()) return false;
if (CodegenBinding.canHaveOuter(context, classDescriptor)) return false;
if (classDescriptor.getVisibility() == Visibilities.PRIVATE ||
@@ -791,21 +800,20 @@ public class FunctionCodegen extends ParentCodegenAware {
}
public void genDelegate(FunctionDescriptor functionDescriptor, FunctionDescriptor overriddenDescriptor, StackValue field) {
genDelegate(functionDescriptor, (ClassDescriptor) overriddenDescriptor.getContainingDeclaration(), field,
typeMapper.mapSignature(functionDescriptor),
typeMapper.mapSignature(overriddenDescriptor.getOriginal())
genDelegate(functionDescriptor, overriddenDescriptor.getOriginal(), (ClassDescriptor) overriddenDescriptor.getContainingDeclaration(), field
);
}
public void genDelegate(
FunctionDescriptor functionDescriptor,
final FunctionDescriptor delegateFunction,
final FunctionDescriptor delegatedTo,
final ClassDescriptor toClass,
final StackValue field,
final JvmMethodSignature jvmDelegateMethodSignature,
final JvmMethodSignature jvmDelegatingMethodSignature
final StackValue field
) {
final JvmMethodSignature jvmDelegateMethodSignature = typeMapper.mapSignature(delegateFunction);
final JvmMethodSignature jvmDelegateToMethodSignature = typeMapper.mapSignature(delegatedTo);
generateMethod(
OtherOrigin(functionDescriptor), jvmDelegateMethodSignature, functionDescriptor,
OtherOrigin(delegateFunction), jvmDelegateMethodSignature, delegateFunction,
new FunctionGenerationStrategy() {
@Override
public void generateBody(
@@ -815,11 +823,11 @@ public class FunctionCodegen extends ParentCodegenAware {
@NotNull MethodContext context,
@NotNull MemberCodegen<?> parentCodegen
) {
Method overriddenMethod = jvmDelegatingMethodSignature.getAsmMethod();
Method delegateToMethod = jvmDelegateToMethodSignature.getAsmMethod();
Method delegateMethod = jvmDelegateMethodSignature.getAsmMethod();
Type[] argTypes = delegateMethod.getArgumentTypes();
Type[] originalArgTypes = overriddenMethod.getArgumentTypes();
Type[] originalArgTypes = delegateToMethod.getArgumentTypes();
InstructionAdapter iv = new InstructionAdapter(mv);
iv.load(0, OBJECT_TYPE);
@@ -832,13 +840,22 @@ public class FunctionCodegen extends ParentCodegenAware {
String internalName = typeMapper.mapType(toClass).getInternalName();
if (toClass.getKind() == ClassKind.TRAIT) {
iv.invokeinterface(internalName, overriddenMethod.getName(), overriddenMethod.getDescriptor());
iv.invokeinterface(internalName, delegateToMethod.getName(), delegateToMethod.getDescriptor());
}
else {
iv.invokevirtual(internalName, overriddenMethod.getName(), overriddenMethod.getDescriptor());
iv.invokevirtual(internalName, delegateToMethod.getName(), delegateToMethod.getDescriptor());
}
StackValue.onStack(overriddenMethod.getReturnType()).put(delegateMethod.getReturnType(), iv);
StackValue stackValue = AsmUtil.genNotNullAssertions(
state,
StackValue.onStack(delegateToMethod.getReturnType()),
TypesPackage.getApproximationTo(
delegatedTo.getReturnType(),
delegateFunction.getReturnType(),
new Approximation.DataFlowExtras.OnlyMessage(delegatedTo.getName() + "(...)"))
);
stackValue.put(delegateMethod.getReturnType(), iv);
iv.areturn(delegateMethod.getReturnType());
}

View File

@@ -24,9 +24,9 @@ import kotlin.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.backend.common.CodegenUtil;
import org.jetbrains.jet.backend.common.CodegenUtilKt;
import org.jetbrains.jet.backend.common.DataClassMethodGenerator;
import org.jetbrains.jet.codegen.binding.MutableClosure;
import org.jetbrains.jet.codegen.bridges.BridgesPackage;
import org.jetbrains.jet.codegen.context.*;
import org.jetbrains.jet.codegen.signature.BothSignatureWriter;
import org.jetbrains.jet.codegen.state.GenerationState;
@@ -50,13 +50,14 @@ import org.jetbrains.jet.lang.resolve.calls.model.VarargValueArgument;
import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants;
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
import org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames;
import org.jetbrains.jet.lang.resolve.java.descriptor.JavaCallableMemberDescriptor;
import org.jetbrains.jet.lang.resolve.java.diagnostics.JvmDeclarationOrigin;
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmClassSignature;
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodParameterKind;
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodParameterSignature;
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodSignature;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.types.*;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lexer.JetTokens;
@@ -426,7 +427,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
generateFunctionsForDataClasses();
generateBuiltinMethodStubs();
new CollectionStubMethodGenerator(state, descriptor, functionCodegen, v).generate();
generateToArray();
@@ -484,7 +485,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
iv.load(0, classAsmType);
iv.invokestatic("kotlin/jvm/internal/CollectionToArray", "toArray", "(Ljava/util/Collection;)[Ljava/lang/Object;", false);
iv.areturn(Type.getObjectType("[Ljava/lang/Object;"));
iv.areturn(Type.getType("[Ljava/lang/Object;"));
FunctionCodegen.endVisit(mv, "toArray", myClass);
}
@@ -498,98 +499,17 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
mv.visitCode();
iv.load(0, classAsmType);
iv.load(1, Type.getObjectType("[Ljava/lang/Object;"));
iv.load(1, Type.getType("[Ljava/lang/Object;"));
iv.invokestatic("kotlin/jvm/internal/CollectionToArray", "toArray",
"(Ljava/util/Collection;[Ljava/lang/Object;)[Ljava/lang/Object;", false);
iv.areturn(Type.getObjectType("[Ljava/lang/Object;"));
iv.areturn(Type.getType("[Ljava/lang/Object;"));
FunctionCodegen.endVisit(mv, "toArray", myClass);
}
}
}
private class MethodStubGenerator {
private final Set<String> generatedSignatures = new HashSet<String>();
public void generate(
@NotNull String name,
@NotNull String desc,
@NotNull ClassifierDescriptor returnedClassifier,
@NotNull ClassifierDescriptor... valueParameterClassifiers
) {
// avoid generating same signature twice
if (!generatedSignatures.add(name + desc)) return;
if (CodegenUtil.getDeclaredFunctionByRawSignature(
descriptor, Name.identifier(name), returnedClassifier, valueParameterClassifiers) == null) {
int access = descriptor.getKind() == ClassKind.TRAIT ?
ACC_PUBLIC | ACC_ABSTRACT :
ACC_PUBLIC;
MethodVisitor mv = v.newMethod(NO_ORIGIN, access, name, desc, null, null);
if (descriptor.getKind() != ClassKind.TRAIT) {
mv.visitCode();
genThrow(new InstructionAdapter(mv), "java/lang/UnsupportedOperationException", "Mutating immutable collection");
FunctionCodegen.endVisit(mv, "built-in stub for " + name + desc, null);
}
}
}
}
private void generateBuiltinMethodStubs() {
KotlinBuiltIns builtIns = KotlinBuiltIns.getInstance();
MethodStubGenerator methodStubs = new MethodStubGenerator();
if (isSubclass(descriptor, builtIns.getCollection())) {
ClassifierDescriptor classifier = getSubstituteForTypeParameterOf(builtIns.getCollection(), 0);
methodStubs.generate("add", "(Ljava/lang/Object;)Z", builtIns.getBoolean(), classifier);
methodStubs.generate("remove", "(Ljava/lang/Object;)Z", builtIns.getBoolean(), builtIns.getAny());
methodStubs.generate("addAll", "(Ljava/util/Collection;)Z", builtIns.getBoolean(), builtIns.getCollection());
methodStubs.generate("removeAll", "(Ljava/util/Collection;)Z", builtIns.getBoolean(), builtIns.getCollection());
methodStubs.generate("retainAll", "(Ljava/util/Collection;)Z", builtIns.getBoolean(), builtIns.getCollection());
methodStubs.generate("clear", "()V", builtIns.getUnit());
}
if (isSubclass(descriptor, builtIns.getList())) {
ClassifierDescriptor classifier = getSubstituteForTypeParameterOf(builtIns.getList(), 0);
methodStubs.generate("set", "(ILjava/lang/Object;)Ljava/lang/Object;", classifier, builtIns.getInt(), classifier);
methodStubs.generate("add", "(ILjava/lang/Object;)V", builtIns.getUnit(), builtIns.getInt(), classifier);
methodStubs.generate("remove", "(I)Ljava/lang/Object;", classifier, builtIns.getInt());
}
if (isSubclass(descriptor, builtIns.getMap())) {
ClassifierDescriptor keyClassifier = getSubstituteForTypeParameterOf(builtIns.getMap(), 0);
ClassifierDescriptor valueClassifier = getSubstituteForTypeParameterOf(builtIns.getMap(), 1);
methodStubs.generate("put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", valueClassifier, keyClassifier,
valueClassifier);
methodStubs.generate("remove", "(Ljava/lang/Object;)Ljava/lang/Object;", valueClassifier, builtIns.getAny());
methodStubs.generate("putAll", "(Ljava/util/Map;)V", builtIns.getUnit(), builtIns.getMap());
methodStubs.generate("clear", "()V", builtIns.getUnit());
}
if (isSubclass(descriptor, builtIns.getMapEntry())) {
ClassifierDescriptor valueClassifier = getSubstituteForTypeParameterOf(builtIns.getMapEntry(), 1);
methodStubs.generate("setValue", "(Ljava/lang/Object;)Ljava/lang/Object;", valueClassifier, valueClassifier);
}
if (isSubclass(descriptor, builtIns.getIterator())) {
methodStubs.generate("remove", "()V", builtIns.getUnit());
}
}
@NotNull
private ClassifierDescriptor getSubstituteForTypeParameterOf(@NotNull ClassDescriptor trait, int index) {
TypeParameterDescriptor listTypeParameter = trait.getTypeConstructor().getParameters().get(index);
TypeSubstitutor deepSubstitutor = SubstitutionUtils.buildDeepSubstitutor(descriptor.getDefaultType());
TypeProjection substitute = deepSubstitutor.substitute(new TypeProjectionImpl(listTypeParameter.getDefaultType()));
assert substitute != null : "Couldn't substitute: " + descriptor;
ClassifierDescriptor classifier = substitute.getType().getConstructor().getDeclarationDescriptor();
assert classifier != null : "No classifier: " + substitute.getType();
return classifier;
}
private void generateFunctionsForDataClasses() {
if (!KotlinBuiltIns.getInstance().isData(descriptor)) return;
@@ -644,15 +564,23 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
else {
iv.invokestatic("java/util/Arrays", "equals",
"([" + elementType.getDescriptor() + "[" + elementType.getDescriptor() + ")Z", false);
"(" + asmType.getDescriptor() + asmType.getDescriptor() + ")Z", false);
}
iv.ifeq(ne);
}
else if (asmType.getSort() == Type.FLOAT) {
iv.invokestatic("java/lang/Float", "compare", "(FF)I", false);
iv.ifne(ne);
}
else if (asmType.getSort() == Type.DOUBLE) {
iv.invokestatic("java/lang/Double", "compare", "(DD)I", false);
iv.ifne(ne);
}
else {
StackValue value = genEqualsForExpressionsOnStack(iv, JetTokens.EQEQ, asmType, asmType);
value.put(Type.BOOLEAN_TYPE, iv);
iv.ifeq(ne);
}
iv.ifeq(ne);
}
iv.mark(eq);
@@ -1152,7 +1080,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
DefaultParameterValueLoader.DEFAULT, null);
CallableMethod callableMethod = typeMapper.mapToCallableMethod(constructorDescriptor);
FunctionCodegen.generateConstructorWithoutParametersIfNeeded(state, callableMethod, constructorDescriptor, v);
FunctionCodegen.generateConstructorWithoutParametersIfNeeded(state, callableMethod, constructorDescriptor, v, myClass);
if (isClassObject(descriptor)) {
context.recordSyntheticAccessorIfNeeded(constructorDescriptor, bindingContext);
@@ -1286,13 +1214,15 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
JetExpression expression = ((JetDelegatorByExpressionSpecifier) specifier).getDelegateExpression();
PropertyDescriptor propertyDescriptor = CodegenUtil.getDelegatePropertyIfAny(expression, descriptor, bindingContext);
ClassDescriptor superClassDescriptor = getSuperClass(specifier);
if (CodegenUtil.isFinalPropertyWithBackingField(propertyDescriptor, bindingContext)) {
result.addField((JetDelegatorByExpressionSpecifier) specifier, propertyDescriptor);
}
else {
result.addField((JetDelegatorByExpressionSpecifier) specifier, typeMapper.mapType(superClassDescriptor), "$delegate_" + n);
JetType expressionType = state.getBindingContext().get(BindingContext.EXPRESSION_TYPE, expression);
Type asmType =
expressionType != null ? typeMapper.mapType(expressionType) : typeMapper.mapType(getSuperClass(specifier));
result.addField((JetDelegatorByExpressionSpecifier) specifier, asmType, "$delegate_" + n);
}
n++;
}
@@ -1357,8 +1287,12 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getInstanceReference());
assert descriptor instanceof CallableDescriptor ||
descriptor instanceof ClassDescriptor : "'This' reference target should be class or callable descriptor but was " + descriptor;
if (context.getCallableDescriptorWithReceiver() != descriptor) {
context.lookupInContext(descriptor, null, state, true);
if (descriptor instanceof ClassDescriptor) {
context.lookupInContext(descriptor, StackValue.local(0, OBJECT_TYPE), state, true);
}
if (descriptor instanceof CallableDescriptor) {
constructorContext.generateReceiver((CallableDescriptor) descriptor, state, true);
}
}
};
@@ -1385,10 +1319,18 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
}
if (superCall != null && !isAnonymousObject(descriptor)) {
JetValueArgumentList argumentList = superCall.getValueArgumentList();
if (argumentList != null) {
argumentList.accept(visitor);
if (superCall != null) {
ResolvedCall<?> resolvedCall = CallUtilPackage.getResolvedCallWithAssert(superCall, bindingContext);
ClassDescriptor superClass = ((ConstructorDescriptor) resolvedCall.getResultingDescriptor()).getContainingDeclaration();
if (superClass.isInner()) {
constructorContext.lookupInContext(superClass.getContainingDeclaration(), StackValue.local(0, OBJECT_TYPE), state, true);
}
if (!isAnonymousObject(descriptor)) {
JetValueArgumentList argumentList = superCall.getValueArgumentList();
if (argumentList != null) {
argumentList.accept(visitor);
}
}
}
}
@@ -1409,32 +1351,11 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
private void generateTraitMethods() {
if (JetPsiUtil.isTrait(myClass)) return;
for (DeclarationDescriptor declaration : descriptor.getDefaultType().getMemberScope().getAllDescriptors()) {
if (!(declaration instanceof CallableMemberDescriptor)) continue;
CallableMemberDescriptor inheritedMember = (CallableMemberDescriptor) declaration;
CallableMemberDescriptor traitMember = BridgesPackage.findTraitImplementation(inheritedMember);
if (traitMember == null) continue;
assert traitMember.getModality() != Modality.ABSTRACT : "Cannot delegate to abstract trait method: " + inheritedMember;
// inheritedMember can be abstract here. In order for FunctionCodegen to generate the method body, we're creating a copy here
// with traitMember's modality
CallableMemberDescriptor copy =
inheritedMember.copy(inheritedMember.getContainingDeclaration(), traitMember.getModality(), Visibilities.PUBLIC,
CallableMemberDescriptor.Kind.DECLARATION, true);
if (traitMember instanceof SimpleFunctionDescriptor) {
generateDelegationToTraitImpl((FunctionDescriptor) traitMember, (FunctionDescriptor) copy);
}
else if (traitMember instanceof PropertyDescriptor) {
for (PropertyAccessorDescriptor traitAccessor : ((PropertyDescriptor) traitMember).getAccessors()) {
for (PropertyAccessorDescriptor inheritedAccessor : ((PropertyDescriptor) copy).getAccessors()) {
if (inheritedAccessor.getClass() == traitAccessor.getClass()) { // same accessor kind
generateDelegationToTraitImpl(traitAccessor, inheritedAccessor);
}
}
}
for (Map.Entry<FunctionDescriptor, FunctionDescriptor> entry : CodegenUtil.getTraitMethods(descriptor).entrySet()) {
FunctionDescriptor traitFun = entry.getKey();
//skip java 8 default methods
if (!(traitFun instanceof JavaCallableMemberDescriptor)) {
generateDelegationToTraitImpl(traitFun, entry.getValue());
}
}
}
@@ -1508,17 +1429,29 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
for (JvmMethodParameterSignature parameter : parameters) {
if (superIndex >= superParameters.size()) break;
JvmMethodParameterKind superKind = superParameters.get(superIndex).getKind();
JvmMethodParameterKind kind = parameter.getKind();
Type type = parameter.getAsmType();
// Stop when we reach the actual value parameters present in the code; they will be generated via ResolvedCall below
if (superParameters.get(superIndex).getKind() == JvmMethodParameterKind.VALUE &&
kind == JvmMethodParameterKind.SUPER_CALL_PARAM) {
if (superKind == JvmMethodParameterKind.VALUE && kind == JvmMethodParameterKind.SUPER_CALL_PARAM) {
// Stop when we reach the actual value parameters present in the code; they will be generated via ResolvedCall below
break;
}
if (kind == JvmMethodParameterKind.SUPER_CALL_PARAM || kind == JvmMethodParameterKind.ENUM_NAME_OR_ORDINAL ||
(kind == JvmMethodParameterKind.OUTER && superConstructor.getContainingDeclaration().isInner())) {
if (superKind == JvmMethodParameterKind.OUTER) {
assert kind == JvmMethodParameterKind.OUTER || kind == JvmMethodParameterKind.SUPER_CALL_PARAM :
String.format("Non-outer parameter incorrectly mapped to outer for %s: %s vs %s",
constructorDescriptor, parameters, superParameters);
// Super constructor requires OUTER parameter, but our OUTER instance may be different from what is expected by the super
// constructor. We need to traverse our outer classes from the bottom up, to find the needed class
// TODO: isSuper should be "true" but this makes some tests on inner classes extending outer fail
// See innerExtendsOuter.kt, semantics of inner classes extending their outer should be changed to be as in Java
ClassDescriptor outerForSuper = (ClassDescriptor) superConstructor.getContainingDeclaration().getContainingDeclaration();
StackValue outer = codegen.generateThisOrOuter(outerForSuper, false);
outer.put(outer.type, codegen.v);
superIndex++;
}
else if (kind == JvmMethodParameterKind.SUPER_CALL_PARAM || kind == JvmMethodParameterKind.ENUM_NAME_OR_ORDINAL) {
iv.load(offset, type);
superIndex++;
}
@@ -1665,7 +1598,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
if (specifier instanceof JetDelegatorByExpressionSpecifier) {
DelegationFieldsInfo.Field field = delegationFieldsInfo.getInfo((JetDelegatorByExpressionSpecifier) specifier);
generateDelegateField(field);
generateDelegates(getSuperClass(specifier), field);
JetExpression delegateExpression = ((JetDelegatorByExpressionSpecifier) specifier).getDelegateExpression();
JetType delegateExpressionType = state.getBindingContext().get(BindingContext.EXPRESSION_TYPE, delegateExpression);
generateDelegates(getSuperClass(specifier), delegateExpressionType, field);
}
}
}
@@ -1677,17 +1612,17 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
fieldInfo.name, fieldInfo.type.getDescriptor(), /*TODO*/null, null);
}
protected void generateDelegates(ClassDescriptor toClass, DelegationFieldsInfo.Field field) {
for (Map.Entry<CallableMemberDescriptor, CallableMemberDescriptor> entry : CodegenUtil.getDelegates(descriptor, toClass).entrySet()) {
protected void generateDelegates(ClassDescriptor toTrait, JetType delegateExpressionType, DelegationFieldsInfo.Field field) {
for (Map.Entry<CallableMemberDescriptor, CallableDescriptor> entry : CodegenUtilKt.getDelegates(descriptor, toTrait, delegateExpressionType).entrySet()) {
CallableMemberDescriptor callableMemberDescriptor = entry.getKey();
CallableMemberDescriptor overriddenDescriptor = entry.getValue();
CallableDescriptor delegateTo = entry.getValue();
if (callableMemberDescriptor instanceof PropertyDescriptor) {
propertyCodegen
.genDelegate((PropertyDescriptor) callableMemberDescriptor, (PropertyDescriptor) overriddenDescriptor, field.getStackValue());
.genDelegate((PropertyDescriptor) callableMemberDescriptor, (PropertyDescriptor) delegateTo, field.getStackValue());
}
else if (callableMemberDescriptor instanceof FunctionDescriptor) {
functionCodegen
.genDelegate((FunctionDescriptor) callableMemberDescriptor, (FunctionDescriptor) overriddenDescriptor, field.getStackValue());
.genDelegate((FunctionDescriptor) callableMemberDescriptor, (FunctionDescriptor) delegateTo, field.getStackValue());
}
}
}

View File

@@ -166,13 +166,13 @@ public class JvmCodegenUtil {
if (JetTypeMapper.isAccessor(property)) return false;
// Inline functions can't use direct access because a field may not be visible at the call site
if (context.isInlineFunction()) return false;
if (context.isInlineFunction() && property.getVisibility() != Visibilities.PRIVATE) return false;
// Only properties of the same class can be directly accessed, except when we are evaluating expressions in the debugger
if (!isCallInsideSameClassAsDeclared(property, context) && !isDebuggerContext(context)) return false;
// Delegated and extension properties have no backing fields
if (isDelegated || property.getReceiverParameter() != null) return false;
if (isDelegated || property.getExtensionReceiverParameter() != null) return false;
// Class object properties cannot be accessed directly because their backing fields are stored in the containing class
if (DescriptorUtils.isClassObject(property.getContainingDeclaration())) return false;
@@ -203,7 +203,7 @@ public class JvmCodegenUtil {
}
@Nullable
public static ClassDescriptor getExpectedThisObjectForConstructorCall(
public static ClassDescriptor getDispatchReceiverParameterForConstructorCall(
@NotNull ConstructorDescriptor descriptor,
@Nullable CalculatedClosure closure
) {
@@ -214,10 +214,10 @@ public class JvmCodegenUtil {
//for compilation against binaries
//TODO: It's best to use this code also for compilation against sources
// but sometimes structures that have expectedThisObject (bug?) mapped to static classes
ReceiverParameterDescriptor expectedThisObject = descriptor.getExpectedThisObject();
if (expectedThisObject != null) {
ClassDescriptor expectedThisClass = (ClassDescriptor) expectedThisObject.getContainingDeclaration();
// but sometimes structures that have dispatchReceiver (bug?) mapped to static classes
ReceiverParameterDescriptor dispatchReceiver = descriptor.getDispatchReceiverParameter();
if (dispatchReceiver != null) {
ClassDescriptor expectedThisClass = (ClassDescriptor) dispatchReceiver.getContainingDeclaration();
if (!expectedThisClass.getKind().isSingleton()) {
return expectedThisClass;
}

View File

@@ -91,7 +91,7 @@ public class JvmRuntimeTypes {
@NotNull
public Collection<JetType> getSupertypesForClosure(@NotNull FunctionDescriptor descriptor) {
ReceiverParameterDescriptor receiverParameter = descriptor.getReceiverParameter();
ReceiverParameterDescriptor receiverParameter = descriptor.getExtensionReceiverParameter();
List<TypeProjection> typeArguments = new ArrayList<TypeProjection>(2);
@@ -127,21 +127,21 @@ public class JvmRuntimeTypes {
@NotNull
public Collection<JetType> getSupertypesForFunctionReference(@NotNull FunctionDescriptor descriptor) {
ReceiverParameterDescriptor receiverParameter = descriptor.getReceiverParameter();
ReceiverParameterDescriptor expectedThisObject = descriptor.getExpectedThisObject();
ReceiverParameterDescriptor extensionReceiver = descriptor.getExtensionReceiverParameter();
ReceiverParameterDescriptor dispatchReceiver = descriptor.getDispatchReceiverParameter();
List<TypeProjection> typeArguments = new ArrayList<TypeProjection>(2);
ClassDescriptor classDescriptor;
JetType receiverType;
if (receiverParameter != null) {
if (extensionReceiver != null) {
classDescriptor = kExtensionFunctionImpl;
receiverType = receiverParameter.getType();
receiverType = extensionReceiver.getType();
typeArguments.add(new TypeProjectionImpl(receiverType));
}
else if (expectedThisObject != null) {
else if (dispatchReceiver != null) {
classDescriptor = kMemberFunctionImpl;
receiverType = expectedThisObject.getType();
receiverType = dispatchReceiver.getType();
typeArguments.add(new TypeProjectionImpl(receiverType));
}
else {
@@ -165,7 +165,7 @@ public class JvmRuntimeTypes {
receiverType,
ExpressionTypingUtils.getValueParametersTypes(descriptor.getValueParameters()),
descriptor.getReturnType(),
receiverParameter != null
extensionReceiver != null
);
return Arrays.asList(kFunctionImplType, kFunctionType);

View File

@@ -366,7 +366,7 @@ public class PackageCodegen {
SmartList<PackageFragmentDescriptor> fragments = new SmartList<PackageFragmentDescriptor>();
for (JetFile file : files) {
PackageFragmentDescriptor fragment = state.getBindingContext().get(BindingContext.FILE_TO_PACKAGE_FRAGMENT, file);
assert fragment != null : "package fragment is null for " + file;
assert fragment != null : "package fragment is null for " + file + "\n" + file.getText();
assert expectedFqName.equals(fragment.getFqName()) :
"expected package fq name: " + expectedFqName + ", actual: " + fragment.getFqName();

View File

@@ -39,7 +39,8 @@ class PlatformStaticGenerator(
Opcodes.ACC_STATIC or AsmUtil.getMethodAsmFlags(descriptor, OwnerKind.IMPLEMENTATION),
asmMethod.getName()!!,
asmMethod.getDescriptor()!!,
null, null)
typeMapper.mapSignature(descriptor).getGenericsSignature(),
FunctionCodegen.getThrownExceptions(descriptor, typeMapper))
AnnotationCodegen.forMethod(methodVisitor, typeMapper)!!.genAnnotations(descriptor, asmMethod.getReturnType())
@@ -48,7 +49,7 @@ class PlatformStaticGenerator(
val iv = InstructionAdapter(methodVisitor)
val classDescriptor = descriptor.getContainingDeclaration() as ClassDescriptor
val singletonValue = StackValue.singleton(classDescriptor, typeMapper)!!
singletonValue.put(singletonValue.`type`, iv);
singletonValue.put(singletonValue.type, iv);
var index = 0;
for (paramType in asmMethod.getArgumentTypes()) {
iv.load(index, paramType);

View File

@@ -142,7 +142,7 @@ public class PropertyCodegen {
if (declaration == null) return true;
// Delegated or extension properties can only be referenced via accessors
if (declaration.hasDelegate() || declaration.getReceiverTypeRef() != null) return true;
if (declaration.hasDelegate() || declaration.getReceiverTypeReference() != null) return true;
// Class object properties always should have accessors, because their backing fields are moved/copied to the outer class
if (isClassObject(descriptor.getContainingDeclaration())) return true;
@@ -206,7 +206,7 @@ public class PropertyCodegen {
private void generateSyntheticMethodIfNeeded(@NotNull PropertyDescriptor descriptor) {
if (descriptor.getAnnotations().isEmpty()) return;
ReceiverParameterDescriptor receiver = descriptor.getReceiverParameter();
ReceiverParameterDescriptor receiver = descriptor.getExtensionReceiverParameter();
String name = JvmAbi.getSyntheticMethodNameForAnnotatedProperty(descriptor.getName());
String desc = receiver == null ? "()V" : "(" + typeMapper.mapType(receiver.getType()) + ")V";
@@ -395,7 +395,7 @@ public class PropertyCodegen {
v.areturn(type);
}
else if (callableDescriptor instanceof PropertySetterDescriptor) {
ReceiverParameterDescriptor receiverParameter = propertyDescriptor.getReceiverParameter();
ReceiverParameterDescriptor receiverParameter = propertyDescriptor.getExtensionReceiverParameter();
if (receiverParameter != null) {
paramCode += codegen.typeMapper.mapType(receiverParameter.getType()).getSize();
}
@@ -484,21 +484,19 @@ public class PropertyCodegen {
return JvmAbi.SETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName.asString());
}
public void genDelegate(@NotNull PropertyDescriptor delegate, @NotNull PropertyDescriptor overridden, @NotNull StackValue field) {
ClassDescriptor toClass = (ClassDescriptor) overridden.getContainingDeclaration();
public void genDelegate(@NotNull PropertyDescriptor delegate, @NotNull PropertyDescriptor delegateTo, @NotNull StackValue field) {
ClassDescriptor toClass = (ClassDescriptor) delegateTo.getContainingDeclaration();
PropertyGetterDescriptor getter = delegate.getGetter();
if (getter != null) {
//noinspection ConstantConditions
functionCodegen.genDelegate(getter, toClass, field,
typeMapper.mapSignature(getter), typeMapper.mapSignature(overridden.getGetter().getOriginal()));
functionCodegen.genDelegate(getter, delegateTo.getGetter().getOriginal(), toClass, field);
}
PropertySetterDescriptor setter = delegate.getSetter();
if (setter != null) {
//noinspection ConstantConditions
functionCodegen.genDelegate(setter, toClass, field,
typeMapper.mapSignature(setter), typeMapper.mapSignature(overridden.getSetter().getOriginal()));
functionCodegen.genDelegate(setter, delegateTo.getSetter().getOriginal(), toClass, field);
}
}
}

View File

@@ -22,6 +22,7 @@ import org.jetbrains.jet.codegen.state.GenerationState;
import org.jetbrains.jet.codegen.state.JetTypeMapper;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.impl.ClassDescriptorImpl;
import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl;
import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
@@ -149,6 +150,21 @@ public class SamWrapperCodegen {
.getFunctions(Name.identifier("invoke")).iterator().next().getOriginal();
StackValue functionField = StackValue.field(functionType, ownerType, FUNCTION_FIELD_NAME, false);
codegen.genDelegate(erasedInterfaceFunction, invokeFunction, functionField);
// generate sam bridges
// TODO: erasedInterfaceFunction is actually not an interface function, but function in generated class
SimpleFunctionDescriptor originalInterfaceErased = samType.getAbstractMethod().getOriginal();
SimpleFunctionDescriptorImpl descriptorForBridges = SimpleFunctionDescriptorImpl
.create(erasedInterfaceFunction.getContainingDeclaration(), erasedInterfaceFunction.getAnnotations(), originalInterfaceErased.getName(),
CallableMemberDescriptor.Kind.DECLARATION, erasedInterfaceFunction.getSource());
descriptorForBridges
.initialize(null, originalInterfaceErased.getDispatchReceiverParameter(), originalInterfaceErased.getTypeParameters(),
originalInterfaceErased.getValueParameters(), originalInterfaceErased.getReturnType(), Modality.OPEN,
originalInterfaceErased.getVisibility());
descriptorForBridges.addOverriddenDescriptor(originalInterfaceErased);
codegen.generateBridges(descriptorForBridges);
}
@NotNull

View File

@@ -313,7 +313,7 @@ public abstract class StackValue {
public static StackValue thisOrOuter(ExpressionCodegen codegen, ClassDescriptor descriptor, boolean isSuper, boolean isExplicit) {
// Coerce this/super for traits to support traits with required classes.
// Coerce explicit 'this' for the case when it is smartcasted.
// Coerce explicit 'this' for the case when it is smart cast.
// Do not coerce for other classes due to the 'protected' access issues (JVMS 7, 4.9.2 Structural Constraints).
boolean coerceType = descriptor.getKind() == ClassKind.TRAIT || (isExplicit && !isSuper);
return new ThisOuter(codegen, descriptor, isSuper, coerceType);
@@ -333,7 +333,7 @@ public abstract class StackValue {
ExpressionCodegen codegen,
@Nullable CallableMethod callableMethod
) {
if (resolvedCall.getThisObject().exists() || resolvedCall.getReceiverArgument().exists() || isLocalFunCall(callableMethod)) {
if (resolvedCall.getDispatchReceiver().exists() || resolvedCall.getExtensionReceiver().exists() || isLocalFunCall(callableMethod)) {
return new CallReceiver(resolvedCall, receiver, codegen, callableMethod, true);
}
return receiver;
@@ -358,6 +358,10 @@ public abstract class StackValue {
return field(info.getFieldType(), Type.getObjectType(info.getOwnerInternalName()), info.getFieldName(), true);
}
public static boolean couldSkipReceiverOnStaticCall(StackValue value) {
return value instanceof Local || value instanceof Constant;
}
private static class None extends StackValue {
public static final None INSTANCE = new None();
@@ -413,10 +417,17 @@ public abstract class StackValue {
put(type, v);
}
else if (depth == 1) {
if (type.getSize() != 1) {
int size = this.type.getSize();
if (size == 1) {
v.swap();
} else if (size == 2) {
v.dupX2();
v.pop();
} else {
throw new UnsupportedOperationException("don't know how to move type " + type + " to top of stack");
}
v.swap();
coerceTo(type, v);
}
else {
throw new UnsupportedOperationException("unsupported move-to-top depth " + depth);
@@ -506,7 +517,7 @@ public abstract class StackValue {
opcode = jumpIfFalse ? IFGT : IFLE;
}
else {
throw new UnsupportedOperationException("don't know how to generate this condjump");
throw new UnsupportedOperationException("Don't know how to generate this condJump: " + opToken);
}
if (operandType == Type.FLOAT_TYPE || operandType == Type.DOUBLE_TYPE) {
if (opToken == JetTokens.GT || opToken == JetTokens.GTEQ) {
@@ -692,7 +703,7 @@ public abstract class StackValue {
v.store(firstParamIndex, type);
}
ReceiverValue receiverParameter = resolvedGetCall.getReceiverArgument();
ReceiverValue receiverParameter = resolvedGetCall.getExtensionReceiver();
int receiverIndex = -1;
if (receiverParameter.exists()) {
Type type = codegen.typeMapper.mapType(receiverParameter.getType());
@@ -700,9 +711,9 @@ public abstract class StackValue {
v.store(receiverIndex, type);
}
ReceiverValue thisObject = resolvedGetCall.getThisObject();
ReceiverValue dispatchReceiver = resolvedGetCall.getDispatchReceiver();
int thisIndex = -1;
if (thisObject.exists()) {
if (dispatchReceiver.exists()) {
thisIndex = frame.enterTemp(OBJECT_TYPE);
v.store(thisIndex, OBJECT_TYPE);
}
@@ -723,14 +734,14 @@ public abstract class StackValue {
throw new UnsupportedOperationException();
}
if (resolvedSetCall.getThisObject().exists()) {
if (resolvedSetCall.getReceiverArgument().exists()) {
codegen.generateReceiverValue(resolvedSetCall.getThisObject(), OBJECT_TYPE);
if (resolvedSetCall.getDispatchReceiver().exists()) {
if (resolvedSetCall.getExtensionReceiver().exists()) {
codegen.generateReceiverValue(resolvedSetCall.getDispatchReceiver(), OBJECT_TYPE);
}
v.load(realReceiverIndex, realReceiverType);
}
else {
if (resolvedSetCall.getReceiverArgument().exists()) {
if (resolvedSetCall.getExtensionReceiver().exists()) {
v.load(realReceiverIndex, realReceiverType);
}
else {
@@ -780,13 +791,13 @@ public abstract class StackValue {
}
}
if (call.getThisObject().exists()) {
if (call.getReceiverArgument().exists()) {
if (call.getDispatchReceiver().exists()) {
if (call.getExtensionReceiver().exists()) {
return false;
}
}
else {
if (codegen.typeMapper.mapType(call.getResultingDescriptor().getReceiverParameter().getType())
if (codegen.typeMapper.mapType(call.getResultingDescriptor().getExtensionReceiverParameter().getType())
.getSize() != 1) {
return false;
}
@@ -1107,14 +1118,14 @@ public abstract class StackValue {
) {
CallableDescriptor descriptor = resolvedCall.getResultingDescriptor();
ReceiverParameterDescriptor expectedThisObject = descriptor.getExpectedThisObject();
ReceiverParameterDescriptor receiverParameter = descriptor.getReceiverParameter();
ReceiverParameterDescriptor dispatchReceiver = descriptor.getDispatchReceiverParameter();
ReceiverParameterDescriptor extensionReceiver = descriptor.getExtensionReceiverParameter();
if (receiverParameter != null) {
return callableMethod != null ? callableMethod.getReceiverClass() : typeMapper.mapType(receiverParameter.getType());
if (extensionReceiver != null) {
return callableMethod != null ? callableMethod.getReceiverClass() : typeMapper.mapType(extensionReceiver.getType());
}
else if (expectedThisObject != null) {
return callableMethod != null ? callableMethod.getThisType() : typeMapper.mapType(expectedThisObject.getType());
else if (dispatchReceiver != null) {
return callableMethod != null ? callableMethod.getThisType() : typeMapper.mapType(dispatchReceiver.getType());
}
else if (isLocalFunCall(callableMethod)) {
return callableMethod.getGenerateCalleeType();
@@ -1127,28 +1138,28 @@ public abstract class StackValue {
public void put(Type type, InstructionAdapter v) {
CallableDescriptor descriptor = resolvedCall.getResultingDescriptor();
ReceiverValue thisObject = resolvedCall.getThisObject();
ReceiverValue receiverArgument = resolvedCall.getReceiverArgument();
ReceiverValue dispatchReceiver = resolvedCall.getDispatchReceiver();
ReceiverValue extensionReceiver = resolvedCall.getExtensionReceiver();
int depth = 0;
if (thisObject.exists()) {
if (dispatchReceiver.exists()) {
if (!AnnotationsPackage.isPlatformStaticInObject(descriptor)) {
if (receiverArgument.exists()) {
if (extensionReceiver.exists()) {
//noinspection ConstantConditions
Type resultType =
callableMethod != null ?
callableMethod.getOwner() :
codegen.typeMapper.mapType(descriptor.getExpectedThisObject().getType());
codegen.typeMapper.mapType(descriptor.getDispatchReceiverParameter().getType());
codegen.generateReceiverValue(thisObject, resultType);
codegen.generateReceiverValue(dispatchReceiver, resultType);
}
else {
genReceiver(v, thisObject, type, null, 0);
genReceiver(v, dispatchReceiver, type, null, 0);
}
depth = 1;
}
}
else if (isLocalFunCall(callableMethod)) {
assert receiver == none() || receiverArgument.exists() :
assert receiver == none() || extensionReceiver.exists() :
"Receiver should be present only for local extension function: " + callableMethod;
StackValue value = codegen.findLocalOrCapturedValue(descriptor.getOriginal());
assert value != null : "Local fun should be found in locals or in captured params: " + resolvedCall;
@@ -1157,8 +1168,8 @@ public abstract class StackValue {
depth = 1;
}
if (putReceiverArgumentOnStack && receiverArgument.exists()) {
genReceiver(v, receiverArgument, type, descriptor.getReceiverParameter(), depth);
if (putReceiverArgumentOnStack && extensionReceiver.exists()) {
genReceiver(v, extensionReceiver, type, descriptor.getExtensionReceiverParameter(), depth);
}
}

View File

@@ -75,7 +75,7 @@ public class TailRecursionCodegen {
}
assignParameterValues(fd, callable, arguments);
if (callable.getReceiverClass() != null) {
if (resolvedCall.getReceiverArgument() != fd.getReceiverParameter().getValue()) {
if (resolvedCall.getExtensionReceiver() != fd.getExtensionReceiverParameter().getValue()) {
StackValue expression = context.getReceiverExpression(codegen.typeMapper);
expression.store(callable.getReceiverClass(), v);
}

View File

@@ -180,7 +180,12 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
assert descriptor != null :
String.format("No descriptor for enum entry \n---\n%s\n---\n", JetPsiUtil.getElementTextWithContext(enumEntry));
if (!enumEntry.getDeclarations().isEmpty()) {
if (enumEntry.getDeclarations().isEmpty()) {
for (JetDelegationSpecifier specifier : enumEntry.getDelegationSpecifiers()) {
specifier.accept(this);
}
}
else {
bindingTrace.record(ENUM_ENTRY_CLASS_NEED_SUBCLASS, descriptor);
super.visitEnumEntry(enumEntry);
}

View File

@@ -33,7 +33,7 @@ public final class MutableClosure implements CalculatedClosure {
private final ResolvedCall<ConstructorDescriptor> superCall;
private final ClassDescriptor enclosingClass;
private final CallableDescriptor enclosingReceiverDescriptor;
private final CallableDescriptor enclosingFunWithReceiverDescriptor;
private boolean captureThis;
private boolean captureReceiver;
@@ -48,7 +48,7 @@ public final class MutableClosure implements CalculatedClosure {
) {
this.enclosingClass = enclosingClass;
this.superCall = superCall;
this.enclosingReceiverDescriptor = enclosingExtensionMemberForClass(classDescriptor);
this.enclosingFunWithReceiverDescriptor = enclosingExtensionMemberForClass(classDescriptor);
}
@Nullable
@@ -56,7 +56,7 @@ public final class MutableClosure implements CalculatedClosure {
DeclarationDescriptor classContainer = classDescriptor.getContainingDeclaration();
if (classContainer instanceof CallableMemberDescriptor) {
CallableMemberDescriptor member = getDirectMember((CallableMemberDescriptor) classContainer);
if (member.getReceiverParameter() != null) {
if (member.getExtensionReceiverParameter() != null) {
return member;
}
}
@@ -85,9 +85,8 @@ public final class MutableClosure implements CalculatedClosure {
@Override
public JetType getCaptureReceiverType() {
if (captureReceiver) {
//noinspection ConstantConditions
ReceiverParameterDescriptor parameter = enclosingReceiverDescriptor.getReceiverParameter();
assert parameter != null : "Receiver parameter should exist in " + enclosingReceiverDescriptor;
ReceiverParameterDescriptor parameter = getEnclosingReceiverDescriptor();
assert parameter != null : "Receiver parameter should exist in " + enclosingFunWithReceiverDescriptor;
return parameter.getType();
}
@@ -95,8 +94,8 @@ public final class MutableClosure implements CalculatedClosure {
}
public void setCaptureReceiver() {
if (enclosingReceiverDescriptor == null) {
throw new IllegalStateException();
if (enclosingFunWithReceiverDescriptor == null) {
throw new IllegalStateException("Extension receiver parameter should exist");
}
this.captureReceiver = true;
}
@@ -122,12 +121,13 @@ public final class MutableClosure implements CalculatedClosure {
public void captureVariable(EnclosedValueDescriptor value) {
if (captureVariables == null) {
captureVariables = new HashMap<DeclarationDescriptor, EnclosedValueDescriptor>();
captureVariables = new LinkedHashMap<DeclarationDescriptor, EnclosedValueDescriptor>();
}
captureVariables.put(value.getDescriptor(), value);
}
public CallableDescriptor getEnclosingReceiverDescriptor() {
return enclosingReceiverDescriptor;
@Nullable
public ReceiverParameterDescriptor getEnclosingReceiverDescriptor() {
return enclosingFunWithReceiverDescriptor != null ? enclosingFunWithReceiverDescriptor.getExtensionReceiverParameter() : null;
}
}

View File

@@ -31,10 +31,7 @@ import org.jetbrains.jet.storage.LockBasedStorageManager;
import org.jetbrains.jet.storage.NullableLazyValue;
import org.jetbrains.org.objectweb.asm.Type;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import static org.jetbrains.jet.codegen.AsmUtil.CAPTURED_THIS_FIELD;
import static org.jetbrains.jet.codegen.AsmUtil.getVisibilityAccessFlag;
@@ -109,7 +106,7 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
public final CallableDescriptor getCallableDescriptorWithReceiver() {
if (contextDescriptor instanceof CallableDescriptor) {
CallableDescriptor callableDescriptor = (CallableDescriptor) getContextDescriptor();
return callableDescriptor.getReceiverParameter() != null ? callableDescriptor : null;
return callableDescriptor.getExtensionReceiverParameter() != null ? callableDescriptor : null;
}
return null;
}
@@ -160,8 +157,8 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
}
@NotNull
public ClassContext intoAnonymousClass(@NotNull ClassDescriptor descriptor, @NotNull ExpressionCodegen codegen) {
return new AnonymousClassContext(codegen.getState().getTypeMapper(), descriptor, OwnerKind.IMPLEMENTATION, this, codegen);
public ClassContext intoAnonymousClass(@NotNull ClassDescriptor descriptor, @NotNull ExpressionCodegen codegen, @NotNull OwnerKind ownerKind) {
return new AnonymousClassContext(codegen.getState().getTypeMapper(), descriptor, ownerKind, this, codegen);
}
@NotNull
@@ -231,7 +228,7 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
@NotNull
public DeclarationDescriptor getAccessor(@NotNull DeclarationDescriptor descriptor, boolean isForBackingFieldInOuterClass, @Nullable JetType delegateType) {
if (accessors == null) {
accessors = new HashMap<DeclarationDescriptor, DeclarationDescriptor>();
accessors = new LinkedHashMap<DeclarationDescriptor, DeclarationDescriptor>();
}
descriptor = descriptor.getOriginal();
DeclarationDescriptor accessor = accessors.get(descriptor);

View File

@@ -112,7 +112,7 @@ public interface LocalLookup {
RECEIVER {
@Override
public boolean isCase(DeclarationDescriptor d) {
return d instanceof CallableDescriptor;
return d instanceof ReceiverParameterDescriptor;
}
@Override
@@ -123,9 +123,11 @@ public interface LocalLookup {
MutableClosure closure,
Type classType
) {
if (closure.getEnclosingReceiverDescriptor() != d) return null;
if (closure.getEnclosingReceiverDescriptor() != d) {
return null;
}
JetType receiverType = ((CallableDescriptor) d).getReceiverParameter().getType();
JetType receiverType = closure.getEnclosingReceiverDescriptor().getType();
Type type = state.getTypeMapper().mapType(receiverType);
StackValue innerValue = StackValue.field(type, classType, CAPTURED_RECEIVER_FIELD, false);
closure.setCaptureReceiver();
@@ -137,7 +139,7 @@ public interface LocalLookup {
@Override
public StackValue outerValue(@NotNull EnclosedValueDescriptor d, @NotNull ExpressionCodegen codegen) {
CallableDescriptor descriptor = (CallableDescriptor) d.getDescriptor();
return StackValue.local(descriptor.getExpectedThisObject() != null ? 1 : 0, d.getType());
return StackValue.local(descriptor.getDispatchReceiverParameter() != null ? 1 : 0, d.getType());
}
};

View File

@@ -25,14 +25,13 @@ import org.jetbrains.jet.codegen.StackValue;
import org.jetbrains.jet.codegen.binding.MutableClosure;
import org.jetbrains.jet.codegen.state.GenerationState;
import org.jetbrains.jet.codegen.state.JetTypeMapper;
import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants;
import org.jetbrains.org.objectweb.asm.Label;
import org.jetbrains.org.objectweb.asm.Type;
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.OBJECT_TYPE;
public class MethodContext extends CodegenContext<CallableMemberDescriptor> {
private final boolean isInliningLambda;
private Label methodStartLabel;
@@ -59,7 +58,7 @@ public class MethodContext extends CodegenContext<CallableMemberDescriptor> {
public StackValue getReceiverExpression(JetTypeMapper typeMapper) {
assert getCallableDescriptorWithReceiver() != null;
@SuppressWarnings("ConstantConditions")
Type asmType = typeMapper.mapType(getCallableDescriptorWithReceiver().getReceiverParameter().getType());
Type asmType = typeMapper.mapType(getCallableDescriptorWithReceiver().getExtensionReceiverParameter().getType());
return StackValue.local(AsmUtil.getReceiverIndex(this, getContextDescriptor()), asmType);
}
@@ -72,6 +71,15 @@ public class MethodContext extends CodegenContext<CallableMemberDescriptor> {
return getParentContext().lookupInContext(d, result, state, ignoreNoOuter);
}
@Nullable
public StackValue generateReceiver(@NotNull CallableDescriptor descriptor, @NotNull GenerationState state, boolean ignoreNoOuter) {
if (getCallableDescriptorWithReceiver() == descriptor) {
return getReceiverExpression(state.getTypeMapper());
}
ReceiverParameterDescriptor parameter = descriptor.getExtensionReceiverParameter();
return lookupInContext(parameter, StackValue.local(0, OBJECT_TYPE), state, ignoreNoOuter);
}
@Override
public boolean isStatic() {
return getParentContext().isStatic();

View File

@@ -0,0 +1,143 @@
/*
* Copyright 2010-2014 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.jet.codegen.inline
import org.jetbrains.org.objectweb.asm.tree.MethodNode
import org.jetbrains.org.objectweb.asm.tree.LabelNode
import com.google.common.collect.LinkedListMultimap
import org.jetbrains.org.objectweb.asm.Label
import java.util.ArrayList
import com.intellij.util.containers.Stack
import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode
import com.google.common.collect.Lists
import org.jetbrains.org.objectweb.asm.tree.TryCatchBlockNode
import java.util.Comparator
import java.util.Collections
public abstract class CoveringTryCatchNodeProcessor<T: IntervalWithHandler>() {
private val tryBlockStarts = LinkedListMultimap.create<LabelNode, T>()
private val tryBlockEnds = LinkedListMultimap.create<LabelNode, T>()
public val allTryCatchNodes: ArrayList<T> = arrayListOf()
private val currentCoveringBlocks: Stack<T> = Stack()
public val coveringFromInnermost: List<T>
get() = currentCoveringBlocks.reverse()
fun addNewTryCatchNode(newInfo: T) {
tryBlockStarts.put(newInfo.startLabel, newInfo)
tryBlockEnds.put(newInfo.endLabel, newInfo)
allTryCatchNodes.add(newInfo)
}
fun remapStartLabel(oldStart: LabelNode, remapped: T) {
tryBlockStarts.remove(oldStart, remapped)
tryBlockStarts.put(remapped.startLabel, remapped)
}
public fun getStartNodes(label: LabelNode): List<T> {
return tryBlockStarts.get(label)
}
public fun getEndNodes(label: LabelNode): List<T> {
return tryBlockEnds.get(label)
}
//Keep information about try blocks that cover current instruction -
// pushing and popping it to stack entering and exiting tryCatchBlock start and end labels
public open fun updateCoveringTryBlocks(curIns: AbstractInsnNode, directOrder: Boolean) {
if (curIns !is LabelNode) return
val infosToClose = if (!directOrder) getStartNodes(curIns) else getEndNodes(curIns)
for (startNode in infosToClose) {
val pop = currentCoveringBlocks.pop()
//Temporary disabled cause during patched structure of exceptions changed
// if (startNode != pop) {
// throw RuntimeException("Wrong try-catch structure " + startNode + " " + pop + " " + infosToClose.size())
// };
}
//Reversing list order cause we should pop external block before internal one
// (originally internal blocks goes before external one, such invariant preserved via sortTryCatchBlocks method)
val infoToOpen = if (!directOrder) getEndNodes(curIns) else getStartNodes(curIns)
for (info in infoToOpen.reverse()) {
currentCoveringBlocks.add(info)
}
}
public abstract fun instructionIndex(inst: AbstractInsnNode): Int
private fun isEmptyInterval(node: T): Boolean {
val start = node.startLabel
var end: AbstractInsnNode = node.endLabel
while (end != start && end is LabelNode) {
end = end.getPrevious()
}
return start == end;
}
public fun getNonEmptyNodes(): List<T> {
return allTryCatchNodes.filterNot { isEmptyInterval(it) }
}
public fun sortTryCatchBlocks() {
val comp = Comparator {(t1: T, t2: T): Int ->
var result = instructionIndex(t1.handler) - instructionIndex(t2.handler)
if (result == 0) {
result = instructionIndex(t1.startLabel) - instructionIndex(t2.startLabel)
if (result == 0) {
assert(false, "Error: support multicatch finallies!")
result = instructionIndex(t1.endLabel) - instructionIndex(t2.endLabel)
}
}
result
}
Collections.sort<T>(allTryCatchNodes, comp)
}
}
public class DefaultProcessor(val node: MethodNode) : CoveringTryCatchNodeProcessor<TryCatchBlockNodeWrapper>() {
{
node.tryCatchBlocks.forEach { addNode(it) }
}
fun addNode(node: TryCatchBlockNode) {
addNewTryCatchNode(TryCatchBlockNodeWrapper(node))
}
override fun instructionIndex(inst: AbstractInsnNode): Int {
return node.instructions.indexOf(inst)
}
}
public class TryCatchBlockNodeWrapper(val node: TryCatchBlockNode) : IntervalWithHandler {
override val startLabel: LabelNode
get() = node.start
override val endLabel: LabelNode
get() = node.end
override val handler: LabelNode
get() = node.handler
override val type: String?
get() = node.type
}

View File

@@ -18,6 +18,7 @@ package org.jetbrains.jet.codegen.inline;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import com.intellij.util.containers.Stack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.codegen.*;
@@ -31,7 +32,6 @@ import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedSimpl
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.impl.AnonymousFunctionDescriptor;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
@@ -42,25 +42,26 @@ import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodSignature;
import org.jetbrains.jet.lang.types.lang.InlineStrategy;
import org.jetbrains.jet.lang.types.lang.InlineUtil;
import org.jetbrains.jet.renderer.DescriptorRenderer;
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.Method;
import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode;
import org.jetbrains.org.objectweb.asm.tree.LabelNode;
import org.jetbrains.org.objectweb.asm.tree.MethodNode;
import org.jetbrains.org.objectweb.asm.tree.TryCatchBlockNode;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.*;
import static org.jetbrains.jet.codegen.AsmUtil.*;
import static org.jetbrains.jet.codegen.AsmUtil.getMethodAsmFlags;
import static org.jetbrains.jet.codegen.AsmUtil.isPrimitive;
import static org.jetbrains.jet.codegen.inline.InlineCodegenUtil.addInlineMarker;
public class InlineCodegen implements CallGenerator {
private final GenerationState state;
private final JetTypeMapper typeMapper;
private final BindingContext bindingContext;
private final SimpleFunctionDescriptor functionDescriptor;
private final JvmMethodSignature jvmSignature;
@@ -90,7 +91,6 @@ public class InlineCodegen implements CallGenerator {
this.codegen = codegen;
this.callElement = callElement;
this.functionDescriptor = functionDescriptor.getOriginal();
bindingContext = codegen.getBindingContext();
initialFrameSize = codegen.getFrameMap().getCurrentSize();
context = (MethodContext) getContext(functionDescriptor, state);
@@ -241,7 +241,7 @@ public class InlineCodegen implements CallGenerator {
}
}
};
List<MethodInliner.ExternalFinallyBlockInfo> infos = MethodInliner.processReturns(adapter, labelOwner, true, null);
List<MethodInliner.PointForExternalFinallyBlocks> infos = MethodInliner.processReturns(adapter, labelOwner, true, null);
generateAndInsertFinallyBlocks(adapter, infos);
adapter.accept(new InliningInstructionAdapter(codegen.v));
@@ -418,7 +418,7 @@ public class InlineCodegen implements CallGenerator {
private void putClosureParametersOnStack() {
for (LambdaInfo next : expressionMap.values()) {
activeLambda = next;
codegen.pushClosureOnStack(next.closure, false, this);
codegen.pushClosureOnStack(next.getClassDescriptor(), true, this);
}
activeLambda = null;
}
@@ -483,19 +483,62 @@ public class InlineCodegen implements CallGenerator {
}
public void generateAndInsertFinallyBlocks(MethodNode intoNode, List<MethodInliner.ExternalFinallyBlockInfo> insertPoints) {
public void generateAndInsertFinallyBlocks(MethodNode intoNode, List<MethodInliner.PointForExternalFinallyBlocks> insertPoints) {
if (!codegen.hasFinallyBlocks()) return;
for (MethodInliner.ExternalFinallyBlockInfo insertPoint : insertPoints) {
MethodNode finallyNode = InlineCodegenUtil.createEmptyMethodNode();
ExpressionCodegen finallyCodegen =
new ExpressionCodegen(finallyNode, codegen.getFrameMap(), codegen.getReturnType(),
codegen.getContext(), codegen.getState(), codegen.getParentCodegen());
finallyCodegen.addBlockStackElementsForNonLocalReturns(codegen.getBlockStackElements());
Map<AbstractInsnNode, MethodInliner.PointForExternalFinallyBlocks> extensionPoints =
new HashMap<AbstractInsnNode, MethodInliner.PointForExternalFinallyBlocks>();
for (MethodInliner.PointForExternalFinallyBlocks insertPoint : insertPoints) {
extensionPoints.put(insertPoint.beforeIns, insertPoint);
}
finallyCodegen.generateFinallyBlocksIfNeeded(insertPoint.returnType);
DefaultProcessor processor = new DefaultProcessor(intoNode);
InlineCodegenUtil.insertNodeBefore(finallyNode, intoNode, insertPoint.beforeIns);
AbstractInsnNode curInstr = intoNode.instructions.getFirst();
while (curInstr != null) {
processor.updateCoveringTryBlocks(curInstr, true);
MethodInliner.PointForExternalFinallyBlocks extension = extensionPoints.get(curInstr);
if (extension != null) {
Label start = new Label();
Label end = new Label();
MethodNode finallyNode = InlineCodegenUtil.createEmptyMethodNode();
finallyNode.visitLabel(start);
ExpressionCodegen finallyCodegen =
new ExpressionCodegen(finallyNode, codegen.getFrameMap(), codegen.getReturnType(),
codegen.getContext(), codegen.getState(), codegen.getParentCodegen());
finallyCodegen.addBlockStackElementsForNonLocalReturns(codegen.getBlockStackElements());
finallyCodegen.generateFinallyBlocksIfNeeded(extension.returnType);
finallyNode.visitLabel(end);
//Exception table for external try/catch/finally blocks will be generated in original codegen after exiting this method
InlineCodegenUtil.insertNodeBefore(finallyNode, intoNode, curInstr);
List<TryCatchBlockNodeWrapper> blocks = processor.getCoveringFromInnermost();
ListIterator<TryCatchBlockNodeWrapper> iterator = blocks.listIterator(blocks.size());
while (iterator.hasPrevious()) {
TryCatchBlockNodeWrapper previous = iterator.previous();
LabelNode oldStart = previous.getStartLabel();
TryCatchBlockNode node = previous.getNode();
node.start = (LabelNode) end.info;
processor.remapStartLabel(oldStart, previous);
TryCatchBlockNode additionalNode = new TryCatchBlockNode(oldStart, (LabelNode) start.info, node.handler, node.type);
processor.addNode(additionalNode);
}
}
curInstr = curInstr.getNext();
}
processor.sortTryCatchBlocks();
Iterable<TryCatchBlockNodeWrapper> nodes = processor.getNonEmptyNodes();
intoNode.tryCatchBlocks.clear();
for (TryCatchBlockNodeWrapper node : nodes) {
intoNode.tryCatchBlocks.add(node.getNode());
}
}

View File

@@ -17,21 +17,25 @@
package org.jetbrains.jet.codegen.inline;
import com.google.common.base.Objects;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists;
import com.intellij.util.containers.Stack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import org.jetbrains.jet.codegen.AsmUtil;
import org.jetbrains.org.objectweb.asm.*;
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.tree.*;
import org.jetbrains.org.objectweb.asm.util.Textifier;
import org.jetbrains.org.objectweb.asm.util.TraceMethodVisitor;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.*;
import static org.jetbrains.jet.codegen.inline.InlineCodegenUtil.*;
public class InternalFinallyBlockInliner {
public class InternalFinallyBlockInliner extends CoveringTryCatchNodeProcessor<TryCatchBlockNodeInfo> {
private static class FinallyBlockInfo {
@@ -43,6 +47,18 @@ public class InternalFinallyBlockInliner {
startIns = inclusiveStart;
endInsExclusive = exclusiveEnd;
}
public boolean isEmpty() {
if (!(startIns instanceof LabelNode)) {
return false;
}
AbstractInsnNode end = endInsExclusive;
while (end != startIns && end instanceof LabelNode) {
end = end.getPrevious();
}
return startIns == end;
}
}
public static void processInlineFunFinallyBlocks(@NotNull MethodNode inlineFun, int lambdaTryCatchBlockNodes) {
@@ -60,22 +76,18 @@ public class InternalFinallyBlockInliner {
@NotNull
private final MethodNode inlineFun;
private final List<TryCatchBlockNodeInfo> inlineFunTryBlockInfo;
private final ListMultimap<LabelNode, TryCatchBlockNodeInfo> tryBlockStarts = LinkedListMultimap.create();
private final ListMultimap<LabelNode, TryCatchBlockNodeInfo> tryBlockEnds = LinkedListMultimap.create();
//lambdaTryCatchBlockNodes is number of TryCatchBlockNodes that was inlined with lambdas into function
//due to code generation specific they placed before function TryCatchBlockNodes
private InternalFinallyBlockInliner(@NotNull MethodNode inlineFun, List<TryCatchBlockNodeInfo> inlineFunTryBlockInfo) {
this.inlineFun = inlineFun;
this.inlineFunTryBlockInfo = inlineFunTryBlockInfo;
for (TryCatchBlockNodeInfo block : inlineFunTryBlockInfo) {
addNewTryCatchNode(block);
}
}
private int initAndGetVarIndexForNonLocalReturnValue() {
//sortTryCatchBlocks();/*TODO maybe remove*/
mapLabelsToTryCatchBlocks();
MaxLocalsCalculator tempCalcNode = new MaxLocalsCalculator(
InlineCodegenUtil.API,
@@ -88,7 +100,6 @@ public class InternalFinallyBlockInliner {
private void processInlineFunFinallyBlocks() {
int nextTempNonLocalVarIndex = initAndGetVarIndexForNonLocalReturnValue();
Stack<TryCatchBlockNodeInfo> coveringTryCatchBlocks = new Stack<TryCatchBlockNodeInfo>();
InsnList instructions = inlineFun.instructions;
//As we do finally block code search after non-local return instruction
@@ -96,10 +107,19 @@ public class InternalFinallyBlockInliner {
// So we do instruction processing in reverse order!
AbstractInsnNode curIns = instructions.getLast();
while (curIns != null) {
updateCoveringTryBlocks(coveringTryCatchBlocks, curIns);
updateCoveringTryBlocks(curIns);
//At this point only global return is possible, local one already substituted with: goto endLabel
if (!InlineCodegenUtil.isReturnOpcode(curIns.getOpcode()) || !InlineCodegenUtil.isMarkedReturn(curIns)) {
if (!InlineCodegenUtil.isReturnOpcode(curIns.getOpcode()) ||
!InlineCodegenUtil.isMarkedReturn(curIns)) {
curIns = curIns.getPrevious();
continue;
}
List<TryCatchBlockNodeInfo> currentCoveringNodes = getCoveringFromInnermost();
checkCoveringBlocksInvariant(currentCoveringNodes);
if (currentCoveringNodes.isEmpty() ||
currentCoveringNodes.get(currentCoveringNodes.size() - 1).getOnlyCopyNotProcess()) {
curIns = curIns.getPrevious();
continue;
}
@@ -113,69 +133,59 @@ public class InternalFinallyBlockInliner {
// Each group that corresponds to try/*catches*/finally contains tryCatch block with default handler.
// For each such group we should insert corresponding finally before non-local return.
// So we split all try blocks on current instructions to groups and process them independently
List<TryBlockCluster<TryCatchBlockNodeInfo>> clusters = InlinePackage.doClustering(coveringTryCatchBlocks);
ListIterator<TryBlockCluster<TryCatchBlockNodeInfo>> tryCatchBlockIterator = clusters.listIterator(clusters.size());
//Reverse visiting cause innermost tryCatchBlocks in the end
while (tryCatchBlockIterator.hasPrevious()) {
TryBlockCluster originalFinallyCluster = tryCatchBlockIterator.previous();
List<TryCatchBlockNodeInfo> clusterBlocks = originalFinallyCluster.getBlocks();
TryCatchBlockNodeInfo originalFinallyBlock = clusterBlocks.get(0);
List<TryBlockCluster<TryCatchBlockNodeInfo>> clustersFromInnermost = InlinePackage.doClustering(currentCoveringNodes);
Iterator<TryBlockCluster<TryCatchBlockNodeInfo>> tryCatchBlockIterator = clustersFromInnermost.iterator();
FinallyBlockInfo finallyInfo = findFinallyBlockBody(originalFinallyBlock, inlineFunTryBlockInfo);
checkClusterInvariant(clustersFromInnermost);
List<TryCatchBlockNodeInfo> additionalNodesToSplit = new ArrayList<TryCatchBlockNodeInfo>();
while (tryCatchBlockIterator.hasNext()) {
TryBlockCluster clusterToFindFinally = tryCatchBlockIterator.next();
List<TryCatchBlockNodeInfo> clusterBlocks = clusterToFindFinally.getBlocks();
TryCatchBlockNodeInfo nodeWithDefaultHandlerIfExists = clusterBlocks.get(clusterBlocks.size() - 1);
FinallyBlockInfo finallyInfo = findFinallyBlockBody(nodeWithDefaultHandlerIfExists, getAllTryCatchNodes());
if (finallyInfo == null) continue;
if (nodeWithDefaultHandlerIfExists.getOnlyCopyNotProcess()) {
additionalNodesToSplit.addAll(clusterBlocks);
continue;
}
instructions.resetLabels();
List<TryCatchBlockNodePosition> tryCatchBlockInlinedInFinally = findTryCatchBlocksInlinedInFinally(finallyInfo);
//Keep some information about label nodes, we need it to understand whether it's jump inside finally block or outside
// in first case we do call VISIT on instruction otherwise recreating jump instruction (see below)
Set<LabelNode> labelsInsideFinally = rememberOriginalLabelNodes(finallyInfo);
//Creating temp node for finally block copy with some additional instruction
MethodNode finallyBlockCopy = createEmptyMethodNode();
Label newFinallyStart = new Label();
Label newFinallyEnd = new Label();
Label insertedBlockEnd = new Label();
if (nonLocalReturnType != Type.VOID_TYPE) {
boolean generateAloadAstore = nonLocalReturnType != Type.VOID_TYPE && !finallyInfo.isEmpty();
if (generateAloadAstore) {
finallyBlockCopy.visitVarInsn(nonLocalReturnType.getOpcode(Opcodes.ISTORE), nextTempNonLocalVarIndex);
}
finallyBlockCopy.visitLabel(newFinallyStart);
//Keep some information about label nodes, we need it to understand whether it's jump inside finally block or outside
// in first case we do call VISIT on instruction otherwise recreating jump instruction (see below)
Set<LabelNode> labelsInsideFinally = rememberOriginalLabelNodes(finallyInfo);
//Writing finally block body to temporary node
AbstractInsnNode currentIns = finallyInfo.startIns;
while (currentIns != finallyInfo.endInsExclusive) {
//This condition allows another model for non-local returns processing
if (false && InlineCodegenUtil.isReturnOpcode(currentIns.getOpcode()) && !InlineCodegenUtil.isMarkedReturn(currentIns)) {
//substitute all local returns in finally finallyInfo with non-local one lambdaFinallyBlocks try finallyInfo
//TODO same for jumps
Type localReturnType = InlineCodegenUtil.getReturnType(currentIns.getOpcode());
substituteReturnValueInFinally(nextTempNonLocalVarIndex, nonLocalReturnType, finallyBlockCopy,
localReturnType, true);
boolean isInsOrJumpInsideFinally =
!(currentIns instanceof JumpInsnNode) ||
labelsInsideFinally.contains(((JumpInsnNode) currentIns).label);
instrInsertFinallyBefore.accept(finallyBlockCopy);
curIns.accept(finallyBlockCopy);
}
else {
boolean isInsOrJumpInsideFinally =
!(currentIns instanceof JumpInsnNode) ||
labelsInsideFinally.contains(((JumpInsnNode) currentIns).label);
if (isInsOrJumpInsideFinally) {
currentIns.accept(finallyBlockCopy); //VISIT
}
else {
//keep original jump: add currentIns clone
finallyBlockCopy.instructions.add(new JumpInsnNode(currentIns.getOpcode(), ((JumpInsnNode) currentIns).label));
}
}
copyInstruction(nextTempNonLocalVarIndex, curIns, instrInsertFinallyBefore, nonLocalReturnType, finallyBlockCopy,
currentIns, isInsOrJumpInsideFinally);
currentIns = currentIns.getNext();
}
finallyBlockCopy.visitLabel(newFinallyEnd);
if (nonLocalReturnType != Type.VOID_TYPE) {
if (generateAloadAstore) {
finallyBlockCopy.visitVarInsn(nonLocalReturnType.getOpcode(Opcodes.ILOAD), nextTempNonLocalVarIndex);
nextTempNonLocalVarIndex += nonLocalReturnType.getSize(); //TODO: do more wise indexing
}
@@ -185,15 +195,76 @@ public class InternalFinallyBlockInliner {
//Copying finally body before non-local return instruction
InlineCodegenUtil.insertNodeBefore(finallyBlockCopy, inlineFun, instrInsertFinallyBefore);
nextPrev = updateExceptionTable(coveringTryCatchBlocks, nextPrev, clusterBlocks, newFinallyStart, newFinallyEnd,
tryCatchBlockInlinedInFinally, labelsInsideFinally, (LabelNode) insertedBlockEnd.info);
updateExceptionTable(clusterBlocks, newFinallyStart, newFinallyEnd,
tryCatchBlockInlinedInFinally, labelsInsideFinally, (LabelNode) insertedBlockEnd.info, additionalNodesToSplit);
}
//skip just inserted finally
curIns = curIns.getPrevious();
while (curIns != null && curIns != nextPrev) {
updateCoveringTryBlocks(curIns);
curIns = curIns.getPrevious();
}
curIns = nextPrev;
}
inlineFun.tryCatchBlocks.clear();
for (TryCatchBlockNodeInfo info : inlineFunTryBlockInfo) {
inlineFun.tryCatchBlocks.add(info.getNode());
substituteTryBlockNodes();
}
private static void copyInstruction(
int nextTempNonLocalVarIndex,
@NotNull AbstractInsnNode curIns,
@NotNull AbstractInsnNode instrInsertFinallyBefore,
@NotNull Type nonLocalReturnType,
@NotNull MethodNode finallyBlockCopy,
@NotNull AbstractInsnNode currentIns,
boolean isInsOrJumpInsideFinally
) {
//This condition allows another model for non-local returns processing
if (false) {
boolean isReturnForSubstitution =
InlineCodegenUtil.isReturnOpcode(currentIns.getOpcode()) && !InlineCodegenUtil.isMarkedReturn(currentIns);
if (!isInsOrJumpInsideFinally || isReturnForSubstitution) {
//substitute all local returns and jumps outside finally with non-local return
Type localReturnType = InlineCodegenUtil.getReturnType(currentIns.getOpcode());
substituteReturnValueInFinally(nextTempNonLocalVarIndex, nonLocalReturnType, finallyBlockCopy,
localReturnType, isReturnForSubstitution);
instrInsertFinallyBefore.accept(finallyBlockCopy);
curIns.accept(finallyBlockCopy);
} else {
currentIns.accept(finallyBlockCopy); //VISIT
}
}
else {
if (isInsOrJumpInsideFinally) {
currentIns.accept(finallyBlockCopy); //VISIT
}
else {
//keep original jump: add currentIns clone
finallyBlockCopy.instructions.add(new JumpInsnNode(currentIns.getOpcode(), ((JumpInsnNode) currentIns).label));
}
}
}
private static void checkCoveringBlocksInvariant(List<TryCatchBlockNodeInfo> coveringTryCatchBlocks) {
boolean isWasOnlyLocal = false;
for (TryCatchBlockNodeInfo info : Lists.reverse(coveringTryCatchBlocks)) {
assert !isWasOnlyLocal || info.getOnlyCopyNotProcess();
if (info.getOnlyCopyNotProcess()) {
isWasOnlyLocal = true;
}
}
}
private static void checkClusterInvariant(List<TryBlockCluster<TryCatchBlockNodeInfo>> clusters) {
boolean isWasOnlyLocal;
isWasOnlyLocal = false;
for (TryBlockCluster<TryCatchBlockNodeInfo> cluster : Lists.reverse(clusters)) {
TryCatchBlockNodeInfo info = cluster.getBlocks().get(0);
assert !isWasOnlyLocal || info.getOnlyCopyNotProcess();
if (info.getOnlyCopyNotProcess()) {
isWasOnlyLocal = true;
}
}
}
@@ -208,17 +279,14 @@ public class InternalFinallyBlockInliner {
return labelsInsideFinally;
}
@Nullable
private AbstractInsnNode updateExceptionTable(
@NotNull Stack<TryCatchBlockNodeInfo> coveringTryBlocks,
@Nullable AbstractInsnNode nextPrev,
private void updateExceptionTable(
@NotNull List<TryCatchBlockNodeInfo> updatingClusterBlocks,
@NotNull Label newFinallyStart,
@NotNull Label newFinallyEnd,
@NotNull List<TryCatchBlockNodePosition> tryCatchBlockPresentInFinally,
@NotNull Set<LabelNode> labelsInsideFinally,
@NotNull LabelNode insertedBlockEnd
@NotNull LabelNode insertedBlockEnd,
@NotNull List<TryCatchBlockNodeInfo> patched
) {
//copy tryCatchFinallies that totally in finally block
@@ -246,9 +314,7 @@ public class InternalFinallyBlockInliner {
assert inlineFun.instructions.indexOf(additionalTryCatchBlock.start) <= inlineFun.instructions.indexOf(additionalTryCatchBlock.end);
TryCatchBlockNodeInfo newInfo = new TryCatchBlockNodeInfo(additionalTryCatchBlock, true);
tryBlockStarts.put(newInfo.getStartLabel(), newInfo);
tryBlockEnds.put(newInfo.getEndLabel(), newInfo);
inlineFunTryBlockInfo.add(newInfo);
addNewTryCatchNode(newInfo);
}
}
else if (clusterPosition == TryCatchPosition.END) {
@@ -272,7 +338,7 @@ public class InternalFinallyBlockInliner {
assert Objects.equal(startNode.getType(), endNode.getType()) : "Different handler types : " + startNode.getType() + " " + endNode.getType();
patchTryBlocks((LabelNode) startNode.getStartLabel().getLabel().info, endNode, false);
patchTryBlocks((LabelNode) startNode.getStartLabel().getLabel().info, endNode);
}
}
}
@@ -284,7 +350,7 @@ public class InternalFinallyBlockInliner {
//TODO rewrite to clusters
for (TryCatchBlockNodePosition endBlockPosition : singleCluster.getBlocks()) {
TryCatchBlockNodeInfo endNode = endBlockPosition.getNodeInfo();
patchTryBlocks((LabelNode) insertedBlockEnd.getLabel().info, endNode, true);
patchTryBlocks((LabelNode) insertedBlockEnd.getLabel().info, endNode);
//nextPrev = (AbstractInsnNode) insertedBlockEnd.getLabel().info;
}
@@ -293,38 +359,35 @@ public class InternalFinallyBlockInliner {
}
assert handler2Cluster.isEmpty() : "Unmatched clusters " + handler2Cluster.size();
List<TryCatchBlockNodeInfo > toProcess = new ArrayList<TryCatchBlockNodeInfo>();
toProcess.addAll(patched);
toProcess.addAll(updatingClusterBlocks);
patched.clear();
// Inserted finally shouldn't be handled by corresponding catches,
// so we should split original interval by inserted finally one
for (TryCatchBlockNodeInfo block : updatingClusterBlocks) {
for (TryCatchBlockNodeInfo block : toProcess) {
//update exception mapping
LabelNode oldStartNode = block.getNode().start;
tryBlockStarts.remove(oldStartNode, block);
block.getNode().start = (LabelNode) newFinallyEnd.info;
//tryBlockStarts.put(block.getStartLabel(), block);
remapStartLabel(oldStartNode, block);
patched.add(block);
TryCatchBlockNode additionalTryCatchBlock =
new TryCatchBlockNode(oldStartNode, (LabelNode) newFinallyStart.info, block.getNode().handler, block.getNode().type);
TryCatchBlockNodeInfo newInfo = new TryCatchBlockNodeInfo(additionalTryCatchBlock, false);
tryBlockStarts.put(additionalTryCatchBlock.start, newInfo);
tryBlockEnds.put(additionalTryCatchBlock.end, newInfo);
inlineFunTryBlockInfo.add(newInfo);
TryCatchBlockNodeInfo newInfo = new TryCatchBlockNodeInfo(additionalTryCatchBlock, block.getOnlyCopyNotProcess());
addNewTryCatchNode(newInfo);
//TODO add assert
nextPrev = additionalTryCatchBlock.end;
coveringTryBlocks.pop();
}
sortTryCatchBlocks(inlineFunTryBlockInfo);
return nextPrev;
sortTryCatchBlocks();
}
private void patchTryBlocks(@NotNull LabelNode newStartLabelNode, @NotNull TryCatchBlockNodeInfo endNode, boolean sort) {
private void patchTryBlocks(@NotNull LabelNode newStartLabelNode, @NotNull TryCatchBlockNodeInfo endNode) {
LabelNode oldStart = endNode.getStartLabel();
endNode.getNode().start = newStartLabelNode;
tryBlockStarts.remove(oldStart, endNode);
tryBlockStarts.put(endNode.getNode().start, endNode);
remapStartLabel(oldStart, endNode);
TryCatchBlockNode endTryBlock = endNode.getNode();
TryCatchBlockNode additionalTryCatchBlock =
@@ -334,10 +397,7 @@ public class InternalFinallyBlockInliner {
endTryBlock.type);
TryCatchBlockNodeInfo newInfo = new TryCatchBlockNodeInfo(additionalTryCatchBlock, endNode.getOnlyCopyNotProcess());
tryBlockStarts.put(newInfo.getStartLabel(), newInfo);
tryBlockEnds.put(newInfo.getEndLabel(), newInfo);
inlineFunTryBlockInfo.add(newInfo);
addNewTryCatchNode(newInfo);
}
private static LabelNode getNewOrOldLabel(LabelNode oldHandler, @NotNull Set<LabelNode> labelsInsideFinally) {
@@ -350,25 +410,9 @@ public class InternalFinallyBlockInliner {
//Keep information about try blocks that cover current instruction -
// pushing and popping it to stack entering and exiting tryCatchBlock start and end labels
private void updateCoveringTryBlocks(Stack<TryCatchBlockNodeInfo> coveringTryBlocks, AbstractInsnNode curIns) {
if (!(curIns instanceof LabelNode)) return;
List<TryCatchBlockNodeInfo> infos = tryBlockStarts.get((LabelNode) curIns);
for (TryCatchBlockNodeInfo startNode : infos) {
if (!startNode.getOnlyCopyNotProcess()) {
TryCatchBlockNodeInfo pop = coveringTryBlocks.pop();
//Temporary disabled cause during patched structure of exceptions changed
//assert startNode == pop : "Wrong try-catch structure " + startNode + " " + pop + " " + infos.size();
}
}
//Reversing list order cause we should pop external block before internal one
// (originally internal blocks goes before external one, such invariant preserved via sortTryCatchBlocks method)
for (TryCatchBlockNodeInfo info : Lists.reverse(tryBlockEnds.get((LabelNode) curIns))) {
if (!info.getOnlyCopyNotProcess()) {
coveringTryBlocks.add(info);
}
}
public void updateCoveringTryBlocks(@NotNull AbstractInsnNode curIns) {
super.updateCoveringTryBlocks(curIns, false);
checkCoveringBlocksInvariant(getCoveringFromInnermost());
}
private static boolean hasFinallyBlocks(List<TryCatchBlockNodeInfo> inlineFunTryBlockInfo) {
@@ -380,13 +424,6 @@ public class InternalFinallyBlockInliner {
return false;
}
private void mapLabelsToTryCatchBlocks() {
for (TryCatchBlockNodeInfo block : inlineFunTryBlockInfo) {
tryBlockStarts.put(block.getNode().start, block);
tryBlockEnds.put(block.getNode().end, block);
}
}
//As described above all tryCatch group that have finally block also should contains tryCatchBlockNode with default handler.
//So we assume that instructions between end of tryCatchBlock and start of next tryCatchBlock with same default handler is required finally body.
//There is at least two tryCatchBlockNodes in list cause there is always tryCatchBlockNode on first instruction of default handler:
@@ -396,6 +433,15 @@ public class InternalFinallyBlockInliner {
@NotNull TryCatchBlockNodeInfo tryCatchBlock,
@NotNull List<TryCatchBlockNodeInfo> tryCatchBlocks
) {
if (tryCatchBlock.getOnlyCopyNotProcess()) {
AbstractInsnNode start = new LabelNode();
AbstractInsnNode end = new LabelNode();
InsnList insnList = new InsnList();
insnList.add(start);
insnList.add(end);
return new FinallyBlockInfo(start, end);
}
List<TryCatchBlockNodeInfo> sameDefaultHandler = new ArrayList<TryCatchBlockNodeInfo>();
LabelNode defaultHandler = null;
boolean afterStartBlock = false;
@@ -427,7 +473,13 @@ public class InternalFinallyBlockInliner {
AbstractInsnNode endFinallyChainExclusive = skipLastGotoIfNeeded(nextIntervalWithSameDefaultHandler.getNode().handler,
nextIntervalWithSameDefaultHandler.getNode().start);
return new FinallyBlockInfo(startFinallyChain.getNext(), endFinallyChainExclusive);
FinallyBlockInfo finallyInfo = new FinallyBlockInfo(startFinallyChain.getNext(), endFinallyChainExclusive);
if (inlineFun.instructions.indexOf(finallyInfo.startIns) > inlineFun.instructions.indexOf(finallyInfo.endInsExclusive)) {
throw new AssertionError("Inconsistent finally: block end occurs before start " + traceInterval(finallyInfo.endInsExclusive, finallyInfo.startIns));
}
return finallyInfo;
}
@NotNull
@@ -470,22 +522,20 @@ public class InternalFinallyBlockInliner {
private List<TryCatchBlockNodePosition> findTryCatchBlocksInlinedInFinally(@NotNull FinallyBlockInfo finallyInfo) {
List<TryCatchBlockNodePosition> result = new ArrayList<TryCatchBlockNodePosition>();
Map<TryCatchBlockNodeInfo, TryCatchBlockNodePosition> processedBlocks = new HashMap<TryCatchBlockNodeInfo, TryCatchBlockNodePosition>();
for (AbstractInsnNode curInstr = finallyInfo.startIns; curInstr != finallyInfo.endInsExclusive; curInstr = curInstr.getNext()) {
if (!(curInstr instanceof LabelNode)) continue;
LabelNode curLabel = (LabelNode) curInstr;
List<TryCatchBlockNodeInfo> startedTryBlocks = tryBlockStarts.get(curLabel);
if (startedTryBlocks != null) {
for (TryCatchBlockNodeInfo block : startedTryBlocks) {
assert !processedBlocks.containsKey(block) : "Try catch block already processed before start label!!! " + block;
TryCatchBlockNodePosition info = new TryCatchBlockNodePosition(block, TryCatchPosition.START);
processedBlocks.put(block, info);
result.add(info);
}
List<TryCatchBlockNodeInfo> startedTryBlocks = getStartNodes(curLabel);
for (TryCatchBlockNodeInfo block : startedTryBlocks) {
assert !processedBlocks.containsKey(block) : "Try catch block already processed before start label!!! " + block;
TryCatchBlockNodePosition info = new TryCatchBlockNodePosition(block, TryCatchPosition.START);
processedBlocks.put(block, info);
result.add(info);
}
List<TryCatchBlockNodeInfo> endedTryBlocks = tryBlockEnds.get(curLabel);
if (endedTryBlocks == null) continue;
List<TryCatchBlockNodeInfo> endedTryBlocks = getEndNodes(curLabel);
for (TryCatchBlockNodeInfo block : endedTryBlocks) {
TryCatchBlockNodePosition info = processedBlocks.get(block);
@@ -527,21 +577,38 @@ public class InternalFinallyBlockInliner {
return result;
}
private void sortTryCatchBlocks(@NotNull List<TryCatchBlockNodeInfo> inlineFunTryBlockInfo) {
Comparator<TryCatchBlockNodeInfo> comp = new Comparator<TryCatchBlockNodeInfo>() {
@Override
public int compare(@NotNull TryCatchBlockNodeInfo t1, @NotNull TryCatchBlockNodeInfo t2) {
int result = inlineFun.instructions.indexOf(t1.getNode().handler) - inlineFun.instructions.indexOf(t2.getNode().handler);
if (result == 0) {
result = inlineFun.instructions.indexOf(t1.getNode().start) - inlineFun.instructions.indexOf(t2.getNode().start);
if (result == 0) {
assert false : "Error: support multicatch finallies!";
result = inlineFun.instructions.indexOf(t1.getNode().end) - inlineFun.instructions.indexOf(t2.getNode().end);
}
}
return result;
}
};
Collections.sort(inlineFunTryBlockInfo, comp);
@Override
public int instructionIndex(@NotNull AbstractInsnNode inst) {
return inlineFun.instructions.indexOf(inst);
}
private void substituteTryBlockNodes() {
inlineFun.tryCatchBlocks.clear();
for (TryCatchBlockNodeInfo info : getNonEmptyNodes()) {
inlineFun.tryCatchBlocks.add(info.getNode());
}
}
private static String traceInterval(AbstractInsnNode startNode, AbstractInsnNode stopNode) {
Textifier p = new Textifier();
TraceMethodVisitor visitor = new TraceMethodVisitor(p);
while (startNode != stopNode) {
startNode.accept(visitor);
startNode = startNode.getNext();
}
startNode.accept(visitor);
StringWriter out = new StringWriter();
p.print(new PrintWriter(out));
return out.toString();
}
@SuppressWarnings({"UnusedDeclaration", "UseOfSystemOutOrSystemErr"})
@TestOnly
private void flushCurrentState(@NotNull AbstractInsnNode curNonLocal) {
substituteTryBlockNodes();
System.out.println("Will process instruction at : " + inlineFun.instructions.indexOf(curNonLocal) + " " + curNonLocal.toString());
String text = getNodeText(inlineFun);
System.out.println(text);
}
}

View File

@@ -18,9 +18,6 @@ package org.jetbrains.jet.codegen.inline;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.tree.FieldInsnNode;
import org.jetbrains.org.objectweb.asm.tree.MethodNode;
import org.jetbrains.jet.codegen.AsmUtil;
import org.jetbrains.jet.codegen.binding.CalculatedClosure;
import org.jetbrains.jet.codegen.context.EnclosedValueDescriptor;
@@ -32,12 +29,15 @@ import org.jetbrains.jet.lang.psi.JetFunctionLiteral;
import org.jetbrains.jet.lang.psi.JetFunctionLiteralExpression;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.tree.FieldInsnNode;
import org.jetbrains.org.objectweb.asm.tree.MethodNode;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static org.jetbrains.jet.codegen.binding.CodegenBinding.CLOSURE;
import static org.jetbrains.jet.codegen.binding.CodegenBinding.anonymousClassForFunction;
import static org.jetbrains.jet.codegen.binding.CodegenBinding.asmTypeForAnonymousClass;
import static org.jetbrains.jet.codegen.binding.CodegenBinding.*;
public class LambdaInfo implements CapturedParamOwner, LabelOwner {
@@ -49,7 +49,7 @@ public class LambdaInfo implements CapturedParamOwner, LabelOwner {
@Nullable
public final String labelName;
public final CalculatedClosure closure;
private final CalculatedClosure closure;
private MethodNode node;

View File

@@ -356,7 +356,6 @@ public class MethodInliner {
AbstractInsnNode cur = node.instructions.getFirst();
int index = 0;
Set<LabelNode> possibleDeadLabels = new HashSet<LabelNode>();
while (cur != null) {
Frame<SourceValue> frame = sources[index];
@@ -416,15 +415,12 @@ public class MethodInliner {
if (frame == null) {
//clean dead code otherwise there is problems in unreachable finally block, don't touch label it cause try/catch/finally problems
if (prevNode.getType() == AbstractInsnNode.LABEL) {
possibleDeadLabels.add((LabelNode) prevNode);
//NB: Cause we generate exception table for default handler using gaps (see ExpressionCodegen.visitTryExpression)
//it may occurs that interval for default handler starts before catch start label, so this label seems as dead,
//but as result all this labels will be merged into one (see KT-5863)
} else {
node.instructions.remove(prevNode);
}
} else {
//Cause we generate exception table for default handler using gaps (see ExpressionCodegen.visitTryExpression)
//it may occurs that interval for default handler starts before catch start label, so this label seems as dead,
//but as result all this labels will be merged into one (see KT-5863)
possibleDeadLabels.remove(prevNode.getPrevious());
}
}
@@ -432,7 +428,7 @@ public class MethodInliner {
List<TryCatchBlockNode> blocks = node.tryCatchBlocks;
for (Iterator<TryCatchBlockNode> iterator = blocks.iterator(); iterator.hasNext(); ) {
TryCatchBlockNode block = iterator.next();
if (possibleDeadLabels.contains(block.start) && possibleDeadLabels.contains(block.end)) {
if (isEmptyTryInterval(block)) {
iterator.remove();
}
}
@@ -440,6 +436,15 @@ public class MethodInliner {
return node;
}
private static boolean isEmptyTryInterval(@NotNull TryCatchBlockNode tryCatchBlockNode) {
LabelNode start = tryCatchBlockNode.start;
AbstractInsnNode end = tryCatchBlockNode.end;
while (end != start && end instanceof LabelNode) {
end = end.getPrevious();
}
return start == end;
}
public LambdaInfo getLambdaIfExists(AbstractInsnNode insnNode) {
if (insnNode.getOpcode() == Opcodes.ALOAD) {
int varIndex = ((VarInsnNode) insnNode).var;
@@ -581,11 +586,11 @@ public class MethodInliner {
@NotNull
//process local and global returns (local substituted with goto end-label global kept unchanged)
public static List<ExternalFinallyBlockInfo> processReturns(@NotNull MethodNode node, @NotNull LabelOwner labelOwner, boolean remapReturn, Label endLabel) {
public static List<PointForExternalFinallyBlocks> processReturns(@NotNull MethodNode node, @NotNull LabelOwner labelOwner, boolean remapReturn, Label endLabel) {
if (!remapReturn) {
return Collections.emptyList();
}
List<ExternalFinallyBlockInfo> result = new ArrayList<ExternalFinallyBlockInfo>();
List<PointForExternalFinallyBlocks> result = new ArrayList<PointForExternalFinallyBlocks>();
InsnList instructions = node.instructions;
AbstractInsnNode insnNode = instructions.getFirst();
while (insnNode != null) {
@@ -616,7 +621,7 @@ public class MethodInliner {
}
//genetate finally block before nonLocalReturn flag/return/goto
result.add(new ExternalFinallyBlockInfo(isLocalReturn ? insnNode : insnNode.getPrevious(), getReturnType(insnNode.getOpcode())
result.add(new PointForExternalFinallyBlocks(isLocalReturn ? insnNode : insnNode.getPrevious(), getReturnType(insnNode.getOpcode())
));
}
insnNode = insnNode.getNext();
@@ -624,13 +629,14 @@ public class MethodInliner {
return result;
}
public static class ExternalFinallyBlockInfo {
//Place to insert finally blocks from try blocks that wraps inline fun call
public static class PointForExternalFinallyBlocks {
final AbstractInsnNode beforeIns;
final Type returnType;
public ExternalFinallyBlockInfo(AbstractInsnNode beforeIns, Type returnType) {
public PointForExternalFinallyBlocks(AbstractInsnNode beforeIns, Type returnType) {
this.beforeIns = beforeIns;
this.returnType = returnType;
}

View File

@@ -33,7 +33,7 @@ trait IntervalWithHandler {
val startLabel: LabelNode
val endLabel: LabelNode
val handler: LabelNode
val `type`: String?
val type: String?
}
class TryCatchBlockNodeInfo(val node: TryCatchBlockNode, val onlyCopyNotProcess: Boolean) : IntervalWithHandler {
@@ -43,16 +43,16 @@ class TryCatchBlockNodeInfo(val node: TryCatchBlockNode, val onlyCopyNotProcess:
override val endLabel: LabelNode
get() = node.end
override val handler: LabelNode
get() = node.handler!!
override val `type`: String?
get() = node.`type`
get() = node.handler
override val type: String?
get() = node.type
}
class TryCatchBlockNodePosition(val nodeInfo: TryCatchBlockNodeInfo, var position: TryCatchPosition): IntervalWithHandler by nodeInfo
class TryBlockCluster<T : IntervalWithHandler>(val blocks: MutableList<T>) {
val defaultHandler: T?
get() = blocks.firstOrNull() { it.`type` == null }
get() = blocks.firstOrNull() { it.type == null }
}

View File

@@ -39,10 +39,18 @@ public class ArrayGet extends IntrinsicMethod {
List<JetExpression> arguments,
StackValue receiver
) {
int argumentIndex;
if (receiver == null || receiver == StackValue.none()) {
receiver = codegen.gen(arguments.get(0));
argumentIndex = 1;
} else {
argumentIndex = 0;
}
receiver.put(receiver.type, v);
Type type = correctElementType(receiver.type);
codegen.gen(arguments.get(0), Type.INT_TYPE);
codegen.gen(arguments.get(argumentIndex), Type.INT_TYPE);
v.aload(type);

View File

@@ -58,8 +58,8 @@ public class Clone extends IntrinsicMethod {
}
private static boolean isSuperCall(@NotNull ResolvedCall<?> resolvedCall) {
ReceiverValue thisObject = resolvedCall.getThisObject();
return thisObject instanceof ExpressionReceiver &&
((ExpressionReceiver) thisObject).getExpression() instanceof JetSuperExpression;
ReceiverValue dispatchReceiver = resolvedCall.getDispatchReceiver();
return dispatchReceiver instanceof ExpressionReceiver &&
((ExpressionReceiver) dispatchReceiver).getExpression() instanceof JetSuperExpression;
}
}

View File

@@ -18,18 +18,21 @@ package org.jetbrains.jet.codegen.intrinsics;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import org.jetbrains.jet.codegen.ExpressionCodegen;
import org.jetbrains.jet.codegen.StackValue;
import org.jetbrains.jet.lang.psi.JetExpression;
import org.jetbrains.jet.lang.psi.JetParenthesizedExpression;
import org.jetbrains.jet.lang.psi.JetPsiUtil;
import org.jetbrains.jet.lang.psi.JetReferenceExpression;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import java.util.List;
import static org.jetbrains.jet.codegen.AsmUtil.genIncrement;
import static org.jetbrains.jet.codegen.AsmUtil.isPrimitive;
import static org.jetbrains.jet.lang.resolve.BindingContext.EXPRESSION_TYPE;
public class Increment extends IntrinsicMethod {
private final int myDelta;
@@ -51,15 +54,15 @@ public class Increment extends IntrinsicMethod {
assert isPrimitive(returnType) : "Return type of Increment intrinsic should be of primitive type : " + returnType;
if (arguments.size() > 0) {
JetExpression operand = arguments.get(0);
while (operand instanceof JetParenthesizedExpression) {
operand = ((JetParenthesizedExpression) operand).getExpression();
}
JetExpression operand = JetPsiUtil.deparenthesize(arguments.get(0));
if (operand instanceof JetReferenceExpression && returnType == Type.INT_TYPE) {
int index = codegen.indexOfLocal((JetReferenceExpression) operand);
if (index >= 0) {
StackValue.preIncrement(index, myDelta).put(returnType, v);
return returnType;
JetType operandType = codegen.getBindingContext().get(EXPRESSION_TYPE, operand);
if (operandType != null && KotlinBuiltIns.getInstance().isPrimitiveType(operandType)) {
StackValue.preIncrement(index, myDelta).put(returnType, v);
return returnType;
}
}
}
StackValue value = codegen.genQualified(receiver, operand);

View File

@@ -106,7 +106,7 @@ class IntrinsicsMap {
@Nullable
private static FqNameUnsafe getReceiverParameterFqName(@NotNull CallableMemberDescriptor descriptor) {
ReceiverParameterDescriptor receiverParameter = descriptor.getReceiverParameter();
ReceiverParameterDescriptor receiverParameter = descriptor.getExtensionReceiverParameter();
if (receiverParameter == null) return null;
ClassifierDescriptor classifier = receiverParameter.getType().getConstructor().getDeclarationDescriptor();

View File

@@ -19,6 +19,7 @@ package org.jetbrains.jet.codegen.intrinsics;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.codegen.AsmUtil;
import org.jetbrains.jet.codegen.ExpressionCodegen;
import org.jetbrains.jet.codegen.StackValue;
import org.jetbrains.jet.lang.psi.JetExpression;
@@ -44,6 +45,10 @@ public class JavaClassProperty extends IntrinsicMethod {
) {
Type type = receiver.type;
if (isPrimitive(type)) {
if (!StackValue.couldSkipReceiverOnStaticCall(receiver)) {
receiver.put(type, v);
AsmUtil.pop(v, type);
}
v.getstatic(boxType(type).getInternalName(), "TYPE", "Ljava/lang/Class;");
}
else {

View File

@@ -144,9 +144,13 @@ public class BoxingInterpreter extends OptimizationBasicInterpreter {
private static boolean isBoxing(@NotNull AbstractInsnNode insn) {
if (insn.getOpcode() != Opcodes.INVOKESTATIC) return false;
MethodInsnNode methodInsnNode = (MethodInsnNode) insn;
MethodInsnNode node = (MethodInsnNode) insn;
return isWrapperClassName(methodInsnNode.owner) && "valueOf".equals(methodInsnNode.name);
return isWrapperClassName(node.owner) && "valueOf".equals(node.name) &&
Type.getMethodDescriptor(
Type.getObjectType(node.owner),
AsmUtil.unboxType(Type.getObjectType(node.owner))
).equals(node.desc);
}
private static boolean isNextMethodCallOfProgressionIterator(

View File

@@ -21,7 +21,6 @@ import com.intellij.util.containers.MultiMap
import org.jetbrains.jet.codegen.ClassBuilderFactory
import org.jetbrains.jet.codegen.SignatureCollectingClassBuilderFactory
import org.jetbrains.jet.lang.descriptors.*
import org.jetbrains.jet.lang.diagnostics.DiagnosticHolder
import org.jetbrains.jet.lang.resolve.BindingContext
import org.jetbrains.jet.lang.resolve.java.diagnostics.*
import java.util.*
@@ -31,11 +30,12 @@ import org.jetbrains.jet.utils.addIfNotNull
import org.jetbrains.jet.codegen.ClassBuilderMode
import org.jetbrains.jet.lang.resolve.java.descriptor.SamAdapterDescriptor
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
import org.jetbrains.jet.lang.diagnostics.DiagnosticSink
class BuilderFactoryForDuplicateSignatureDiagnostics(
builderFactory: ClassBuilderFactory,
bindingContext: BindingContext,
private val diagnostics: DiagnosticHolder
private val diagnostics: DiagnosticSink
) : SignatureCollectingClassBuilderFactory(builderFactory) {
// Avoid errors when some classes are not loaded for some reason

View File

@@ -26,7 +26,7 @@ import org.jetbrains.jet.codegen.optimization.OptimizationClassBuilderFactory;
import org.jetbrains.jet.codegen.when.MappingsClassesForWhenByEnum;
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
import org.jetbrains.jet.lang.descriptors.ScriptDescriptor;
import org.jetbrains.jet.lang.diagnostics.DiagnosticHolder;
import org.jetbrains.jet.lang.diagnostics.DiagnosticSink;
import org.jetbrains.jet.lang.psi.JetClassOrObject;
import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.reflect.ReflectionTypes;
@@ -120,7 +120,7 @@ public class GenerationState {
@NotNull List<JetFile> files
) {
this(project, builderFactory, Progress.DEAF, module, bindingContext, files, true, true, GenerateClassFilter.GENERATE_ALL,
false, false, null, null, DiagnosticHolder.DO_NOTHING, null);
false, false, null, null, DiagnosticSink.DO_NOTHING, null);
}
public GenerationState(
@@ -137,7 +137,7 @@ public class GenerationState {
boolean disableOptimization,
@Nullable Collection<FqName> packagesWithRemovedFiles,
@Nullable String moduleId,
@NotNull DiagnosticHolder diagnostics,
@NotNull DiagnosticSink diagnostics,
@Nullable File outDirectory
) {
this.project = project;

View File

@@ -159,7 +159,9 @@ public class JetTypeMapper {
private Type mapReturnType(@NotNull CallableDescriptor descriptor, @Nullable BothSignatureWriter sw) {
JetType returnType = descriptor.getReturnType();
assert returnType != null : "Function has no return type: " + descriptor;
if (returnType.equals(KotlinBuiltIns.getInstance().getUnitType()) && !(descriptor instanceof PropertyGetterDescriptor)) {
if (returnType.equals(KotlinBuiltIns.getInstance().getUnitType())
&& !TypeUtils.isNullableType(returnType)
&& !(descriptor instanceof PropertyGetterDescriptor)) {
if (sw != null) {
sw.writeAsmType(Type.VOID_TYPE);
}
@@ -220,7 +222,7 @@ public class JetTypeMapper {
if (descriptor instanceof ClassDescriptor) {
FqNameUnsafe className = DescriptorUtils.getFqName(descriptor);
if (className.isSafe()) {
known = KotlinToJavaTypesMap.getInstance().getJavaAnalog(className.toSafe(), jetType.isNullable());
known = KotlinToJavaTypesMap.getInstance().getJavaAnalog(className.toSafe(), TypeUtils.isNullableType(jetType));
}
}
@@ -524,7 +526,7 @@ public class JetTypeMapper {
Type calleeType = isLocalNamedFun(functionDescriptor) ? owner : null;
Type receiverParameterType;
ReceiverParameterDescriptor receiverParameter = functionDescriptor.getOriginal().getReceiverParameter();
ReceiverParameterDescriptor receiverParameter = functionDescriptor.getOriginal().getExtensionReceiverParameter();
if (receiverParameter != null) {
receiverParameterType = mapType(receiverParameter.getType());
}
@@ -624,7 +626,7 @@ public class JetTypeMapper {
sw.writeParametersStart();
writeThisIfNeeded(f, kind, sw);
ReceiverParameterDescriptor receiverParameter = f.getReceiverParameter();
ReceiverParameterDescriptor receiverParameter = f.getExtensionReceiverParameter();
if (receiverParameter != null) {
writeParameter(sw, JvmMethodParameterKind.RECEIVER, receiverParameter.getType());
}
@@ -664,7 +666,7 @@ public class JetTypeMapper {
public Method mapDefaultMethod(@NotNull FunctionDescriptor functionDescriptor, @NotNull OwnerKind kind, @NotNull CodegenContext<?> context) {
Method jvmSignature = mapSignature(functionDescriptor, kind).getAsmMethod();
Type ownerType = mapOwner(functionDescriptor, isCallInsideSameModuleAsDeclared(functionDescriptor, context, getOutDirectory()));
String descriptor = getDefaultDescriptor(jvmSignature, functionDescriptor.getReceiverParameter() != null);
String descriptor = getDefaultDescriptor(jvmSignature, functionDescriptor.getExtensionReceiverParameter() != null);
boolean isConstructor = "<init>".equals(jvmSignature.getName());
if (!isStaticMethod(kind, functionDescriptor) && !isConstructor) {
descriptor = descriptor.replace("(", "(" + ownerType.getDescriptor());
@@ -683,7 +685,7 @@ public class JetTypeMapper {
//noinspection ConstantConditions
if (!KotlinBuiltIns.getInstance().isPrimitiveType(descriptor.getReturnType())) return false;
for (FunctionDescriptor overridden : OverrideResolver.getAllOverriddenDescriptors(descriptor)) {
for (FunctionDescriptor overridden : getAllOverriddenDescriptors(descriptor)) {
//noinspection ConstantConditions
if (!KotlinBuiltIns.getInstance().isPrimitiveType(overridden.getOriginal().getReturnType())) return true;
}
@@ -713,7 +715,7 @@ public class JetTypeMapper {
if (kind == OwnerKind.TRAIT_IMPL) {
thisType = getTraitImplThisParameterClass((ClassDescriptor) descriptor.getContainingDeclaration());
}
else if (isAccessor(descriptor) && descriptor.getExpectedThisObject() != null) {
else if (isAccessor(descriptor) && descriptor.getDispatchReceiverParameter() != null) {
thisType = (ClassDescriptor) descriptor.getContainingDeclaration();
}
else return;
@@ -804,7 +806,7 @@ public class JetTypeMapper {
private void writeAdditionalConstructorParameters(@NotNull ConstructorDescriptor descriptor, @NotNull BothSignatureWriter sw) {
CalculatedClosure closure = bindingContext.get(CodegenBinding.CLOSURE, descriptor.getContainingDeclaration());
ClassDescriptor captureThis = getExpectedThisObjectForConstructorCall(descriptor, closure);
ClassDescriptor captureThis = getDispatchReceiverParameterForConstructorCall(descriptor, closure);
if (captureThis != null) {
writeParameter(sw, JvmMethodParameterKind.OUTER, captureThis.getDefaultType());
}
@@ -930,7 +932,7 @@ public class JetTypeMapper {
return asmTypeForAnonymousClass(bindingContext, (FunctionDescriptor) descriptor);
}
else if (descriptor instanceof PropertyDescriptor || descriptor instanceof FunctionDescriptor) {
ReceiverParameterDescriptor receiverParameter = ((CallableDescriptor) descriptor).getReceiverParameter();
ReceiverParameterDescriptor receiverParameter = ((CallableDescriptor) descriptor).getExtensionReceiverParameter();
assert receiverParameter != null : "Callable should have a receiver parameter: " + descriptor;
return StackValue.sharedTypeForType(mapType(receiverParameter.getType()));
}

View File

@@ -25,6 +25,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
import org.jetbrains.jet.lang.resolve.constants.NullValue;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.TypeUtils;
import org.jetbrains.org.objectweb.asm.Label;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
@@ -135,7 +136,7 @@ abstract public class SwitchCodegen {
assert subjectJetType != null : "subject type can't be null (i.e. void)";
if (subjectJetType.isNullable()) {
if (TypeUtils.isNullableType(subjectJetType)) {
int nullEntryIndex = findNullEntryIndex(expression);
Label nullLabel = nullEntryIndex == -1 ? defaultLabel : entryLabels.get(nullEntryIndex);
Label notNullLabel = new Label();

View File

@@ -38,6 +38,9 @@ public abstract class CommonCompilerArguments {
@Argument(value = "X", description = "Print a synopsis of advanced options")
public boolean extraHelp;
@Argument(value = "Xno-inline", description = "Disable method inlining")
public boolean noInline;
public List<String> freeArgs = new SmartList<String>();
@NotNull

View File

@@ -63,9 +63,6 @@ public class K2JVMCompilerArguments extends CommonCompilerArguments {
@Argument(value = "Xno-param-assertions", description = "Don't generate not-null assertions on parameters of methods accessible from Java")
public boolean noParamAssertions;
@Argument(value = "Xno-inline", description = "Disable method inlining")
public boolean noInline;
@Argument(value = "Xno-optimize", description = "Disable optimizations")
public boolean noOptimize;

View File

@@ -116,14 +116,8 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
errStream.print(messageRenderer.renderPreamble());
printVersionIfNeeded(errStream, arguments, messageRenderer);
MessageCollector collector = new PrintingMessageCollector(errStream, messageRenderer, arguments.verbose);
if (arguments.suppressWarnings) {
collector = new FilteringMessageCollector(collector, Predicates.equalTo(CompilerMessageSeverity.WARNING));
}
try {
return exec(collector, services, arguments);
}
@@ -134,6 +128,12 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
@NotNull
public ExitCode exec(@NotNull MessageCollector messageCollector, @NotNull Services services, @NotNull A arguments) {
printVersionIfNeeded(messageCollector, arguments);
if (arguments.suppressWarnings) {
messageCollector = new FilteringMessageCollector(messageCollector, Predicates.equalTo(CompilerMessageSeverity.WARNING));
}
GroupingMessageCollector groupingCollector = new GroupingMessageCollector(messageCollector);
try {
Disposable rootDisposable = Disposer.newDisposable();
@@ -164,17 +164,12 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
@NotNull Disposable rootDisposable
);
protected void printVersionIfNeeded(
@NotNull PrintStream errStream,
@NotNull A arguments,
@NotNull MessageRenderer messageRenderer
) {
if (arguments.version) {
String versionMessage = messageRenderer.render(CompilerMessageSeverity.INFO,
"Kotlin Compiler version " + KotlinVersion.VERSION,
CompilerMessageLocation.NO_LOCATION);
errStream.println(versionMessage);
}
protected void printVersionIfNeeded(@NotNull MessageCollector messageCollector, @NotNull A arguments) {
if (!arguments.version) return;
messageCollector.report(CompilerMessageSeverity.INFO,
"Kotlin Compiler version " + KotlinVersion.VERSION,
CompilerMessageLocation.NO_LOCATION);
}
/**

View File

@@ -23,6 +23,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.util.Consumer;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import kotlin.Function0;
@@ -48,7 +49,6 @@ import org.jetbrains.jet.config.Services;
import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.k2js.analyze.TopDownAnalyzerFacadeForJS;
import org.jetbrains.k2js.config.*;
import org.jetbrains.k2js.facade.K2JSTranslator;
import org.jetbrains.k2js.facade.MainCallParameters;
import java.io.File;
@@ -58,6 +58,7 @@ import java.util.List;
import static org.jetbrains.jet.cli.common.ExitCode.COMPILATION_ERROR;
import static org.jetbrains.jet.cli.common.ExitCode.OK;
import static org.jetbrains.jet.cli.common.messages.CompilerMessageLocation.NO_LOCATION;
import static org.jetbrains.k2js.facade.K2JSTranslator.translateWithMainCallParameters;
public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
@@ -170,7 +171,8 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
@Nullable File outputPostfix
) {
try {
return K2JSTranslator.translateWithMainCallParameters(mainCall, sourceFiles, outputFile, outputPrefix, outputPostfix, config);
//noinspection unchecked
return translateWithMainCallParameters(mainCall, sourceFiles, outputFile, outputPrefix, outputPostfix, config, Consumer.EMPTY_CONSUMER);
}
catch (Exception e) {
throw new RuntimeException(e);
@@ -196,12 +198,14 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
}
EcmaVersion ecmaVersion = EcmaVersion.defaultVersion();
String moduleId = FileUtil.getNameWithoutExtension(new File(arguments.outputFile));
boolean inlineEnabled = !arguments.noInline;
if (arguments.libraryFiles != null) {
return new LibrarySourcesConfig(project, moduleId, Arrays.asList(arguments.libraryFiles), ecmaVersion, arguments.sourceMap);
return new LibrarySourcesConfig(project, moduleId, Arrays.asList(arguments.libraryFiles), ecmaVersion, arguments.sourceMap, inlineEnabled);
}
else {
// lets discover the JS library definitions on the classpath
return new ClassPathLibraryDefintionsConfig(project, moduleId, ecmaVersion, arguments.sourceMap);
return new ClassPathLibraryDefintionsConfig(project, moduleId, ecmaVersion, arguments.sourceMap, inlineEnabled);
}
}
@@ -213,4 +217,4 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
return MainCallParameters.mainWithoutArguments();
}
}
}
}

View File

@@ -168,7 +168,7 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
}
}
public static void putAdvancedOptions(@NotNull CompilerConfiguration configuration, @NotNull K2JVMCompilerArguments arguments) {
private static void putAdvancedOptions(@NotNull CompilerConfiguration configuration, @NotNull K2JVMCompilerArguments arguments) {
configuration.put(JVMConfigurationKeys.DISABLE_CALL_ASSERTIONS, arguments.noCallAssertions);
configuration.put(JVMConfigurationKeys.DISABLE_PARAM_ASSERTIONS, arguments.noParamAssertions);
configuration.put(JVMConfigurationKeys.DISABLE_INLINE, arguments.noInline);

View File

@@ -47,7 +47,7 @@ import javax.annotation.PreDestroy;
/* This file is generated by org.jetbrains.jet.generators.injectors.InjectorsPackage. DO NOT EDIT! */
@SuppressWarnings("all")
public class InjectorForJavaDescriptorResolver {
private final Project project;
private final BindingTrace bindingTrace;
private final GlobalContextImpl globalContext;
@@ -73,7 +73,7 @@ public class InjectorForJavaDescriptorResolver {
private final AnnotationDescriptorLoader annotationDescriptorLoader;
private final DescriptorLoadersStorage descriptorLoadersStorage;
private final ConstantDescriptorLoader constantDescriptorLoader;
public InjectorForJavaDescriptorResolver(
@NotNull Project project,
@NotNull BindingTrace bindingTrace
@@ -138,25 +138,25 @@ public class InjectorForJavaDescriptorResolver {
javaClassFinder.initialize();
}
@PreDestroy
public void destroy() {
}
public GlobalContextImpl getGlobalContext() {
return this.globalContext;
}
public ModuleDescriptorImpl getModule() {
return this.module;
}
public JavaDescriptorResolver getJavaDescriptorResolver() {
return this.javaDescriptorResolver;
}
public JavaClassFinderImpl getJavaClassFinder() {
return this.javaClassFinder;
}
}

View File

@@ -36,6 +36,7 @@ import org.jetbrains.jet.lang.resolve.java.resolver.PsiBasedMethodSignatureCheck
import org.jetbrains.jet.lang.resolve.java.resolver.PsiBasedExternalAnnotationResolver;
import org.jetbrains.jet.lang.resolve.java.structure.impl.JavaPropertyInitializerEvaluatorImpl;
import org.jetbrains.jet.lang.resolve.java.resolver.JavaSourceElementFactoryImpl;
import org.jetbrains.jet.lang.resolve.java.JavaFlexibleTypeCapabilitiesProvider;
import org.jetbrains.jet.lang.resolve.AdditionalCheckerProvider;
import org.jetbrains.jet.lang.resolve.AnnotationResolver;
import org.jetbrains.jet.lang.resolve.calls.CallResolver;
@@ -71,7 +72,7 @@ import javax.annotation.PreDestroy;
/* This file is generated by org.jetbrains.jet.generators.injectors.InjectorsPackage. DO NOT EDIT! */
@SuppressWarnings("all")
public class InjectorForLazyResolveWithJava {
private final Project project;
private final GlobalContext globalContext;
private final StorageManager storageManager;
@@ -92,6 +93,7 @@ public class InjectorForLazyResolveWithJava {
private final PsiBasedExternalAnnotationResolver psiBasedExternalAnnotationResolver;
private final JavaPropertyInitializerEvaluatorImpl javaPropertyInitializerEvaluator;
private final JavaSourceElementFactoryImpl javaSourceElementFactory;
private final JavaFlexibleTypeCapabilitiesProvider javaFlexibleTypeCapabilitiesProvider;
private final AdditionalCheckerProvider additionalCheckerProvider;
private final AnnotationResolver annotationResolver;
private final CallResolver callResolver;
@@ -121,7 +123,7 @@ public class InjectorForLazyResolveWithJava {
private final AnnotationDescriptorLoader annotationDescriptorLoader;
private final DescriptorLoadersStorage descriptorLoadersStorage;
private final ConstantDescriptorLoader constantDescriptorLoader;
public InjectorForLazyResolveWithJava(
@NotNull Project project,
@NotNull GlobalContext globalContext,
@@ -154,6 +156,7 @@ public class InjectorForLazyResolveWithJava {
this.globalJavaResolverContext = new GlobalJavaResolverContext(storageManager, javaClassFinder, virtualFileFinder, deserializedDescriptorResolver, psiBasedExternalAnnotationResolver, traceBasedExternalSignatureResolver, traceBasedErrorReporter, psiBasedMethodSignatureChecker, lazyResolveBasedCache, javaPropertyInitializerEvaluator, javaSourceElementFactory, moduleClassResolver);
this.lazyJavaPackageFragmentProvider = new LazyJavaPackageFragmentProvider(globalJavaResolverContext, module);
this.javaDescriptorResolver = new JavaDescriptorResolver(lazyJavaPackageFragmentProvider, module);
this.javaFlexibleTypeCapabilitiesProvider = new JavaFlexibleTypeCapabilitiesProvider();
this.additionalCheckerProvider = org.jetbrains.jet.lang.resolve.kotlin.JavaDeclarationCheckerProvider.INSTANCE$;
this.annotationResolver = new AnnotationResolver();
this.callResolver = new CallResolver();
@@ -250,6 +253,7 @@ public class InjectorForLazyResolveWithJava {
delegatedPropertyResolver.setExpressionTypingServices(expressionTypingServices);
typeResolver.setAnnotationResolver(annotationResolver);
typeResolver.setFlexibleTypeCapabilitiesProvider(javaFlexibleTypeCapabilitiesProvider);
typeResolver.setModuleDescriptor(module);
typeResolver.setQualifiedExpressionResolver(qualifiedExpressionResolver);
@@ -277,17 +281,17 @@ public class InjectorForLazyResolveWithJava {
javaClassFinder.initialize();
}
@PreDestroy
public void destroy() {
}
public ResolveSession getResolveSession() {
return this.resolveSession;
}
public JavaDescriptorResolver getJavaDescriptorResolver() {
return this.javaDescriptorResolver;
}
}

View File

@@ -38,6 +38,7 @@ import org.jetbrains.jet.lang.resolve.java.resolver.PsiBasedExternalAnnotationRe
import org.jetbrains.jet.lang.resolve.java.structure.impl.JavaPropertyInitializerEvaluatorImpl;
import org.jetbrains.jet.lang.resolve.java.resolver.JavaSourceElementFactoryImpl;
import org.jetbrains.jet.lang.resolve.java.lazy.SingleModuleClassResolver;
import org.jetbrains.jet.lang.resolve.java.JavaFlexibleTypeCapabilitiesProvider;
import org.jetbrains.jet.lang.resolve.kotlin.VirtualFileFinder;
import org.jetbrains.jet.lang.resolve.BodyResolver;
import org.jetbrains.jet.lang.resolve.AnnotationResolver;
@@ -59,6 +60,7 @@ import org.jetbrains.jet.lang.resolve.calls.CallCompleter;
import org.jetbrains.jet.lang.resolve.calls.CandidateResolver;
import org.jetbrains.jet.lang.resolve.ControlFlowAnalyzer;
import org.jetbrains.jet.lang.resolve.DeclarationsChecker;
import org.jetbrains.jet.lang.resolve.ModifiersChecker;
import org.jetbrains.jet.lang.resolve.FunctionAnalyzerExtension;
import org.jetbrains.jet.lang.resolve.ScriptBodyResolver;
import org.jetbrains.jet.lang.resolve.DeclarationResolver;
@@ -81,7 +83,7 @@ import javax.annotation.PreDestroy;
/* This file is generated by org.jetbrains.jet.generators.injectors.InjectorsPackage. DO NOT EDIT! */
@SuppressWarnings("all")
public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnalyzer {
private final Project project;
private final GlobalContext globalContext;
private final StorageManager storageManager;
@@ -104,6 +106,7 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
private final JavaPropertyInitializerEvaluatorImpl javaPropertyInitializerEvaluator;
private final JavaSourceElementFactoryImpl javaSourceElementFactory;
private final SingleModuleClassResolver singleModuleClassResolver;
private final JavaFlexibleTypeCapabilitiesProvider javaFlexibleTypeCapabilitiesProvider;
private final VirtualFileFinder virtualFileFinder;
private final BodyResolver bodyResolver;
private final AnnotationResolver annotationResolver;
@@ -125,6 +128,7 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
private final CandidateResolver candidateResolver;
private final ControlFlowAnalyzer controlFlowAnalyzer;
private final DeclarationsChecker declarationsChecker;
private final ModifiersChecker modifiersChecker;
private final FunctionAnalyzerExtension functionAnalyzerExtension;
private final ScriptBodyResolver scriptBodyResolver;
private final DeclarationResolver declarationResolver;
@@ -141,7 +145,7 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
private final AnnotationDescriptorLoader annotationDescriptorLoader;
private final DescriptorLoadersStorage descriptorLoadersStorage;
private final ConstantDescriptorLoader constantDescriptorLoader;
public InjectorForTopDownAnalyzerForJvm(
@NotNull Project project,
@NotNull GlobalContext globalContext,
@@ -177,6 +181,7 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
this.deserializationGlobalContextForJava = new DeserializationGlobalContextForJava(storageManager, getModuleDescriptor(), javaClassDataFinder, annotationDescriptorLoader, constantDescriptorLoader, lazyJavaPackageFragmentProvider);
this.additionalCheckerProvider = org.jetbrains.jet.lang.resolve.kotlin.JavaDeclarationCheckerProvider.INSTANCE$;
this.globalSearchScope = com.intellij.psi.search.GlobalSearchScope.allScope(project);
this.javaFlexibleTypeCapabilitiesProvider = new JavaFlexibleTypeCapabilitiesProvider();
this.bodyResolver = new BodyResolver();
this.annotationResolver = new AnnotationResolver();
this.callResolver = new CallResolver();
@@ -197,6 +202,7 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
this.callCompleter = new CallCompleter(argumentTypeResolver, candidateResolver);
this.controlFlowAnalyzer = new ControlFlowAnalyzer();
this.declarationsChecker = new DeclarationsChecker();
this.modifiersChecker = new ModifiersChecker(bindingTrace, additionalCheckerProvider);
this.functionAnalyzerExtension = new FunctionAnalyzerExtension();
this.scriptBodyResolver = new ScriptBodyResolver();
this.declarationResolver = new DeclarationResolver();
@@ -300,6 +306,7 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
delegatedPropertyResolver.setExpressionTypingServices(expressionTypingServices);
typeResolver.setAnnotationResolver(annotationResolver);
typeResolver.setFlexibleTypeCapabilitiesProvider(javaFlexibleTypeCapabilitiesProvider);
typeResolver.setModuleDescriptor(moduleDescriptor);
typeResolver.setQualifiedExpressionResolver(qualifiedExpressionResolver);
@@ -307,8 +314,8 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
controlFlowAnalyzer.setTrace(bindingTrace);
declarationsChecker.setAdditionalCheckerProvider(additionalCheckerProvider);
declarationsChecker.setDescriptorResolver(descriptorResolver);
declarationsChecker.setModifiersChecker(modifiersChecker);
declarationsChecker.setTrace(bindingTrace);
functionAnalyzerExtension.setTrace(bindingTrace);
@@ -358,29 +365,29 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
javaClassFinder.initialize();
}
@PreDestroy
public void destroy() {
}
public ModuleDescriptor getModuleDescriptor() {
return this.moduleDescriptor;
}
public TopDownAnalyzer getTopDownAnalyzer() {
return this.topDownAnalyzer;
}
public LazyTopDownAnalyzer getLazyTopDownAnalyzer() {
return this.lazyTopDownAnalyzer;
}
public JavaDescriptorResolver getJavaDescriptorResolver() {
return this.javaDescriptorResolver;
}
public DeserializationGlobalContextForJava getDeserializationGlobalContextForJava() {
return this.deserializationGlobalContextForJava;
}
}

View File

@@ -14,17 +14,12 @@
* limitations under the License.
*/
package org.jetbrains.jet.lang.psi.stubs;
package org.jetbrains.jet.lang.resolve.java
import com.intellij.psi.stubs.StubElement;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.psi.JetImportDirective;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.resolve.TypeResolver.FlexibleTypeCapabilitiesProvider
import org.jetbrains.jet.lang.types.FlexibleTypeCapabilities
import org.jetbrains.jet.lang.resolve.java.lazy.types.LazyJavaTypeResolver
public interface PsiJetImportDirectiveStub extends StubElement<JetImportDirective> {
boolean isAbsoluteInRootPackage();
boolean isAllUnder();
@Nullable
String getAliasName();
boolean isValid();
}
public class JavaFlexibleTypeCapabilitiesProvider : FlexibleTypeCapabilitiesProvider() {
override fun getCapabilities(): FlexibleTypeCapabilities = LazyJavaTypeResolver.FlexibleJavaClassifierTypeCapabilities
}

View File

@@ -53,7 +53,7 @@ public class AlternativeFieldSignatureData extends ElementAlternativeSignatureDa
try {
checkForSyntaxErrors(altPropertyDeclaration);
checkFieldAnnotation(altPropertyDeclaration, field, isVar);
altReturnType = computeReturnType(originalReturnType, altPropertyDeclaration.getTypeRef(),
altReturnType = computeReturnType(originalReturnType, altPropertyDeclaration.getTypeReference(),
new HashMap<TypeParameterDescriptor, TypeParameterDescriptorImpl>());
}
catch (AlternativeSignatureMismatchException e) {
@@ -73,7 +73,7 @@ public class AlternativeFieldSignatureData extends ElementAlternativeSignatureDa
field.getName().asString(), altProperty.getName());
}
if (altProperty.getTypeRef() == null) {
if (altProperty.getTypeReference() == null) {
throw new AlternativeSignatureMismatchException("Field annotation for shouldn't have type reference");
}

View File

@@ -28,6 +28,7 @@ import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
import org.jetbrains.jet.lang.descriptors.impl.TypeParameterDescriptorImpl;
import org.jetbrains.jet.lang.descriptors.impl.ValueParameterDescriptorImpl;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.java.JavaPackage;
import org.jetbrains.jet.lang.resolve.java.resolver.DescriptorResolverUtils;
import org.jetbrains.jet.lang.resolve.java.resolver.ExternalAnnotationResolver;
import org.jetbrains.jet.lang.resolve.java.structure.JavaMember;
@@ -89,7 +90,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
computeValueParameters(valueParameters);
if (originalReturnType != null) {
altReturnType = computeReturnType(originalReturnType, altFunDeclaration.getReturnTypeRef(), originalToAltTypeParameters);
altReturnType = computeReturnType(originalReturnType, altFunDeclaration.getTypeReference(), originalToAltTypeParameters);
}
if (hasSuperMethods) {
@@ -101,11 +102,25 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
}
}
public static List<ValueParameterDescriptor> updateNames(
List<ValueParameterDescriptor> originalValueParameters,
List<ValueParameterDescriptor> altValueParameters
) {
List<ValueParameterDescriptor> result = new ArrayList<ValueParameterDescriptor>(originalValueParameters.size());
for (int i = 0; i < originalValueParameters.size(); i++) {
ValueParameterDescriptor originalValueParameter = originalValueParameters.get(i);
ValueParameterDescriptor altValueParameter = altValueParameters.get(i);
result.add(originalValueParameter.copy(originalValueParameter.getContainingDeclaration(), altValueParameter.getName()));
}
return result;
}
private void checkParameterAndReturnTypesForOverridingMethods(
@NotNull List<ValueParameterDescriptor> valueParameters,
@NotNull List<TypeParameterDescriptor> methodTypeParameters,
@Nullable JetType returnType
) {
if (JavaPackage.getPLATFORM_TYPES()) return;
TypeSubstitutor substitutor = DescriptorResolverUtils.createSubstitutorForTypeParameters(originalToAltTypeParameters);
for (ValueParameterDescriptor parameter : valueParameters) {

View File

@@ -21,7 +21,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
import org.jetbrains.jet.lang.resolve.java.mapping.JavaToKotlinClassMapBuilder;
/* package */ class CollectionClassMapping extends JavaToKotlinClassMapBuilder {
public class CollectionClassMapping extends JavaToKotlinClassMapBuilder {
private static CollectionClassMapping instance = null;
@NotNull

View File

@@ -1,131 +0,0 @@
/*
* Copyright 2010-2013 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.jet.lang.resolve.java.kotlinSignature;
import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Lists;
import com.intellij.openapi.util.Pair;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.java.structure.JavaMethod;
import org.jetbrains.jet.lang.resolve.java.structure.JavaSignatureFormatter;
import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.renderer.DescriptorRenderer;
import java.util.*;
public class JavaToKotlinMethodMap {
public static final JavaToKotlinMethodMap INSTANCE = new JavaToKotlinMethodMap();
private final JavaToKotlinMethodMapGenerated mapContainer = new JavaToKotlinMethodMapGenerated();
private JavaToKotlinMethodMap() {
}
@NotNull
public List<FunctionDescriptor> getFunctions(
@NotNull JavaMethod javaMethod,
@NotNull FqName classFqName,
@NotNull ClassDescriptor containingClass
) {
ImmutableCollection<ClassData> classDatas = mapContainer.map.get(classFqName.asString());
List<FunctionDescriptor> result = Lists.newArrayList();
Set<ClassDescriptor> allSuperClasses = new HashSet<ClassDescriptor>(DescriptorUtils.getSuperclassDescriptors(containingClass));
String serializedMethod = JavaSignatureFormatter.getInstance().formatMethod(javaMethod);
for (ClassData classData : classDatas) {
String expectedSerializedFunction = classData.method2Function.get(serializedMethod);
if (expectedSerializedFunction == null) continue;
ClassDescriptor kotlinClass = classData.kotlinClass;
if (!allSuperClasses.contains(kotlinClass)) continue;
Collection<FunctionDescriptor> functions = kotlinClass.getDefaultType().getMemberScope().getFunctions(javaMethod.getName());
for (FunctionDescriptor function : functions) {
if (expectedSerializedFunction.equals(serializeFunction(function))) {
result.add(function);
}
}
}
return result;
}
@NotNull
public static String serializeFunction(@NotNull FunctionDescriptor fun) {
return DescriptorRenderer.COMPACT.render(fun);
}
// used in generated code
static Pair<String, String> pair(String a, String b) {
return Pair.create(a, b);
}
// used in generated code
static void put(
ImmutableMultimap.Builder<String, ClassData> builder,
String javaFqName,
String kotlinQualifiedName,
Pair<String, String>... methods2Functions
) {
ImmutableMap<String, String> methods2FunctionsMap = pairs2Map(methods2Functions);
ClassDescriptor kotlinClass;
if (kotlinQualifiedName.contains(".")) { // Map.Entry and MutableMap.MutableEntry
String[] kotlinNames = kotlinQualifiedName.split("\\.");
assert kotlinNames.length == 2 : "unexpected qualified name " + kotlinQualifiedName;
ClassDescriptor outerClass = KotlinBuiltIns.getInstance().getBuiltInClassByName(Name.identifier(kotlinNames[0]));
kotlinClass = DescriptorUtils.getInnerClassByName(outerClass, kotlinNames[1]);
assert kotlinClass != null : "Class not found: " + kotlinQualifiedName;
}
else {
kotlinClass = KotlinBuiltIns.getInstance().getBuiltInClassByName(Name.identifier(kotlinQualifiedName));
}
builder.put(javaFqName, new ClassData(kotlinClass, methods2FunctionsMap));
}
private static ImmutableMap<String, String> pairs2Map(Pair<String, String>[] pairs) {
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
for (Pair<String, String> pair : pairs) {
builder.put(pair.first, pair.second);
}
return builder.build();
}
static class ClassData {
@NotNull
public final ClassDescriptor kotlinClass;
@NotNull
public Map<String, String> method2Function;
public ClassData(@NotNull ClassDescriptor kotlinClass, @NotNull Map<String, String> method2Function) {
this.kotlinClass = kotlinClass;
this.method2Function = method2Function;
}
}
}

View File

@@ -1,254 +0,0 @@
/*
* Copyright 2010-2014 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.jet.lang.resolve.java.kotlinSignature;
import com.google.common.collect.ImmutableMultimap;
import static org.jetbrains.jet.lang.resolve.java.kotlinSignature.JavaToKotlinMethodMap.*;
/* This file is generated by org.jetbrains.jet.generators.jvm.GenerateJavaToKotlinMethodMap. DO NOT EDIT! */
@SuppressWarnings("unchecked")
class JavaToKotlinMethodMapGenerated {
final ImmutableMultimap<String, JavaToKotlinMethodMap.ClassData> map;
JavaToKotlinMethodMapGenerated() {
ImmutableMultimap.Builder<String, JavaToKotlinMethodMap.ClassData> b = ImmutableMultimap.builder();
put(b, "java.lang.Object", "Any",
pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
pair("hashCode()", "fun hashCode(): kotlin.Int"),
pair("toString()", "fun toString(): kotlin.String")
);
put(b, "java.lang.String", "String",
pair("compareTo(java.lang.String)", "fun compareTo(other: kotlin.String): kotlin.Int"),
pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
pair("hashCode()", "fun hashCode(): kotlin.Int"),
pair("toString()", "fun toString(): kotlin.String")
);
put(b, "java.lang.CharSequence", "CharSequence",
pair("toString()", "fun toString(): kotlin.String")
);
put(b, "java.lang.Throwable", "Throwable",
pair("getCause()", "fun getCause(): kotlin.Throwable?"),
pair("getMessage()", "fun getMessage(): kotlin.String?"),
pair("printStackTrace()", "fun printStackTrace(): kotlin.Unit"),
pair("toString()", "fun toString(): kotlin.String")
);
put(b, "java.lang.Comparable", "Comparable",
pair("compareTo(T)", "fun compareTo(other: T): kotlin.Int")
);
put(b, "java.lang.Enum", "Enum",
pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
pair("hashCode()", "fun hashCode(): kotlin.Int"),
pair("name()", "fun name(): kotlin.String"),
pair("ordinal()", "fun ordinal(): kotlin.Int"),
pair("toString()", "fun toString(): kotlin.String")
);
put(b, "java.lang.annotation.Annotation", "Annotation",
pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
pair("hashCode()", "fun hashCode(): kotlin.Int"),
pair("toString()", "fun toString(): kotlin.String")
);
put(b, "java.lang.Iterable", "Iterable",
pair("iterator()", "fun iterator(): kotlin.Iterator<T>")
);
put(b, "java.lang.Iterable", "MutableIterable",
pair("iterator()", "fun iterator(): kotlin.MutableIterator<T>")
);
put(b, "java.util.Iterator", "Iterator",
pair("hasNext()", "fun hasNext(): kotlin.Boolean"),
pair("next()", "fun next(): T")
);
put(b, "java.util.Iterator", "MutableIterator",
pair("hasNext()", "fun hasNext(): kotlin.Boolean"),
pair("next()", "fun next(): T"),
pair("remove()", "fun remove(): kotlin.Unit")
);
put(b, "java.util.Collection", "Collection",
pair("contains(java.lang.Object)", "fun contains(o: kotlin.Any?): kotlin.Boolean"),
pair("containsAll(java.util.Collection<?>)", "fun containsAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
pair("hashCode()", "fun hashCode(): kotlin.Int"),
pair("isEmpty()", "fun isEmpty(): kotlin.Boolean"),
pair("iterator()", "fun iterator(): kotlin.Iterator<E>"),
pair("size()", "fun size(): kotlin.Int")
);
put(b, "java.util.Collection", "MutableCollection",
pair("add(E)", "fun add(e: E): kotlin.Boolean"),
pair("addAll(java.util.Collection<? extends E>)", "fun addAll(c: kotlin.Collection<E>): kotlin.Boolean"),
pair("clear()", "fun clear(): kotlin.Unit"),
pair("contains(java.lang.Object)", "fun contains(o: kotlin.Any?): kotlin.Boolean"),
pair("containsAll(java.util.Collection<?>)", "fun containsAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
pair("hashCode()", "fun hashCode(): kotlin.Int"),
pair("isEmpty()", "fun isEmpty(): kotlin.Boolean"),
pair("iterator()", "fun iterator(): kotlin.MutableIterator<E>"),
pair("remove(java.lang.Object)", "fun remove(o: kotlin.Any?): kotlin.Boolean"),
pair("removeAll(java.util.Collection<?>)", "fun removeAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
pair("retainAll(java.util.Collection<?>)", "fun retainAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
pair("size()", "fun size(): kotlin.Int")
);
put(b, "java.util.List", "List",
pair("contains(java.lang.Object)", "fun contains(o: kotlin.Any?): kotlin.Boolean"),
pair("containsAll(java.util.Collection<?>)", "fun containsAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
pair("get(int)", "fun get(index: kotlin.Int): E"),
pair("hashCode()", "fun hashCode(): kotlin.Int"),
pair("indexOf(java.lang.Object)", "fun indexOf(o: kotlin.Any?): kotlin.Int"),
pair("isEmpty()", "fun isEmpty(): kotlin.Boolean"),
pair("iterator()", "fun iterator(): kotlin.Iterator<E>"),
pair("lastIndexOf(java.lang.Object)", "fun lastIndexOf(o: kotlin.Any?): kotlin.Int"),
pair("listIterator()", "fun listIterator(): kotlin.ListIterator<E>"),
pair("listIterator(int)", "fun listIterator(index: kotlin.Int): kotlin.ListIterator<E>"),
pair("size()", "fun size(): kotlin.Int"),
pair("subList(int, int)", "fun subList(fromIndex: kotlin.Int, toIndex: kotlin.Int): kotlin.List<E>")
);
put(b, "java.util.List", "MutableList",
pair("add(E)", "fun add(e: E): kotlin.Boolean"),
pair("add(int, E)", "fun add(index: kotlin.Int, element: E): kotlin.Unit"),
pair("addAll(int, java.util.Collection<? extends E>)", "fun addAll(index: kotlin.Int, c: kotlin.Collection<E>): kotlin.Boolean"),
pair("addAll(java.util.Collection<? extends E>)", "fun addAll(c: kotlin.Collection<E>): kotlin.Boolean"),
pair("clear()", "fun clear(): kotlin.Unit"),
pair("contains(java.lang.Object)", "fun contains(o: kotlin.Any?): kotlin.Boolean"),
pair("containsAll(java.util.Collection<?>)", "fun containsAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
pair("get(int)", "fun get(index: kotlin.Int): E"),
pair("hashCode()", "fun hashCode(): kotlin.Int"),
pair("indexOf(java.lang.Object)", "fun indexOf(o: kotlin.Any?): kotlin.Int"),
pair("isEmpty()", "fun isEmpty(): kotlin.Boolean"),
pair("iterator()", "fun iterator(): kotlin.MutableIterator<E>"),
pair("lastIndexOf(java.lang.Object)", "fun lastIndexOf(o: kotlin.Any?): kotlin.Int"),
pair("listIterator()", "fun listIterator(): kotlin.MutableListIterator<E>"),
pair("listIterator(int)", "fun listIterator(index: kotlin.Int): kotlin.MutableListIterator<E>"),
pair("remove(int)", "fun remove(index: kotlin.Int): E"),
pair("remove(java.lang.Object)", "fun remove(o: kotlin.Any?): kotlin.Boolean"),
pair("removeAll(java.util.Collection<?>)", "fun removeAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
pair("retainAll(java.util.Collection<?>)", "fun retainAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
pair("set(int, E)", "fun set(index: kotlin.Int, element: E): E"),
pair("size()", "fun size(): kotlin.Int"),
pair("subList(int, int)", "fun subList(fromIndex: kotlin.Int, toIndex: kotlin.Int): kotlin.MutableList<E>")
);
put(b, "java.util.Set", "Set",
pair("contains(java.lang.Object)", "fun contains(o: kotlin.Any?): kotlin.Boolean"),
pair("containsAll(java.util.Collection<?>)", "fun containsAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
pair("hashCode()", "fun hashCode(): kotlin.Int"),
pair("isEmpty()", "fun isEmpty(): kotlin.Boolean"),
pair("iterator()", "fun iterator(): kotlin.Iterator<E>"),
pair("size()", "fun size(): kotlin.Int")
);
put(b, "java.util.Set", "MutableSet",
pair("add(E)", "fun add(e: E): kotlin.Boolean"),
pair("addAll(java.util.Collection<? extends E>)", "fun addAll(c: kotlin.Collection<E>): kotlin.Boolean"),
pair("clear()", "fun clear(): kotlin.Unit"),
pair("contains(java.lang.Object)", "fun contains(o: kotlin.Any?): kotlin.Boolean"),
pair("containsAll(java.util.Collection<?>)", "fun containsAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
pair("hashCode()", "fun hashCode(): kotlin.Int"),
pair("isEmpty()", "fun isEmpty(): kotlin.Boolean"),
pair("iterator()", "fun iterator(): kotlin.MutableIterator<E>"),
pair("remove(java.lang.Object)", "fun remove(o: kotlin.Any?): kotlin.Boolean"),
pair("removeAll(java.util.Collection<?>)", "fun removeAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
pair("retainAll(java.util.Collection<?>)", "fun retainAll(c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean"),
pair("size()", "fun size(): kotlin.Int")
);
put(b, "java.util.Map", "Map",
pair("containsKey(java.lang.Object)", "fun containsKey(key: kotlin.Any?): kotlin.Boolean"),
pair("containsValue(java.lang.Object)", "fun containsValue(value: kotlin.Any?): kotlin.Boolean"),
pair("entrySet()", "fun entrySet(): kotlin.Set<kotlin.Map.Entry<K, V>>"),
pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
pair("get(java.lang.Object)", "fun get(key: kotlin.Any?): V?"),
pair("hashCode()", "fun hashCode(): kotlin.Int"),
pair("isEmpty()", "fun isEmpty(): kotlin.Boolean"),
pair("keySet()", "fun keySet(): kotlin.Set<K>"),
pair("size()", "fun size(): kotlin.Int"),
pair("values()", "fun values(): kotlin.Collection<V>")
);
put(b, "java.util.Map", "MutableMap",
pair("clear()", "fun clear(): kotlin.Unit"),
pair("containsKey(java.lang.Object)", "fun containsKey(key: kotlin.Any?): kotlin.Boolean"),
pair("containsValue(java.lang.Object)", "fun containsValue(value: kotlin.Any?): kotlin.Boolean"),
pair("entrySet()", "fun entrySet(): kotlin.MutableSet<kotlin.MutableMap.MutableEntry<K, V>>"),
pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
pair("get(java.lang.Object)", "fun get(key: kotlin.Any?): V?"),
pair("hashCode()", "fun hashCode(): kotlin.Int"),
pair("isEmpty()", "fun isEmpty(): kotlin.Boolean"),
pair("keySet()", "fun keySet(): kotlin.MutableSet<K>"),
pair("put(K, V)", "fun put(key: K, value: V): V?"),
pair("putAll(java.util.Map<? extends K,? extends V>)", "fun putAll(m: kotlin.Map<out K, V>): kotlin.Unit"),
pair("remove(java.lang.Object)", "fun remove(key: kotlin.Any?): V?"),
pair("size()", "fun size(): kotlin.Int"),
pair("values()", "fun values(): kotlin.MutableCollection<V>")
);
put(b, "java.util.Map.Entry", "Map.Entry",
pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
pair("getKey()", "fun getKey(): K"),
pair("getValue()", "fun getValue(): V"),
pair("hashCode()", "fun hashCode(): kotlin.Int")
);
put(b, "java.util.Map.Entry", "MutableMap.MutableEntry",
pair("equals(java.lang.Object)", "fun equals(other: kotlin.Any?): kotlin.Boolean"),
pair("getKey()", "fun getKey(): K"),
pair("getValue()", "fun getValue(): V"),
pair("hashCode()", "fun hashCode(): kotlin.Int"),
pair("setValue(V)", "fun setValue(value: V): V")
);
put(b, "java.util.ListIterator", "ListIterator",
pair("hasNext()", "fun hasNext(): kotlin.Boolean"),
pair("hasPrevious()", "fun hasPrevious(): kotlin.Boolean"),
pair("next()", "fun next(): T"),
pair("nextIndex()", "fun nextIndex(): kotlin.Int"),
pair("previous()", "fun previous(): T"),
pair("previousIndex()", "fun previousIndex(): kotlin.Int")
);
put(b, "java.util.ListIterator", "MutableListIterator",
pair("add(E)", "fun add(e: T): kotlin.Unit"),
pair("hasNext()", "fun hasNext(): kotlin.Boolean"),
pair("hasPrevious()", "fun hasPrevious(): kotlin.Boolean"),
pair("next()", "fun next(): T"),
pair("nextIndex()", "fun nextIndex(): kotlin.Int"),
pair("previous()", "fun previous(): T"),
pair("previousIndex()", "fun previousIndex(): kotlin.Int"),
pair("remove()", "fun remove(): kotlin.Unit"),
pair("set(E)", "fun set(e: T): kotlin.Unit")
);
map = b.build();
}
}

View File

@@ -30,6 +30,7 @@ import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
import org.jetbrains.jet.lang.descriptors.impl.TypeParameterDescriptorImpl;
import org.jetbrains.jet.lang.descriptors.impl.ValueParameterDescriptorImpl;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.java.JavaPackage;
import org.jetbrains.jet.lang.resolve.java.descriptor.JavaMethodDescriptor;
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodSignature;
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmSignaturePackage;
@@ -57,10 +58,12 @@ public class SignaturesPropagationData {
KotlinToJvmSignatureMapper.class.getClassLoader()
).iterator().next();
private final JavaMethodDescriptor autoMethodDescriptor;
private final List<TypeParameterDescriptor> modifiedTypeParameters;
private final ValueParameters modifiedValueParameters;
private final JetType modifiedReturnType;
private final JetType modifiedReturnType;
private final List<String> signatureErrors = Lists.newArrayList();
private final List<FunctionDescriptor> superFunctions;
private final Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> autoTypeParameterToModified;
@@ -76,7 +79,7 @@ public class SignaturesPropagationData {
) {
this.containingClass = containingClass;
JavaMethodDescriptor autoMethodDescriptor =
autoMethodDescriptor =
createAutoMethodDescriptor(containingClass, method, autoReturnType, receiverType, autoValueParameters, autoTypeParameters);
superFunctions = getSuperFunctionsForMethod(method, autoMethodDescriptor, containingClass);
@@ -150,6 +153,8 @@ public class SignaturesPropagationData {
private JetType modifyReturnTypeAccordingToSuperMethods(
@NotNull JetType autoType // type built by JavaTypeTransformer
) {
if (JavaPackage.getPLATFORM_TYPES()) return autoType;
List<TypeAndVariance> typesFromSuperMethods = ContainerUtil.map(superFunctions,
new Function<FunctionDescriptor, TypeAndVariance>() {
@Override
@@ -162,6 +167,8 @@ public class SignaturesPropagationData {
}
private List<TypeParameterDescriptor> modifyTypeParametersAccordingToSuperMethods(List<TypeParameterDescriptor> autoTypeParameters) {
if (JavaPackage.getPLATFORM_TYPES()) return autoTypeParameters;
List<TypeParameterDescriptor> result = Lists.newArrayList();
for (TypeParameterDescriptor autoParameter : autoTypeParameters) {
@@ -215,7 +222,7 @@ public class SignaturesPropagationData {
new Function<FunctionDescriptor, TypeAndName>() {
@Override
public TypeAndName fun(FunctionDescriptor superFunction) {
ReceiverParameterDescriptor receiver = superFunction.getReceiverParameter();
ReceiverParameterDescriptor receiver = superFunction.getExtensionReceiverParameter();
int index = receiver != null ? originalIndex - 1 : originalIndex;
if (index == -1) {
assert receiver != null : "can't happen: index is -1, while function is not extension";
@@ -318,7 +325,7 @@ public class SignaturesPropagationData {
boolean someSupersNotExtension = false;
for (FunctionDescriptor superFunction : superFunctions) {
if (superFunction.getReceiverParameter() != null) {
if (superFunction.getExtensionReceiverParameter() != null) {
someSupersExtension = true;
}
else {
@@ -343,7 +350,7 @@ public class SignaturesPropagationData {
boolean someSupersNotVararg = false;
for (FunctionDescriptor superFunction : superFunctions) {
int originalIndex = originalParam.getIndex();
int index = superFunction.getReceiverParameter() != null ? originalIndex - 1 : originalIndex;
int index = superFunction.getExtensionReceiverParameter() != null ? originalIndex - 1 : originalIndex;
if (index != -1 && superFunction.getValueParameters().get(index).getVarargElementType() != null) {
someSupersVararg = true;
}
@@ -399,9 +406,9 @@ public class SignaturesPropagationData {
@NotNull List<TypeAndVariance> typesFromSuper,
@NotNull TypeUsage howThisTypeIsUsed
) {
if (autoType.isError()) {
return autoType;
}
if (autoType.isError()) return autoType;
if (JavaPackage.getPLATFORM_TYPES()) return autoType;
boolean resultNullable = typeMustBeNullable(autoType, typesFromSuper, howThisTypeIsUsed);
ClassifierDescriptor resultClassifier = modifyTypeClassifier(autoType, typesFromSuper);
@@ -430,11 +437,14 @@ public class SignaturesPropagationData {
@NotNull ClassifierDescriptor classifier,
@NotNull List<TypeAndVariance> typesFromSuper
) {
if (typesFromSuper.isEmpty()) return autoType.getArguments();
List<TypeProjection> autoArguments = autoType.getArguments();
if (!(classifier instanceof ClassDescriptor)) {
assert autoArguments.isEmpty() :
"Unexpected type arguments when type constructor is not ClassDescriptor, type = " + autoType;
"Unexpected type arguments when type constructor is not ClassDescriptor, type = " + autoType +
", classifier = " + classifier + ", classifier class = " + classifier.getClass();
return autoArguments;
}
@@ -462,6 +472,8 @@ public class SignaturesPropagationData {
@NotNull TypeProjection argument,
@NotNull List<TypeProjectionAndVariance> projectionsFromSuper
) {
if (projectionsFromSuper.isEmpty()) return argument.getProjectionKind();
Set<Variance> projectionKindsInSuper = Sets.newLinkedHashSet();
for (TypeProjectionAndVariance projectionAndVariance : projectionsFromSuper) {
projectionKindsInSuper.add(projectionAndVariance.typeProjection.getProjectionKind());
@@ -575,7 +587,7 @@ public class SignaturesPropagationData {
boolean someSupersCovariantNullable = false;
boolean someSupersNotNull = false;
for (TypeAndVariance typeFromSuper : typesFromSuper) {
if (!typeFromSuper.type.isNullable()) {
if (!TypeUtils.isNullableType(typeFromSuper.type)) {
someSupersNotNull = true;
}
else {
@@ -590,23 +602,23 @@ public class SignaturesPropagationData {
if (someSupersNotNull && someSupersNotCovariantNullable) {
reportError("Incompatible types in superclasses: " + typesFromSuper);
return autoType.isNullable();
return TypeUtils.isNullableType(autoType);
}
else if (someSupersNotNull) {
return false;
}
else if (someSupersNotCovariantNullable || someSupersCovariantNullable) {
boolean annotatedAsNotNull = howThisTypeIsUsed != TYPE_ARGUMENT && !autoType.isNullable();
boolean annotatedAsNotNull = howThisTypeIsUsed != TYPE_ARGUMENT && !TypeUtils.isNullableType(autoType);
if (annotatedAsNotNull && someSupersNotCovariantNullable) {
DescriptorRenderer renderer = DescriptorRenderer.SOURCE_CODE_SHORT_NAMES_IN_TYPES;
DescriptorRenderer renderer = DescriptorRenderer.SHORT_NAMES_IN_TYPES;
reportError("In superclass type is nullable: " + typesFromSuper + ", in subclass it is not: " + renderer.renderType(autoType));
return true;
}
return !annotatedAsNotNull;
}
return autoType.isNullable();
return TypeUtils.isNullableType(autoType);
}
@NotNull
@@ -616,7 +628,7 @@ public class SignaturesPropagationData {
) {
ClassifierDescriptor classifier = autoType.getConstructor().getDeclarationDescriptor();
if (!(classifier instanceof ClassDescriptor)) {
assert classifier != null : "no declaration descriptor for type " + autoType;
assert classifier != null : "no declaration descriptor for type " + autoType + ", auto method descriptor: " + autoMethodDescriptor;
if (classifier instanceof TypeParameterDescriptor && autoTypeParameterToModified.containsKey(classifier)) {
return autoTypeParameterToModified.get(classifier);

View File

@@ -26,6 +26,7 @@ import org.jetbrains.jet.lang.descriptors.impl.TypeParameterDescriptorImpl;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.TypeResolver;
import org.jetbrains.jet.lang.resolve.java.JavaPackage;
import org.jetbrains.jet.lang.resolve.java.mapping.JavaToKotlinClassMap;
import org.jetbrains.jet.lang.resolve.java.mapping.KotlinToJavaTypesMap;
import org.jetbrains.jet.lang.resolve.java.resolver.TypeUsage;
@@ -72,7 +73,7 @@ public class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
@Override
public JetType visitNullableType(@NotNull JetNullableType nullableType, Void aVoid) {
if (!originalType.isNullable() && typeUsage != TYPE_ARGUMENT) {
if (!TypeUtils.isNullableType(originalType) && typeUsage != TYPE_ARGUMENT) {
throw new AlternativeSignatureMismatchException("Auto type '%s' is not-null, while type in alternative signature is nullable: '%s'",
DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(originalType), nullableType.getText());
}
@@ -83,7 +84,7 @@ public class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
@Override
public JetType visitFunctionType(@NotNull JetFunctionType type, Void data) {
return visitCommonType(type.getReceiverTypeRef() == null
return visitCommonType(type.getReceiverTypeReference() == null
? KotlinBuiltIns.getInstance().getFunction(type.getParameters().size())
: KotlinBuiltIns.getInstance().getExtensionFunction(type.getParameters().size()), type);
}
@@ -133,6 +134,8 @@ public class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
List<TypeProjection> arguments = originalType.getArguments();
if (arguments.size() != type.getTypeArgumentsAsTypes().size()) {
if (JavaPackage.getPLATFORM_TYPES()) return originalType;
throw new AlternativeSignatureMismatchException("'%s' type in method signature has %d type arguments, while '%s' in alternative signature has %d of them",
DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(originalType), arguments.size(), type.getText(),
type.getTypeArgumentsAsTypes().size());
@@ -185,7 +188,7 @@ public class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
if (type instanceof JetUserType) {
JetTypeProjection typeProjection = ((JetUserType) type).getTypeArguments().get(i);
altProjectionKind = TypeResolver.resolveProjectionKind(typeProjection.getProjectionKind());
if (altProjectionKind != projectionKind && projectionKind != Variance.INVARIANT) {
if (altProjectionKind != projectionKind && projectionKind != Variance.INVARIANT && !JavaPackage.getPLATFORM_TYPES()) {
throw new AlternativeSignatureMismatchException("Projection kind mismatch, actual: %s, in alternative signature: %s",
projectionKind, altProjectionKind);
}

View File

@@ -25,6 +25,7 @@ import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
import org.jetbrains.jet.lang.resolve.BindingTrace;
import org.jetbrains.jet.lang.resolve.java.JavaBindingContext;
import org.jetbrains.jet.lang.resolve.java.JavaPackage;
import org.jetbrains.jet.lang.resolve.java.kotlinSignature.AlternativeFieldSignatureData;
import org.jetbrains.jet.lang.resolve.java.kotlinSignature.AlternativeMethodSignatureData;
import org.jetbrains.jet.lang.resolve.java.kotlinSignature.SignaturesPropagationData;
@@ -94,6 +95,12 @@ public class TraceBasedExternalSignatureResolver implements ExternalSignatureRes
returnType, typeParameters, hasSuperMethods);
if (data.isAnnotated() && !data.hasErrors()) {
if (JavaPackage.getPLATFORM_TYPES()) {
// We only take parameter names from the @KotlinSignature
return new AlternativeMethodSignature(returnType, receiverType,
AlternativeMethodSignatureData.updateNames(valueParameters, data.getValueParameters()),
typeParameters, Collections.<String>emptyList(), true);
}
return new AlternativeMethodSignature(data.getReturnType(), receiverType, data.getValueParameters(), data.getTypeParameters(),
Collections.<String>emptyList(), true);
}
@@ -113,6 +120,9 @@ public class TraceBasedExternalSignatureResolver implements ExternalSignatureRes
new AlternativeFieldSignatureData(externalAnnotationResolver, field, returnType, project, isVar);
if (data.isAnnotated() && !data.hasErrors()) {
if (JavaPackage.getPLATFORM_TYPES()) {
return new AlternativeFieldSignature(returnType, null);
}
return new AlternativeFieldSignature(data.getReturnType(), null);
}

View File

@@ -52,7 +52,14 @@ public class JavaAnnotationImpl extends JavaElementImpl<PsiAnnotation> implement
@Nullable
public ClassId getClassId() {
PsiClass resolved = resolvePsi();
return resolved == null ? null : computeClassId(resolved);
if (resolved != null) return computeClassId(resolved);
// External annotations do not have PSI behind them,
// so we can only heuristically reconstruct annotation class ids from qualified names
String qualifiedName = getPsi().getQualifiedName();
if (qualifiedName != null) return ClassId.topLevel(new FqName(qualifiedName));
return null;
}
@Nullable

View File

@@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.resolve.java.structure.impl;
import com.intellij.psi.PsiExpression;
import com.intellij.psi.impl.JavaConstantExpressionEvaluator;
import com.intellij.psi.util.PsiUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
@@ -43,4 +44,11 @@ public class JavaPropertyInitializerEvaluatorImpl implements JavaPropertyInitial
}
return null;
}
@Override
public boolean isNotNullCompileTimeConstant(@NotNull JavaField field) {
// PsiUtil.isCompileTimeConstant returns false for null-initialized fields,
// see com.intellij.psi.util.IsConstantExpressionVisitor.visitLiteralExpression()
return PsiUtil.isCompileTimeConstant(((JavaFieldImpl) field).getPsi());
}
}

View File

@@ -17,11 +17,9 @@
package org.jetbrains.jet.lang.resolve.kotlin
import org.jetbrains.jet.lang.resolve.AdditionalCheckerProvider
import com.google.common.collect.Lists
import org.jetbrains.jet.lang.resolve.AnnotationChecker
import org.jetbrains.jet.lang.psi.JetDeclaration
import org.jetbrains.jet.lang.descriptors.MemberDescriptor
import org.jetbrains.jet.lang.diagnostics.DiagnosticHolder
import org.jetbrains.jet.lang.resolve.annotations.hasPlatformStaticAnnotation
import org.jetbrains.jet.lang.psi.JetNamedFunction
import org.jetbrains.jet.lang.resolve.DescriptorUtils
@@ -30,21 +28,40 @@ import org.jetbrains.jet.lang.resolve.java.diagnostics.ErrorsJvm
import org.jetbrains.jet.lexer.JetTokens
import org.jetbrains.jet.lang.psi.JetProperty
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor
import org.jetbrains.jet.lang.diagnostics.DiagnosticSink
import org.jetbrains.jet.lang.descriptors.Visibilities
import org.jetbrains.jet.lang.resolve.annotations.hasInlineAnnotation
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor
import org.jetbrains.jet.lang.diagnostics.Errors
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
public object JavaDeclarationCheckerProvider : AdditionalCheckerProvider {
override val annotationCheckers: List<AnnotationChecker> = listOf(PlatformStaticAnnotationChecker())
override val annotationCheckers: List<AnnotationChecker> = listOf(PlatformStaticAnnotationChecker(), LocalFunInlineChecker())
}
public class LocalFunInlineChecker : AnnotationChecker {
override fun check(declaration: JetDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink) {
if (descriptor.hasInlineAnnotation() &&
declaration is JetNamedFunction &&
descriptor is FunctionDescriptor &&
descriptor.getVisibility() == Visibilities.LOCAL) {
diagnosticHolder.report(Errors.NOT_YET_SUPPORTED_IN_INLINE.on(declaration, declaration, descriptor))
}
}
}
public class PlatformStaticAnnotationChecker : AnnotationChecker {
override fun check(declaration: JetDeclaration, descriptor: MemberDescriptor, diagnosticHolder: DiagnosticHolder) {
override fun check(declaration: JetDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink) {
if (descriptor.hasPlatformStaticAnnotation()) {
if (declaration is JetNamedFunction) {
val insideObject = DescriptorUtils.containerKindIs(descriptor, ClassKind.OBJECT)
val insideClassObject = DescriptorUtils.containerKindIs(descriptor, ClassKind.CLASS_OBJECT)
if (!insideObject && !(insideClassObject && DescriptorUtils.containerKindIs(descriptor.getContainingDeclaration(), ClassKind.CLASS))) {
if (!insideObject && !(insideClassObject && DescriptorUtils.containerKindIs(descriptor.getContainingDeclaration()!!, ClassKind.CLASS))) {
diagnosticHolder.report(ErrorsJvm.PLATFORM_STATIC_NOT_IN_OBJECT.on(declaration, descriptor));
}

View File

@@ -52,8 +52,11 @@ public class VirtualFileKotlinClass private(
deprecated("Use KotlinBinaryClassCache")
fun create(file: VirtualFile): VirtualFileKotlinClass? {
assert(file.getFileType() == JavaClassFileType.INSTANCE) { "Trying to read binary data from a non-class file $file" }
val byteContent = file.contentsToByteArray()
if (byteContent.isEmpty()) return null
try {
return FileBasedKotlinClass.create(file.contentsToByteArray()) {
return FileBasedKotlinClass.create(byteContent) {
name, header, innerClasses ->
VirtualFileKotlinClass(file, name, header, innerClasses)
}

View File

@@ -19,7 +19,7 @@ package org.jetbrains.jet.analyzer
import org.jetbrains.jet.lang.psi.JetExpression
import org.jetbrains.jet.lang.resolve.scopes.JetScope
import org.jetbrains.jet.di.InjectorForMacros
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo
import org.jetbrains.jet.lang.resolve.calls.smartcasts.DataFlowInfo
import org.jetbrains.jet.lang.types.JetType
import org.jetbrains.jet.lang.types.TypeUtils
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor

View File

@@ -108,9 +108,9 @@ public class CheckerTestUtil {
});
// this code is used in tests and in internal action 'copy current file as diagnostic test'
//noinspection TestOnlyProblems
for (JetExpression expression : bindingContext.getSliceContents(BindingContext.AUTOCAST).keySet()) {
for (JetExpression expression : bindingContext.getSliceContents(BindingContext.SMARTCAST).keySet()) {
if (PsiTreeUtil.isAncestor(root, expression, false)) {
debugAnnotations.add(new DebugInfoDiagnostic(expression, DebugInfoDiagnosticFactory.AUTOCAST));
debugAnnotations.add(new DebugInfoDiagnostic(expression, DebugInfoDiagnosticFactory.SMARTCAST));
}
}
return debugAnnotations;
@@ -411,7 +411,7 @@ public class CheckerTestUtil {
}
public static class DebugInfoDiagnosticFactory extends DiagnosticFactory<DebugInfoDiagnostic> {
public static final DebugInfoDiagnosticFactory AUTOCAST = new DebugInfoDiagnosticFactory("AUTOCAST");
public static final DebugInfoDiagnosticFactory SMARTCAST = new DebugInfoDiagnosticFactory("SMARTCAST");
public static final DebugInfoDiagnosticFactory ELEMENT_WITH_ERROR_TYPE = new DebugInfoDiagnosticFactory("ELEMENT_WITH_ERROR_TYPE");
public static final DebugInfoDiagnosticFactory UNRESOLVED_WITH_TARGET = new DebugInfoDiagnosticFactory("UNRESOLVED_WITH_TARGET");
public static final DebugInfoDiagnosticFactory MISSING_UNRESOLVED = new DebugInfoDiagnosticFactory("MISSING_UNRESOLVED");

View File

@@ -37,12 +37,14 @@ import org.jetbrains.jet.lang.resolve.calls.CallExpressionResolver;
import org.jetbrains.jet.lang.resolve.DescriptorResolver;
import org.jetbrains.jet.lang.resolve.DelegatedPropertyResolver;
import org.jetbrains.jet.lang.resolve.TypeResolver;
import org.jetbrains.jet.lang.resolve.TypeResolver.FlexibleTypeCapabilitiesProvider;
import org.jetbrains.jet.lang.resolve.QualifiedExpressionResolver;
import org.jetbrains.jet.lang.resolve.calls.CallResolverExtensionProvider;
import org.jetbrains.jet.lang.resolve.calls.CallCompleter;
import org.jetbrains.jet.lang.resolve.calls.CandidateResolver;
import org.jetbrains.jet.lang.resolve.ControlFlowAnalyzer;
import org.jetbrains.jet.lang.resolve.DeclarationsChecker;
import org.jetbrains.jet.lang.resolve.ModifiersChecker;
import org.jetbrains.jet.lang.resolve.FunctionAnalyzerExtension;
import org.jetbrains.jet.lang.resolve.ScriptBodyResolver;
import org.jetbrains.annotations.NotNull;
@@ -51,7 +53,7 @@ import javax.annotation.PreDestroy;
/* This file is generated by org.jetbrains.jet.generators.injectors.InjectorsPackage. DO NOT EDIT! */
@SuppressWarnings("all")
public class InjectorForBodyResolve {
private final Project project;
private final GlobalContext globalContext;
private final StorageManager storageManager;
@@ -73,15 +75,17 @@ public class InjectorForBodyResolve {
private final DescriptorResolver descriptorResolver;
private final DelegatedPropertyResolver delegatedPropertyResolver;
private final TypeResolver typeResolver;
private final FlexibleTypeCapabilitiesProvider flexibleTypeCapabilitiesProvider;
private final QualifiedExpressionResolver qualifiedExpressionResolver;
private final CallResolverExtensionProvider callResolverExtensionProvider;
private final CallCompleter callCompleter;
private final CandidateResolver candidateResolver;
private final ControlFlowAnalyzer controlFlowAnalyzer;
private final DeclarationsChecker declarationsChecker;
private final ModifiersChecker modifiersChecker;
private final FunctionAnalyzerExtension functionAnalyzerExtension;
private final ScriptBodyResolver scriptBodyResolver;
public InjectorForBodyResolve(
@NotNull Project project,
@NotNull GlobalContext globalContext,
@@ -110,12 +114,14 @@ public class InjectorForBodyResolve {
this.descriptorResolver = new DescriptorResolver();
this.delegatedPropertyResolver = new DelegatedPropertyResolver();
this.typeResolver = new TypeResolver();
this.flexibleTypeCapabilitiesProvider = new FlexibleTypeCapabilitiesProvider();
this.qualifiedExpressionResolver = new QualifiedExpressionResolver();
this.callResolverExtensionProvider = new CallResolverExtensionProvider();
this.candidateResolver = new CandidateResolver();
this.callCompleter = new CallCompleter(argumentTypeResolver, candidateResolver);
this.controlFlowAnalyzer = new ControlFlowAnalyzer();
this.declarationsChecker = new DeclarationsChecker();
this.modifiersChecker = new ModifiersChecker(bindingTrace, additionalCheckerProvider);
this.functionAnalyzerExtension = new FunctionAnalyzerExtension();
this.scriptBodyResolver = new ScriptBodyResolver();
@@ -176,6 +182,7 @@ public class InjectorForBodyResolve {
delegatedPropertyResolver.setExpressionTypingServices(expressionTypingServices);
typeResolver.setAnnotationResolver(annotationResolver);
typeResolver.setFlexibleTypeCapabilitiesProvider(flexibleTypeCapabilitiesProvider);
typeResolver.setModuleDescriptor(moduleDescriptor);
typeResolver.setQualifiedExpressionResolver(qualifiedExpressionResolver);
@@ -183,8 +190,8 @@ public class InjectorForBodyResolve {
controlFlowAnalyzer.setTrace(bindingTrace);
declarationsChecker.setAdditionalCheckerProvider(additionalCheckerProvider);
declarationsChecker.setDescriptorResolver(descriptorResolver);
declarationsChecker.setModifiersChecker(modifiersChecker);
declarationsChecker.setTrace(bindingTrace);
functionAnalyzerExtension.setTrace(bindingTrace);
@@ -192,13 +199,13 @@ public class InjectorForBodyResolve {
scriptBodyResolver.setExpressionTypingServices(expressionTypingServices);
}
@PreDestroy
public void destroy() {
}
public BodyResolver getBodyResolver() {
return this.bodyResolver;
}
}

View File

@@ -38,6 +38,7 @@ import org.jetbrains.jet.lang.resolve.calls.CallExpressionResolver;
import org.jetbrains.jet.lang.resolve.DescriptorResolver;
import org.jetbrains.jet.lang.resolve.DelegatedPropertyResolver;
import org.jetbrains.jet.lang.resolve.TypeResolver;
import org.jetbrains.jet.lang.resolve.TypeResolver.FlexibleTypeCapabilitiesProvider;
import org.jetbrains.jet.lang.resolve.QualifiedExpressionResolver;
import org.jetbrains.jet.lang.resolve.calls.CallResolverExtensionProvider;
import org.jetbrains.jet.lang.resolve.calls.CallCompleter;
@@ -51,7 +52,7 @@ import javax.annotation.PreDestroy;
/* This file is generated by org.jetbrains.jet.generators.injectors.InjectorsPackage. DO NOT EDIT! */
@SuppressWarnings("all")
public class InjectorForLazyResolve {
private final Project project;
private final GlobalContext globalContext;
private final StorageManager storageManager;
@@ -74,6 +75,7 @@ public class InjectorForLazyResolve {
private final DescriptorResolver descriptorResolver;
private final DelegatedPropertyResolver delegatedPropertyResolver;
private final TypeResolver typeResolver;
private final FlexibleTypeCapabilitiesProvider flexibleTypeCapabilitiesProvider;
private final QualifiedExpressionResolver qualifiedExpressionResolver;
private final CallResolverExtensionProvider callResolverExtensionProvider;
private final CallCompleter callCompleter;
@@ -81,7 +83,7 @@ public class InjectorForLazyResolve {
private final JetImportsFactory jetImportsFactory;
private final ScopeProvider scopeProvider;
private final ScriptBodyResolver scriptBodyResolver;
public InjectorForLazyResolve(
@NotNull Project project,
@NotNull GlobalContext globalContext,
@@ -112,6 +114,7 @@ public class InjectorForLazyResolve {
this.descriptorResolver = new DescriptorResolver();
this.delegatedPropertyResolver = new DelegatedPropertyResolver();
this.typeResolver = new TypeResolver();
this.flexibleTypeCapabilitiesProvider = new FlexibleTypeCapabilitiesProvider();
this.qualifiedExpressionResolver = new QualifiedExpressionResolver();
this.callResolverExtensionProvider = new CallResolverExtensionProvider();
this.candidateResolver = new CandidateResolver();
@@ -175,6 +178,7 @@ public class InjectorForLazyResolve {
delegatedPropertyResolver.setExpressionTypingServices(expressionTypingServices);
typeResolver.setAnnotationResolver(annotationResolver);
typeResolver.setFlexibleTypeCapabilitiesProvider(flexibleTypeCapabilitiesProvider);
typeResolver.setModuleDescriptor(moduleDescriptor);
typeResolver.setQualifiedExpressionResolver(qualifiedExpressionResolver);
@@ -185,13 +189,13 @@ public class InjectorForLazyResolve {
scriptBodyResolver.setExpressionTypingServices(expressionTypingServices);
}
@PreDestroy
public void destroy() {
}
public ResolveSession getResolveSession() {
return this.resolveSession;
}
}

View File

@@ -27,6 +27,7 @@ import org.jetbrains.jet.storage.StorageManager;
import org.jetbrains.jet.lang.resolve.AdditionalCheckerProvider;
import org.jetbrains.jet.lang.resolve.AnnotationResolver;
import org.jetbrains.jet.lang.resolve.TypeResolver;
import org.jetbrains.jet.lang.resolve.TypeResolver.FlexibleTypeCapabilitiesProvider;
import org.jetbrains.jet.lang.resolve.QualifiedExpressionResolver;
import org.jetbrains.jet.lang.resolve.calls.CallExpressionResolver;
import org.jetbrains.jet.lang.resolve.DescriptorResolver;
@@ -45,7 +46,7 @@ import javax.annotation.PreDestroy;
/* This file is generated by org.jetbrains.jet.generators.injectors.InjectorsPackage. DO NOT EDIT! */
@SuppressWarnings("all")
public class InjectorForMacros {
private final Project project;
private final ModuleDescriptor moduleDescriptor;
private final PlatformToKotlinClassMap platformToKotlinClassMap;
@@ -57,6 +58,7 @@ public class InjectorForMacros {
private final AdditionalCheckerProvider additionalCheckerProvider;
private final AnnotationResolver annotationResolver;
private final TypeResolver typeResolver;
private final FlexibleTypeCapabilitiesProvider flexibleTypeCapabilitiesProvider;
private final QualifiedExpressionResolver qualifiedExpressionResolver;
private final CallExpressionResolver callExpressionResolver;
private final DescriptorResolver descriptorResolver;
@@ -69,7 +71,7 @@ public class InjectorForMacros {
private final ArgumentTypeResolver argumentTypeResolver;
private final CallCompleter callCompleter;
private final CandidateResolver candidateResolver;
public InjectorForMacros(
@NotNull Project project,
@NotNull ModuleDescriptor moduleDescriptor
@@ -85,6 +87,7 @@ public class InjectorForMacros {
this.additionalCheckerProvider = org.jetbrains.jet.lang.resolve.AdditionalCheckerProvider.Empty.INSTANCE$;
this.annotationResolver = new AnnotationResolver();
this.typeResolver = new TypeResolver();
this.flexibleTypeCapabilitiesProvider = new FlexibleTypeCapabilitiesProvider();
this.qualifiedExpressionResolver = new QualifiedExpressionResolver();
this.callExpressionResolver = new CallExpressionResolver();
this.descriptorResolver = new DescriptorResolver();
@@ -127,6 +130,7 @@ public class InjectorForMacros {
annotationResolver.setTypeResolver(typeResolver);
typeResolver.setAnnotationResolver(annotationResolver);
typeResolver.setFlexibleTypeCapabilitiesProvider(flexibleTypeCapabilitiesProvider);
typeResolver.setModuleDescriptor(moduleDescriptor);
typeResolver.setQualifiedExpressionResolver(qualifiedExpressionResolver);
@@ -151,21 +155,21 @@ public class InjectorForMacros {
candidateResolver.setArgumentTypeResolver(argumentTypeResolver);
}
@PreDestroy
public void destroy() {
}
public ExpressionTypingServices getExpressionTypingServices() {
return this.expressionTypingServices;
}
public ExpressionTypingComponents getExpressionTypingComponents() {
return this.expressionTypingComponents;
}
public CallResolver getCallResolver() {
return this.callResolver;
}
}

View File

@@ -40,12 +40,14 @@ import org.jetbrains.jet.lang.resolve.calls.CallExpressionResolver;
import org.jetbrains.jet.lang.resolve.DescriptorResolver;
import org.jetbrains.jet.lang.resolve.DelegatedPropertyResolver;
import org.jetbrains.jet.lang.resolve.TypeResolver;
import org.jetbrains.jet.lang.resolve.TypeResolver.FlexibleTypeCapabilitiesProvider;
import org.jetbrains.jet.lang.resolve.QualifiedExpressionResolver;
import org.jetbrains.jet.lang.resolve.calls.CallResolverExtensionProvider;
import org.jetbrains.jet.lang.resolve.calls.CallCompleter;
import org.jetbrains.jet.lang.resolve.calls.CandidateResolver;
import org.jetbrains.jet.lang.resolve.ControlFlowAnalyzer;
import org.jetbrains.jet.lang.resolve.DeclarationsChecker;
import org.jetbrains.jet.lang.resolve.ModifiersChecker;
import org.jetbrains.jet.lang.resolve.FunctionAnalyzerExtension;
import org.jetbrains.jet.lang.resolve.ScriptBodyResolver;
import org.jetbrains.jet.lang.resolve.DeclarationResolver;
@@ -61,7 +63,7 @@ import javax.annotation.PreDestroy;
/* This file is generated by org.jetbrains.jet.generators.injectors.InjectorsPackage. DO NOT EDIT! */
@SuppressWarnings("all")
public class InjectorForTopDownAnalyzerBasic {
private final Project project;
private final GlobalContext globalContext;
private final StorageManager storageManager;
@@ -86,12 +88,14 @@ public class InjectorForTopDownAnalyzerBasic {
private final DescriptorResolver descriptorResolver;
private final DelegatedPropertyResolver delegatedPropertyResolver;
private final TypeResolver typeResolver;
private final FlexibleTypeCapabilitiesProvider flexibleTypeCapabilitiesProvider;
private final QualifiedExpressionResolver qualifiedExpressionResolver;
private final CallResolverExtensionProvider callResolverExtensionProvider;
private final CallCompleter callCompleter;
private final CandidateResolver candidateResolver;
private final ControlFlowAnalyzer controlFlowAnalyzer;
private final DeclarationsChecker declarationsChecker;
private final ModifiersChecker modifiersChecker;
private final FunctionAnalyzerExtension functionAnalyzerExtension;
private final ScriptBodyResolver scriptBodyResolver;
private final DeclarationResolver declarationResolver;
@@ -101,7 +105,7 @@ public class InjectorForTopDownAnalyzerBasic {
private final OverrideResolver overrideResolver;
private final TypeHierarchyResolver typeHierarchyResolver;
private final ScriptHeaderResolver scriptHeaderResolver;
public InjectorForTopDownAnalyzerBasic(
@NotNull Project project,
@NotNull GlobalContext globalContext,
@@ -133,12 +137,14 @@ public class InjectorForTopDownAnalyzerBasic {
this.descriptorResolver = new DescriptorResolver();
this.delegatedPropertyResolver = new DelegatedPropertyResolver();
this.typeResolver = new TypeResolver();
this.flexibleTypeCapabilitiesProvider = new FlexibleTypeCapabilitiesProvider();
this.qualifiedExpressionResolver = new QualifiedExpressionResolver();
this.callResolverExtensionProvider = new CallResolverExtensionProvider();
this.candidateResolver = new CandidateResolver();
this.callCompleter = new CallCompleter(argumentTypeResolver, candidateResolver);
this.controlFlowAnalyzer = new ControlFlowAnalyzer();
this.declarationsChecker = new DeclarationsChecker();
this.modifiersChecker = new ModifiersChecker(bindingTrace, additionalCheckerProvider);
this.functionAnalyzerExtension = new FunctionAnalyzerExtension();
this.scriptBodyResolver = new ScriptBodyResolver();
this.declarationResolver = new DeclarationResolver();
@@ -225,6 +231,7 @@ public class InjectorForTopDownAnalyzerBasic {
delegatedPropertyResolver.setExpressionTypingServices(expressionTypingServices);
typeResolver.setAnnotationResolver(annotationResolver);
typeResolver.setFlexibleTypeCapabilitiesProvider(flexibleTypeCapabilitiesProvider);
typeResolver.setModuleDescriptor(moduleDescriptor);
typeResolver.setQualifiedExpressionResolver(qualifiedExpressionResolver);
@@ -232,8 +239,8 @@ public class InjectorForTopDownAnalyzerBasic {
controlFlowAnalyzer.setTrace(bindingTrace);
declarationsChecker.setAdditionalCheckerProvider(additionalCheckerProvider);
declarationsChecker.setDescriptorResolver(descriptorResolver);
declarationsChecker.setModifiersChecker(modifiersChecker);
declarationsChecker.setTrace(bindingTrace);
functionAnalyzerExtension.setTrace(bindingTrace);
@@ -266,21 +273,21 @@ public class InjectorForTopDownAnalyzerBasic {
scriptHeaderResolver.setTrace(bindingTrace);
}
@PreDestroy
public void destroy() {
}
public ModuleDescriptor getModuleDescriptor() {
return this.moduleDescriptor;
}
public TopDownAnalyzer getTopDownAnalyzer() {
return this.topDownAnalyzer;
}
public LazyTopDownAnalyzer getLazyTopDownAnalyzer() {
return this.lazyTopDownAnalyzer;
}
}

View File

@@ -1,20 +1,4 @@
/*
* Copyright 2010-2014 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.
*/
/* The following code was generated by JFlex 1.4.3 on 7/15/14 9:40 PM */
/* The following code was generated by JFlex 1.4.3 on 10/13/14 2:48 PM */
package org.jetbrains.jet.kdoc.lexer;
@@ -28,8 +12,8 @@ import java.lang.Character;
/**
* This class is a scanner generated by
* <a href="http://www.jflex.de/">JFlex</a> 1.4.3
* on 7/15/14 9:40 PM from the specification file
* <tt>C:/Projects/kotlin/compiler/frontend/src/org/jetbrains/jet/kdoc/lexer/KDoc.flex</tt>
* on 10/13/14 2:48 PM from the specification file
* <tt>/Users/abreslav/work/kotlin/compiler/frontend/src/org/jetbrains/jet/kdoc/lexer/KDoc.flex</tt>
*/
class _KDocLexer implements FlexLexer {
/** initial size of the lookahead buffer */
@@ -569,11 +553,6 @@ class _KDocLexer implements FlexLexer {
zzMarkedPos = zzMarkedPosL;
switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
case 5:
{ if (isLastToken()) return KDocTokens.END;
else return KDocTokens.TEXT;
}
case 11: break;
case 3:
{ if (yytextContainLineBreaks()) {
yybegin(LINE_BEGINNING);
@@ -583,6 +562,11 @@ class _KDocLexer implements FlexLexer {
return KDocTokens.TEXT; // internal white space
}
}
case 11: break;
case 5:
{ if (isLastToken()) return KDocTokens.END;
else return KDocTokens.TEXT;
}
case 12: break;
case 9:
{ yybegin(CONTENTS);
@@ -594,9 +578,9 @@ class _KDocLexer implements FlexLexer {
return KDocTokens.WIKI_LINK_CLOSE;
}
case 14: break;
case 6:
case 8:
{ yybegin(CONTENTS);
return KDocTokens.MARKDOWN_ESCAPED_CHAR;
return KDocTokens.WIKI_LINK_OPEN;
}
case 15: break;
case 10:
@@ -604,24 +588,24 @@ class _KDocLexer implements FlexLexer {
return KDocTokens.START;
}
case 16: break;
case 1:
{ return TokenType.BAD_CHARACTER;
}
case 17: break;
case 6:
{ yybegin(CONTENTS);
return KDocTokens.MARKDOWN_ESCAPED_CHAR;
}
case 18: break;
case 2:
{ yybegin(CONTENTS);
return KDocTokens.TEXT;
}
case 17: break;
case 1:
{ return TokenType.BAD_CHARACTER;
}
case 18: break;
case 19: break;
case 4:
{ yybegin(CONTENTS_BEGINNING);
return KDocTokens.LEADING_ASTERISK;
}
case 19: break;
case 8:
{ yybegin(CONTENTS);
return KDocTokens.WIKI_LINK_OPEN;
}
case 20: break;
default:
if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {

View File

@@ -157,8 +157,6 @@ public interface JetControlFlowBuilder {
@NotNull List<PseudoValue> inputValues
);
void compilationError(@NotNull JetElement element, @NotNull String message);
void write(
@NotNull JetElement assignment,
@NotNull JetElement lValue,

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