Commit Graph

2749 Commits

Author SHA1 Message Date
Ilya Kirillov f1f6740ec9 Show warnings for Java methods with external annotations when they called from Kotlin code 2019-03-27 20:10:46 +03:00
Denis Zharkov 82c6b51fab Simplify initialization process for JavaClassFinderImpl
After this change, it's not required to call "initialize" with
binding trace and KotlinCodeAnalyzer that is rather useful for FIR
2019-03-27 17:17:59 +03:00
Alexey Tsvetkov db6a7779b8 Check friend jars paths for exact match
Fixes CompileKotlinAgainstCustomBinariesTest.testInternalFromForeignModule
after unifying non-build-file mode and build-file mode.

Previously when the compiler was run without -Xbuild-file argument,
it was not using modules internally, so we were not checking if internal
descriptors were contained in destination dir of current module
(without -Xbuild-file we were returning false at `if (modules.isEmpty())
return false` in `ModuleVisibilityHelperImpl#isInFriendModule`).

After switching to using modules for CLI compilation,
any jar file contained in destination dir was considered friend,
because only a prefix was checked.
2019-03-25 16:39:47 +03:00
Alexander Udalov 87c6b723f0 Add JvmBuiltIns.Kind instead of boolean flags in constructor 2019-03-22 14:59:03 +01:00
Alexander Udalov ed86757817 Rework how built-in types are loaded in compiler for JVM
In TopDownAnalyzerFacadeForJVM, we now always use the "load built-ins
from module dependencies" behavior that was previously only enabled with
the dedicated CLI argument -Xload-builtins-from-dependencies. However,
sometimes we compile code without kotlin-stdlib in the classpath, and we
don't want everything to crash because some standard type like
kotlin.Unit hasn't been found.

To mitigate this, we add another module at the end of the dependencies
list, namely a "fallback built-ins" module. This module loads all
built-in declarations from the compiler's class loader, as was done by
default previously. This prevents the compiler from crashing if any
built-in declaration is not found, but compiling the code against
built-ins found in the compiler is still discouraged, so we report an
error if anything is resolved to a declaration from this module, via a
new checker MissingBuiltInDeclarationChecker.

Also introduce a new CLI argument -Xsuppress-missing-builtins-error
specifically to suppress this error and to allow compiling code against
compiler's own built-ins.

 #KT-19227 Fixed
 #KT-28198 Fixed
2019-03-22 14:59:03 +01:00
Alexander Udalov 05700b8c43 Use JvmResolveUtil.createContainer in AbstractDescriptorRendererTest 2019-03-22 14:59:03 +01:00
Mikhail Glukhikh 484e67727f JavaClassifierTypeImpl: convert to Kotlin & cleanup 2019-03-14 17:56:57 +03:00
Mikhail Glukhikh 21d19f4144 JavaClassifierTypeImpl.java -> kt 2019-03-14 17:56:41 +03:00
Alexander Udalov d12e5ddafc Generate bytecode for array intrinsics manually
#KT-28285 Fixed
2019-03-11 18:36:10 +01:00
Alexander Udalov f9be21c935 Report warning on @Synchronized on inline methods
Until KT-27310 is supported, we warn users that this has no effect.

 #KT-29884 Fixed
2019-03-11 18:32:44 +01:00
Alexander Udalov 518b03125c Support JVM target versions up to 12
#KT-26240 Fixed
2019-03-07 11:42:31 +01:00
Alexander Udalov c7c377e1b1 Use JvmTarget.DEFAULT instead of JVM_1_6 where applicable 2019-03-07 11:42:31 +01:00
Alexander Udalov 59fda8d7ce Support JvmPackageName with JvmMultifileClass
This is an internal feature of our standard library needed to compile
new API for unsigned types
2019-03-06 15:34:23 +01:00
Alexander Udalov d1e33534db Implement typeOf intrinsic on JVM
#KT-29915 Fixed
2019-03-05 18:16:31 +01:00
Alexander Udalov 5d297c40fd Minor, move ReifiedTypeParameterSubstitutionChecker to PlatformConfiguratorBase 2019-03-05 17:58:10 +01:00
Natalia Selezneva 254374c619 Use ModuleInfo in VirtualFileFinder to add script dependencies in search scope
Otherwise it prevent to inline functions from those dependencies during scratch compilation
2019-02-20 18:36:38 +03:00
Mikhael Bogdanov a020170a92 Report missed INLINE_FROM_HIGHER_PLATFORM diagnostic for derived class
Inline function descriptor in derived class represented as FAKE_OVERRIDE.
 So we should find it in base class declaration
 (not interface cause inline function can't be virtual, but always final)
 and then check class version.

 #KT-29402 Fixed
2019-02-19 10:51:36 +01:00
Mikhael Bogdanov b03065b2ba Minor. Reformat 2019-02-19 10:51:35 +01:00
Alexander Udalov f2bf81e799 Fix UOE when using Java annotation with infinity/NaN as default value
The root problem is the fact that ConstantExpressionEvaluator returns
null for values such as infinity and NaN loaded from cls psi (see
IDEA-207252). This commit simply reverts a part of 8ab9226805 where we
started to compute default values more often than needed. In
LazyJavaClassMemberScope, we only need to check whether or not there
_is_ a default value, not compute its value.

 #KT-29792 Fixed
2019-02-15 19:13:53 +01:00
Denis Zharkov abad408d7b Do not implicitly propagate deprecations originated in Java
^KT-29604 Fixed
2019-02-13 16:21:05 +03:00
Alexander Udalov db487a622a Add -Xsanitize-parentheses to workaround ASM 6.1 issue in frame computation
#KT-29475 Fixed
2019-01-31 15:47:43 +01:00
Mikhael Bogdanov a122cba862 Switch Kotlin project to jvm-target 1.8
#KT-29405
2019-01-31 07:43:05 +01:00
Alexander Udalov f2bf0dc236 Drop unneeded synthetic package fragment construction from KotlinBuiltIns
Instead use package views of builtInsModule
2019-01-28 15:18:52 +01:00
Sergey Rostov 0f2fb4ff82 Build: remove intellijCore/annotations.jar usages 2019-01-28 13:43:08 +03:00
Alexander Udalov a2f4efbc2a Report error on state in multi-file class with -Xmultifile-parts-inherit
Simplify MultifileClassPartCodegen, remove related tests and change some
tests to use const val instead of val because backing fields for const
properties are stored in the facade, not parts

 #KT-23701 Fixed
2019-01-25 15:57:13 +01:00
Alexander Udalov 6b5a16884c Refactor inheritMultifileParts to be a JVM analysis flag
Instead of a JVMConfigurationKeys key. This will allow to use it in a
checker in 'frontend.java'
2019-01-25 15:57:13 +01:00
Vyacheslav Gerasimov 13d87e8eae Remove as31 bunch files 2019-01-14 21:29:02 +03:00
Denis Zharkov 254380d418 Generate special bridges for removeAt/getOrDefault
In case we extending some Map specialization with non-trivial type arguments,
e.g. Map<String, String> from Kotlin point-of-view it has
"remove(String, String)" signature while in Java it's "remove(Object, Object)".

So, we generate an override "remove(String, String)" in first Kotlin class of the hierarchy,
which body delegates to "super.remove(Object, Object)"

Also, we generate a final override for "remove(Object, Object)" to allow
for Java inheritors choose only the version with String while overriding.

The main idea of the fix is to make mayBeUsedAsSuperImplementation
return true in case of PlatformDependent annotations.
Otherwise, we weren't able to choose the impl from the java.util.Map
as a delegate in our bridge.

Another part of the fix is overriding `isDeclaration`:
it was necessary because otherwise bridge-generation algorithm
was assuming that there's already an actual declaration
in the first sub-class (TestMap) in the test and we need to
delegate to the latter instead of the method from the interface

^KT-26069 Fixed
2019-01-14 14:54:18 +03:00
Nikita Katkov 4db9174b4d Error on calling suspend functions inside Lock.withLock body
See SuspensionPointInsideCriticalSectionChecker
2018-12-28 19:56:26 +03:00
Alexander Udalov 8ab9226805 Fix loading default Java annotation values in actual typealias from binary classes
#KT-22704 Fixed
2018-12-28 13:02:15 +01:00
Mikhail Zarechenskiy e4a4d1169e Prohibit JvmOverloads on constructors of annotation classes
In LV >= 1.4 & -progressive

 #KT-25702 Fixed
2018-12-24 12:48:00 +03:00
Mikhael Bogdanov c19c979b7d Use last asm api for visitor construction 2018-12-20 12:55:09 +01:00
Mikhael Bogdanov 1a0c3dfaa6 Use last ASM version to read binaries
#KT-28798 Fixed
2018-12-17 12:18:52 +01:00
Denis Zharkov a422db91b2 Transform KotlinClassFinder::findKotlinClass to extension 2018-12-13 20:38:25 +03:00
Denis Zharkov f153d97f40 Avoid multiple subsequent reading of the same class-file in front-end
^KT-23466 Fixed
2018-12-13 20:38:24 +03:00
Denis Zharkov bc61e5a3bc Minor. Reformat BinaryJavaClass 2018-12-13 20:37:46 +03:00
Yan Zhulanow 3c8714696d Add a LookupLocation to 'getSyntheticExtensionProperties()', use it in 'DebuggerFieldSyntheticScopeProvider' 2018-12-12 21:40:43 +09:00
Yan Zhulanow ada71ce3cd Evaluate: Use '<name>_field' syntax for field value evaluation (KT-14075) 2018-12-12 21:40:42 +09:00
Yan Zhulanow c2f33c0dfd Provide a default implementation for 'SyntheticScope' 2018-12-12 21:40:42 +09:00
Denis Zharkov a83f0e5fb7 Add diagnostic for calling ConcurrentHashMap::contains by convention
^KT-18053 Fixed
2018-12-12 15:37:50 +03:00
Alexey Tsvetkov f231817559 Delay I/O when transforming ABI classes 2018-12-11 22:48:53 +03:00
Simon Ogorodnik e3aed04d96 Extract module info & target platform to separate frontend.common 2018-12-11 22:07:41 +03:00
Andrey Uskov c85f56a0a8 Remove some bunches for build scripts. 2018-12-06 19:44:09 +03:00
Denis Zharkov d7d0407afb Fix parameters nullability for generated overloads in light classes
When making KtLightNullabilityAnnotation after test org.jetbrains.kotlin.idea.caches.resolve.IdeLightClassTestGenerated.NullabilityAnnotations#testJvmOverloads
started failing the wrong assumption was made that for
@JvmOverloads-generated overloads their last parameter is always nullable
(see removed isNullableInJvmOverloads function) and that lead to a bug,
namely KT-28556.

The actual problem of this test started failing was incorrect definition
of kotlinOrigin in KtLightParameter for case of JvmOverloads:
wrong KtParameter was being chosen before

This commit fixes the issue by propagating how actually generated
parameters in codegen relate to source KtParameters'

^KT-28556 Fixed
2018-12-05 16:34:44 +03:00
Mikhael Bogdanov 7ee13ca353 Generalize parameter index calculation in ASM 7 support
Second part for d2a205c72d commit

 #KT-27774 Fixed
2018-11-29 16:45:50 +01:00
Yan Zhulanow 11e23ecc70 Kapt: Fix 'apt+compile' mode, clear package caches directly 2018-11-27 22:21:23 +09:00
Alexander Udalov 4c64db66dc Use File.toPath instead of Paths.get+File.toURI in moduleVisibilityUtils
#KT-27930 Fixed
2018-11-15 16:51:37 +01:00
Alexey Tsvetkov 78ee48e1cd Minor: add missing import 2018-11-13 22:11:18 +03:00
Alexander Udalov 3bfe138dbe Support KClassValue in JavaActualAnnotationArgumentExtractor
#KT-22704 Fixed
2018-11-13 19:05:14 +01:00
Alexander Udalov 49d6a7a7cb Refactor and improve code obtaining actual Java annotation parameter values
Extract Java-specific code into module 'frontend.java' and use already
existing JavaAnnotationArgument facilities to determine the default
parameter value in an actual Java annotation class.

Annotation arguments are not yet supported because to create an instance
of AnnotationValue, we need a descriptor, which is not available at this
point.

 #KT-22704 In Progress
 #KT-28077 Open
2018-11-13 19:05:14 +01:00