Commit Graph

47 Commits

Author SHA1 Message Date
Jinseong Jeon ab2a2b3a87 FIR2IR: eager conversion of annotations in Library class and members 2020-06-11 10:57:51 +03:00
Mikhail Glukhikh b2c78e490e [FIR2IR] Remove some descriptor-around calls 2020-06-09 11:40:25 +03:00
Vitaly fe047f9b47 [JS BE] mutes tests for JS_IR_ES6, which muted for JS_IR 2020-05-27 00:32:56 +03:00
Dmitry Petrov 2f82c5b6af JVM: Fix default parameter values handling
When we generate call for 'foo', we make decision about invoking
a 'foo$default' too late, after the call arguments are generated.
If 'foo' was an override, and base class (interface) was generic,
'foo' in base class could have a different Kotlin and JVM
signature, so the arguments we generated could be generated wrong
(primitive or inline class values instead of boxes, see KT-38680).
Also, we always selected first base class in supertypes list,
which caused KT-15971.

Look into resolved call and see if we should actually call
'foo$default' instead of 'foo' when determining actual callable.

Overrides can't introduce default parameter values, and
override-equivalent inherited methods with default parameters
is an error in a child class. Thus, if we are calling a class
member function with a default parameters, there should be one
and only one overridden function that has default parameter values
and overrides nothing.
2020-05-20 07:19:29 +03:00
Mark Punzalan 371c4561a0 [IR/FIR] Use isExpect from IR element instead of descriptor in
ExpectDeclarationRemover.
2020-05-18 17:20:43 +02:00
Mikhail Glukhikh f98c73cb30 [FIR] Support FirMetadataSource.File in FIR2IR & serializer (KT-38156) 2020-04-28 07:35:04 +03:00
Roman Artemev 766b8bf74b [KLIB MPP] Mute broken test
- To fix this test `ExpectActualTable` has to be refactored from usage
 of descriptors to IdSignature since Wrapped and Deserialized descriptors
 for the same declaration are not equal to each other.
2020-04-14 11:12:08 +03:00
Alexander Gorshenev 97be5617ca Renamed -Xklib-mpp to -Xexpect-actual-linker to reduce user confusion 2020-04-08 05:23:12 +03: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
Alexander Gorshenev ab79c3e0a0 Properly mute (and unmute) tests for unrelated backends 2019-12-18 19:29:56 +03:00
Alexander Gorshenev dc8240c24e Expect/actual support in klibs under -Xklib-mpp 2019-12-18 19:29:56 +03:00
Mark Punzalan 9df2f69f09 [FIR] Disable failing blackbox codegen tests for FIR. 2019-11-19 11:00:09 +03:00
Ilmir Usmanov ea5b529d19 Check default parameters of expect suspend functions on original
functions instead of function views.
 #KT-24461 Fixed
2019-11-12 20:12:37 +03:00
Alexander Udalov 4be0e00071 JVM IR: support multi-file classes
Without the `-Xmultifile-parts-inherit` mode for now.

This is implemented as follows: FileClassLowering collects information
about multifile parts and the corresponding facades, which a later
GenerateMultifileFacades phase uses to generate new IrFile instances and
add it to the module fragment that's being compiled.

Note that GenerateMultifileFacades is in the end of lowering phases
because delegates in the facade should be generated for all additional
functions generated by certain lowerings (default arguments,
JvmOverloads, etc.). If GenerateMultifileFacades was right after
FileClassLowering, they would still be generated, but we'd then process
them in lowerings mentioned above, which would result in duplicated
logic in the bytecode. There's a new bytecode text test which checks
that this doesn't happen for functions with default arguments.
2019-08-05 21:27:21 +02:00
Georgy Bronnikov ce6e2621cf Unmute working tests 2019-08-04 01:35:05 +03:00
Alexander Udalov bbbd47ead3 Minor, rename codegen test 2019-06-07 15:01:44 +02:00
Roman Artemev 5686de7e09 [JS IR BE] Make kotlinx.io compile
- Fix expect/actual default arguments
 - Fix dynamic type in inliner
 - Fix external varargs
2019-05-31 13:14:43 +03:00
Ting-Yuan Huang 74e8c7c1c5 JVM_IR: generate default constructor
Quoted from https://kotlinlang.org/docs/reference/classes.html

"On the JVM, if all of the parameters of the primary constructor have
 default values, the compiler will generate an additional parameterless
 constructor which will use the default values. This makes it easier to
 use Kotlin with libraries such as Jackson or JPA that create class
 instances through parameterless constructors."
2019-05-30 18:53:27 +02:00
Mikhail Zarechenskiy bbec3bf001 Fix exception on star import from typealias
#KT-30983 Fixed
2019-05-26 21:32:07 +03:00
pyos 90f11211d3 JVM_IR: wrap performInline in enterIntoInlining/exitFromInliningOf 2019-05-06 16:23:28 +02:00
Svyatoslav Kuzmich b0bd5802bb Remove optionalExpectation hacks
Add common sources to Generate IR Runtime
2019-04-24 13:06:58 +03:00
Alexander Udalov 2f003ef545 Generate classes in MultifileClassCodegen exactly the same as in PackageCodegen
Two known issues with generateNonPartClassDeclarations that was here
before were the fact that we didn't sort sealed classes and its
subclasses which led to NoSuchMethodError (KT-27097), and the fact that
we didn't skip expect classes which led to incorrect duplicate JVM class
name diagnostic (KT-30843)

 #KT-27097 Fixed
 #KT-30843 Fixed
2019-04-10 14:39:16 +03:00
Georgy Bronnikov 451cda79de Rewrite AnnotationCodegen for IR, removing descriptors 2019-03-23 19:04:36 +03:00
Steven Schäfer 3f4c5c8d53 Resolve type aliases when looking for default arguments to actual methods.
Change-Id: I059093c1af32fcd7a2de36c25160c352d6f03a3c
2019-03-14 14:59:34 +01:00
Steven Schäfer 4c8425caeb Run ExpectDeclarationsRemoving in the JVM_IR backend. 2019-03-12 09:29:00 +01:00
Alexander Udalov b8bc79e17c Support non-trivial default argument values in expected functions on JVM
#KT-22818 Fixed
2019-02-26 11:02:30 +01:00
Mikhael Bogdanov 306a982722 Temporary disable line numbers generation for default values from expect declarations
Proper SMAP support for default values from expect declarations is required.
 Default value in expect declaration could has line number that
 exceed line count in actual file that causes an error

  #KT-23739 Fixed
  #KT-29174 Open
2019-01-11 15:27:51 +01:00
Roman Artemev e436e7cf61 [JS IR BE] Support call super with default parameters 2018-12-18 15:55:09 +03:00
Anton Bannykh 3a105debb3 [JS IR BE] fix default arguments lowering 2018-10-18 14:25:48 +03:00
Svyatoslav Kuzmich 02277d0293 [JS IR BE] ExpectDeclarationsRemoving lowering
* Copy lowering from konan to common
* Keep actual default parameters when both actual and expect default parameters are present
* Run lowering before inline in JS IR BE to fix
  box/multiplatform/defaultArguments/inlineFunctionWithDefaultLambda.kt
2018-10-15 00:03:46 +03:00
Alexander Udalov 04ba1cff05 Minor, unmute bothInExpectAndActual.kt for JS_IR 2018-10-01 16:17:14 +02:00
Pavel Punegov 7c2c4e68ce Ignore 2 tests in Native: default arguments got from expect declarations there 2018-09-28 14:22:27 +03:00
Alexander Udalov 3ca81b95c2 Use non-allowed actual defaults in backends to workaround compiler exception
It's difficult to fix KT-22818 until the IR comes along, so we're
providing a workaround where one can disable the
ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS error and provide default values
in the actual function, to avoid exception from the backend.

 #KT-22818
2018-09-21 17:30:05 +03:00
Roman Artemev 8a871b3f0c Update tests 2018-08-31 15:34:18 +03:00
Pavel Punegov 1a7d366733 Disable JVM tests in native 2018-08-28 13:48:44 +03:00
Alexander Udalov e56374908e Disallow using optional annotations outside common module sources
#KT-25196 Fixed
2018-08-21 12:49:10 +02:00
Roman Artemev c62e4b4fcf [JS IR BE] Support coroutines
* Move FinallyBlockLowering to common part
* Fix catching of dynamic exception
* Fix bridges for suspend functions
* Disable explicit cast to Unit
* Run lowering per module
* Update some test data
2018-08-08 18:33:39 +03:00
Mikhael Bogdanov e149cbe852 Mute failed jvm ir tests 2018-06-28 12:26:41 +02:00
Alexander Udalov 1951d38f40 Retain optional expected annotations when compiling platform code
After this change, optional expected annotations will be compiled to
physical class files on JVM, and stored to metadata on other platforms,
to allow their usages from dependent platform modules. For example:

    @OptionalExpectation
    expect annotation class A

When compiling this code on JVM, A.class will be produced as if the
class A did neither have the 'expect' modifier, nor had it been
annotated with OptionalExpectation. Note that if there's no actual
annotation class for A, then usages (which can only be usages as
annotation entries) are simply skipped.

Class A will be public from Kotlin's point of view (since it should
be possible to use it in Kotlin sources), but _package-private_ in Java
to disallow its usages outside of the declaring module.

 #KT-18882 Fixed
 #KT-24617 Fixed
2018-06-26 10:23:55 +02:00
Anton Bannykh 96355e2732 JS IR: mute codegen box tests automatically 2018-06-09 19:15:38 +03:00
Anton Bannykh 03e46ce0ca JS: more default arguments fixes (KT-24413, KT-21968 fixed)
MPP-related:
* inherited from interfaces
* inherited body from interface
* default arguments in an interface, implemented by a class delegate
* super call of a method with default argument

Also:
* inheritance from an interface and another interface descendant (KT-21968)
* inheritance through an intermediate interface
2018-05-28 15:27:21 +03:00
Alexander Udalov bf3419c3bd Introduce OptionalExpectation for annotations missing on some platforms
This commits adds a new annotation OptionalExpectation to the standard
library, which is experimental. To enable its usage, either pass
'-Xuse-experimental=kotlin.ExperimentalMultiplatform' as a compiler
argument, or '-Xuse-experimental=kotlin.Experimental' and also annotate
each usage with `@UseExperimental(ExperimentalMultiplatform::class)`

 #KT-18882 Fixed
2018-05-24 13:14:51 +02:00
Alexander Udalov c63cd430d1 Fix no-arg constructor generation for actual class 2018-04-30 15:26:50 +02:00
Alexander Udalov a8488cf298 Fix JvmOverloads generation for actual methods
`countDefaultParameters` uses `hasDefaultValue` to compute the number of
parameters which have default values, which handles actual parameters
(who have default values in the expected declaration) correctly. Thus,
`getRemainingParameters` should use it as well to determine the list of
parameters to be skipped in each generated overload

 #KT-23910 Fixed
2018-04-30 15:26:50 +02:00
Roman Artemev a121a4a6b2 Added test to check default params in declaration (issue KT-23239) 2018-03-21 12:44:24 +03:00
Alexander Udalov 9e500831dd Allow expect/actual annotation constructors to have default values
When a parameter has a default argument value both in the expected
annotation and in the actual annotation, they must be equal. This check
has been only implemented for the case when actual annotation is Kotlin
source code, and NOT a Java class coming from an actual typealias. The
latter case would require a bit more work in passing a platform-specific
annotation-value-reading component to ExpectedActualDeclarationChecker,
and is therefore postponed.

For now, Java annotations that are visible through actual type aliases
cannot have default argument values for parameters which already have
default values in the expected annotation declaration

 #KT-22703 Fixed
 #KT-22704 Open
2018-02-05 14:13:32 +01:00
Alexander Udalov db4ce703a6 Support default arguments for expected declarations
#KT-21913 Fixed
2018-02-05 13:38:05 +01:00