Commit Graph

2408 Commits

Author SHA1 Message Date
Alexander Udalov
52a71ec0b0 Support .jar archives in friend paths (for internal visibility)
(cherry picked from commit 939f969f12)
2017-05-15 12:21:21 +03:00
Alexander Udalov
82e6324c45 Support compilation against modular JDK (9+)
For more information about the "jrt" file system, see
http://openjdk.java.net/jeps/220 and
https://bugs.openjdk.java.net/browse/JDK-8066492.

This commit fixes DiagnosticsWithJdk9TestGenerated.testKt11167

 #KT-11167 Fixed
2017-04-27 20:48:24 +03:00
Mikhail Zarechenskiy
fcf70fda22 Fix exception when classes erroneously have no name
#KT-16775 Fixed

 Exception appears because of different representation of classes without name. For Kotlin we load them with `SpecialNames.NO_NAME_PROVIDED`, but for Java (for light classes) with `SpecialNames.safeIdentifier`
2017-04-27 18:57:45 +03:00
Alexander Udalov
38ea9986ab Make KotlinType.isError extension instead of member 2017-04-26 18:10:49 +03:00
Alexey Tsvetkov
50085722d1 Fix internal visibility check for deserialized typealiases
#KT-15495 fixed
2017-04-25 16:27:23 +03:00
Denis Zharkov
513655239d Introduce initializer-related properties into JavaField
It's much more convenient to use and implement these
properties instead of manual "pattern matching" in the
JavaPropertyInitializerEvaluatorImpl
2017-04-21 12:56:30 +03:00
Denis Zharkov
a5c352dc9f Add -Xuse-old-class-files-reading CLI argument
By default we use the fast implementation in CLI compiler,
but in the most of the tests the old one is enabled

Also add tests on CompiledJava with the fast class reading
implementation
2017-04-21 12:56:29 +03:00
Denis Zharkov
af202ef5bc Get rid of wrong assumption that Java* classes are always PSI-based
See org.jetbrains.kotlin.load.java.structure.impl.classFiles.BinaryJavaClass
as a counter-example, these classes may be used now in CLI too and they
aren't built upon Java PSI
2017-04-21 12:56:29 +03:00
Denis Zharkov
d65af8f951 Introduce custom Java model implementation for class-files
It's only used for CLI compiler, and it should improve performance
of loading Java descriptors from class-files

For IntelliJ, it leads to 10-15% percent speedup of Kotlin Builder

Before this change, we were using a Java model based on Java PSI that
also read class files, but do it less effectively since it performs
some extra work, that we don't need, e.g. eagerly reading all
the inner classes
2017-04-21 12:56:29 +03:00
Denis Zharkov
88950521a8 Refactor KotlinCliJavaFileManager: make it return JavaClass
It seems to be very natural refactoring considering the
following changes: optimizing KotlinCliJavaFileManagerImpl.findClass
to make it read class files manually instead of requesting PSI
2017-04-21 12:48:31 +03:00
Denis Zharkov
506d7ab3d2 Replace JavaClass.innerClasses with innerClassNames
Also add a findInnerClass method that can find an inner class
by its name

This change helps to avoid loading all the inner class files
eagerly (that may be rather slow), while all the names are available
in InnerClass attribute
2017-04-21 12:48:31 +03:00
Denis Zharkov
5936424659 Replace JavaClassifierType.canonicalText with classifierQualifiedName
The reason is that canonicalText requires some additional
computations to be done when reading class files, while
in fact we only need a class name of the type
2017-04-21 12:48:31 +03:00
Denis Zharkov
e4cb5496b8 Optimize getSingleAbstractMethodOrNull
Searching for the single abstract method leads to computing
whole member scopes of given intrefaces, especially when
they contain a lot of methods (i.e. they're definitely not SAMs)

On the other side this method is very hot because it's called
for each Java interface used as a type for some value parameter
(for building SAM adapters)

The idea is to apply some heuristics to understand using only
JavaMethod and supertypes that this interface is definitely not a SAM
2017-04-21 12:48:31 +03:00
Alexander Udalov
1ce4612f74 Refactor module usages in HeaderImplDeclarationChecker
Instead of a vague name "moduleToCheck", use explicit names
"commonModule" and "platformModule".
2017-04-20 22:13:32 +03:00
Anton Bannykh
d5bcf18e5c JS: disable JVM specific part of internal visibility resolution 2017-04-19 18:53:27 +03:00
Simon Ogorodnik
2380e0bacc Optimize PluginDeclarationProviderFactory.getStubBasedPackageMemberDeclarationProvider
Add cache for fast package exists check in specific module
 #KT-16850 fixed
2017-04-18 17:58:45 +03:00
Pavel V. Talanov
c436a9af07 TargetPlatform#getDefaultImports(): cache result in all implementations 2017-04-18 14:59:39 +03:00
Mikhael Bogdanov
46cdf0215e Add codegen tests with substituted bytecode version (1.8->1.9) 2017-04-17 13:22:04 +02:00
Pavel V. Talanov
4f701285b1 Light class builder: do not generate methods delegating to DefaultImpls in kotlin classes
Class APIs from java point of view stays the same so we can avoid generating those methods
Otherwise we have to calculate all supertypes when getMethods() is called,
    which imposes severe performance penalties
We have to pretend these methods are not 'abstract' (also we consider them 'default' for safety)
    so java highlighting does not report "class should be abstract" for all inheritors
We have to manually report "class should be abstract" on some of the java inheritors,
    specifically those that are implementing interfaces directly
	    as opposed to extending kotlin classes implementing those interfaces
2017-04-09 15:09:01 +03:00
Alexander Udalov
d440f07111 Use Java 7+ diamond operator in compiler modules 2017-04-03 14:51:15 +03:00
Alexander Udalov
37f435da93 Use List.sort instead of Collections.sort 2017-04-03 14:50:33 +03:00
Alexander Udalov
a9f35ae898 Replace Map operations with computeIfAbsent 2017-04-03 14:50:32 +03:00
Alexander Udalov
5ebee6ceca Use Java 8 lambdas instead of anonymous classes in compiler modules 2017-04-03 14:49:23 +03:00
Alexander Udalov
34f0576135 Invoke "remove unnecessary final" intention in compiler modules 2017-04-03 14:26:52 +03:00
Pavel V. Talanov
aeda85b256 FileScopeProvider(Impl): use DefaultImplementation annotation 2017-03-30 18:59:17 +03:00
Alexander Udalov
801a93edbc Refactor KotlinJavaPsiFacade.KotlinPsiElementFinderImpl
Split KotlinPsiElementFinderImpl into two classes: one is used in the
compiler (boolean field isCliFileManager previously handled that), the
other is used in IDE and possibly other non-CLI scenarios.

Also avoid a possible class cast exception in
KotlinJavaPsiFacade.knownClassNamesInPackage
2017-03-27 17:19:24 +03:00
Ilya Gorbunov
dce0da68c6 Cleanup: post-cleanup after deprecation cleanup in compiler
Replace `takeIf { !expr }` with `takeUnless { expr }`.
Cleanup redundant parethesis as in `listOf((expr))`.
Replace `listOf(expr)` with `expr.let(::listOf)` where the former caused significant indentation change.
2017-03-23 16:48:38 +03:00
Alexander Udalov
579238c3be Remove deprecated declarations from project code, cleanup usages 2017-03-22 20:25:54 +03:00
Pavel V. Talanov
dbcd141a46 Extract superclass from AnnotationResolver 2017-03-15 20:52:24 +03:00
Pavel V. Talanov
8794005234 JvmPlatform#getDefaultImports: avoid recomputing JvmBuiltins
We need to use LockBasedStorageManager() (instead of NO_LOCKS) since getDefaultImports()
    can be called concurrently in certain scenarios
2017-03-15 20:52:23 +03:00
Pavel V. Talanov
babb3b557d J2K ImportPath: kotlinify 2017-03-15 20:51:17 +03:00
Mikhail Glukhikh
b121bf8802 Cleanup: fix some compiler warnings (mostly deprecations, javaClass) 2017-03-15 17:35:31 +03:00
Mikhail Glukhikh
d0cc1635db Cleanup: apply "Use synthetic property access syntax" 2017-03-15 16:13:40 +03:00
Alexander Udalov
cf7048dd0f Do not inject CompilerConfiguration into compiler front-end
Inject LanguageVersionSettings instead; all information relevant to the
analysis should be now passed via an instance of LanguageVersionSettings
(which should be renamed to a more general name in the future).

This is partially a revert of d499998 and related commits
2017-03-15 11:02:59 +03:00
Alexander Udalov
f5d4dd33da Inject JvmTarget into some JVM-specific call checkers
This makes it possible to drop CompilerConfiguration from
CallCheckerContext, which in turn helps to avoid passing the entire
CompilerConfiguration instance through front-end
2017-03-15 11:02:57 +03:00
Alexander Udalov
573c6ab5d4 Move JvmTarget to frontend.java, introduce TargetPlatformVersion
Previously JvmTarget was declared in module 'util' which is accessible
for example from 'frontend', which is not very good.

Also add a superinterface named TargetPlatformVersion which is going to
be used in platform-independent injectors in 'frontend' in the following
commits. Use it in one place (LanguageVersionSettingsProviderImpl.kt)
instead of DescriptionAware because TargetPlatformVersion sounds like a
better abstraction than DescriptionAware here
2017-03-15 11:02:56 +03:00
Dmitry Petrov
3c09a26e16 KT-5248 Don't wrap variable if it is captured only in inlined closures
Remove non-escaping Ref's on bytecode postprocessing pass.
2017-03-13 09:04:31 +03:00
Mikhael Bogdanov
f2fea9a04a Generate unboxing operation on boxed class not Number.class when possible 2017-03-10 10:04:30 +01:00
Mikhael Bogdanov
5e80d80797 Fix for KT-16732: Type 'java/lang/Number' (current frame, stack[0]) is not assignable to 'java/lang/Character
#KT-16732 Fixed
2017-03-10 10:04:29 +01:00
Dmitry Jemerov
cbccb68948 Fix logic for searching inner classes in LazyResolveBasedCache.findInPackageFragments()
#KT-14058 Fixed
2017-03-09 11:47:21 +01:00
Dmitry Petrov
18fb70b32f Potential fix for KT-16673
See also:
http://stackoverflow.com/questions/42571812/unsupportedoperationexception-while-building-a-kotlin-project-in-idea

'original' for SamAdapterFunctionScope.MyFunctionDescriptor#doSubstitute should exactly match 'this.original',
so we can just provide it by default in SamAdapterFunctionScope.MyFunctionDescriptor#newCopyBuilder.
2017-03-06 22:00:09 +03:00
Mikhael Bogdanov
ff9fe85507 Fix for KT-16614: Report inability to inline 1.8 bytecode into 1.6 bytecode as an error, no as an exception 2017-03-06 15:15:22 +01:00
Alexander Udalov
25c1828288 JS: write and load pre-release flag on binaries 2017-03-03 13:33:51 +03:00
Alexander Udalov
2b1b1fb0d4 Merge VirtualFileKotlinClassFinder into VirtualFileFinder
VirtualFileKotlinClassFinder was the only direct subclass of VirtualFileFinder
2017-03-03 13:33:50 +03:00
Alexander Udalov
abb5bc6aba Simplify VirtualFileFinder and their factories' hierarchy
Since there's no JsVirtualFileFinder anymore, inline JvmVirtualFileFinder into
VirtualFileFinder and drop "Jvm" prefix everywhere
2017-03-03 13:33:50 +03:00
Denis Zharkov
415c3d57af Fix substitutor for synthetic SAM adapters
When synthetic member comes not from the receiver type itself,
but from one of its supertypes it doesn't make sense to subsitute
the member with receiver type, we should obtain relevant supertype
and use it instead.

 #KT-16578 Fixed
2017-03-02 15:06:59 +03:00
Alexander Udalov
12b48f86e7 Do not load error classes in ReflectionTypes
Previously ReflectionTypes.find returned an error class in case a class
is not found in the module dependencies. The problem with this approach
is that each call site should call ErrorUtils.isError on the result and
report an error if needed, in order to stop this type from reaching the
codegen, which can't handle error types.

Now we create a MockClassDescriptor instance instead. It's not an error
class, so it'll be handled correctly in the codegen. Also its scope is
empty and errors are reported on any non-trivial usage (see
MissingDependencyClassChecker), so this approach is not worse than error
classes

 #KT-16484 Fixed
2017-02-28 20:19:58 +03:00
Alexander Udalov
21449763ab Add extension CompilerConfiguration.languageVersionSettings for convenience 2017-02-21 10:58:19 +03:00
Alexander Udalov
d499998655 Inject CompilerConfiguration instead of LanguageVersionSettings
LanguageVersionSettings can be read from the configuration. Also, the
configuration may be used for other stuff, not related to language version
settings, soon
2017-02-20 16:18:00 +03:00
Alexander Udalov
ee1152bc98 Simplify injection of LanguageVersionSettings into JVM analysis
Pass the LanguageVersionSettings instance inside the CompilerConfiguration,
since it's needed anyway. In compiler and tests, the configuration comes from
KotlinCoreEnvironment; in IDE, we're constructing it in JvmAnalyzerFacade
2017-02-20 16:18:00 +03:00