Commit Graph

39787 Commits

Author SHA1 Message Date
Alexey Sedunov e3e4c447fa Generate equals/hashCode(): Use class literals when possible
#KT-18683 Fixed
2017-06-29 17:42:18 +03:00
Alexey Sedunov 50a38df8b1 Remove Parentheses: Forbid on call inside a call without argument list
#KT-18699 Fixed
2017-06-29 17:42:17 +03:00
Alexey Sedunov 20969f161c Introduce Parameter: Fix NPE on invalid parameter name or type
EA-95189 Fixed
2017-06-29 17:42:16 +03:00
Alexey Sedunov 2e8b374ce8 Move: Use KtNamedDeclaration as referrer when reporting a conflict
EA-103817 Fixed
2017-06-29 17:42:15 +03:00
Alexey Sedunov 58addf72ff New File Action: Do not start under write action
EA-102468 Fixed
2017-06-29 17:42:14 +03:00
Alexey Sedunov b1637df8df Misc: Format generated members under write action
EA-87901 Fixed
2017-06-29 17:42:13 +03:00
Alexey Sedunov 392370bb23 Extract Interface: Fix NPE
EA-90440 Fixed
2017-06-29 17:42:11 +03:00
Alexey Sedunov dd0f8e98e8 Create Type Alias From Usage: Disable on PsiPackage
EA-92625 Fixed
2017-06-29 17:42:10 +03:00
Alexey Sedunov 6060a39494 Change Signature: Use correct index in getOriginalParameter()
#KT-18642 Fixed
 #KT-18606 Fixed
2017-06-29 17:42:09 +03:00
Nikolay Krasko 9122f58d5d Re-enable optimize on the fly activation when unused imports found
Remove deprecated usages
2017-06-29 16:56:15 +03:00
Nikolay Krasko 6a5d6854bb Refactoring: inline implementation into KotlinStdJSProjectDescriptor 2017-06-29 16:56:15 +03:00
Nikolay Krasko df393e18fe Configure AbstractInspectionTest with project descriptors
Previous implements produced flaky tests when non-js tests were
executed after js.
2017-06-29 16:56:15 +03:00
Nikolay Krasko be28c4a48f Remove unused configuration of runtime library
The project descriptor used in the test already has the configuration.
Also directive is not used in tests.
2017-06-29 16:56:15 +03:00
Mikhail Glukhikh c8a9b5f67a Restrict range of "simplifiable call chain" inspection 2017-06-29 16:25:58 +03:00
Mikhail Glukhikh 840847e47c Code cleanup: several inspections applied 2017-06-29 16:25:57 +03:00
Mikhail Glukhikh fdca96634e Add restrictions for "simplifiable call chain" inspection
Do not use on maps; do not suggest for lambdas with return inside
Related to KT-18274
2017-06-29 16:25:55 +03:00
Mikhail Glukhikh 2f0159a7ab Minor fix: useless call on collection type 2017-06-29 16:25:54 +03:00
Mikhail Glukhikh 36be1fdaef Introduce "simplifiable call chain on collection" inspection
Related to KT-12165
So #KT-18274 Fixed
So #KT-17198 Fixed
2017-06-29 16:25:52 +03:00
Mikhail Glukhikh bdb9f00c75 Introduce "Useless call on collection type" inspection
Related to KT-12165
Supported functions: filterNotNull, filterIsInstance,
mapNotNull, mapNotNullTo, mapIndexedNotNull, mapIndexedNotNullTo

Also, "Useless cal on not-null" improved a bit
2017-06-29 16:25:50 +03:00
Mikhail Glukhikh f80f41d254 Introduce "redundant explicit type" inspection #KT-18517 Fixed
Reported cases: constants, constructors, object references
2017-06-29 16:25:47 +03:00
Mikhail Glukhikh 0f4ae3b727 Introduce "Useless call on not-null type" inspection #KT-18386 Fixed
Supported functions: orEmpty(), isNullOrEmpty(), isNullOrBlank()
2017-06-29 16:25:45 +03:00
Alexander Udalov 8c21ff66a4 Always treat all sources as parts of the module being compiled
If a path to the module-info.java file is passed as an argument, we
should treat all other source files passed as arguments (either as
individual source files or inside a source directory) as members of that
module. Previously we treated other source files as members of the
unnamed module, and this resulted in incorrect errors when using a
member exported with a qualification from another named module, for
example

 #KT-18598 In Fixed
2017-06-29 15:59:57 +03:00
Alexander Udalov 5192f946c5 Fix depth-first search for Java 9 modules
To compute modules to be added to compilation roots in
JavaModuleGraph.getAllDependencies, we should look not only for
transitive requirements of root modules, but for transitive requirements
of _root modules' requirements_. The same logic applies to
JavaModuleGraph.reads. In other words, when looking for a path in the
module graph between two modules, the first edge's transitiveness
doesn't matter, but all other edges after the first must be transitive.

There was also a stupid bug in dfs in
JavaModuleGraph.getAllDependencies: we continued the DFS only if the
module _was not_ added to the "visited" set ("add" returns true if the
element was added successfully)

 #KT-18598 In Progress
2017-06-29 15:59:57 +03:00
Alexander Udalov 72f37a278c Do not add all modules from module path when compiling unnamed module
Note that javac reports a nice error in this case ("package foo is
declared in module lib, which is not in the module graph"), but we only
report "unresolved reference" because the corresponding modules are not
added to classpath roots. We should improve this in the future

 #KT-18598 In Progress
2017-06-29 15:59:57 +03:00
Alexander Udalov f8346d21c2 Check type alias expansion for Java 9 module accessibility
#KT-18598 In Progress
2017-06-29 15:59:57 +03:00
Alexander Udalov 8768500844 Fix incorrect behavior and refactor JvmModuleAccessibilityChecker
Previously we assumed that a symbol is accessible if its containing
package is exported by module-info.java. Which was obviously wrong and
could lead to a situation where a symbol would be incorrectly accessible
if a usage module has a dependency on the symbol's module in IDEA
project terms, but does not require it in its module-info.java

 #KT-18598 In Progress
2017-06-29 15:59:57 +03:00
Alexander Udalov 2d3888c710 Do not add JDK .jar roots if the JDK is modular (9+)
Files like ant-javafx.jar, deploy.jar, java.jnlp.jar, javafx-swt.jar etc
should not be added to the classpath if JDK home points to a JDK 9
distribution
2017-06-29 15:59:57 +03:00
Alexander Udalov 9274d963aa Create KotlinCoreEnvironment a bit later in tests
Before this change, diagnostic tests with Java source files failed
because KotlinCoreEnvironment was being created in the test's setUp,
even before the test data file has been split into .java/.kt and the
resulting .java files have been copied to a temporary directory. In
KotlinCoreEnvironment's constructor, we now inspect all roots for
module-info files, which involves calling VirtualFile.getChildren on all
roots in the configuration. CoreLocalVirtualFile.getChildren is
cached on the first access, and so because the temporary directory with
.java files was empty at this point, the VirtualFile for that directory
returned empty array in getChildren later in the test, resulting in
unresolved reference errors.

This is fixed by creating the environment _after_ the .java files have
been copied to a temporary directory. Note that slow assertions for
flexible types are now enabled in KtUsefulTestCase instead of
KotlinTestWithEnvironmentManagement, because BaseDiagnosticsTest no
longer inherits from the latter
2017-06-29 15:59:56 +03:00
Alexander Udalov 03d83db660 Support -Xmodule-path and -Xadd-modules command line arguments
#KT-18598 In Progress
 #KT-18599 Fixed
2017-06-29 15:59:56 +03:00
Alexander Udalov e32880d9a3 Implement Java 9 module visibility checks
In this commit, only IDE tests are added, because we look for module
declarations in the IDE across the whole project, whereas in the
compiler we should do this on the module path only and that requires
separate work (KT-18599) which is done in the following commits.

(The change in Cache.kt is needed so that
JvmModuleAccessibilityChecker.ClassifierUsage, which is an inner class,
would be injected properly.)

 #KT-18598 In Progress
 #KT-18599 In Progress
2017-06-29 15:59:56 +03:00
Alexander Udalov 2275068c94 Introduce JavaModule, refactor module graph construction
#KT-18598 In Progress
 #KT-18599 In Progress
2017-06-29 15:59:56 +03:00
Mikhael Bogdanov 4f914fafca Calculate default mask shift properly
#KT-18689 Fixed
2017-06-29 14:57:42 +02:00
Alexey Andreev 1fa7193901 Change variance of return type of Promise.all function
See KT-18624
2017-06-29 10:34:10 +03:00
Alexey Andreev 479148f7e0 Run JS DCE gradle task in a separate process 2017-06-29 10:32:30 +03:00
Alexey Andreev cfbb9209a7 Add JS DCE gradle plugin 2017-06-29 10:32:30 +03:00
Nikolay Krasko 9eefbc2036 Perform 'all import resolve' once and protect it with lock (EA-79696)
Binding context and diagnostic structures are not thread-safe now and
need to be protected with the lock.

Fix flacky test testRemoveDuplicateImport

This also probably fixes some traces in EA-79696
2017-06-28 18:57:13 +03:00
Nikolay Krasko 9f873f869a Print all diagnostics if null diagnostic found (EA-79696)
Diagnostics collection shouldn't contain nulls, but may do so when there
were unprotected simultaneous writes from several threads.
2017-06-28 18:57:12 +03:00
Mikhail Glukhikh 6c274cecff Protect getSingleAbstractMethodOrNull from data binding deadlock
Now it cannot cause resolve re-entrance
Probably #KT-18687 Fixed
2017-06-28 16:40:27 +03:00
Dmitry Neverov 3e29f9ed5a Don't report as redundant 1st semicolon in enum without entries
So #KT-12524 Fixed
2017-06-28 15:30:40 +03:00
Toshiaki Kameyama 3a606d13f0 Extends range of change visibility intention #KT-14093 Fixed 2017-06-28 15:28:50 +03:00
Dmitry Neverov 44ce5f73f7 Apply De Morgan's laws to non-negated binary expressions
So #KT-18460 Fixed
2017-06-28 15:28:43 +03:00
Toshiaki Kameyama af53a0ecd5 Add quick-fix "Replace with safe call & elvis" #KT-17815 Fixed 2017-06-28 15:28:35 +03:00
Toshiaki Kameyama c2707bb81b Support cascade if / when in lift return / assignment intentions
So #KT-13458 Fixed
So #KT-13436 Fixed
2017-06-28 15:28:28 +03:00
Toshiaki Kameyama ed04b4debd Add quick-fix for empty brackets after primary constructor
So #KT-18534 Fixed
2017-06-28 15:28:21 +03:00
Mikhael Bogdanov 69457ef3f1 Generate optimized hashCode for primitive type with jvmTarget 1.8+
#KT-7571 Fixed
2017-06-28 13:44:07 +02:00
Igor Chevdar d7e4350d42 Ignored/fixed some tests for Kotlin/Native 2017-06-28 12:54:32 +03:00
Alexey Andreev 7b52300287 Remove unnecessary system property from JS tests launch configuration
Replace it with property that allows to disable DCE tests.
This is useful for temporary disabling DCE without examining source
code to find property name.
2017-06-28 10:48:02 +03:00
Alexey Andreev 4037112f28 Implement deepCopy in JsRegExpr 2017-06-28 10:48:01 +03:00
Alexey Andreev 64331ffa40 Avoid excessive copying in JsLabel
See KT-18331
2017-06-28 10:48:01 +03:00
Denis Zharkov 3dc4f8a2ff Do not write generics for $suspendImpl synthetic method
#KT-18252 Fixed
2017-06-28 10:25:08 +03:00