Commit Graph

492 Commits

Author SHA1 Message Date
Vsevolod Tolstopyatov fdd541c1e9 Introduce runtime ClassValue-based cache for typeOf machinery
* Cache KType instances constructor from the given classifier
* For generics, cache KTypes with already substituted arguments
* It significantly speeds up all typeOf-based APIs, both accesses to typeOf and its related properties (i.e. classifier)

#KT-53508

Merge-request: KT-MR-6818
Merged-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
2022-08-09 18:40:32 +00:00
Vsevolod Tolstopyatov c6cbab43f7 Introduce KClass-based cache for KPackageFragment
* It is a heavy-weight object that is hard to compute
* It is being constructed each type _cached_ method ref is used in equals/hashCode
* Module name is deliberately ignored, corresponding doc is added where appropriate 

#KT-48136

Merge-request: KT-MR-6817
Merged-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
2022-08-08 15:57:56 +00:00
Svyatoslav Scherbina 09c131afd2 [Native][tests] Add standalone test for KClass package names
To ensure that after introducing `ReflectionPackageName` annotation,
we still have tests that check KClass package names without it.
2022-08-01 15:24:15 +02:00
Mads Ager 59c2bde10a [K/N] Unmute passing tests. 2022-08-01 08:57:16 +00:00
Pavel Mikhailovskii 846537b367 KT-45375 Lightweight lambdas; KT-52817 introduce @JvmSerializableLambda 2022-07-18 17:10:07 +02:00
Steven Schäfer 2acfb3a41f JVM IR: Avoid direct lambda invokes in inline tests 2022-07-14 23:24:18 +02:00
Vladimir Sukharev a9789203ac Run test genericFunctionReferenceSignature.kt only for JVM and native
Merge-request: KT-MR-6636
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2022-07-12 13:07:14 +00:00
Vladimir Sukharev fd52f475cb Devirtualization fails to eliminate boxing in function reference context
^KT-49847 Fixed

Merge-request: KT-MR-6460
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2022-07-12 08:26:27 +00:00
Pavel Mikhailovskii 65b2cee913 KT-23397 Optimize out field for property delegate when it's safe (JVM) 2022-06-07 10:46:01 +00:00
Ilya Gorbunov e14ac2a062 Test kotlin-repeatable annotations on Android
(except for type-use annotations)
2022-06-04 10:39:37 +00:00
Pavel Mikhailovskii 3b5179686e KT-52592 Fix NPE from KProperty.getExtensionDelegate on property delegated to another property; make $delegate methods private 2022-06-01 14:02:28 +00:00
wrongwrong 2da8d53791 Fix callBy for InlineClassAwareCaller in case of >=32 parameters
#KT-51804 Fixed
2022-04-13 23:35:48 +02:00
Ilya Gorbunov 3778b1fde1 Remove ExperimentalStdlibApi no longer required in tests 2022-04-12 15:03:42 +00:00
Alexander Udalov ae2c4753df Fix incorrect test data on KCallable.call for inline classes 2022-03-18 12:29:05 +01:00
Alexander Udalov 8b56babb1d Fix type mapping of nullable inline class types in reflection
Based on #4761.

 #KT-31141 Fixed

Co-authored-by: wrongwrong <boranti1995@gmail.com>
2022-03-18 12:29:05 +01:00
wrongwrong a1b6c9f546 Fixed a bug where DEFAULT_CONSTRUCTOR_MARKER appeared twice as an argument
#KT-27598 Fixed

Co-authored-by: Alexander Udalov <alexander.udalov@jetbrains.com>
2022-03-17 00:54:09 +01:00
wrongwrong c4735f9f29 Add tests for KFunction involving value classes
See KT-31141.
2022-03-10 23:28:40 +01:00
Vladimir Dolzhenko 918a91dbdf Escape special names with backticks in test data
#KT-51248
2022-02-10 21:20:47 +00:00
Ivan Kochurkin 522d2064bb [FIR2IR] Initialize fake overrides for callable references 2021-12-09 12:31:24 +00:00
Mikhail Glukhikh a6d4f9c3b0 FIR: don't change explicitly given anonymous function type 2021-12-09 13:26:40 +03:00
Mikhail Glukhikh 5b058cfcdc FIR2IR: support RawType internal annotation 2021-12-09 13:26:32 +03:00
Igor Yakovlev 4f9b54da26 [WASM] Remove ignore from wasm std text tests 2021-12-07 21:33:28 +03:00
Mads Ager d89680b30d [FIR] Serialize annotations for type parameters properly 2021-12-01 18:25:06 +03:00
Mads Ager f220e4a5ed [FIR] Fix a couple of issues in annotation serialization. 2021-11-30 18:00:00 +03:00
Mikhail Glukhikh cf104c8433 FIR: add status line to all failing black box tests 2021-11-20 03:37:31 +03:00
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00
Alexander Udalov 850d76f6bf Remove error on annotated types as arguments to typeOf
Instead, document that `KType.annotations` returns an empty list for
types created with `typeOf`. Annotations might be supported in the
future.

 #KT-49573 Fixed
 #KT-29919
2021-11-16 15:02:50 +01:00
Igor Yakovlev a7f0f62f69 [WASM] Generate missing WASM tests and mute failing ones 2021-11-15 19:53:49 +03:00
zhelenskiy c1dc1f7e33 Diagnostics renamed
Signed-off-by: zhelenskiy <zhelenskiy2000@yandex.ru>
2021-11-13 12:38:45 +01:00
Dmitry Petrov d5f6674d2d JVM_IR KT-49335 run RepeatedAnnotationLowering per module
Otherwise, we drop annotation constructors in AnnotationLowering,
which breaks RAL in case of annotation container declared in different
file.
2021-10-21 21:22:36 +03:00
Nikolay Lunyak e5d5e5be44 [FIR] Reorder scopes for KT-34822 2021-10-05 19:37:53 +03:00
Mikhail Glukhikh fc6403679a Rename !USE_EXPERIMENTAL test directive to !OPT_IN 2021-09-10 16:29:16 +03:00
Alexander Udalov 04c5bbdcf8 JVM IR: change generation scheme of property $delegate methods
Generate $delegate method as instance method in
PropertyReferenceDelegationLowering, and remove dispatch receiver later
in MakePropertyDelegateMethodsStatic. The method needs to be static to
be non-overridable (see delegateMethodIsNonOverridable.kt), and public
to be accessible in reflection.

Otherwise we generated incorrect IR where a static function accessed an
instance field of the containing class, which failed in multiple places
including LocalDeclarationsLowering.

 #KT-48350 Fixed
2021-08-31 14:07:22 +02:00
Alexander Udalov 0b11d4214c Make typeOf stable since 1.6
#KT-45396 Fixed
2021-08-30 19:36:32 +02:00
Alexander Udalov 0a6d010d1c Support new repeatable annotations in kotlin-reflect
- Unwrap Kotlin-repeatable annotations (with implicit container)
- Introduce `KAnnotatedElement.findAnnotations` to find instances of
  repeated annotations

 #KT-12794
2021-07-30 19:53:33 +02:00
Alexander Udalov 3b513ba299 Minor, add test on typeOf subtyping with mutable collections 2021-07-22 15:55:15 +02:00
Dmitriy Novozhilov 4deb935f76 [FIR] Mark value classes as inline in raw fir building 2021-07-13 10:31:23 +03:00
Alexander Udalov d43ed1cf75 Minor, add test on typeOf with intersection type 2021-07-09 14:53:57 +02:00
Alexander Udalov a7e48c3af1 Improve toString of platform types created by typeOf
In the stdlib implementation, render "!" if the type is only
nullability-flexible. Otherwise, render "($lower..$upper)".

Note that full kotlin-reflect has a much more complicated logic (see
`DescriptorRendererImpl.renderFlexibleType`) that renders things like
`(Mutable)List` and so on. It is not a goal of the stdlib implementation
to replicate all of that, since it requires copying a large amount of
code, namely the entirety of `JavaToKotlinClassMap` to map Java class
names to Kotlin.
2021-07-09 14:53:56 +02:00
Alexander Udalov ddfa94e7e9 Support Nothing type in typeOf
The proper support will come in KT-15518, but that would be a breaking
change even for stable Kotlin without kotlin-reflect. Before that issue
is fixed, represent Nothing in types with the Void class, and use a flag
in the no-reflect implementation to remember that it's not actually the
Void class itself.

 #KT-39166 Fixed
2021-07-09 14:40:05 +02:00
Ilya Muradyan 787ce6335c Change nestedClasses logic to accept classes with nested type aliases
#KT-47650 fixed
2021-07-08 21:04:53 +03:00
Alexander Udalov ae07127f08 JVM IR: support raw types in typeOf 2021-07-01 19:33:56 +02:00
Alexander Udalov 012c7c39af Improve KType.toString for primitive type arguments in stdlib implementation 2021-07-01 19:33:55 +02:00
Alexander Udalov 7306256127 JVM IR: support mutability-flexible types 2021-07-01 19:33:55 +02:00
Alexander Udalov 0cb905a4b1 Support mutable collection types in typeOf
flexibleTypes_1_6.kt is fixed for JVM IR in a subsequent commit.

 #KT-35877 Fixed
2021-07-01 19:33:55 +02:00
Alexander Udalov 6e975b3498 Support flexible types internally in typeOf
#KT-45066 Fixed
2021-07-01 19:33:55 +02:00
Ivan Kochurkin 5741374883 [FIR] Report UPPER_BOUND_VIOLATED only on checkers stage, fix detection of missing cases and testData 2021-06-25 20:57:45 +03:00
Dmitry Petrov 851980e36f JVM_IR KT-45103 optimize direct invoke for lambdas and callable refs 2021-05-18 22:20:12 +03:00
Alexander Udalov 8308f5d7d3 Create array instances of correct types in reflection
Based on #4168.

 #KT-44977 Fixed

Co-authored-by: Arkady Bazhanov <arkady.bazhanov@gmail.com>
2021-05-14 11:16:29 +02:00
Alexander Udalov 21e9bd7ea2 Add regression tests for obsolete issues
#KT-9304
 #KT-14961
 #KT-16549
 #KT-21080
 #KT-28234
 #KT-30102
 #KT-31994
 #KT-34291
 #KT-38099
 #KT-41174
 #KT-44622
 #KT-44701
 #KT-44781
 #KT-44849
 #KT-44978
 #KT-45081
 #KT-45286
 #KT-45383
 #KT-45444
 #KT-45907
2021-04-20 21:24:29 +02:00