Commit Graph

168 Commits

Author SHA1 Message Date
Jinseong Jeon 078cf02c8a FIR: Provide dispatch receiver for 'field' according to property type 2020-03-30 16:57:53 +03:00
Mikhail Glukhikh d1fc6ff6ee [FIR2IR] Don't provide backing field symbols for non-Java property refs 2020-03-30 16:23:11 +03:00
Mikhail Glukhikh d4ae992417 [FIR] Apply type arguments for callable references 2020-03-30 16:23:11 +03:00
Mikhail Glukhikh 810b607a65 [FIR2IR] Provide receivers also for property callable references 2020-03-30 16:23:10 +03:00
Mikhail Glukhikh 697006d782 [FIR2IR] Re-use receiver application logic in callable ref conversion 2020-03-30 16:23:10 +03:00
Juan Chen d8539fdde9 [FIR2IR] Add dispatch & extension receivers to callable references 2020-03-30 16:23:10 +03:00
Igor Chevdar 90abf1fda0 [JS_IR] Don't capture the bound receiver of a CR 2020-03-28 15:26:19 +03:00
Jinseong Jeon cdf5a2a5a1 FIR: set dispatch receiver parameter for inner class's constructor. 2020-03-25 12:40:09 +03:00
Mikhail Glukhikh 03143bc788 [FIR2IR] Implement mapping of FIR & IR built-in class members 2020-03-24 12:15:18 +03:00
Dmitry Petrov afacb4b4b2 KT-37604 Use proper type when generating constructor call 2020-03-24 11:31:47 +03:00
Mikhail Glukhikh a4c7619c89 [FIR2IR] Introduce & use FirBuiltInsPackageFragment
Without this commit, JVM name mapping logic in BE does not work for FIR,
because FIR cannot use old BuiltInsPackageFragmentImpl descriptor.
In this commit we add our own implementation thus fixing
a pack of FIR black box tests.
2020-03-24 10:37:53 +03:00
Jinseong Jeon e46a4246d2 FIR: regard property accessor without body as FirDefaultPropertyAccessor 2020-03-23 15:12:54 +03:00
Mikhail Glukhikh 9836520287 [FIR2IR] Generate synthetic bodies for Enum.values() and valueOf() 2020-03-20 11:55:34 +03:00
Mikhail Bogdanov bc214868ef Minor. Clean tests 2020-03-19 16:45:10 +01:00
Mikhail Glukhikh 6739135d17 [FIR2IR] Add pre-caching of built-in classes to avoid their duplications 2020-03-18 17:09:37 +03:00
Mikhail Glukhikh 0f0e5e603d [FIR2IR] Use IR built-in types, their symbols & constructors directly 2020-03-18 17:09:36 +03:00
Mikhail Glukhikh 20c4a7b244 [FIR2IR] Introduce staged transformation (first step)
Now FE IR -> BE IR transformation is performed in multiple stages
controller by Fir2IrConverter. Stages are
 * files & classes registration
 * supertypes & type parameters handling
 * functions & properties signature generation
 * body generation

After each step we have guarantee (with exception of local classes &
type inference combination, and external symbols) that required symbols
(class/function/property/variable/type parameter)
are already bound to real declarations and have correct parents.

This commit also fixes incorrect parents for local classes
2020-03-13 12:18:02 +03:00
Dmitry Petrov 90d012cecb Handle unbound extension receiver in callable reference adaptation 2020-03-10 16:56:48 +03:00
Mikhail Glukhikh ed6c9e67a1 FIR2IR: convert qualifiers to companion objects, if any 2020-03-10 15:19:34 +03:00
Alexander Udalov 676ffff015 Minor, fix builtinFunctionReferenceOwner.kt for android-tests
In codegen tests on Android, everything is being run with kotlin-reflect
in the classpath. So a package is no longer represented by a
reflect-less PackageReference, but by a full-blown KPackageImpl. Use a
less specific supertype ClassBasedDeclarationContainer instead, the one
which is a supertype of both PackageReference and KPackageImpl, and
which still allows to get the underlying jClass.
2020-03-10 12:59:54 +01: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
Alexander Udalov 8d7c8672ac Generate reference to existing class for builtin function references
Instead of non-existing `kotlin.KotlinPackage`, which led to
NoClassDefFoundError as soon as reflection tried to call getOwner on a
builtin callable reference, use a reference to a new physical class
`kotlin.jvm.internal.Intrinsics$Kotlin`. This will allow to support
KT-17151.

Note that for API version less than 1.4, this will still lead to
NoClassDefFoundError, but this is not worse than the current situation
where it happens anyway.
2020-03-06 16:55:05 +01:00
Steven Schäfer bb5a639153 JVM IR: Turn static callable references into singletons 2020-03-05 22:19:53 +03:00
Mikhail Glukhikh 940567b8bd FIR2IR: set enum class modality properly for complex entries case 2020-03-04 16:55:33 +03:00
Roman Artemev 5dcac16cf7 [JS IR] Update test data 2020-03-03 18:54:36 +03:00
Roman Artemev 161bb72439 [JS IR] Update test data 2020-03-03 18:54:36 +03:00
Mikhail Glukhikh 2308e5bb7c FIR2IR: in case of use-site generic type use call from original class 2020-02-28 15:29:02 +03:00
Mikhail Glukhikh 096dc25701 FIR: change callableId of fake overrides to derived class owner 2020-02-28 15:29:02 +03:00
Georgy Bronnikov 963258189a JVM_IR: change parameter type computation in InlineCallableReferenceToLambda
The reference type is approximated in Psi2Ir, so we may get Nothing as
a reference type argument. Better look at the arguments of the
referenced function.
2020-02-28 12:59:21 +03:00
Anton Bannykh e7816b4ec2 JS: support callable references with vararg and default parameters conversion 2020-02-27 15:12:49 +03:00
Mikhail Glukhikh a3f676317f FIR2IR: pre-cache type parameters before function creation
Type parameters can be referred from e.g. function return type,
so we should determine them earlier to be able to set their indexes
2020-02-20 18:34:51 +03:00
Juan Chen 9dd8eda1c9 [FIR]: fix library methods in packages
Library methods such as 'listOf' are resolved
to have the package fragments as their parents,
but JVM expects their containing file classes as parents.
This fix generates those file classes and
uses them as parent replacements for such library methods.
2020-02-20 14:24:02 +03:00
Mikhail Glukhikh ace259314b Use 'symbol' instead of 'classId' in FirResolvedQualifier
This commit solves problem with resolved qualifier of local class
#KT-36758 Fixed
2020-02-19 22:41:23 +03:00
Mikhail Glukhikh 9017654b9d [FIR] Handle default parameters when checking callable reference type
#KT-36759 Fixed
2020-02-19 18:09:06 +03:00
Roman Artemev e57d34dd9e Make fix test:
- [JS IR] Unmute fixed tests
 - [IrText] Update testdata
 - [WASM] Temporary turn wasm test off
 - [FirText] Temporary turn fit text tests off
 - [JVM IR] Turn off klib jvm test
 - [IR] Add new test
2020-02-14 18:22:17 +03:00
Denis Zharkov 5a2cdfcab4 FIR: Run callable references resolution for synthetic-select calls 2020-02-12 16:05:11 +03: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
Georgy Bronnikov 17e1f081c7 JVM_IR: handle nested function references in InlineCallableReferenceToLambda 2020-02-10 18:47:04 +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
Mikhail Zarechenskiy 60a2d0f037 [NI] Approximate receivers for callable reference candidates
#KT-36221 Fixed
2020-01-31 18:26:32 +03:00
Mikhail Zarechenskiy ce690d8a1d Add test for obsolete issue
#KT-36121 Obsolete
2020-01-29 11:43:11 +03:00
Ilya Gorbunov 0f6df5971b Mute tests failing in JS_IR backend due to KT-35944 2020-01-16 15:36:16 +03:00
Dmitriy Novozhilov 5111d1721a [TEST] Add js runtime to failing box test 2020-01-15 22:12:29 +03:00
Dmitriy Novozhilov 04ce10b6c1 [NI] Improve completing callable references with type variable as expected type
#KT-32462 Fixed
2020-01-15 22:12:28 +03:00
Steven Schäfer 929fb5c82b Mute FIR tests containing broken function calls 2020-01-08 13:20:00 +01:00
Igor Chevdar 9e17140daf [JS_IR] Turned on passing JS_IR tests 2019-12-24 15:54:45 +03:00
Georgy Bronnikov 92c2cfa968 JVM_IR: handle property references at class level 2019-12-13 20:44:09 +03:00
Mark Punzalan 5afab1ac2b [FIR] FIR2IR: Populate calls with type arguments and function type
parameters with bounds/supertypes.
2019-11-25 09:37:47 +03:00
Pavel Kirpichenkov 8c103629a6 Disable FIR box test for callable references to vararg function 2019-11-22 18:22:04 +03:00
Pavel Kirpichenkov f80a71517f [NI] Handle vararg parameter in reflection type wrt array types
Vararg parameter in reflection type is interpreted as covariant
array type against array in expected functional type and as
vararg element type otherwise. For instance having function
fun foo(vararg args: Int): Unit { /*...*/ }
reference ::foo can be passed against expected
(Int) -> Unit,
(Int, Int) -> Unit, etc.
In none of such cases type for parameter in foo's reflection type
should be changed to array.
However, against expected type (IntArray) -> Unit args' type
must become IntArray.

^KT-25514 Fixed
2019-11-21 20:07:14 +03:00