Commit Graph

5711 Commits

Author SHA1 Message Date
Nikita Bobko f4ba5aaf9a [FE 1.0] Prohibit implicit Java actualization in K1
^KT-58545 Fixed
Review: https://jetbrains.team/p/kt/reviews/10561

It's not yet supported in K2 KT-59213

Related tests:
- ApiTest.testStdlib
- RuntimePublicAPITest.kotlinStdlibRuntimeMerged
- KotlinProjectViewTestGenerated.test_Arrays (in Kotlin plugin)
2023-07-25 22:30:09 +02:00
Roman Efremov ad84c83ee9 [FE] Skip more special annotations in KMP annotation matching
Many errors are reported in stdlib with these annotations
(SinceKotlin, Deprecated, so on).
But having them only on expect is a valid case. E.g. SinceKotlin added
if some old platform-specific API becomes commonized.

^KT-58551
2023-07-24 09:48:49 +00:00
Roman Efremov 234f453173 [FE, IR] Don't check SOURCE annotations if actual declaration has no source
^KT-58551
2023-07-24 09:48:49 +00:00
Nikita Bobko 4f3ecedbca [FE] Stop ignoring ABSTRACT_MEMBER_NOT_IMPLEMENTED for expect classes
^KT-59739 Fixed
Review: https://jetbrains.team/p/kt/reviews/11038/timeline
2023-07-24 09:15:11 +00:00
Pavel Kunyavskiy d797505f06 [K/N] Drop merging forward and real declaration in deserializer
^KT-59643
2023-07-24 08:24:20 +00:00
Svyatoslav Scherbina cba955cb3e Native, K1: add ExperimentalForeignApi to generated forward declarations
cinterop tool should add ExperimentalForeignApi to all generated
declarations, to indicate their experimental status and discourage using
them in public Kotlin API. But the same considerations are applicable
to forward declarations (cnames.*, objcnames.*), which are generated not
by cinterop tool, but directly by the compiler.

This commit adds ExperimentalForeignApi to those compiler-generated
classes.

^KT-58362
2023-07-21 17:44:09 +00:00
Dmitrii Gridin 82061a73eb [util] SmartPrinter: override toString to print content instead of identity hash
Otherwise, all current exceptions contain only something like SmartPrinter@1234
2023-07-21 12:40:00 +00:00
Ilya Kirillov 25911b1fec Move SmartPrinter to kotlin.core.util.runtime so it's accessible from KotlinExceptionWithAttachments 2023-07-18 11:49:20 +00:00
Dmitriy Novozhilov 73b580572b [FE] Move @PrivateForInline optIn into :core:compiler.common
This is needed to be able to use it in backend modules too
2023-07-17 21:02:40 +00:00
Roman Efremov 4a598afc36 [FE] Prohibit expect or actual opt-in annotations
^KT-58554
2023-07-13 08:15:42 +00:00
Abduqodiri Qurbonzoda 7346cf4777 Introduce jdk-api-validator to ensure kotlin-reflect uses jdk6 API
Merge-request: KT-MR-6930
Merged-by: Abduqodiri Qurbonzoda <abduqodiri.qurbonzoda@jetbrains.com>
2023-07-12 05:13:08 +00:00
Nikolay Lunyak 8541143d6f [FIR] Fix the TODO in FirConflictsHelpers
According to
https://github.com/Kotlin/KEEP/blob/master/proposals/enhancing-main-convention.md#rules-and-semantics,
only main function without args may avoid
`CONFLICTING_OVERLOADS`, but since the
jps/jps-plugin/testData/incremental/withJava/other/mainRedeclaration
test dates back to 2015, this is not the
current behavior.
2023-07-10 09:28:54 +00:00
Pavel Kunyavskiy ef9413108b [K/N] Consolidate forward declarations handling
This is refactoring in preparation for KT-59764.
Names and layout of forward declarations related classes
was copy-pasted many times over compiler code.

Implementing KT-59764 would require copy-pasting it two more times.
So instead of doing this it was put in single place.

No behaviour changes intended in this commit.
2023-07-10 08:59:16 +00:00
Pavel Kunyavskiy 0179b45840 Introduce compiler.common.native module 2023-07-10 08:59:16 +00:00
Dmitriy Novozhilov d3a098e7ef [FIR] Remove redundant TODOs from FirSamResolver 2023-07-05 08:25:42 +00:00
Vladimir Dolzhenko 4a7aea0dc6 Change the order of final properties initialization and ctor
To avoid case with NPE due to race-condition on publishing
non-fully initialized object in ctor via
`TypeRefinementSupport.Enabled(this)`

#KT-59852

Merge-request: KT-MR-10917
Merged-by: Vladimir Dolzhenko <Vladimir.Dolzhenko@jetbrains.com>
2023-07-03 10:51:53 +00:00
Ilya Kirillov 5b4916a808 Introduce StandardNames.IMPLICIT_LAMBDA_PARAMETER_NAME
and use it instead of hardcoded constant
2023-06-30 13:43:31 +00:00
Alexander Udalov f5bbf2b4fe Reflection: create synthetic classes for Java lambdas
... as well as $SwitchMap and other synthetic classes generated by javac
or other JVM language compilers or runtimes.

Note that for Kotlin, all synthetic classes were already handled by the
subsequent check for `KotlinClassHeader.Kind.SYNTHETIC_CLASS`, but after
this change we won't call `ReflectKotlinClass.create` for those, which
is a minor optimization.

 #KT-41373 Fixed
2023-06-30 13:11:41 +00:00
Alexander Udalov 5dc882abf5 Reflection: create synthetic classes instead of throwing UOE
... for Kotlin-generated classes which do not correspond to a "class"
from the Kotlin language's point of view. For example, Kotlin lambdas,
file facade classes, multifile class facade/part classes, WhenMappings,
DefaultImpls. They can be distinguished from normal classes by the value
of `KotlinClassHeader.Kind` (which is the same as `Metadata.kind`).

Another theoretical option would be to throw exception at the point
where the `::class` expression is used, if the expression's type on the
left-hand side is a synthetic class. But we can't really do that since
it'll affect performance of most `<expression>::class` expressions.

So, construct a fake synthetic class instead, without any members except
equals/hashCode/toString, and without any non-trivial modifiers. It kind
of contradicts the general idea that kotlin-reflect presents anything
exactly the same as the compiler sees it, but arguably it's worth it to
avoid unexpected exceptions like in KT-41373.

In the newly added test, Java lambda check is muted but it should work
exactly the same as for Kotlin lambdas and other synthetic classes. It's
fixed in a subsequent commit.

 #KT-41373 In Progress
2023-06-30 13:11:41 +00:00
Alexander Udalov d833b732c9 Reflection: support Java anonymous/local classes
Local classes and anonymous objects are normal classes and
kotlin-reflect can load all declarations and modifiers from them, and
support calling members, exactly in the same way as it does for normal
non-local classes.

 #KT-41373 In Progress
2023-06-30 13:11:41 +00:00
Anna Kozlova 137f8b7c70 [decompiler] ensure names starting with numbers are escaped
^ KTIJ-25985
2023-06-23 11:17:46 +00:00
Artem Kobzar 64158a8a2f [K/JS] Add file-to-file compilation ^KT-6168 Fixed 2023-06-22 18:23:45 +00:00
Vladimir Dolzhenko 05652e7d8d Improve exception handling and reporting
#KT-59445
2023-06-22 14:14:18 +00:00
aleksandrina-streltsova d439bdd49f Move ClassId for IntrinsicConstEvaluation to StandardClassIds
^KTIJ-19863
2023-06-22 12:33:52 +00:00
Kirill Rakhman ee91ee9403 [FIR] Set publishedApiEffectiveVisibility on deserialized declarations
#KT-58641 Fixed
2023-06-21 07:34:29 +00:00
Abduqodiri Qurbonzoda 1be0e3f70e Document that arrayOfNulls throws RuntimeException on negative size 2023-06-20 16:31:59 +00:00
Abduqodiri Qurbonzoda da8f9fbd04 Document that array constructor throws RuntimeException on negative size 2023-06-20 16:31:59 +00:00
Abduqodiri Qurbonzoda 60cafc6623 Document the exceptions Iterator throws 2023-06-19 11:41:10 +00:00
Ivan Kylchik 6f4f06757a [IR] Add KType to IrBuiltins 2023-06-14 19:02:39 +00:00
Kirill Rakhman 8ff67218f5 [FIR] Fix serialization of annotation vararg arguments
#KT-58937 Fixed
2023-06-14 08:41:27 +00:00
Dmitriy Novozhilov ba41e8ec38 [IR] Use common expect/actual matching algorithm in IR actualizer
^KT-58578 Fixed
2023-06-10 07:33:29 +00:00
Dmitriy Novozhilov 623019cff1 [FE] Move substitutor related methods to TypeSystemContext
Also use TypeSystemContext instead of TypeSystemInferenceExtensionContext
  in AbstractExpectActualCompatibilityChecker

This is needed to have an ability to implement ExpectActualMatchingContext
  for IR backend. IrTypeSystemContext may operate with type substitutors,
  but there is no sense to implement all methods from TypeSystemInferenceExtensionContext
  in it
2023-06-10 07:33:29 +00:00
Denis.Zharkov 0775748aa9 Postpone enabling JSpecify annotations by default until 2.0
Thus, KT-55586 is being postponed, too.
The reasoning behind this change is that the language-committee issue
has not been approved yet, so new annotation package can't be enabled
by default, but it seems that it doesn't make sense having
a different behavior for the old one but at least that would make them
work consistently, so we postpone them, too.
2023-06-06 12:45:31 +00:00
Kirill Rakhman d1ce55cbd2 [FIR2IR] Fix infinite loop between annotation and annotation parameter
When an annotation constructor value parameter is annotated with the
very same annotation, FIR2IR went in an infinite loop when trying
to generate it.
To fix this, the constructor is added to the Fir2IrDeclarationStorage
cache before generating the value parameters.
To accommodate for the missing parameters, the value arguments count
is determined using the FIR.
2023-05-30 15:53:12 +00:00
Denis.Zharkov 2e5b783cc6 K2: Refine how JDK members are mapped to built-in classes
Previously, the semantic was more-or-less correct for most of the cases
but some corner one, like `sort` in MutableList didn't work properly.

Namely, `sort` should be marked there in a way to forbid to call it
everywhere beside super-calls.
Also, overriding it should be allowed.

Mostly, the logic was re-written to K2 model from K1-related
JvmBuiltInsCustomizer.

^KT-57694 In progress
^KT-57269 Fixed
2023-05-30 10:44:41 +00:00
Alexander Udalov 3eb7ac1aac Remove ReflectProperties.lazy, replace with lazy(PUBLICATION)
There's no point in using `ReflectProperties.lazy` over
`lazy(PUBLICATION)`, especially because of the subtle problems the
former can create, such as KT-27585. This is inspired by the fix in
99b38ccb74, although in this case I couldn't come up with an example
that would lead to a runtime exception.
2023-05-24 16:39:45 +00:00
Dmitriy Novozhilov fdc236296d [FIR2IR] Generate @FlexibleMutability annotation on IR types if needed 2023-05-24 14:07:32 +00:00
Mikhail Glukhikh 2fcd296db8 FE: fix effective visibility bound calculation logic
#KT-58757 Fixed
#KT-58840 Fixed
2023-05-24 08:56:20 +00:00
Roman Efremov 439cc88525 [FE] Prohibit expect external and expect tailrec
^KT-58536 Fixed
2023-05-23 12:43:51 +00:00
Karl Wingblade 72e678ad69 KT-52071 Fallback if sys prop read is blocked
If the Java Security Manager blocks reading the system property
`kotlin.ignore.old.metadata`, then continue gracefully with the
default value.
2023-05-22 16:06:56 +02:00
Kirill Rakhman df03f0df0a [FIR] Implement deprecation for implementing var by inherited val
#KT-56779 Fixed
2023-05-19 15:04:46 +00:00
Ilmir Usmanov f3a22e0ac4 Warn about suspend extension functional types as supertypes
They will become error in 2.0

 #KT-58529 Fixed
 #KT-49175 Fixed
2023-05-19 12:41:37 +02:00
Dmitriy Novozhilov 8338370fbd [FE 1.0] Provide implementation of ExpectActualMatchingContext for FE 1.0
^KT-58578
2023-05-19 10:19:17 +00:00
Dmitriy Novozhilov b26b649d4e [FE] Introduce commonized version of expect/actual compatibility calculator
This is needed to use the same code for those checks between
  both frontends and backend

^KT-58578
2023-05-19 10:19:17 +00:00
Vladimir Dolzhenko 37c493f593 Add missed DOT_DEFAULT_EXTENSION
#KTIJ-25470
2023-05-17 12:45:19 +00:00
Denis.Zharkov b0c5d26d92 Add new JDK-21 List methods to HIDDEN_METHOD_SIGNATURES
Tests are on the way waiting for Build agents with EA version
(KT-58716 for tracking)

^KT-58371 Fixed
2023-05-17 06:42:52 +00:00
Mads Ager 089928ba2b [K2] Support legacy serialization for custom function type extensions.
For Compose libraries, it is important that libraries built with
K2 in version 2.0 can be read and used by a version 1.9 K1
compiler. That is not possible if custom function types are
in the metadata.

^KT-58456 Fixed
2023-05-12 10:49:43 +00:00
Dmitrii Gridin ae88726fae [FIR] treat constructors of local classes as local declarations
The main problem: we are trying to lazily resolve local declaration

^KT-58546
^KT-58490
2023-05-10 09:59:15 +00:00
Anna Kozlova 366c67a668 extract StandartNames.NAME constant 2023-05-09 07:36:10 +00:00
Ilya Gorbunov b35b727d73 KT-53778 Remove experimental annotations from open ranges 2023-04-28 17:12:15 +00:00