Commit Graph

193 Commits

Author SHA1 Message Date
Victor Petukhov a264cbfe7d Move CallUtil.kt under the resolve.util package 2021-09-27 16:12:01 +03:00
Victor Petukhov 1635bcad10 Move CallResolverUtil.kt under the resolve.util package 2021-09-27 16:12:00 +03:00
Vyacheslav Gerasimov ab146bd6d4 Build: Fix deprecated Gradle configurations usages
for migration to Gradle 7+ #KTI-559
2021-09-26 18:28:44 +03:00
Ilmir Usmanov 486c6b3c15 Remove obsolete experimental coroutines support
in compiler.
2021-08-13 22:31:30 +02:00
Dmitry Petrov c77884f067 Refactor SAM type handling, replace non-approximated arguments with * 2021-06-22 21:13:56 +03:00
Victor Petukhov 4aeabb6b0f Use upper bound aware type approximator for intersection types inside sam types in contravariant positions to build proper types in terms of subtyping 2021-06-22 21:13:55 +03:00
Alexander Udalov b2005302dc JVM, JVM IR: erase generic SAM supertypes
Also, do not try to use invokedynamic on SAM calls with intersection
types, because intersection type is not allowed as an immediate type
projection of a supertype, and constructing a fake override in
LambdaMetafactoryArgumentsBuilder led to an exception. This fixes the
problem which was worked around earlier in e6c089ef, effectively
reverting that commit.

The main motivation for this change is that LambdaMetafactory also
doesn't generate generic signature for SAM wrapper classes at runtime.
Since these classes are synthetic, nobody should rely on the fact that
they have generic supertypes, which was observable only via Java
reflection.

 #KT-46149 Fixed
 #KT-46238 Fixed
2021-04-22 10:53:15 +02:00
Alexander Udalov e6c089ef40 IR: fix SAM conversion for types with contravariant intersection argument type
In the added test, the problem was that the SAM type as computed by
`SamTypeFactory.createByValueParameter` was `Consumer<{BaseClass &
BaseInterface}>`, which was latter approximated in psi2ir during the
KotlinType->IrType conversion to `Consumer<out Any?>` (here:
https://github.com/JetBrains/kotlin/blob/3034d9d791cf1f9033104e12448e0d262d3bc3ce/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ArgumentsGenerationUtils.kt#L606),
because intersection type argument is approximated to `out Any?`.

To avoid this, replace intersection type in immediate arguments of a SAM
type with the common supertype of its components at the same place where
we're getting rid of projections.

 #KT-45945 Fixed
2021-04-20 17:31:14 +02:00
Igor Chevdar 246a907753 [FE][PSI2IR] Generalized SamType
Operations regarding <fun interface> are common for all backends
2021-03-24 20:42:40 +05:00
Alexander Udalov c1a292b01b Psi2ir: improve exception stack traces
- Do not wrap exceptions resulting from generating error expressions
  multiple times, as that could lead to stack traces where the identical
  code is wrapped many times and is printed in the exception message on
  each step, which was difficult to read
- Add element location (file name, line number & position) to the
  message, similarly to exceptions from codegen, when catching and
  rethrowing exceptions at the top level
2020-11-06 19:26:48 +01:00
Dmitriy Novozhilov d1fd1da56f Rename Visibility to DescriptorVisibility 2020-09-04 11:07:42 +03:00
Mikhail Bogdanov 9c0b96af71 Report error on missed specialization in compatibility mode
#KT-39603 Fixed
2020-06-19 11:57:36 +02:00
Alexander Udalov fc1217ba07 Generate delegates to DefaultImpls in fun interface wrappers
#KT-37436 Fixed
2020-06-09 11:44:31 +02:00
Jinseong Jeon bcf277d885 Add comments for generators about data/inline class (in psi2ir and fir2ir) and annotations (fir2ir). 2020-05-14 09:41:11 +03:00
Dmitriy Dolovov 90e888a1b6 Discriminate overloading expect MemberDescriptors
Issue #KT-38298
2020-04-28 13:16:18 +07:00
Dmitry Petrov 24b8495e00 KT-30419 Box inline classes in return types of covariant overrides
Use boxed version of an inline class in return type position for
covariant and generic-specialized overrides.

Also fixes KT-35234 and KT-31585.
2020-04-01 22:59:14 +03:00
Alexander Udalov a4cc5ea1da Remove unneeded dependency of backend-common on ir.tree 2020-02-05 22:45:12 +01:00
Alexander Udalov 2552540f71 IR: wrap exceptions and add file path in per-file lowerings
Also add file path to the wrapped exception in JVM IR codegen
2019-12-03 11:06:54 +01:00
Vladimir Dolzhenko 10ea8abc2b Wrap file.declarations with runReadAction
#EA-209932 Fixed
2019-10-21 17:18:04 +02:00
Denis Zharkov 67410f7a57 Parametrize behavior of DescriptorEquivalenceForOverrides::areCallableDescriptorsEquivalent
The changes introduced 471134d31e are only needed
for the case of HMPP project while for other cases it might break the behavior
a bit like in KT-34027

See org.jetbrains.kotlin.resolve.calls.results.OverloadingConflictResolver#filterOutEquivalentCalls

Before 471134d we were comparing
"fun foo(x: String)" with "[substituted] fun foo(x: String)"
and areCallableDescriptorsEquivalent returned false for such case.
Thus, both overrides were left in the resulting set.

After 471134d, those two descriptors
becamed considered as equal thus having a possibility to remove any of them.

The problem is that "areCallableDescriptorsEquivalent" has kind of
unclear contract. Effectively it checks whether two descriptors match
to the same declaration

But straightforward fixing of this exact call-site (using original descriptors)
doesn't help: behavior might change in a very subtle way (see org.jetbrains.kotlin.spec.checkers.DiagnosticsTestSpecGenerated.NotLinked.Dfa.Pos#test72)

So, the main idea is changing the contract for areCallableDescriptorsEquivalent
only when project is HMPP one.

^KT-34027 In Progress
2019-09-30 20:09:42 +03:00
Yan Zhulanow ae7550c5af Move out JVM debugger functionality 2019-05-30 15:27:07 +09:00
nikita.movshin 65244b4bea Update copyright.
Change the copyright from "JetBrains s.r.o." to
"JetBrains s.r.o. and Kotlin Project contributors"
Update only 2 lines copyright.
2019-04-23 20:09:22 +03:00
Alexander Udalov 4b712bd14b Remove dependency of backend-common on descriptors.jvm 2019-03-05 16:28:34 +01:00
Alexander Udalov 3d1858a8c5 Refactor and rename CodegenUtil.getDeclarationsToGenerate
Move logic regarding expect classes to the only relevant call site at
PackageCodegenImpl, and return the list of members to remove code
duplication at remaining call sites
2019-02-19 16:37:46 +01:00
Mikhael Bogdanov a122cba862 Switch Kotlin project to jvm-target 1.8
#KT-29405
2019-01-31 07:43:05 +01:00
Sergey Rostov f35185b261 Build: remove explicit dependencies to org.jetbrains.annotations 2019-01-28 13:43:08 +03:00
Denis Zharkov 5ec93f2718 Avoid assertion in bridges-generation for light classes
^KT-11656
2019-01-14 14:54:18 +03:00
Denis Zharkov e0ff7281b4 Minor. Introduce FunctionHandle::mightBeIncorrectCode 2019-01-14 14:54:18 +03:00
Denis Zharkov 949214c10b Refactor bridges generation for JVM
Make a separate subclass for DescriptorBasedFunctionHandle
to allow customize the behavior without complex abstract concepts
like `areDeclarationAndDefinitionSame`
2019-01-14 14:54:18 +03:00
Denis Zharkov 5cc242e878 Refactor FunctionHandle::isInterfaceDeclaration
- Give it more clear name mayBeUsedAsSuperImplementation
  because defining if it can be used as super-implementation
  this is what it used for
- The meaning is negated, so it's needed to negate its usages and impls
- Also, reuse it in findSuperImplementationForStubDelegation
2019-01-14 14:54:18 +03:00
Sergey Rostov 883970fadb Add explicit dependencies to nullable annotations 2018-12-26 09:07:06 +03:00
Ilmir Usmanov 9af7316845 Add call checker to report error more granulary if possible
This, however, works only for calls of 'synchronized' only. Thus, it
does not support inline functions of any kind.
2018-10-09 22:55:51 +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
Mikhael Bogdanov 92ce50b22c JVM_IR. Cache defaultImpls function declarations 2018-08-31 15:34:18 +03:00
Anton Bannykh 934e11aa60 JS: support unsigned primitive vararg's 2018-08-30 14:57:20 +03:00
Mikhail Zarechenskiy c253b39acf Refactoring: extract generator for functions from Any 2018-08-06 10:19:46 +03:00
Ilmir Usmanov 4811757d8d Disable intercepted instrinsic in 1.3
Fix compiler bootstrapping.
2018-07-17 22:25:43 +03:00
Pavel V. Talanov 770c280ba5 Light classes: handle broken context in case of supertype delegation
This lead to an exception being thrown frequently
Proper fix would be to prevent binding context from being corrupted
Known cases are hard to debug/reproduce

 #EA-101081 Fixed
2018-07-17 17:37:20 +02:00
Ilmir Usmanov bc4a7aec76 Remove suspendCoroutineOrReturn intrinsic from compiler
#KT-21240: Fixed

Also, change logic of intrinsics check.

 #KT-23438: Fixed
2018-07-16 15:09:18 +03:00
Denis Zharkov 170086250b Support new Continuation API in JVM BE
#KT-24863 Fixed
2018-07-09 15:27:19 +03:00
Dmitry Petrov 353076f596 compiler/ir/backend.common is NOT a part of compiler/backend-common 2018-06-29 11:24:46 +03: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
Alexander Udalov 4e217b180a Pass BindingContext to CodegenUtil.getActualDeclarations
Will be used in a subsequent commit. Also rename getActualDeclarations
-> getDeclarationsToGenerate
2018-06-26 10:23:55 +02:00
Mikhael Bogdanov e58e05f9be Minor. Reformat 2018-06-04 10:49:57 +02:00
Denis Vnukov e3829a70b0 Stable order of synthesized bridges.
In some cases when several bridge methods are generated, their order
is undetermenistic. For example for class ClassLowerWithContext in the
following example

```
interface IrElement
class IrClassContext

interface IrElementVisitor<out R, in D> {
    fun visitElement(element: IrElement, data: D): R
}

interface IrElementTransformer<in D> : IrElementVisitor<IrElement, D> {
    override fun visitElement(element: IrElement, data: D): IrElement =
            element.also { throw RuntimeException() }
}

abstract class ClassLowerWithContext : IrElementTransformer<IrClassContext?>
```

kotlin compiler synthesizes two additional bridges:

  public IrElement visitElement(IrElement, IrClassContext);
  [bridge] public Object visitElement(IrElement, Object);
  [bridge] public IrElement visitElement(IrElement, Object);

Unfortunately the behavior is not deterministic and not easy to reproduce.
2018-04-18 15:36:33 +02:00
Ilmir Usmanov 2cfe387bab Move coroutines to kotlin.coroutines package: compiler
Generate continuation type as kotlin.coroutines.Continuaion. This code will
fail at runtime since there is no stdlib backing this change yet.
However, in order to generate compatible stdlib we need a compiler, which
generates continuation type as kotlin.coroutines.Continuation.
Thus, firstly we support the change in the compiler, make it bootstrap
compiler and only then change stdlib and tests accordingly.
 #KT-23362
2018-04-10 22:51:46 +03:00
Mikhael Bogdanov 2a8041e77e Check method abstractness during bridge generation per method not interface 2018-04-03 19:18:14 +02:00
Alexey Tsvetkov 8a82c1618c Use Plugins DSL in Kotlin Gradle scripts
When plugins DSL is used, there is no need to
manually generate typesafe accessors for extensions and
conventions (by running `./gradlew kotlinDslAccessorsSnapshot`).
2018-03-26 16:09:29 +03:00
Yan Zhulanow 34d1611ed4 Add Pill support to compiler and IDE modules 2018-03-02 03:15:17 +03:00
Ilmir Usmanov 87bbac9d43 Take coroutineContext into account in RedundantSuspendModifierInspection
#KT-22651: Fixed
2018-02-08 19:34:20 +03:00