Commit Graph

3045 Commits

Author SHA1 Message Date
Mikhael Bogdanov e45a892499 Support mixed compilation of new default with non-default or @JvmDefault 2020-04-09 07:37:32 +02:00
Mikhael Bogdanov 0570c05683 Rename hasJvmDefaultAnnotation method to isCompiledToJvmDefaultIfNoAbstract 2020-04-09 07:37:30 +02:00
Mikhael Bogdanov bfd709290b Explicitly pass jvmDefaultMode 2020-04-09 07:37:30 +02:00
Kevin Bierhoff 7448761dfd only stub default constructor when compiling against .java source files 2020-04-07 17:48:39 +02:00
Igor Yakovlev 43468c6d55 Filter enum synthetic methods for stub based classes
Fixed #KT-36095
2020-03-30 13:46:08 +03:00
Alexander Udalov 15d2a06132 Extract module 'config.jvm' out of 'frontend.java'
This allows to get rid of dependency cli.common -> frontend.java.
2020-03-28 21:30:04 +01:00
Alexander Udalov a9f7ff254b Add -Xno-optimized-callable-references to disable KT-27362 optimization
This argument is useful in situations where the stdlib version which the
code compiles against is different from the one which is available at
runtime, such as the case of kotlin-gradle-plugin, which depends on the
compiler/stdlib compiled by 1.4, but may be executed in Gradle where
only 1.3.x is available.

 #KT-37435
2020-03-13 10:07:22 +01:00
Mikhail Zarechenskiy 7c86911f44 Filter out PSI values & valueOf methods from Java structure
These methods were recently added in Java PSI for IJ 201 and now have
 clash with the methods that we add on our side. Note that we can't
 start using methods from PSI as is because of different nullability:
 they have flexible types in their signatures while current methods
 have not-null types

 #KT-36095 Fixed
2020-03-12 00:15:03 +03:00
Alexander Udalov 98aecbef6b Optimize runtime representation for callable reference subclasses
Instead of generating overrides for getOwner/getName/getSignature in
each anonymous class representing a callable reference, pass them to the
superclass' constructor and store as fields. This occupies some small
memory but helps to reduce the size of the generated class files, and
will be helpful for adding further runtime information to callable
references, such as information about implicit conversions this
reference has been subject to.

Represent owner as java.lang.Class + boolean instead of
KDeclarationContainer, so that the unnecessary wrapping Class->KClass
wouldn't happen before it's needed, and also to make sure all callable
references remain serializable.

Note that the argument type where the "is declaration container a class"
is passed is int instead of boolean. The plan is to pass the
aforementioned implicit conversion information as bits of this same
integer value.

 #KT-27362 Fixed
2020-03-06 16:55:07 +01:00
Victor Petukhov e8524137c3 NI: exclude not fixed type variables from types on which null checks should be generated
^KT-36371 Fixed
2020-02-19 15:58:08 +03:00
Victor Petukhov f10696da5e Fix formatting of RuntimeAssertion.kt 2020-02-19 15:58:08 +03:00
Yan Zhulanow eb3685d6ac EA-218902: Check PsiElement for validity 2020-02-14 17:35:17 +09:00
Dmitry Petrov 866f188120 Report JVM signature clashes from JVM_IR
Also:

* Do not rename public ABI fields
This includes backing fields for const, lateinit, @JvmField properties,
and instance fields for objects.

* FAKE_OVERRIDE declarations for static members of parent Java classes
Required to report cases when a Kotlin function accidentally overrides
Java class member.
2020-02-13 11:35:48 +03:00
Mikhail Zarechenskiy c1db9b6d40 [NI] Fix incremental compilation for SAM adapters
This commit fixes test:
 - JavaUsedInKotlin.SamConversions#testMethodAddedSamAdapter
2020-02-13 11:16:00 +03:00
Mikhail Zarechenskiy 319a38bd5c [NI-MIGRATE] Update diagnostic messages 2020-02-13 11:15:59 +03:00
Alexander Udalov 953b461c53 Add new compiler errors and flags when JVM compiles against JVM IR
From now on, the old JVM backend will report an error by default when
compiling against class files produced by the JVM IR backend. This is
needed because we're not yet sure that the ABI generated by JVM IR is
fully correct and do not want to land in a 2-dimensional compatibility
situation where we'll need to consider twice more scenarios when
introducing any breaking change in the language. This is generally OK
since the JVM IR backend is still going to be experimental in 1.4.

However, for purposes of users which _do_ need to compile something with
the old backend against JVM IR, we provide two new compiler flags:
* -Xallow-jvm-ir-dependencies -- allows to suppress the error when
  compiling with the old backend against JVM IR.
* -Xir-binary-with-stable-api -- allows to mark the generated binaries
  as stable, when compiling anything with JVM IR, so that dependent
  modules will compile even with the old backend automatically. In this
  case, the author usually does not care for the generated ABI, or s/he
  ensures that it's consistent with the one expected by the old compiler
  with some external tools.

Internally, this is implemented by storing two new flags in
kotlin.Metadata: one tells if the class file was compiled with the JVM
IR, and another tells if the class file is stable (in case it's compiled
with JVM IR). Implementation is similar to the diagnostic reported by
the pre-release dependency checker.
2020-01-29 17:20:41 +01:00
Georgy Bronnikov 8f4b4007fe JVM_IR: Add test for compiling against cross-platform Klib 2020-01-28 12:19:43 +03:00
Dmitry Petrov 2d3a142786 Commonize 'fun interface' handling as much as possible
TODO decide something about SamType.createByValueParameter in case of
out-projected types.
2020-01-28 11:40:14 +03:00
Mikhail Zarechenskiy b75ab5c832 Refactoring: SingleAbstractMethodUtils -> JavaSingleAbstractMethodUtils 2020-01-27 11:03:58 +03:00
Mikhail Zarechenskiy 0530f9ed1c Refactoring: generify and remove duplicated code 2020-01-27 11:03:57 +03:00
Mikhail Zarechenskiy 4e3c27c4ec Refactoring: move SamConversionOracle to core 2020-01-27 11:03:57 +03:00
Mikhail Zarechenskiy 02387e77dd Refactoring: rename SamConversionTransformer -> SamConversionOracle 2020-01-27 11:03:56 +03:00
Mikhail Zarechenskiy 08f80ba15a Refactoring: remove useless method 2020-01-27 11:03:55 +03:00
Mikhail Zarechenskiy 00469712d1 [NI] Don't use only platform specific checks for FIC in inference 2020-01-27 11:03:55 +03:00
Alexander Udalov 5321a6af33 Forbid spread operator in signature-polymorphic calls
#KT-35226 Fixed
2020-01-21 15:57:35 +01:00
Mikhail Zarechenskiy 0fdebdfeba Refactoring: move SamConversionResolverImpl to core module 2020-01-17 19:36:07 +03:00
Mikhail Zarechenskiy cd5c1b96bb Refactoring: move SamConversionResolver to more applicable package 2020-01-17 19:36:07 +03:00
Mikhail Zarechenskiy c93c82236c Refactoring: move common parts about SAMs to frontend module 2020-01-17 19:36:06 +03:00
Mikhail Zarechenskiy fc32e8b017 FIC: Add synthetic constructors for fun interfaces aka explicit FIC 2020-01-17 19:36:05 +03:00
Mikhail Zarechenskiy 0f242a9931 FIC: Support conversions for suspend functions 2020-01-17 19:36:04 +03:00
Mikhail Zarechenskiy 87e79e72a9 Refactoring: move SamConversionResolver to core.descriptors 2020-01-17 19:36:02 +03:00
Mikhail Zarechenskiy c71c1d45c6 FIC: Make SAM conversions also for fun interfaces, add base test 2020-01-17 19:36:01 +03:00
Mikhail Zarechenskiy 193d807a1e Refactoring: make parameters of getFunctionTypeForSamType not null 2020-01-17 19:36:01 +03:00
Mikhail Zarechenskiy 588259a034 Add feature that allows references to synthetic properties with warning
See KT-35933 for details
2020-01-16 09:37:34 +03:00
Alexander Udalov 04a6f4d92b JVM IR: minor, use chars from JvmSimpleNameBacktickChecker in ClassCodegen 2020-01-14 13:54:12 +01:00
Mikhael Bogdanov 2ed0cb2a89 Support type annotations
#KT-35843 Fixed
2020-01-09 14:00:11 +01:00
Mikhail Zarechenskiy e078282767 Fix ambiguity between Java and Kotlin SAM candidates
Because of incorrect flag we generated synthetic SAM candidates and got ambiguity when feature `SamConversionPerArgument` was enabled (Gradle case) because candidates for Java were duplicated

 #KT-35579 Fixed
2019-12-23 12:22:20 +03:00
Denis Zharkov e8131d6e30 Choose Java field during overload resolution with a pure Kotlin property
^KT-31244 Fixed
2019-12-19 10:53:31 +03:00
Victor Petukhov 07269661b4 NI: Allow to resolve to functions with SAM conversion and passing array without spread as vararg (with warning)
^KT-35224 Fixed
2019-12-12 23:46:16 +03:00
Ilya Chernikov 7dd9ed7e38 [NI] Fix loosing type annotations on extension functions
#KT-32138 fixed
2019-11-29 13:44:41 +01:00
Mikhail Zarechenskiy eb73650209 Fix race in IDE: inject proper storage manager for type parameters
With NO_LOCKS strategy we can easily end up in a situation when
 constraint system for a generic call is built incorrectly,
 producing flaky errors (or don't produce errors at all)

 Now proper storage manager is injected for all cases except:
 - IR
 - Codegen
 - Serialization plugin
 - Fake local objects

 Most likely, NO_LOCKS strategy for these cases is fine as at that point
 the compiler works in one thread

 #KT-34786 Fixed
2019-11-26 10:52:45 +03:00
Alexander Udalov 57a674e9e6 Make fast class files reading mode default in compiler tests
This makes sense because this mode is the default in the production
compiler. Forgetting to enable it where necessary led to different
bizarre test failures, see for example changes around 3fee84b966 and
KT-34826
2019-11-11 15:40:49 +01:00
Alexander Udalov 5c89f2fa54 Support KClass.qualifiedName in stdlib-only reflection implementation
#KT-34586 Fixed
2019-10-29 15:51:25 +01:00
Alexander Udalov c164745301 Support KClass.simpleName in stdlib-only reflection implementation
#KT-33646 Fixed
2019-10-29 15:51:21 +01:00
Alexander Udalov df4ab4ed81 Add JVM bytecode target version 13
#KT-34119 Fixed
2019-10-29 12:54:24 +01:00
Mikhael Bogdanov c78dbaf6b3 Initializer default values in 'tailrec' method in proper order
#KT-31540 Fixed
2019-10-17 13:06:36 +02:00
Yan Zhulanow a4c8ccee06 kapt: Fix compilation in 'compile' running mode (KT-33800) 2019-10-08 19:13:57 +09:00
Pavel Kirpichenkov b7e5d9faae Update annotation rendering in diagnostics
Disable annotation rendering in default type and descriptor renderers.
Preserve annotations in Android and Serialization plugins.
Update error texts in ide tests.
Nullability annotations in Java descriptors are rendered with context-dependent renderer.

#KT-20258 Fixed
2019-10-04 11:18:45 +03:00
Alexander Udalov 6ef434a711 JVM IR: add -Xir-check-local-names to check names for consistency
Since KotlinTypeMapper is no longer used in the JVM IR backend, we need
not run CodegenBinding.initTrace and check that names of local entities
are exactly equal to local names computed by that algorithm.

However, it's still useful as an opt-in flag, to discover issues where
unwanted elements take part in the naming (such as temporary IR
variables, see for example cb2e68fece). So we introduce a new command
line argument -Xir-check-local-names which, when the IR backend is used
(via -Xuse-ir), launches the name computation algorithm from the old
backend and then compares that the names are exactly equal to the names
computed by the IR backend in InventNamesForLocalClasses.
2019-09-18 17:55:42 +02:00
Matthew Gharrity a1f4a4572a Check cancelation in KotlinJavaPsiFacade.findPackage()
This may help with some UI freezes caused by KT-33394, although
it does not fix the underlying performance problem.
2019-09-16 10:58:58 -07:00