Commit Graph

2488 Commits

Author SHA1 Message Date
Alexander Udalov
4e77897bfd Pass LanguageSettingsProvider to AnalyzerFacade explicitly
This way is more flexible for example for tests, where configuring the
service implementation may be tricky (it's usually done in
KotlinCoreEnvironment in production code)
2017-07-28 20:15:28 +03:00
Alexander Udalov
224df7a1ea Change -Xload-jsr305-annotations argument to -Xjsr305-annotations={ignore|enable}
See https://youtrack.jetbrains.com/issue/KT-19229 for a complete
explanation

 #KT-19229 Fixed
 #KT-10942
2017-07-26 11:45:25 +03:00
Alexander Udalov
2f99f6ad34 Refactor AnalysisFlags and their support in IDE
* Support flags with any value (not just Boolean)
* Support all flags by parsing arguments in KotlinFacetSettings, instead
  of manually listing known flags

 #KT-19210 Fixed
2017-07-26 11:45:24 +03:00
Alexander Udalov
def3f73fdd Use AnnotationDescriptor.fqName instead of type
Also use the annotationClass extension property instead of
TypeUtils.getClassDescriptor(annotation.type)
2017-07-20 13:26:13 +03:00
Denis Zharkov
90e894b171 Use known jvm binary class for package part if possible 2017-07-20 10:53:09 +03:00
Denis Zharkov
99a10d8d63 Minor. Rename compactIfPossible -> compact
As ArrayList can always be compacted
2017-07-20 10:53:09 +03:00
Denis Zharkov
d7cee95d95 Call compactIfPossible where it's possible in BinaryJava*
It helps to avoid retaining a lot of redundant empty SmartList's
instances
2017-07-20 10:53:09 +03:00
Denis Zharkov
c7e6f200da Use SmartList for storing annotations in binary classes
Looks like in the most cases there are <= 1 annotations
in real declarations
2017-07-20 10:53:09 +03:00
Roman Elizarov
f2b5f37b22 Support inline suspend functions built with compiler version less than 1.1.4/1.2-M1
The error message is removed and is replaced with a code that adapts
inline suspend functions produced by the old compiler with the
suspension markers that new compiler expects.
2017-07-19 08:59:55 +03:00
Mikhail Glukhikh
dfe2c16bc7 More cleanup: lift return / assignment out 2017-07-10 12:59:58 +03:00
Alexander Udalov
03a6488464 Use module path instead of class path for stdlib on Java 9
Also report the "named does not read unnamed" error, which was not
possible previously because we wouldn't be able to read anything from
kotlin-stdlib (because it was added to the unnamed module by default)
2017-07-10 12:48:21 +03:00
Alexander Udalov
4128064f87 Move JavaModuleGraph from 'frontend.java' to 'cli' 2017-07-10 12:48:21 +03:00
Alexander Udalov
5b8e58fe36 Implement module accessibility checks differently in compiler and IDE
Essentially, the logic that was previously in
JvmModuleAccessibilityChecker.diagnosticFor, is moved into a new
abstract method JavaModuleResolver.checkAccessibility, which is
implemented differently in the compiler and in the IDE. In the compiler,
we use our JavaModuleInfo and JavaModuleGraph, as previously. In the
IDE, we use intellij's PsiJavaModule and JavaModuleGraphUtil.

This fixes strange behavior in IDE where some modules could be observed
in an invalid state. The cause of that was the JavaModuleGraph instance
caching modules in IdeJavaModuleResolver, which is a project component.

Moreover, this will allow to report an error "named module does not read
unnamed module" in the compiler, and avoid reporting it in the IDE (see
the comment in IdeJavaModuleResolver about that)
2017-07-10 12:48:21 +03:00
Alexander Udalov
127cd1295e Disable JSR-305 annotations by default, introduce CLI argument
No package annotations are going to be loaded, and
TypeQualifierDefault/TypeQualifierNickname are no longer recognized by
default. Use the CLI argument "-Xload-jsr305-annotations" to enable this
behavior back

 #KT-10942
2017-07-07 22:08:50 +03:00
Alexander Udalov
3808ecbd1e Minor, return a set in JavaModuleGraph.getAllDependencies
To prevent duplicate roots to be added
2017-07-06 13:01:15 +03:00
Alexander Udalov
7ab018da7b Use ASM 6 API to read class files in IDE
Otherwise ASM throws exceptions trying to read module-info.class

 #KT-13072 Fixed
2017-07-06 13:01:13 +03:00
Alexander Udalov
c428505d4d Load automatic module names correctly
Load the Automatic-Module-Name manifest entry value if it's present (see
http://mail.openjdk.java.net/pipermail/jpms-spec-observers/2017-May/000877.html),
otherwise sanitize the name of the .jar file, throwing out all chars
except alphanumeric, duplicate dots and a version qualifier
2017-07-06 12:50:05 +03:00
Denis Zharkov
42b2534c46 Remove redundant check in WhenByPlatformEnumChecker
If a type is annotated as not null its upper bound is not nullable
in most cases besides override conflicts, but in the latter case
we should behave consistently with flexibility of this type
2017-07-03 17:55:37 +03:00
Denis Zharkov
79e14f88e4 Support package level annotations in Java
#KT-10942 In Progress
2017-07-03 17:55:37 +03:00
Denis Zharkov
b7ead75947 Minor. Move BinaryJavaModifierListOwner -> MapBasedJavaAnnotationOwner 2017-07-03 17:55:04 +03:00
Alexander Udalov
37982e4bb1 Move SAM-related descriptor classes to module frontend.java
Also move SyntheticMemberDescriptor to module resolution
2017-06-30 21:02:18 +03:00
Mikhail Glukhikh
840847e47c Code cleanup: several inspections applied 2017-06-29 16:25:57 +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
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
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
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
Denis Zharkov
cb95986c36 Report error on calls to obsolete inline suspend functions
They do not contain markers for suspend calls in them

See the changes introduced for fixing KT-16603
2017-06-28 10:24:27 +03:00
Alexander Udalov
69efb81a12 Minor refactoring in JavaModuleInfo
Remove unused declarations
2017-06-26 16:22:05 +03:00
Alexander Udalov
a25aa2fed8 Cleanup DefaultErrorMessagesJvm
Use static imports, use Kotlin stdlib API, use more precise renderers
2017-06-21 15:42:59 +03:00
Dmitry Petrov
0a622e4440 Rewrite OtherOrigin overloads to prevent further silly problems
#KT-18413 Fixed Target versions 1.1.4
2017-06-20 13:31:36 +03:00
Mikhail Zarechenskiy
011231f2ab Collect sam adapters for constructors in synthetic scope
Also place computation of synthetic constructors under one function
2017-06-16 16:44:52 +03:00
Alexander Udalov
7febd846e8 Export 'intellij-core' in module 'frontend'
Remove intellij-core from dependencies of modules which already depend
on frontend or any module that exports frontend (such as frontend.java)
2017-06-06 14:29:26 +03:00
Alexander Udalov
cc2f607be3 Remove dependency of module 'frontend.java' on 'javac-wrapper'
This breaks the circular dependency between them
2017-06-06 14:29:24 +03:00
Alexander Udalov
1df13e0bc9 Move TopDownAnalyzerFacadeForJVM to module 'cli'
It's only used in the command line compiler and in tests
2017-06-06 14:29:23 +03:00
Alexander Udalov
cbaa676c3d Move some declarations between 'descriptors' and 'deserialization'
- Move the following from 'deserialization' to 'descriptors':
  NotFoundClasses.kt
  AdditionalClassPartsProvider.kt
  ClassDescriptorFactory.kt
  PlatformDependentDeclarationFilter.kt
  findClassInModule.kt
- Move the following form 'descriptors' to 'deserialization':
  BuiltInSerializerProtocol.kt
  builtInsPackageFragmentProvider.kt
- Extract a marker interface from BuiltInsPackageFragment and move its
  implementation to 'deserialization'
- Change the type of parameters in PlatformDependentDeclarationFilter
  and AdditionalClassPartsProvider to ClassDescriptor

This will help in getting rid of the circular dependency of
'descriptors' <-> 'deserialization'
2017-06-06 14:29:18 +03:00
Alexander Udalov
e67e0440bb Rename LexicalScope.Empty -> Base
"Empty" is slightly confusing because although the scope has no declared
symbols, it is not empty: it has a parent scope which can contain
symbols and can have parents as well
2017-06-05 10:27:38 +03:00
Dmitry Petrov
4a632857d7 Fix internal compiler error in DefaultParameterValueSubstitutor
Most likely a typo in the original code.
2017-06-02 10:14:33 +03:00
Alexander Udalov
1572d2cf2b Improve modular JDK root module detection
According to the spec, "java.se" and every other non-"java.*" module
that exports at least one package without qualification, is a root.
Currently we only support compilation of a single unnamed module, and
apparently unnamed module should read all root modules.

 #KT-18180 Fixed
2017-05-30 17:35:25 +03:00
Alexander Udalov
5042bbe4a1 Minor refactoring in ContentRoots, JvmContentRoots and usages 2017-05-30 17:35:23 +03:00
Alexander Udalov
a583a2f171 Move JavaModuleInfo and JavaModuleGraph to frontend.java 2017-05-26 19:38:49 +03:00
Dmitry Petrov
96f7a2d38a Fix message for EXTERNAL_DECLARATION_CANNOT_BE_INLINED
#KT-10164 Fixed
2017-05-26 13:58:46 +03:00
Dmitry Petrov
17eab2865d Include containing declaration name in message for JVM signature clashes
#KT-9359 Fixed
2017-05-26 13:58:46 +03:00
Alexander Udalov
f8e82f148a Drop TypeLazinessToken and LazyResolveToken 2017-05-22 18:15:19 +03:00
Dmitry Petrov
a2db4dc0d5 Fix incremental compilation problems related to type alias constructors
1. Determine source element for descriptors with NO_SOURCE recursively.

2. Always provide type abbreviation for type alias constructor
return type.

 #KT-15495 Fixed
2017-05-18 10:55:16 +03:00
baratynskiy
eb85e9f5f3 Introduce isFromSourceCodeInScope function
See `VirtualFileBoundJavaClass` interface
2017-05-17 17:49:33 +03:00
baratynskiy
5eea3b6569 Introduce experimental -Xuse-javac compilation mode
In this mode, javac AST and Symbol files are used during
Kotlin compilation instead of PSI / binary stuff.
Later, they are reused for Java file compilation.
javac in this mode is integrated into kotlinc.
2017-05-17 17:48:17 +03:00