Commit Graph

3453 Commits

Author SHA1 Message Date
Alexander Udalov 3a5d0ab427 JVM IR: fix HashCode intrinsic for generics substituted with primitives
The problem here was that although the IR type of the expression was
primitive, the type of the actual expression in the bytecode generated
after type erasure was `Ljava/lang/Object;`, and we were trying to call
a non-existing method `Object.hashCode(Object)`.

 #KT-41669 Fixed
2020-09-08 23:37:00 +02:00
Alexander Udalov c46c80822c JVM IR: fix enclosing constructor for lambdas in inner classes
Before this change, we stored the enclosing constructor in a map in
JvmBackendContext before moving lambdas and local classes out of
initializer blocks. However, in case the lambda was declared in an inner
class, we stored a reference to the unlowered constructor of the inner
class, whose JVM signature is "()V" instead of the correct "(LOuter;)V".
Java reflection then threw exception if we tried to call
`getEnclosingConstructor()` on such class at runtime. Proguard finished
with errors for the same reason.

It turns out that we can just store the fact that the class has been
moved, and load the matching constructor in codegen, where everything is
already lowered and guaranteed to match with the signatures of the
actual generated declarations.

 #KT-41668 Fixed
2020-09-08 23:37:00 +02:00
Alexander Udalov 228e329d1f JVM IR: generate enclosing constructor only for lambdas in initializers
There was a typo in JvmLocalClassPopupLowering which allowed the
EnclosingMethod for lambdas and anonymous classes in initializers to
become any function in a class, in case when there was no primary
constructor in that class. E.g. in the added test, `getIrrelevantField`
was the EnclosingMethod of the lambda class before this change.
2020-09-08 23:37:00 +02:00
Mads Ager 06680452dc [JVM_IR] Always look for default lambdas in the inliner.
This allows compiler plugins such as Compose to do custom
default argument handling in methods that do not have origin
`FUNCTION_FOR_DEFAULT_PARAMETER`.

The code still bails out early is there is not defaults
mask, so there should be no compile-time penalty.
2020-09-08 19:07:31 +02:00
Steven Schäfer 44ffb1fb3e Psi2Ir: Fix SAM conversion with new inference 2020-09-08 11:14:14 +03:00
pyos f198a19ab0 FIR2IR: add local delegated property generation 2020-09-08 08:40:07 +03:00
Steven Schäfer 4792be2522 JVM IR: Optimize static property references (KT-36975) 2020-09-07 21:01:29 +02:00
Dmitry Petrov 5b53663eb8 PSI2IR KT-41181 don't generate deep trees in hashCode 2020-09-07 16:09:42 +03:00
Dmitriy Novozhilov d1fd1da56f Rename Visibility to DescriptorVisibility 2020-09-04 11:07:42 +03:00
Dmitriy Novozhilov 64ec3fc42b Move BuiltinSpecialProperties and JvmAbi to :core:compiler.common.jvm 2020-09-04 11:07:41 +03:00
Dmitriy Novozhilov 4d5f28d5c0 Move FunctionInvokeDescriptor.BIG_ARITY to :core:compiler.common 2020-09-04 11:07:41 +03:00
Dmitriy Novozhilov bf4bf30b4a Move CompanionObjectMapping to :core:compiler.common 2020-09-04 11:07:40 +03:00
Dmitry Petrov dd016b759e JVM_IR: write raw types as raw in JVM generic signatures 2020-09-04 10:21:49 +03:00
Dmitry Petrov 475522f938 Represent raw types in IR using a special type annotation 2020-09-04 10:21:48 +03:00
Dmitry Petrov 714ab7c37f Handle java raw types in IR
Raw type Q is represented as a flexible type
  Q<B1, ... Bn> .. Q<*, ... *>
where Bi is a representative upper bound of the corresponding ith type
parameter of Q.
When mapping generic signature, JVM takes type arguments of lower bound
(which is 'Q<B1, ..., Bn>').

There is still some difference in how JVM and JVM_IR handle raw type in
signature. It requires additional investigation.
2020-09-04 10:21:48 +03:00
Mark Punzalan 16ab11289c [JS_IR] Enable RangeContainsLowering optimizations. 2020-09-03 18:42:35 +03:00
Roman Artemev 685b74769d [JVM IR] Fix lineNumber passing into CoroutineTransformer.
- Get it from `IrFile` & `IrElement.startOffset` instead of descriptor
 - Unmute stepping tests
2020-09-03 11:37:24 +03:00
pyos 6b65a2ea7d JVM_IR: move classes out of lambdas inlined into initializers
Fixes KT-41465
2020-09-02 20:03:38 +02:00
Roman Artemev fdbc657656 [IR] Fix isFileClass checker 2020-09-01 18:53:17 +03:00
Roman Artemev cae29a5d1c [IR] Clean up WrappedDescriptors API 2020-09-01 17:08:11 +03:00
Roman Artemev c7b57c0fb3 [IR] Use only empty constructor to create WrappedDescriptor 2020-09-01 17:08:11 +03:00
Roman Artemev fd88914cf9 [IR] Remove some descriptor usage from Common/JS/JVM backends
- replace descriptor-based builders with pure IR ones
 - fix matchers
 - fix Ir2Js
 - rewrite some inliner-helpers to pure-IR implementations
2020-09-01 17:08:11 +03:00
Dmitry Petrov 8cb8284957 EnhancedNullability annotation in IR
Fixes KT-40115 & KT-40117.

Move FlexibleNullability annotation to 'kotlin.internal.ir'.
2020-09-01 16:06:03 +03:00
Roman Artemev e592b3af1d [JS IR] Fix CallsLowering's*
- need to fix dev mode since some methods are not handled
 with intrinsic lowering
2020-09-01 14:53:08 +03:00
Roman Artemev 7a6415dc53 [JS IR] Enable IrError element's lowerings in JS 2020-09-01 14:53:08 +03:00
Roman Artemev 4dca3715fa [JS IR | IR] Implement error element lowering to support compilation with errors 2020-09-01 14:53:08 +03:00
Roman Artemev 14b5424583 [JS IR] Support translation of IrError* elements 2020-09-01 14:53:08 +03:00
Roman Artemev 1fd5c1cc65 [IR] Support IrErrorType & IrErrorDeclaration in ir mangler 2020-09-01 14:53:08 +03:00
Roman Artemev 9c36487077 [IR] Disable mangle checker for IrErrorDeclarations 2020-09-01 14:53:07 +03:00
Roman Artemev 563af709a8 [Psi2Ir] Fix generation of IrError* nodes
- Provide detailed description
 - Support syntax-incorrect statements
 - Generate an error declaration if normal generation has failed
2020-09-01 14:53:07 +03:00
Roman Artemev a60782f3df [JS IR] Add CLI argument to setup error tolerance policy
-  Make sure dev mode is enabled if code with errors is allowed
2020-09-01 14:53:07 +03:00
Dmitriy Novozhilov f010dc533c Move Variance.convertVariance to :core:compiler.common 2020-09-01 12:00:11 +03:00
Igor Chevdar 5e71068e61 [IR] Handled degenerate cases of IrStringConcatenation
It is not needed to create StringBuilder if the number of values
being concatenated is 0 or 1
2020-09-01 11:34:17 +05:00
Steven Schäfer 78ab957bfe JVM IR: Fix mangling for suspend functions with inline class params (KT-41374) 2020-08-31 18:43:29 +02:00
Alexander Udalov a639915a34 JVM IR: do not mangle property accessors of unsigned types in annotations
Before this change, we incorrectly mangled the names of annotation
methods (e.g. `getI-pVg5ArA` instead of `i`) because the isSpecial
condition was false.
2020-08-31 14:19:14 +02:00
Alexander Udalov 1e712f8398 IR: remove IrElementVisitorVoidWithContext
It was only used as a superclass in IrInlineReferenceLocator and
LocalDeclarationsLowering. In both cases it's clearer and more optimal
to pass the necessary data via the visitor 'data' variable.
2020-08-31 12:47:54 +02:00
Alexander Udalov 5e48be3d11 Add a fallback flag -Xno-unified-null-checks for KT-22275
#KT-41482 Fixed
2020-08-31 12:43:28 +02:00
Igor Chevdar ab54e43b00 [IR] Commonized SAM equals/hashCode builder 2020-08-31 12:01:29 +05:00
Igor Chevdar 12ddd137bc [IR] Moved isLambda to common IR utils 2020-08-31 12:01:29 +05:00
Steven Schäfer b02f0f0a25 JVM IR: Fix compilation of nested inner classes 2020-08-28 20:03:19 +02:00
Steven Schäfer 02e78bcd76 JVM IR: Use package visibility for fields of captured variables 2020-08-28 20:03:19 +02:00
Roman Artemev 443269af0a [IR] Drop irProviders from stub generator 2020-08-28 18:14:05 +03:00
Roman Artemev 39808789c3 [KLIB] Fix SOE in K/N
- fixes KT-41324
2020-08-28 18:14:04 +03:00
Zalim Bashorov 606232a584 [JS IR] Don't generate "import" statements for external interfaces
#KT-40964 fixed
2020-08-28 13:14:22 +03:00
Zalim Bashorov ba846830c9 [JS IR] Support nativeGetter, nativeSetter and nativeInvoke
#KT-41081 fixed
2020-08-28 13:04:18 +03:00
Dmitriy Novozhilov 12fbb93871 [NI] Extract FE 1.0 specific part from NewCommonSuperTypeCalculator 2020-08-28 10:59:51 +03:00
Alexander Udalov 9d81e50128 IR: undeprecate IrUninitializedType
It's no longer a temporary hack, see the comment.
2020-08-27 18:02:04 +02:00
Alexander Udalov a9ddf02556 Replace deprecated usages of max/min with maxOrNull/minOrNull 2020-08-25 20:33:59 +02:00
Dmitriy Novozhilov a764732020 Rename KotlinBuiltInsNames to StandardNames 2020-08-25 10:41:33 +03:00
Dmitriy Novozhilov 45cf221b97 Move util functions from KotlinBuiltIns to :core:descriptors.common module 2020-08-25 10:31:36 +03:00