Commit Graph

2362 Commits

Author SHA1 Message Date
Pavel Kirpichenkov ebb9f09656 [NI] Fix issues with star projection uncapturing
Prevent stack overflow during uncapturing of star projection
for parameter with recursive upper bound.
Uncapture star projections for flexible type parameters with
respect to flexible upper bound.

^KT-35210 Fixed
2019-12-18 16:19:33 +03:00
Pavel Kirpichenkov 2fc79856a2 [NI] Fix OnlyInputTypes for captured types
Uncapture projections recursively for cases when captured type is not
top-level type or first level type argument
2019-12-18 16:19:32 +03:00
Pavel Kirpichenkov 8dc2784fc4 Reapply "Drop deprecated displayName from descriptor visibility"
Cancel revert due to update in kotlin-mirror/master in native
This reverts commit 39e0c6d55b
2019-12-12 13:57:52 +03:00
Pavel Kirpichenkov 39e0c6d55b Revert "Drop deprecated displayName from descriptor visibility"
This reverts commit 6fa11d1573.
2019-12-11 18:30:24 +03:00
Pavel Kirpichenkov 6fa11d1573 Drop deprecated displayName from descriptor visibility
Deprecated displayName has been replaced with internal and external display
names for better diagnostic messages.
2019-12-11 17:30:29 +03:00
Ilya Chernikov 7dd9ed7e38 [NI] Fix loosing type annotations on extension functions
#KT-32138 fixed
2019-11-29 13:44:41 +01:00
Mikhail Zarechenskiy eb73650209 Fix race in IDE: inject proper storage manager for type parameters
With NO_LOCKS strategy we can easily end up in a situation when
 constraint system for a generic call is built incorrectly,
 producing flaky errors (or don't produce errors at all)

 Now proper storage manager is injected for all cases except:
 - IR
 - Codegen
 - Serialization plugin
 - Fake local objects

 Most likely, NO_LOCKS strategy for these cases is fine as at that point
 the compiler works in one thread

 #KT-34786 Fixed
2019-11-26 10:52:45 +03:00
Mikhail Zarechenskiy b30a9e1d3e [NI] Remove capturing from supertypes during computation of CST 2019-10-31 11:32:05 +03:00
Mikhail Zarechenskiy ca8da22569 [NI] Improve CST algorithm to handle non-fixed variables
#KT-32456 Fixed
 #KT-32423 Fixed
 #KT-32818 Fixed
 #KT-33197 Fixed
2019-10-31 11:32:00 +03:00
Mikhail Zarechenskiy ba6648d535 Minor, reformat Annotations.kt file 2019-10-31 11:31:59 +03:00
Mikhail Zarechenskiy 588218658c [NI] Fix ambiguity for extension functions with exact transient receiver 2019-10-25 16:28:40 +03:00
Pavel Kirpichenkov c21e699783 Fix default type of static classes inside parametrized parents
Default type of LazySubstitutingClassDescriptor is not lazy. However, most of default types are,
and there is an optimization in KotlinTypeFactory, which uses default type for simple type without
type arguments and/or annotations. LazySubstitutingClassDescriptor's default type creates simple type
with factory, which may therefore cause recursion.

#KT-34029 Fixed
2019-10-25 11:59:27 +03:00
Yan Zhulanow 87e0a2d98c Debugger: Fix evaluation of function declarations with expression bodies (KT-32704)
Before this commit, the substituted FunctionDescriptor didn't have a source element.
As a result, 'CodeFragmentParameterAnalyzer.isCodeFragmentDeclaration' failed to recognize such a descriptor as fragment-local, and it was erroneously captured.
2019-10-24 21:33:00 +09:00
Pavel Kirpichenkov 636f5da883 [Minor] Inline and drop reduntant isCallableReflectionType property 2019-10-22 14:51:04 +03:00
Pavel Kirpichenkov 138d558f6a Fix compiler exception during resolution of ambiguous callable references
Function return type can't and should not be used during overload resolution of callable references.
Since it can be DeferredType, its substitution in CS caused exception.
2019-10-22 13:20:27 +03:00
Vladimir Dolzhenko 30229da95a Don't render pure error types in OverrideMemberChooserObject
#KT-34379 Fixed
2019-10-21 17:18:23 +02:00
Pavel Kirpichenkov 42740c8b97 Fix capturing of outer type parameters for classes declared inside init block 2019-10-09 16:01:46 +03:00
Pavel Kirpichenkov b7e5d9faae Update annotation rendering in diagnostics
Disable annotation rendering in default type and descriptor renderers.
Preserve annotations in Android and Serialization plugins.
Update error texts in ide tests.
Nullability annotations in Java descriptors are rendered with context-dependent renderer.

#KT-20258 Fixed
2019-10-04 11:18:45 +03:00
Dmitry Gridin 9da6dcf840 DescriptorRenderer: shouldn't render private modifier by default
#KT-31587 Fixed
2019-10-03 16:00:06 +07:00
Dmitry Petrov a633a33627 KT-14513 Don't generate delegated property metadata when unused
If the delegated property operators involved are inline, and delegated
property metadata parameter is not used (which is often the case, e.g.,
'lazy'), we can skip those properties in metadata generation.

NOT implemented: special case when only 'kProperty.name' is used by the
corresponding delegated property operators.

Also a sneak fix for KT-34060.
2019-10-02 17:14:48 +04:00
Igor Yakovlev c5fc55b84c Fix exception when Enum.valueOf got an invalid argument value
#Fixed KT-30515
2019-10-01 13:53:20 +03: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
Mikhail Zarechenskiy 932d84d568 Fix performance regression in NI by fixing totally incorrect hashCode
The actual problem was introduced in 4f1e85b468, note how `hashCode` is implemented:
```
var currentHashCode = cachedHashCode
if (currentHashCode == 0) return currentHashCode
...
```
It's a silly bug, there should be check `if (currentHashCode != 0) ...` because `0` is used a marker for "uncomputed value".

Now, in the commit 0219b86d06 I added map with `KotlinType` as a key and because of constant `hash` for `KotlinType`, we basically got `List` instead of `Map`, which caused this performance regression

 #KT-34063 Fixed
2019-09-30 10:22:30 +03:00
Dmitriy Dolovov 1a49d88578 [Commonizer] Classifiers 2019-09-27 09:17:56 +07:00
Mikhail Zarechenskiy 1a50a3cbb1 [NI] Avoid computing few things for simple calls without type variables 2019-09-20 17:56:07 +03:00
Mikhail Zarechenskiy 7e8784dca1 [NI] Simplify code that capture types from expression 2019-09-18 00:13:10 +03:00
Pavel Kirpichenkov 0a1b3a8455 Clearify diagnostic messages that involve internal visibilities
KT-7354 Fixed

Visibility.displayText is deprecated with warning.
Diagnostics for java visibilities changed.
2019-09-16 19:00:43 +03:00
Alexander Udalov d16bdded7f JVM IR: reuse JVM code for reified type parameter mappings instead of copy-paste 2019-09-11 23:33:11 +02:00
Alexander Udalov d1df453edc Do not use KotlinTypeMapper in generateTypeOf inline intrinsic
Make ReifiedTypeInliner and related classes generic over the
KotlinTypeMarker subtype (KotlinType or IrType), add a typeSystem to get
arguments/nullability and other properties of types regardless of their
representation, but still fall back to KotlinType when generating the
actual bytecode of other intrinsics (as/is)
2019-09-11 23:33:11 +02:00
Ivan Cilcic 1c2ffa65ca Revert commit with changes in DescriptorRenderer 2019-08-30 11:50:30 +03:00
Ivan Cilcic 6fa7435cd4 Add additional options to DescriptorRender
1) renderContextNearLocalVariable - if true renderer add fq name for local variables after "@" symbol
2) fullContextForLocalVariable - if true then renderer add all fq names for local variables, else only last one
3) useBaseClassAsReceiver - if true then renderer uses dispatch receiver as extension receiver if the last is null
2019-08-30 11:50:27 +03:00
Dmitriy Novozhilov 3e44bc805f [FIR] Return error type from common super type if it present 2019-08-22 10:55:07 +03:00
Alexander Udalov 0c6ab69b52 JVM IR: do not use descriptors in IrTypeMapper.writeFormalTypeParameters 2019-08-21 15:13:49 +02:00
Igor Chevdar 00dc335559 [IrSerializer] Preparations for functional interfaces handling 2019-08-12 17:07:43 +03:00
Alexander Udalov c007f3efb3 Minor, move lazyClosure out of TypeUtils.kt 2019-08-12 14:57:21 +02:00
Dmitry Gridin 3ea195e1a2 DescriptorRenderedImpl: fix order of val & vararg modifier for actual class
#KT-31921 Fixed
2019-08-01 16:08:45 +03:00
Dmitry Gridin a2f937e282 DescriptorRender: cleanup code 2019-08-01 16:08:45 +03:00
Denis Zharkov ffaca279bc Minor. Turn TypeBasedStarProjectionImpl into StarProjectionForAbsentTypeParameter
It's needed to avoid abusing of the class
Star projections should be created based on the relevant type parameter
whenever it's possible
2019-07-30 12:41:41 +03:00
Denis Zharkov 579838cb4e Avoid recursive refinement in NewCapturedTypeConstructor
Potentially, it might contain infinite recursive supertypes
And for such cases, we have to perform lazy refinement (one level per request)
2019-07-30 12:41:41 +03:00
Denis Zharkov a2a1c7e50f Avoid recursive refinement with star projections
Otherwise StackOverflowError or recursion-detection in LockBasedStorageManager
may happen

It's fine to have non-refined type there because it only can affect
content of containing type member scope that should be refined after
being requested
2019-07-30 12:41:41 +03:00
Dmitry Savvinov 6695ddd1d5 Change 'hashCode' of 'TypeProjection'
according to bug when there was exception in
`hashCode` call when projection has some `SpecialType`
like `NO_EXPECTED_TYPE`
2019-07-30 12:41:41 +03:00
Dmitry Savvinov 68c1a7cedd Use stable order for dependsOn and related diagnostics 2019-07-30 12:41:39 +03:00
Dmitry Savvinov 61ec5ed5dd [Misc] Introduce lazyClosure 2019-07-30 12:41:39 +03:00
Dmitriy Novozhilov b477184a3c Fix creating of refined FlexibleType and RawType
There was an issue that `KotlinType.equals` called in `KotlinTypeFactory.flexibleType`
  and `RawType` constructor produced endless recursion of types that wasn't
  computed yet
2019-07-30 12:41:39 +03:00
Denis Zharkov d744192e6f [Invariant fix] Fix false positive internal visibility diagnostic
Effectively, this commit allows for common module
to see internal content of all expect-modules

The problem is that when computing the member scope for A (see the test)
we're building a special member scope for CommonAbstract viewed from JVM
and it's effectively has a fake override of actual member from Jvm/ExpectBase.

OverridingUtil checks if it's visible in CommonAbstract and finds that it's not
thus creating a fake_invisible fake override

The latter results in A::foo override being marked as INVISIBLE_MEMBER_OVERRIDE

Probably, the fix might be smarter
(passing a requested module to OverridingUtil::createAndBindFakeOverride)
but allowing using internal member seems to be safe & simple
because it's reasonable to assume there's no cyclic dependencies
between expected/actual modules
2019-07-30 12:41:39 +03:00
Denis Zharkov c49791f8bb [Invariant Fix] Fix equality for NewCapturedTypeConstructor after refinement 2019-07-30 12:41:38 +03:00
Denis Zharkov 471134d31e [Invariant Fix] Fix callable equivalence definition in case of refined scopes
Before types refinement has been introduced it was reasonable to assume
that whenever we have two callables in the same declaration
they are actually different

But it become false once types refinement were introduced
and the same declarations may appear as different descriptors' instances
when viewing from different modules

The change does look very fragile because in many cases
source element is NO_SOURCE

At the same time, declaring actually different members
with the same signature is prohibited and may make sense only
in case of source-based members
2019-07-30 12:41:38 +03:00
Denis Zharkov 5c2c7e7776 [Invariant fix] Avoid re-resolving declared descriptors in lazy member scopes
It becomes necessary after scopes/types refinement
Without it being applied the code might fail with slice-rewrite errors

KT-32841
2019-07-30 12:41:38 +03:00
Denis Zharkov 53334c038f [API Usage] Use refinement in NI 2019-07-30 12:41:37 +03:00
Denis Zharkov 2bf6bd3724 Do not consider descriptors equality as a reason not to refine type
Otherwise, it results in skipping refinement for JobNode when requested
from JVM module while it's necessary because CompletionHandlerBase's content
depends on the module
2019-07-30 12:41:37 +03:00