Commit Graph

2877 Commits

Author SHA1 Message Date
Ilya Muradyan 017f640f26 Allow skipping extensions resolution for implicit receivers 2020-06-19 13:03:23 +02:00
Mikhail Bogdanov 9c0b96af71 Report error on missed specialization in compatibility mode
#KT-39603 Fixed
2020-06-19 11:57:36 +02:00
Mikhail Bogdanov 5bdf3d5757 Don't generate compatibility stubs for @JvmDefaultWithoutCompatibility 2020-06-19 11:57:35 +02:00
Mikhail Bogdanov 477cca3c99 Add JvmDefaultWithoutCompatibility annotation 2020-06-19 11:57:35 +02:00
Denis Zharkov 429b2a9705 FIR: Optimize deserialized annotations loading 2020-06-19 10:21:09 +03:00
Victor Petukhov 901b794af3 Use lexical scope from trace during checking suspend context if the analysis of engaged parent function isn't completed
^KT-39461 Fixed
2020-06-16 22:00:04 +03:00
Ilya Chernikov 484d026d2f Optimize resolution scope queries from the synthetic scopes
now required descriptors are queried in advance and passed to the
methods, to avoid multiple same name queries in a row
2020-06-11 16:16:15 +02:00
Ilya Chernikov bf97323301 Optimize data handling inside scopes 2020-06-11 16:16:14 +02:00
Pavel Kirpichenkov 8ed4424e3e Clean up API of AbstractResolverForProject
Resolution anchors are IDE-specific.
Creating dedicated methods for them in AbstractResolverForProject leads to meaningless
implementation in non-IDE resolvers. Now this method is implemented only
for IDE resolver and accessed through JvmPlatformParameters.

#KT-24309 In Progress
2020-06-05 11:14:01 +03:00
Dmitry Petrov 202bbdf8dd Forward compatibility hacks for Result.{success, failure}
Don't mangled functions annotated with @JvmName.
Annotate 'Result.success' and 'Result.failure' with @JvmName and
@Suppress("INAPPLICABLE_JVM_NAME").
NB this would require bootstrap.
2020-06-04 12:16:27 +03:00
Pavel Kirpichenkov 7fff8f82e2 Changes after review
- Replace leaking ModuleResolverTracker with use of ModuleDescriptor.Capabilies
- Provide API for retrieving ResolverForProject from ResolutionFacade
- Update names
2020-06-03 20:58:07 +03:00
Pavel Kirpichenkov db1210fc67 Introduce components for library-to-source resolution in IDE
#KT-24309 In progress
2020-06-03 20:58:07 +03:00
Mikhail Zarechenskiy 01de789c76 Add compatibility warning for SAM conversions on Kotlin functions 2020-06-01 10:19:32 +03:00
Dmitry Petrov 94509bdb4e KT-39228 Fix inliner when latest 1.4 compiler used with 1.3 stdlib
Since 1.4.0-dev-8774, we mangle functions returning inline class values,
including functions with return type 'kotlin.Result'. This causes
incompatibility when 1.4 compiler is used with 1.3 (or just some
pre-1.4.0-dev-8774) standard library.

Also, write "message from the future" on functions returning inline
class values indicating that they can be used since compiler version 1.4
(otherwise 1.3 compiler using 1.4 stdlib would fail to find some
@InlineOnly functions such as 'Result.success' and 'Result.failure').
2020-05-29 00:53:00 +03:00
Yan Zhulanow 2044ece335 Kapt: Add DUMP_DEFAULT_PARAMETER_VALUES flag (KT-29355)
Put initializers on fields when corresponding primary constructor
  parameters have a default value specified. The new behavior
  is available under the new 'DUMP_DEFAULT_PARAMETER_VALUES' flag.

Note that this doesn't affect regular functions with default parameter
  values, as well as primary constructor parameters without a
  'val' or 'var' keyword.
2020-05-27 02:38:42 +09:00
Dmitry Petrov de4ebe4395 Prohibit @JvnName on functions mangled because of return type 2020-05-20 07:19:29 +03:00
Dmitry Petrov dc9f64fc9d JVM: Fix reflection tests for new IC ABI 2020-05-20 07:19:28 +03:00
Alexander Udalov 0ce16b9d8c Support non-reified type parameters in typeOf in JVM and JVM_IR
#KT-30279 Fixed
2020-05-13 10:04:28 +02:00
Alexander Udalov 012ffa2993 Support new scheme of compilation of OptionalExpectation annotations
Instead of generating these annotation classes as package-private on
JVM, serialize their metadata to the .kotlin_module file, and load it
when compiling dependent multiplatform modules.

The problem with generating them as package-private was that
kotlin-stdlib for JVM would end up declaring symbols from other
platforms, which would include some annotations from package
kotlin.native. But using that package is discouraged by some tools
because it has a Java keyword in its name. In particular, jlink refused
to work with such artifact altogether (KT-21266).

 #KT-38652 Fixed
2020-05-12 19:28:57 +02:00
Mikhail Zarechenskiy fa50d66afe [NI] Fix SAM conversion for projected-out members
#KT-25290 Fixed
2020-04-29 14:15:25 +03:00
Alexander Udalov 9fa8e009c6 Support equals/hashCode for fun interfaces in JVM and JVM_IR
#KT-33455 Fixed
2020-04-29 12:15:50 +02:00
Alexander Udalov b77e5a21ec Report error if fun interface method has JVM name getFunctionDelegate
This is needed so that it wouldn't clash with the corresponding member
from the kotlin/jvm/internal/FunctionAdapter interface, which all fun
interface wrappers will implement to get proper equals/hashCode. The
workaround is to rename the fun interface method.

 #KT-33455
2020-04-29 12:15:50 +02:00
Alexander Podkhalyuzin 6372c01e49 Added missing specificity comparator to FIR
This is required to correctly resolve overloading in cases when we
need to find most specific alternative in Java between int and Integer.
2020-04-28 17:34:42 +03:00
Mikhail Zarechenskiy e0da30fb13 Remove JavaResolverUtils.java as its usages were moved to core 2020-04-15 02:37:35 +03:00
Mikhail Zarechenskiy 9607739d30 Introduce synthetic scope for constructors of fun interfaces
#KT-37434 Fixed
2020-04-15 02:37:34 +03:00
Mikhail Zarechenskiy e9e21caeaf Refactoring: move utils to create & initialize SAM constructors to core 2020-04-15 02:29:57 +03:00
Mikhail Zarechenskiy 04223f5711 Extract Java specific check from common method out
This is needed for further refactoring
2020-04-15 02:29:53 +03:00
Mikhail Zarechenskiy cf90fe81ac Move Sam(TypeAlias)ConstructorDescriptor to core 2020-04-15 02:06:32 +03:00
Mikhail Zarechenskiy 54497d11ac Move SyntheticMemberDescriptor.kt to core
This is a first part of unification SAM constructors for all platforms
2020-04-15 02:06:32 +03:00
Vladimir Dolzhenko 6fae29bcc0 Add more checkCanceled to PsiFacade.findClass
Relates to #KT-38012
2020-04-14 13:11:11 +02:00
Mikhail Bogdanov 7876d821a9 Minor. Rename jvm default utility methods 2020-04-09 07:37:33 +02:00
Mikhail Bogdanov 261af10019 JVM.IR. Add assertions for JVM defaults checks 2020-04-09 07:37:33 +02:00
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