Commit Graph

142 Commits

Author SHA1 Message Date
Nikolay Krasko 74043089ab Generate modifier list stub under nullable type for suspend functions (KT-20185)
Otherwise there's a PSI and Stub mismatch error produced.

 #KT-20185 Fixed
2017-09-14 12:28:26 +03:00
Nikolay Krasko 99555fa843 Retrieve receiver annotation to stubs from compiled code (KT-19209)
#KT-19209 Fixed
2017-07-28 15:01:32 +03:00
Pavel V. Talanov ca6516c2a2 findDecompiledDeclaration: find builtIns more accurately
Use resolveScope of a reference to help searching for builtIn binaries
Do not search non-builtIn descriptors in random scopes
2017-03-27 21:24:45 +03:00
Pavel V. Talanov dec9fa0324 SourceNavigationHelper: fix navigation to callables
Previously we could differentiate between callables with the same name
    when relevant type declaration were in the same file only
Problem manifested most severely when several copies of sources were attached
    to the same library
2017-03-21 16:20:01 +03:00
Pavel V. Talanov c7f147d058 Introduce NavigationWithMultipleLibrariesTest
Test navigation to library decompiled and source declaration when
there are multiple copies of the same library in project
Related to ba1ee99e97
2017-03-21 16:19:54 +03:00
Mikhail Glukhikh 212f6e0432 Stub creation from cls fixed for suspend function types
(cherry picked from commit f49ef8e)
2017-02-02 17:54:06 +03:00
Alexander Udalov b5fef84e9c Update tests on decompiled text for JS
Because .kjsm files now contain all declarations from the package (contrary to
the JVM decompiler which produces one file for one class/package facade), some
common decompiled text tests started to behave differently on JVM and JS.
Update two of them (Modifiers, ClassWithClassObject) to make results the same,
copy another (TypeAliases) to JVM-/JS-specific tests with different outputs
2017-01-30 11:31:02 +03:00
Denis Zharkov 8fa8ba7055 Move coroutine-related runtime parts to kotlin.coroutines.experimental package
#KT-15975 Fixed
2017-01-27 23:24:13 +03:00
Dmitry Petrov b9f9894310 KT-15677 KT-15775
Update parser & descriptor renderer to handle parenthesized types and function types properly.
Resolve annotations in parenthesized types.

AnnotationsImpl.isEmpty() returned false for targeted annotations only
(e.g., 'fun @receiver:Ann C?.foo()').
Properly keep track of targeted annotations.
2017-01-19 09:53:17 +03:00
Nikolay Krasko c076ad5a8d Don't assign type parameters from original proto if type is substituted with Any (KT-15128)
#KT-15128 Fixed
2016-12-20 15:16:23 +03:00
Dmitry Petrov 80bd916f5d 'SuspendFunction$n' should not be visible in member scopes (should be unresolved).
'SuspendFunction$n' class descriptors are created on demand by KotlinBuiltIns (and cached).
On serialization, types constructed with 'SuspendFunction$n' are written as 'Function$n' with extra flag (SUSPEND_TYPE).
On deserialization, corresponding 'SuspendFunction$n' classes are used.
2016-12-15 23:58:05 +03:00
Denis Zharkov 4737b3dd7f Update stubBuilder/deserialization tests on coroutines 2016-12-15 23:58:02 +03:00
Dmitry Petrov 9dc458375a Build proper modifier list stubs for 'SuspendFunction$n<...>' types. 2016-12-15 23:57:43 +03:00
Dmitry Petrov cf4fb1eb25 Since '@A R.() -> T' is now parsed as '@A (R.() -> T)',
receiver type with modifiers or annotations should be surrounded in parentheses on rendering: '(@A R).() -> T'

This also fixes stub builder tests (which check that stubs are consistent with rendered descriptors).
2016-12-15 23:57:42 +03:00
Dmitry Petrov a15d423db4 Support modifiers on types in parser
(required for 'suspend' on functional types).

TYPE_REFERENCE element now has MODIFIER_LIST child, which hosts annotations and modifiers for the corresponding type reference.

Annotations and modifiers written before an extension function type are now parsed as annotations and modifiers for the functional type, not the receiver type.
So, '@Ann A.(B) -> C' was '(@Ann A).(B) -> C', and became '@Ann (A.(B) -> C)'.
NB: DSL_SCOPE_VIOLATION testData updated accordingly.

Type projection variance modifiers ('in', 'out') belong to a separate modifier list under corresponding type projection (not under a type reference).
'A<in suspend T>' is 'A<(in (suspend T))>', 'A<suspend in T>' is an error.

In stub builder, create a modifier list node to host annotations and modifiers (none so far; TODO properly serialize/deserialize types with modifiers).
2016-12-15 23:57:41 +03:00
Dmitry Petrov f415050913 Suppress TOPLEVEL_TYPEALIASES_ONLY in decompiler and stubBuilder tests. 2016-11-24 10:41:50 +03:00
Zalim Bashorov af4ec9815b Add ability to ignore test for backend w/o checks
It used for the tests from this commit becouse they was failing during setup.
2016-11-09 21:41:12 +03:00
Anton Bannykh 7ee3baa020 Replaced when appropriate 'TARGET_BACKEND: JVM' -> 'IGNORE_BACKEND: JS'. Enabled some succesfully working decompiledText tests. 2016-10-27 14:17:25 +03:00
Nikolay Krasko cdabef51ed Add nullability to receiver type 2016-10-25 13:30:38 +03:00
Nikolay Krasko 22999fe67d Set hasValueArguments in KotlinAnnotationEntryStub to 'true' only if some arguments exist
Currently '()' is used for resolving ambiguity in parsing when annotating function types. This way a decompiled code
will need brackets, but compile code will have annotation without parameters. This commit will allow to make both stub-trees consistent.

Tested in ClsStubBuilderTestGenerated.testAnnotationsOnNullableTypes()
2016-10-25 13:30:37 +03:00
Nikolay Krasko a344ad0644 Fix absence of annotation for function type in cls stubs and ignore @ExtensionFunctionType 2016-10-25 13:30:35 +03:00
Nikolay Krasko d1dfcfaca1 Fix stub-psi mismatch exception on restoring annotation for nullable types
(cherry picked from commit 1aa37f11258dde289a9f7cb700294a038168fbdc)

Conflicts:
	compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/KotlinStubVersions.kt
	idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/TypeClsStubBuilder.kt
2016-10-25 13:22:53 +03:00
Nikolay Krasko 355dca2a97 Add toString for KotlinStubBaseImpl
Try to simplify "Stub and PSI element type mismatch" exception analyze.

(cherry picked from commit 11aa71e)
2016-10-21 00:18:27 +03:00
Dmitry Petrov d2d8f72ffc Annotations on type aliases: typealias is not a "default target".
Add diagnostic test for annotations on type aliases.
2016-10-13 17:52:21 +03:00
Pavel V. Talanov 14f3e4c758 Cls stubs and decompiled text: Do not render parameter names in decompiled text and do not load ParameterName annotation in stubs
Add tests for decompiled text and stubs
2016-10-11 23:38:53 +03:00
Pavel V. Talanov 827b56e277 Navigation to binaries: support navigation to type alias constructors
#KT-13479 Fixed
2016-09-26 18:34:19 +03:00
Denis Zharkov 86c1dbe7b5 Fix decompilation of types based on local classifiers
If deserializing a type with arguments based on a local class for
decompiler, then just return Any type (without arguments).

Previously Any constructor was used with serialized arguments, that lead
to exception

Note that in case of deserialization for compiler nothing changes about
local-classes-based types (LocalClassifierResolverImpl is just inlined)

 #KT-13408 Fixed
2016-09-05 17:54:36 +03:00
Pavel V. Talanov 48d7e8c519 Implement navigation to type aliases in libraries 2016-08-18 16:34:37 +03:00
Denis Zharkov d53c53a900 Support annotations on type aliases declarations 2016-06-28 10:33:29 +03:00
Denis Zharkov e24f0653fb Support type aliases in stub builder 2016-06-28 10:33:29 +03:00
Denis Zharkov 067fe35b72 Fix type deserialization failure when type alias was not found
It's crucial for decompilation as declarations are always being deserialized
with no dependencies

 #KT-12832 Fixed
2016-06-28 10:33:29 +03:00
Denis Zharkov 329fb9d619 Introduce 'coroutine'/'suspend' modifiers 2016-06-08 18:53:16 +03:00
Alexander Udalov 7eafae1936 Drop isAbsoluteInRootPackage from stubs 2016-06-01 19:30:04 +03:00
Pavel V. Talanov ef25b14eab Drop non-generated NavigateToDecompiledLibraryTest
It relies on internal data structure
2016-03-30 21:35:19 +03:00
Pavel V. Talanov 68c0bb9dc2 Generate navigateToDecompiledLibraryTest from the same test data as navigateToLibrarySourceTest
Change test data format
2016-03-30 21:35:18 +03:00
Alexander Udalov 4a533168d9 Rework const val generation in multifile classes
Do not query MultifileClassCodegen#classBuilder early on: this causes the class
file for the facade to be prematurely dumped to the disk in some cases, when
that class file is not yet completely generated. Instead fork the logic in
PropertyCodegen#generateSyntheticMethodIfNeeded: save metadata in parts,
generate method in the facade
2016-03-29 17:53:32 +03:00
Alexander Udalov 5f39f628c9 Fix and test built-ins decompiler for incompatible version 2016-02-26 11:29:10 +03:00
Alexander Udalov f130755972 Use new built-in binary format (.kotlin_builtins files) in IDE
Instead of .kotlin_class and .kotlin_package files, .kotlin_builtins files are
now supported: they are decompiled to a long file consisting of all non-real
classes (those which do not also have .class files) and members in the
corresponding package.

Unlike the old files, .kotlin_builtins files have a binary version in the
beginning, which allows us to skip decompilation and stub building in case the
file has an unsupported version. This could previously lead to exceptions, see
KT-11077, EA-79339.

The change in DecompiledTextFactory is needed because without "defined in ..."
the keys for members in the long decompiled file are not unique, as there are
multiple members with exactly the same signatures in different classes (e.g.
arithmetic operations in primitive classes).

Remove testData files with the decompiled text and stubs of built-in symbols
because now that the whole package is decompiled to a single file, it would be
painful to update these files each time something in built-in sources changes

 #KT-11077 Fixed
2016-02-26 11:29:10 +03:00
Alexander Udalov 04026dbe84 Make Array<T>(size, init) a constructor of Array
It's not marked as inline, this is why 'crossinline' was added in
jaggedArray.kt/jaggedDeep.kt. Will be fixed in the following commits
2016-01-28 03:10:37 +03:00
Denis Zharkov 6c0cd70a22 Introduce PureReifiable annotation
It prevents reporting unsafe substitution warning on expressions
like 'arrayOf(arrayOf(""))'
2016-01-22 19:17:22 +03:00
Denis Zharkov 32755a269c Support annotations on type parameters in stub builder 2016-01-22 19:17:22 +03:00
Ilya Gorbunov 875287574f Update testData for LoadBuiltinsTest and BuiltInDecompilerTest 2016-01-22 05:54:38 +03:00
Ilya Gorbunov f4822cd757 Fix testData in compiler: add collections and ranges package to fq-names. 2016-01-22 05:54:38 +03:00
Ilya Gorbunov de11ed4fc6 Primitive Companion objects do not longer implement IntegerConstants and FloatingPointConstants. All declarations moved inside companions.
IntegerConstants and FloatingPointConstants are dropped.
#KT-8897 Fixed
2015-12-24 06:17:03 +03:00
Alexander Udalov 12e921ab15 Minor, add test on annotation in enum companion 2015-12-23 16:45:26 +03:00
Alexander Udalov f7969621d6 Don't read isStaticInOuter message for fields
It's only written for fields of properties of companion objects of classes;
handle that case manually in deserialization
2015-12-23 16:45:26 +03:00
Alexander Udalov 7449ad2763 Rename Extension annotation to ExtensionFunctionType
The old one is kept temporarily and will be removed later
2015-12-21 20:33:32 +03:00
Ilya Gorbunov 03816373b3 Primitive array constructor-like functions with init lambda.
#KT-8831

Update testData and resolve ambiguity in newArray test
2015-12-18 17:54:09 +03:00
Ilya Gorbunov 58e93d5e1b Update testData for LoadBuiltinsTest and BuiltInDecompilerTest 2015-12-14 04:29:28 +03:00
Alexander Udalov 65c5c99c68 Render decompiled annotations on enum entries 2015-12-13 17:49:44 +03:00