Commit Graph

2513 Commits

Author SHA1 Message Date
Steven Schäfer 6584df3e01 JVM IR: Fix references to const properties in facade classes 2020-02-11 17:01:22 +01:00
Steven Schäfer 058b229544 JVM IR: Handle external static declarations in companion objects 2020-02-11 15:53:25 +01:00
Juan Chen 04e8cba857 [FIR] fixed overridden symbols of "invoke" in KFunction
IR expects overridden symbols of "invoke" in KFunction to be "invoke"
in the corresponding Function classes.
Before this commit we don't set overriddenSymbol, now we do.
2020-02-11 16:09:21 +03:00
Mikhail Glukhikh dc7621a112 [FIR] Fix Java override ambiguity (Kotlin type parameter VS Java Object) 2020-02-11 16:09:20 +03:00
Georgy Bronnikov 17e1f081c7 JVM_IR: handle nested function references in InlineCallableReferenceToLambda 2020-02-10 18:47:04 +03:00
Alexander Udalov 15ff74209c JVM IR: do not resolve fake override in InterfaceSuperCallsLowering
This leads to problems after 4dd794c2d2, because the immediate super
function's DefaultImpls and the implementation's DefaultImpls have
differing type parameters.

Looks like resolveFakeOverride was used here (maybe unintentionally) as
a workaround to the problem caused by the incorrect origin check in
isDefinitelyNotDefaultImplsMethod.
2020-02-10 16:08:10 +01:00
Georgy Bronnikov 182e1c1b3b JVM_IR: Remove buggy special case accessor code from JvmStaticAnnotationLowering
General purpose accessors in SyntheticAnnotationLowering are sufficient.
2020-02-09 13:12:33 +03:00
Steven Schäfer 07737f8fc6 JVM IR: Fix BridgeLowering 2020-02-07 18:44:50 +03:00
Steven Schäfer 5f6af58aeb JVM IR: (Un)mute tests and add more tests for bridge generation 2020-02-07 18:44:50 +03:00
Steven Schäfer 66cbe3b1a8 JVM IR: Remove IrReplacementFunction 2020-02-07 18:44:50 +03:00
Mark Punzalan 8cdef13537 [JVM IR] Add tests to verify correct parameter reflection metadata for
suspend functions.
2020-02-07 12:24:13 +01:00
pyos 06408011f0 JVM_IR: prefer to move, not copy, suspend lambda bodies
Copying breaks reflection metadata.
2020-02-07 12:16:26 +01:00
pyos 08074bb60e JVM_IR: wrap inline suspend references in suspend lambdas 2020-02-07 12:16:26 +01:00
Anton Bannykh 70a4c265de Add tests extracted from regressions 2020-02-06 21:03:41 +03:00
Anton Bannykh 4c4b0ef013 Suspend Functions
2 tests muted due to duplicate variables found by the validator
If memory serves:
- there is a `suspend inline fun` and a callable reference to it
- the suspend function doesn't remove the original function in this
  case anymore
- the duplicate `var`'s are inside the function body and the
  callable reference state machine body
2020-02-06 21:03:40 +03:00
Juan Chen 7249d2f889 [FIR] Fix translation of invokes & add return expressions for lambdas
* fixed NoSuchMethod caused by mismatched signatures of the "invoke" method generated for lambda arguments
* added test cases in invoke.kt for KFunction and anonymous functions
* added a transformer to wrap the last expression in the bodies of lambdas with return
2020-02-06 12:44:14 +03:00
Alexander Udalov 763cb6dd6f JVM IR: keep original KotlinType in eraseTypeParameters
Otherwise EnhancedNullability annotation instance is lost (for some
reason it's not translated to IR elements), and in the newly added test,
the wrapper type in Java is confused with primitive, and this causes
a platform declaration clash error.

Also make IrTypeArgument.eraseTypeParameters private, since it's not
used outside.
2020-02-05 21:51:33 +01:00
Mark Punzalan bc9edea527 [JVM IR] Fix issue with suspend functions in @JvmMultifileClass. 2020-02-05 19:00:54 +01:00
Ilmir Usmanov 8335ad7e98 JVM_IR: Minor. Add test 2020-02-05 15:07:55 +01:00
Ilmir Usmanov e5bd4f74f3 JVM_IR: Do not copy attributes into DEFAULT_IMPLS functions
Otherwise, on creating suspend function views these functions will clash
with interface ones. Instead, compute name of their continuation classes
based on attributes of the interface class.
2020-02-05 15:07:43 +01:00
Ilmir Usmanov fc70455877 JVM_IR: Move suspend function views creation to lowering
Now AddContinuationLowering is responsible for both adding continuation
classes to suspend functions and adding continuation parameters to
them.
Because we cannot create a view if inline suspend function is defined
in another file, we generate a stub without body when we encounter call
to it. And then, when we lower the file containing the function we add
the body. This way we have no unlowered views after the lowering.
Thus, after the lowering there should be no suspend function, which
are not views, therefore, remove VIEW origins.
Because transformations of suspend functions can copy them into another
object, use attribute as a key inside function to view map.
2020-02-05 15:07:37 +01:00
Alexander Udalov 9f9eef44b1 Use captured type approximation from new inference in ExpressionCodegen
This is needed in order to avoid star projections being expanded into
`out Any?`, which is visible for users of `typeOf` since 1.4.

 #KT-30278 Fixed
2020-02-05 13:09:08 +01:00
Mikhail Glukhikh f7d658b624 FIR2IR: fix dispatch receiver generation (non-function case) 2020-02-05 11:19:21 +03:00
Mikhail Glukhikh b09b2673bf FIR2IR: handle non-ambiguous super references properly 2020-02-05 11:19:20 +03:00
Mikhail Glukhikh 71b0840ef9 [FIR] Implement super resolve as a particular tower resolver case 2020-02-05 11:19:19 +03:00
Dmitry Petrov ee020ef290 KT-36336 @EnhancedNullability and null checks
Don't insert implicit null check on a value of @EnhancedNullability type
used where @EnhancedNullability type is expected.

This uncovers a bunch of other problems in FE and BE.
KT-36343 and KT-36347 are bugs in StrictJavaNullabilityAssertions
implementation which should most likely be fixed in next major language
version (with proper breaking change notice).
KT-36344 is a design problem which should be addressed after 1.4 issues
are resolved.
2020-02-05 11:15:41 +03:00
Kristoffer Andersen 4dd794c2d2 [JVM_IR] Propagate Type Parameters to DefaultImpls
This ensures correct generation of generic signatures in the resulting
byte code, but it _is_ a work in progress: the actual type *arguments*
passed for these parameters during compilation are dummy `Any?` types.

Sites that need more work are indicated with TODO's.

- copy type parameters of interfaces to methods moved to DefaultImpls
- implement type parameter renaming scheme from JVM, with proper
  renaming and substitution.
- adjust call sites in bridges in classes->DefaultImpls
- adjust call sites in bridges from DefaultImpls->Interface
- adjust call sites in bridges from DefaultImpls->DefaultImpls
- adjust super calls ->DefaultImpls
- adjust calls in code of Interfaces->DefaultImpls
2020-02-04 17:41:31 +03:00
Denis Zharkov 4f834cb16b FIR: Get rid of replacements map during calls completion
Otherwise, it's complicated to work with nested lambdas:
outer/inner ones may be replaced independently and still refer
to the old one instances.
So in the changed test, if we don't apply the commit, will remain
implicit return and receiver types for the nested lambda

Anyway, once we decided to leave immutable semantics,
replacements are not necessary anymore
2020-02-04 16:24:01 +03:00
Igor Chevdar 8214a9383c Enabled some tests 2020-02-04 16:14:29 +03:00
Jinseong Jeon 451fa245b8 JVM_IR: Change name for (dispatch|extension) receiver of inline class according to naming convention. 2020-02-04 11:52:56 +01:00
Alexander Udalov 19b516cbf4 JVM IR: do not erase static fields in annotation classes 2020-02-04 11:43:24 +01:00
Alexander Udalov 00de5dae32 JVM IR: copy property instead of field in MoveOrCopyCompanionObjectFieldsLowering
This way we're making sure that the copied field has some associated
property, where we can get the value of isConst flag from. That flag is
later used in StaticInitializersLowering to determine whether we need to
erase initializer of a field. The tests are unmuted because now the
initializer is correctly _not_ erased. (They were passing before
switching master to 1.4 because without
NoConstantValueAttributeForNonConstVals, we treated all static fields
with primitive/string values as const, and never erased initializers
because of that.)
2020-02-04 11:43:24 +01:00
Mikhail Zarechenskiy cb07c9172f [NI] Record substituted generic signature for SAM arguments
#KT-36297 Fixed
2020-02-04 10:26:48 +03:00
Mikhail Zarechenskiy 60a2d0f037 [NI] Approximate receivers for callable reference candidates
#KT-36221 Fixed
2020-01-31 18:26:32 +03:00
Juan Chen 188abc243a [FIR] add vararg arguments support, improve vararg parameters support 2020-01-31 16:41:25 +03:00
Mikhael Bogdanov 21d3adf084 Minor. Fix android test compilation 2020-01-31 11:39:55 +01:00
Mark Punzalan 3ee344b836 ForLoopsLowering: Fix issue with break/continue in loop over withIndex. 2020-01-31 10:37:03 +01:00
Alexander Udalov 9f25fdcedc Minor, skip mustBeDocumented.kt for JDK 6 codegen tests
Class.getDeclaredAnnotation is not available before JDK 8
2020-01-31 09:36:17 +01:00
Mads Ager e8a640851a FIR: Change the Fir2Ir handling of smart casts.
Generate the expression with the original type and then insert
an implicit conversion. That matches the behavior of psi2ir
better and therefore avoids breaking backend assumptions.

In particular, IrGetValue expects the type of the underlying
symbol and the type of the IrGetValue to be the same.
2020-01-31 09:31:52 +01:00
Denis Zharkov 47ecaa5b06 FIR: Fix scope intersection types
Otherwise overload resolution ambiguity is reported in the test
2020-01-30 17:12:50 +03:00
Mikhail Glukhikh 2bb5740f47 [FIR] Resolve ambiguities in Java static scopes 2020-01-30 16:28:08 +03:00
Steven Schäfer cf3e4608f3 JVM IR: Support -Xno-call-assertions 2020-01-30 14:43:23 +03:00
Kristoffer Andersen 61e6d346aa [JVM IR] Interface Delegation by Property should use existing field
When a property backed by a final field is the delegate for interface
implementation by delegation, the backend should reuse the backing
field rather than introduce a new, extraneous `$$delegate_n` field.
2020-01-30 14:42:24 +03:00
Mikhael Bogdanov 10900e0d90 JVM_IR. Don't copy synthetic method for property annotations if @JvmStatic presented 2020-01-30 12:31:38 +01:00
Alexander Udalov 186a456e01 JVM IR: fix condition in Documented annotation generation 2020-01-30 00:06:03 +01:00
Mads Ager 73aa36ca59 JVM: Add D8 check that class files can be dexed with D8.
This change adds D8 in addition to Dx which is being deprecated.
At some point after the official Dx deprecation, we should remove
the Dx checker.

Moving to D8 has the additional benefit that D8 can dex code
using java 8 features without using a separate desugaring tool.
2020-01-29 18:00:45 +01:00
Mark Punzalan e226561150 [JVM IR] Copy metadata in IrFieldBuilder.
This fixes an issue with lateinit properties where the metadata from
the original field was not copied to the nullable field in
LateinitLowering. Also consolidated related tests.
2020-01-29 17:12:16 +01:00
Mikhael Bogdanov c42984ca33 Generate proper flags for <clinit> 2020-01-29 16:59:56 +01:00
Mikhael Bogdanov 6c07dbf351 JVM_IR. Support type annotations 2020-01-29 16:59:55 +01:00
Mikhail Zarechenskiy ce690d8a1d Add test for obsolete issue
#KT-36121 Obsolete
2020-01-29 11:43:11 +03:00