Commit Graph

163 Commits

Author SHA1 Message Date
Yan Zhulanow ef698a5747 Fix "PSI/index mismatch" in case of @ParameterName on non-functional types (KT-34524) 2020-05-27 02:38:41 +09:00
Roman Golyshev d7667209b2 KT-37144 Respect quotes in package name during decompilation
- Odd package names (for example `try` in `arrow-core`) were pasted
as-is to the decompiled text
- Because of this, stub checks were failing, forcing completion to start
over and over again, as if something changed in the files
- See EA-5572315 for the error
- ^KT-37144 Fixed
2020-04-13 07:34:28 +00:00
Alexander Podkhalyuzin 5bb74d9840 Fixed generated text from jvm classfile, when quotes is required
#KT-34759 Fixed
2020-03-11 15:41:41 +03:00
Igor Yakovlev 48db96b66d Improved kotlin decompiler range indexes
Fixed #KT-30628
2020-02-11 17:42:12 +03:00
Ilya Gorbunov 30bccc431b Migrate tests to release coroutines
where it's not essential to use experimental ones

#KT-36083
2020-01-29 09:12:41 +03:00
Nikolay Krasko f01b4706d1 Switch to 193 platform 2020-01-19 12:01:53 +03:00
Mikhail Zarechenskiy 8206cadce2 FIC: support fun interfaces in stub builder 2020-01-17 19:36:12 +03:00
Alexander Udalov 9187a85aaf Rename UseExperimental->OptIn, Experimental->RequiresOptIn in quickfix and IDE tests 2020-01-14 21:04:43 +01:00
Nikolay Krasko 8563614b69 193: Mute navigation tests in 193 (KT-34542) 2019-10-28 14:06:05 +03:00
Mikhael Bogdanov d2a205c72d Update synthetic parameter processing logic according to ASM 7 changes
#KT-27774 Fixed
2018-11-07 15:42:57 +01:00
Nikolay Krasko a9c3b27d3e Don't generate stub for value arguments list when no arguments present (KT-23738)
Need this to conform stubs list obtained by decompiler.
Also ignore green stub, because is might not contain actual psi node.
2018-11-06 13:43:19 +03:00
Dmitry Savvinov e2bf43c54f Minor: update testdata in ClsStubBuilder test on contracts 2018-10-18 13:15:05 +03:00
Nikolay Krasko 76a3f23df0 Test for stubs of extension/non-extension properties with same name (KT-27274)
An issue was probably fixed in 98232265d7

 #KT-27274 Fixed
2018-10-08 13:40:25 +03:00
Dmitry Savvinov 5ab79a111d Introduce 'mayHaveContract'-flag in stubs
This is needed for further commit, which supports contracts-based
smartcasts in partial body resolve mode.

NB: Stubs can be built from 3 sources:
- source code (contract presence can be checked by PSI)
- binary data (contract presence can be checked by Kotlin Metadata)
- decompiled sources

The last case is a bit of a headache, because usually bodies are omitted
in decompiled sources. To workaround it, we have to inject stubbed
contract-call in the body.
2018-07-27 16:59:24 +03:00
Nikolay Krasko ac97075020 Check only one class in JS decompiler tests to reuse test data
JVM tests check only single class result, in order to reuse test data
JS tests should do the same. CHECK_PACKAGE is introduced to override
this behaviour explicitly.
2018-04-24 18:51:27 +03:00
Alexander Udalov 965e3ebab2 Do not serialize SOURCE-retained annotations
Also, fix the value of "hasAnnotations" flag to reflect if there are any
_non-source_ annotations on a declaration.

Unfortunately, after this change
IncrementalJsCompilerRunnerTestGenerated$PureKotlin.testAnnotations
starts to fail because of the following problem. The problem is that
annotations on property accessors are not serialized yet on JS (see
KT-14529), yet property proto message has setterFlags field which has
the hasAnnotations flag. Upon the full rebuild of the code in that test,
we correctly write hasAnnotations = true, but annotations themselves are
not serialized. After an incremental build, we deserialize property
setter descriptor, observe its Annotations object which happens to be an
instance of NonEmptyDeserializedAnnotationsWithPossibleTargets. Now,
because annotations itself are not serialized, that Annotations object
has no annotations, yet its isEmpty always returns false (see the code).
Everything worked correctly before the change because in
DescriptorSerializer.hasAnnotations, we used Annotations.isEmpty and the
result was the same in the full rebuild and in the incremental scenario.
But now we're actually loading annotations, to determine their
retention, and that's why the setterFlags are becoming different here
and the test fails

 #KT-23360 Fixed
2018-04-23 18:42:33 +02:00
Zalim Bashorov 09d5a0cb89 Fix usages of IGNORE_BACKEND_WITHOUT_CHECK 2018-04-19 13:17:28 +03:00
Nikolay Krasko bc7ccbc39b Fix stub mismatch for top level declaration with JvmPackageName (KT-21831)
ClassId stores jvm name and it differs from kotlin name in that case.

 #KT-21831 Fixed
2018-03-14 21:16:58 +03:00
Alexander Udalov 71fe8c02a3 Fix rendering of type aliases
- render 'actual' modifier if it's present
- do not render a space after type parameter list
2018-02-05 13:38:06 +01:00
Alexey Sedunov 62580a47dc Misc: Add test for KT-7316
#KT-7316 Fixed
2018-01-17 12:53:57 +03:00
Nikolay Krasko d75656d571 Additional tests for overloads with type aliases and suspend
Failed attempts to reproduce KT-20782, but still may be useful.
2017-10-27 15:09:52 +03:00
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