116 Commits

Author SHA1 Message Date
Alexander Udalov d757847ed6 JVM: enable -Xlambdas=class for some backend tests
These tests are checking the specifics of the class-generated lambdas.
2023-05-12 15:21:00 +00:00
Alexander Udalov 3120a35a88 JvmDefault: remove most tests on @JvmDefault
The tests are removed because JvmDefault is going to be deprecated with
error in KT-54746 and removed later in KT-57696.

Many of the removed tests already had existing counterparts with the new
modes `all` and `all-compatibility`. In this change, I've added such
tests where they were missing, and removed tests which were testing
behavior specific to the JvmDefault annotation, such as some
diagnostics.

 #KT-54746
2023-04-25 14:33:00 +00:00
Nikolay Lunyak bcfafc601e Add EnumEntries to minimal-stdlib-for-tests
This change allows to revert adding `WITH_STDLIB` directive
to tests which happened at `a9343aeb`.

Co-authored-by: Alexander Udalov <Alexander.Udalov@jetbrains.com>
2023-03-02 10:23:38 +00:00
Nikolay Lunyak a9343aeb7d [FIR] KT-55840: Ensure everything actually works
This inconsistency is present due to not using the `// WITH_STDLIB`
in the above tests. When K1 creates the enum, it tries to generate
`entries()`, and for that it tries to load `kotlin.enums.EnumEntries`,
but this is actually an unresolved reference. K1 silently swallows it,
and proceeds.

The reason K2 doesn't fail is that in order to generate `entries()` it
simply creates the necessary `ConeClassLikeType` with the desired
`classId` instead of loading the whole `ClassDescriptor`.

The reason we can still observe `$ENTRIES` and `$entries` in K1
is because they are generated during the JVM codegen, and it
only checks if the `EnumEntries` language feature is supported. It
doesn't check if the `entries` property has really existed in IR
(by this time it's expected to have already been lowered to the
`get-entries` function - that's why "has ... existed").

The reason why the codegen doesn't fail when working with
`kotlin.enums.EnumEntries` is because it creates its
own `IrClassSymbol`.

^KT-55840 Fixed

Merge-request: KT-MR-8727
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2023-02-10 16:57:51 +00:00
Ilya Chernikov 5b3816cce5 Test infra: refactor IGNORE_BACKEND directive
treat it as a general one, introduce *_K1 and *_K2 variants for
more specific ignoring
2022-11-12 16:28:23 +01:00
Alexander Udalov 3b613b3745 Fix some tests related to direct invoke optimization
- Fix test data of light class tests
  (SymbolLightClassesForLibraryTestGenerated).
- Revert the changes in kt8666.kt because they fail on JS IR, and it
  seems that this test is mostly needed for JS anyway.
- Use 'invoke(' as the pattern in bytecode text tests because plain
  'invoke' is used when these tests are run on JDK 11, where indy string
  concatenation is enabled by default and therefore we reference
  `java/lang/invoke/StringConcatFactory`.
2022-07-15 02:29:01 +02: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
Dmitry Petrov 851980e36f JVM_IR KT-45103 optimize direct invoke for lambdas and callable refs 2021-05-18 22:20:12 +03:00
Steven Schäfer 057ead358c JVM: Add FILE target to the JvmSynthetic annotation (#4149) 2021-03-11 13:33:07 +01:00
Steven Schäfer 4e03b1e05f JVM: Allow the JvmSynthetic annotation on file classes (KT-41884) 2020-11-17 22:06:19 +01:00
Mikhail Zarechenskiy a2da00eb49 Prohibit using DeprecatedSinceKotlin outside kotlin subpackage 2020-06-29 14:25:08 +03:00
Mikhail Zarechenskiy 2f55a3fa0d Add various test for DeprecatedSinceKotlin annotation 2020-06-29 14:23:26 +03:00
Alexander Udalov 012ffa2993 Support new scheme of compilation of OptionalExpectation annotations
Instead of generating these annotation classes as package-private on
JVM, serialize their metadata to the .kotlin_module file, and load it
when compiling dependent multiplatform modules.

The problem with generating them as package-private was that
kotlin-stdlib for JVM would end up declaring symbols from other
platforms, which would include some annotations from package
kotlin.native. But using that package is discouraged by some tools
because it has a Java keyword in its name. In particular, jlink refused
to work with such artifact altogether (KT-21266).

 #KT-38652 Fixed
2020-05-12 19:28:57 +02:00
pyos 82899e6243 JVM_IR: reuse MethodNodes for inline functions in same module
This fixes the weird cases when a class gets overwritten by an imperfect
copy, reduces the number of classes in the output if an inline function
contains an inline call that causes it to have regenerated anonymous
objects, and makes inlining of same module functions a bit faster in
general. On the other hand, this may increase memory footprint a bit
because classes cannot be flushed to the output jar, as the inliner
would not be able to locate classes for anonymous objects if they have
already been unloaded from memory.
2020-04-08 07:04:16 +02: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 dcf6a2199a Generate JvmOverloads methods as final
#KT-33240 Fixed
2020-01-29 18:01:57 +01:00
Mads Ager 1b1dff9191 JVM_IR: fix default argument stub visibility.
Match the rules from the old backend:

1. Private and inline only methods get package private default
   argument stubs.

2. Everything else is public.
2020-01-08 13:19:14 +01:00
Steven Schäfer 7f319c18de JVM IR: Mark Enum.$VALUES field as synthetic (#2957) 2020-01-08 13:17:58 +01:00
Alexander Udalov e2a42446ed Use getter names for $annotations methods in most codegen tests
This is needed to update master to 1.4, while still testing the latest
compiler by default. Also add one test on the old behavior.
2019-12-30 16:29:13 +01:00
Alexander Udalov 0cb48999ff JVM IR: retain optional annotations as package private classes
Similarly to how it's done in the old backend (see
PackageCodegenImpl.generateClassesAndObjectsInFile and
AnnotationCodegen.genAnnotation)
2019-12-18 20:25:11 +01:00
pyos 54d707b3b6 JVM_IR: make constructors of named local classes public
They are accessible through reflection
2019-12-16 20:54:48 +01:00
Kristoffer Andersen 18e8896c08 [JVM IR] Leave private @JvmDefault methods on interface
Like the old backend, always leave private @JvmDefault annotated
interface members (properties, methods) on the interface, just like
the old backend. Fix naming, and introduce test to document the naming
scheme.
2019-12-02 08:19:52 +01:00
Kristoffer Andersen 6f8682c950 [JVM IR] Stabilize accesor names in IR Backend
- introduce a scoped counter instead of a global one for name
  generation for accessors. Naive solution not working.

- Introduced hardcoded "jd" suffix for accessors on interfaces, under
  the assumption that the only such accessors are due to JvmDefault
  and their bridges from `$DefaultImpls`. Removed all associated
  templated tests, so the old and IR backend correspond on this matter
  again.

- Respecialized writeFlags from regexps to string-equality: we are
  going for exact matches now!

- Fixed package calculation in `IrUtils.kt`.

- Accessors for static members must be due to accessing super
  classes. Actual super-qualified calls are naturally also accessing
  super classes. Hence the `$s+{hashcode(superClassName)}`
  suffix. Added test to affirm this naming scheme.

- Field getters/setters for static fields must be companion accessors,
  otherwise just labelled as accessors. They are also tagged with `s`
  suffix when accessing static fields.

- For naming of accessors to coincide with the old backend, field
  renaming to avoid JVM signature clashes must be done _after_
  generation of accessors for those fields.
2019-12-02 08:19:52 +01:00
Mikhael Bogdanov a92afc5a89 JVM_IR. Disable private default flag test
JVM_IR generates `public` flag
2019-11-20 12:57:40 +01:00
Mikhael Bogdanov a214d61567 IR. Change visibility to lowered default function/constructors to public 2019-11-20 12:57:38 +01:00
Mikhael Bogdanov 7bab3a1048 Set non-synthetic origin for generated members of PropertyReference 2019-11-20 12:57:34 +01:00
Steven Schäfer 21af7dfbe1 Add tests for constructors taking inline class arguments 2019-10-18 17:20:22 +02:00
Kristoffer Andersen 9d1d6a7b1f JVM IR: Do not generate DefaultImpls if it's empty. This revealed that InterfaceDelegationLowering was relying on the presence of DefaultImpls even when empty. Hence, simply dropping it from InterfaceLowering was not trivial. Moved default delegation in DefaultImpls to SuperType.DefaultImpls to InterfaceLowering. Clean up logic considerably, and document inter-phase dependencies. 2019-10-09 13:03:21 +02:00
Kristoffer Andersen 5cefd4e443 JVM IR: Implement -Xjvm-default=enable 2019-10-09 13:03:21 +02:00
Steven Schäfer f49d5da929 JVM IR: Fix enum constructor visibility 2019-09-24 13:28:08 +03:00
Kristoffer Andersen 52dc469657 JVM IR: Generate synthetic methods for type aliases with annotations 2019-09-24 12:21:42 +02:00
Steven Schäfer e7410348a7 JVM IR: Fix visibility for @InlineOnly functions 2019-09-06 12:12:58 +02:00
Steven Schäfer ee45933e33 JVM IR: Create local classes in PropertyReferenceLowering
In particular, we should not cache classes or instances for property
references, since they may be used inside of inline funtions. This also
allows us to mark the $$delegatedProperties array as package private.
2019-09-06 12:12:58 +02:00
Steven Schäfer 626f4c94f6 Handle special case visibility rules in LocalDeclarationsLowering 2019-09-06 12:12:58 +02:00
Steven Schäfer fd2ad89799 JVM IR: Write ACC_DEPRECATED flags 2019-08-28 19:41:12 +02:00
Steven Schäfer a90ac2438d Set correct field visibility in psi2ir 2019-08-28 19:41:11 +02:00
Alexander Udalov 01ddac58e1 Add language feature for changed name of property annotations method
#KT-31352 Fixed
2019-08-12 16:48:26 +02:00
Alexander Udalov ea0142da60 Use JVM name of getter in synthetic method for property annotations
#KT-31352 In Progress
2019-08-12 16:48:25 +02:00
Steven Schäfer 0c3c0989b4 JVM IR: Don't move inaccessible const fields out of interface companions 2019-08-09 15:22:30 +02:00
Mikhael Bogdanov 1eda42cb88 JVM_IR. Generate SMAP information for anonymous classes
#KT-28092 Fixed
2019-08-08 12:02:50 +02:00
Steven Schäfer f34a08cbbf JVM IR: Convert interface companion fields to static fields. 2019-08-08 12:01:52 +02:00
Steven Schäfer efb938a7c8 (Un)mute tests 2019-07-31 11:18:44 +02:00
Alexander Udalov 29fa1793d3 JVM IR: add InventNamesForLocalClasses pass 2019-07-17 13:55:36 +02:00
Ting-Yuan Huang a447c748bc JVM_IR: support @JvmDefaults in compatibility mode. 2019-06-06 14:10:28 +02:00
Alexander Udalov f9d61f2dc7 Make inline+reified functions synthetic instead of private in bytecode
#KT-18563 Fixed
2019-05-28 16:17:49 +02:00
pyos 40696f65c3 JVM_IR: generate WhenMappings for enum ordinal subjects 2019-05-13 19:09:07 +03:00
Alexander Udalov e22594acde JVM IR: slightly change field renaming convention implementation
Prefer to rename fields from the class, not from the companion, to be
more in line with the old backend's behavior. This has no effect on the
behavior of current tests but removes differences in metadata (since
metadata has information about every property->field mapping) in some of
them
2019-04-30 13:15:29 +02:00
Mikhael Bogdanov b70ff30dc3 Don't generate bridge flag for defaults in JVM IR backend 2019-04-17 14:53:30 +02:00
pyos fb0261bfc1 Remove JvmDescriptorWithExtraFlags and fix syntheticness
(of fields and classes, it is already correct for methods).
2019-04-09 08:18:14 +02:00
pyos 3fdcf8376f Add IR equivalent of the WriteFlags test 2019-04-09 08:11:29 +02:00