Commit Graph

19606 Commits

Author SHA1 Message Date
Dmitry Petrov c0a83c3c8a KT-19251 Process uninitialized stores in mandatory bytecode pass
See
https://youtrack.jetbrains.com/issue/KT-19251
https://github.com/puniverse/quasar/issues/280
https://bugs.openjdk.java.net/browse/JDK-8046233

Inline function calls (as well as try/catch expressions) in constructor
arguments produce bytecode that spills stack, and stores uninitialized
objects (created by 'NEW C', but not initialized by 'C.<init>') to
local variables. Such bytecode is valid according to the JVM spec, but
confuses Quasar (and other bytecode postprocessing tools),
and fails to verify under some (buggy) versions of JDK 8.

In order to avoid that, we apply 'processUnitializedStores' already
implemented for coroutines. It moves 'NEW' instructions after the
constructor arguments evaluation, producing code like

<initialize class C using Class.forName>
<evaluate constructor arguments>
<store constructor arguments to variables>
NEW C
DUP
<load constructor arguments from variables>
INVOKESPECIAL C.<init>(...)

NB some other expressions, such as break/continue in the constructor
arguments, also can produce "weird" bytecode: object is created by a
'NEW C' instruction, but later (conditionally) POPped from stack and
left uninitialized. This, as we know, also can screw bytecode
postprocessing. However, it looks like we can get away with it ATM.
Otherwise it looks like we'd have to analyze constructor arguments, see
if the evaluation can "jump out", and perform argument linearization in
codegen.
2017-09-27 12:38:52 +03:00
Denis Zharkov d6ee774243 Load some of the TYPE_USE annotations in fast class reading mode
Only top-level types on fields, methods' return types and
value parameters are supported to catch-up how class-files are loaded
in IntelliJ (see IDEA-153093)

NB: this commit also affects
ForeignJava8AnnotationsNoAnnotationInClasspathWithFastClassReadingTestGenerated
that were failing before

 #KT-20016 Fixed
2017-09-26 16:40:47 +03:00
Denis Zharkov 08f3dbce67 Fix configuration for FastClassReading foreign-annotations tests
Prior to this change USE_FAST_CLASS_FILES_READING actually
has not worked because the flag is being read in the KotlinCoreEnvironment
constructor 🤦‍♂️
2017-09-26 16:40:47 +03:00
Denis Zharkov fd9025a4fb Add Java8 foreign-annotations tests without jsr305.jar in the classpath
Some of them are expected to fail since neither IntelliJ class reading
nor our fast class reading can read annotations on type arguments
2017-09-26 16:40:47 +03:00
Denis Zharkov 58a0ca61a9 Minor. Fix java test data to make it actually compilable 2017-09-26 16:40:47 +03:00
Denis Zharkov fdc6b37264 Obtain default type qualifiers from value parameters too
#KT-20016 In Progress
2017-09-26 16:40:47 +03:00
Denis Zharkov 71f85812d6 Improve support for TYPE_USE default qualifiers
- Apply default qualifiers to type arguments if they contain TYPE_USE
in applicability list
- Read TYPE_USE placed default qualifier annotations

 #KT-19592 Fixed
 #KT-20016 In Progress
2017-09-26 16:40:47 +03:00
Denis Zharkov 775d6988e8 Preserve flexibility for Java types annotated with @NonNull(UNKNOWN)
Before this chanhe, these annotations are simply ignored, but they should
preserve flexibility in case of enhanced nullability obtained from
enclosing default qualifier

 #KT-20158 Fixed
2017-09-26 16:40:47 +03:00
Denis Zharkov 02d3d9785c Move JSR-305 tests to one directory and strip common name prefix 2017-09-26 16:40:47 +03:00
Denis Zharkov 8a66919a5c Support @NonNull(when = NEVER) nullability annotation
#KT-20131 Fixed
2017-09-26 16:40:47 +03:00
Mikhail Zarechenskiy 8a545f05de Provide quick fix for migration of single elements in named arguments
See more in KT-20171
2017-09-26 14:49:43 +03:00
Mikhail Zarechenskiy 69e3dd89f6 Split diagnostic factory for the ease of code evolution and tooling 2017-09-26 14:49:42 +03:00
Alexey Andreev ca014468ee JS: improve name clash checker to handle complicated cases
See KT-18010
2017-09-26 13:56:19 +03:00
Nikolay Krasko d51f54693f Exist if no identifier found (EA-91332) 2017-09-25 20:41:53 +03:00
Mikhail Glukhikh e8b95b971d Make parentheses necessary for '(x op return y) op z' #KT-16808 Fixed 2017-09-25 18:16:42 +03:00
Dmitry Petrov 8f9ea3e08b Fix const range bounds generation 2017-09-25 17:49:33 +03:00
Mikhail Zarechenskiy 32531b3afc Allow to have all parameters with default values in actual annotation
#KT-19656 In Progress
2017-09-25 16:19:05 +03:00
Alexey Sedunov 0beadddb7f Copy: Improve file copying
- Do not copy individual declarations if entire file is selected
  (keeping original content with comments, formatting, etc.)
- Update package directive when original file packages matches
  its directory

 #KT-20092 Fixed
 #KT-18196 Fixed
2017-09-25 14:40:17 +03:00
Alexander Udalov 23d6690581 Fix codegen for multifile class parts with type aliases only
#KT-20337 Fixed
2017-09-25 11:58:20 +03:00
Alexander Udalov 09f36927a5 Do not try to generate 'expect' declarations in multifile classes
Similarly to PackageCodegenImpl#generateFile

 #KT-15754 Fixed
 #KT-17478 Fixed
2017-09-25 11:58:20 +03:00
Alexander Udalov 3f1ee74475 Minor, refactor compiler-running code in multiplatform integration test
The compiler is run twice and outputs are compared for equality. Thus,
if both runs ended with exceptions, the outputs were never equal because
the compiler was run from different places (stack traces were different
in only one line), which was a bit weird. Now outputs are equal and in
case of an exception, a standard "actual data differs from file content"
message is displayed
2017-09-25 11:58:20 +03:00
Alexander Udalov 2d9f07deec Minor, add test for obsolete issue on "actual missing" error
#KT-20142
2017-09-25 11:58:20 +03:00
Alexander Udalov 2281ac842a Prohibit super constructor call for 'expect' class
#KT-15490 Fixed
2017-09-25 11:58:20 +03:00
Alexander Udalov 8ae7343557 Prohibit 'expect' lateinit member properties
#KT-20319 Fixed
2017-09-25 11:58:20 +03:00
Alexander Udalov 1f992ed845 Improve error on 'expect' delegated property
#KT-15054 Fixed
 #KT-15055 Fixed
2017-09-25 11:58:20 +03:00
Mikhail Glukhikh f348ee9381 Fix a pair of multi-platform messages #KT-20327 Fixed 2017-09-25 11:47:05 +03:00
Ilya Gorbunov 00fa8ee464 Setup JRE version for codegen tests
Add camelCase task name aliases for codegen tests
2017-09-22 15:37:38 +03:00
Denis Zharkov c7812beea4 Fix SOE in SignatureEnhancement::extractNullability
The problem was that `resolveTypeQualifierAnnotation` actually doesn't
guarantee that `typeQualifierAnnotation` is javax.annotation.NonNull
with argument

It could be just any type qualifier (see the test)
2017-09-22 14:15:11 +03:00
Dmitry Jemerov 4549cc7289 Fix CodeConformanceTest for new gradle build 2017-09-21 18:09:25 +02:00
Jonathan Leitschuh 539aed32d2 Improve information regarding running tests that load resources (#1298)
* Improve information regarding running tests that load resources

Figuring out how to run isolated generated tests is not imidiately straightforward.
This clears up confusion by throwing a more helpful error in the tests and
adding a section to the ReadMe.

* Cleanup ReadMe and comments after review feedback
2017-09-21 11:20:49 +02:00
Ilya Chernikov d61695be55 Fix embeddable compiler dependencies, fix dist task, use runtimeJar...
dependencies where appropriate, some helpers refactoring
2017-09-20 11:52:00 +02:00
Alexander Udalov 8f5dae8f57 Do not set KOTLIN_HOME env var for tests
Instead, rework the (already suspicious) KotlinPaths-finding code in
PathUtil to support the new model of running tests (the compiler is
split into several jars according to the project structure) instead of
the old one (where class files were not in the jars, but in the out/
directory).

This fixes Java9ModulesIntegrationTest
2017-09-20 11:51:56 +02:00
Ilya Chernikov 51efd717f6 Extract jvm6-specific test utils, add codegen on specific jdk tests 2017-09-20 11:51:54 +02:00
Ilya Chernikov 5e108d8efd Fix stdlib test in compiler in the gradle environment 2017-09-20 11:51:52 +02:00
Ilya Chernikov dfb0a47260 attempt to fix chained test failures
- commenting out potentially "bad" test
- calculating homedir only once
2017-09-20 11:51:51 +02:00
Ilya Chernikov e92ef59873 Delete obsolete tests - we have no more iml files in the repo 2017-09-20 11:51:50 +02:00
Ilya Chernikov c4de5ee6b7 Fix ScriptGen tests 2017-09-20 11:51:50 +02:00
Ilya Chernikov bcf08c2246 Fix TestExecutedOnlyOnceTest 2017-09-20 11:51:49 +02:00
Ilya Chernikov 4eb4466314 Fix home dir definition in some compiler tests 2017-09-20 11:51:47 +02:00
Ilya Chernikov 1862c78bdc Fix projects for gradle integration tests 2017-09-20 11:51:44 +02:00
Ilya Chernikov 46884bec84 Add missing artifact, fix some deps and publishing 2017-09-20 11:51:38 +02:00
Ilya Chernikov 02ec70e9f1 Fix kotlin-daemon-client project config and publications, fix problem with uploadArchives task 2017-09-20 11:51:32 +02:00
Ilya Chernikov 95035b3d72 Fix various tests 2017-09-20 11:51:23 +02:00
Ilya Chernikov 3aabeca191 Fix maven and android tests after modularizing and rebasing 2017-09-20 11:51:21 +02:00
Ilya Chernikov 0676ebd530 Fix after rebase on master 2017-09-19 23:58:38 +02:00
Ilya Chernikov fd1b677904 Switch reflect to compiled core classes 2017-09-19 23:58:32 +02:00
Ilya Chernikov d89b53dfea Reorganize builtins built and use in the projects 2017-09-19 23:58:31 +02:00
Ilya Chernikov d039d191f2 Fix tests in the new build infrastructure 2017-09-19 23:58:30 +02:00
Ilya Chernikov a61facf3d1 Clean most of the shared source roots conflicts 2017-09-19 23:58:29 +02:00
Alexander Podkhalyuzin 3f8170d369 Clean idea files generated on the gradle import, add them to .gitignore 2017-09-19 23:58:27 +02:00