Commit Graph

9635 Commits

Author SHA1 Message Date
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 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
Dmitry Savvinov 3989f351ff Use modules instead of files for MPP diagnostic
Using files turned to be a bad idea, because people often
use the same name for files with expects and with corresponding actuals.

This commits disambiguiates ambiguous message for
AMBIGUOUS_ACTUALS/AMBGIUOUS_EXPECTS diagnostics by using modules instead
of files

^KT-32582 Fixed
2019-10-02 16:52:40 +03:00
Dmitry Savvinov 45737e51fb Minor: let 'Renderer'-helper return more specific type
This allows to easily re-use other renderers from 'Renderer'-block
(previously, one had to declare 'ContextDependentRenderer' just to get
hold of 'RenderingContext' just to call 'render(O, RenderingContext)'
from DiagnosticParameterRenderer, which would be unused anyways)

This commit introduces more specific subtype,
'ContextIndependentParameterRenderer', which exposes 'render(O)' method
for easy re-use.

Several (ab)uses of 'ContextDependentRenderer' have been removed
2019-10-02 16:52:39 +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
Ilmir Usmanov 08794d17a0 Do not box function argument if it is used in EXACTLY_ONCE lambda
Since we cannot change type of parameter, we cannot replace it with
box type.
 #KT-29510 Fixed
 #KT-29614 Fixed
 #KT-29385 Fixed
2019-09-30 17:42:17 +03:00
Dmitry Gridin 589094377e QualifiedExpressionResolver: change root prefix from _Qfadj4tPV to _root_ide_package_ 2019-09-27 17:52:11 +07:00
Pavel Kirpichenkov 6c8e829f19 Update diagnostics for trailing lambdas, add quickfix
Alternative message for errors, caused by unexpected lambda expression arguments on a new line.
Both diagnostic are reported, if multiple lambda expressions were passed to the call.
For other errors trailing lambda diagnostic overrides the original one.

Quickfix for erroneous trailing lambdas on a new line after call.
Fix separates lambda expression from previous call with semicolon.
All trailing lambda arguments become standalone lambda expressions.
2019-09-25 15:38:17 +03:00
Dmitry Savvinov 937d041bc3 Minor: rename file ResolverForProjectImpl.kt -> AbstractResolverForProject 2019-09-24 17:05:05 +03:00
Dmitry Savvinov bfacc1a3c5 Introduce AbstractResolverForProject
Previously, ResolverForProjectImpl had multiple callbacks in
constructor. Some of those callbacks were used only to overcome module
visibility and provide an ability to inject IDE-specific logic into
compiler (ResolverForProject is in the 'compiler'-module)

This commit introduces abstract class which implements
environment-independent logic (previously, this logic had been stored in
ResolverForProjectImpl) with several abstract met hods (previously,
callbacks). Then, we provide few concrete implementations of
AbstractResolverForProject with clear semantics:

- IdeaResolverForProject: resolver used in IDE, where we have indices,
  oracles, multiple modules, etc.
- ResolverForSingleModuleProject: resolver for project with only one
  module, commonly used for CLI compiler/tests
- one anonymous implementation for MultimoduleTests

This refactoring achieves several things:
- now it is easier to see what kinds of ResolverForProject you might see
  in some particular environment (previously, one had to inspect all
  call-sites of constructor)
- we can easily add IDE-specific logic in IdeaResolverForProject without
  adding noisy callbacks (which most probably wouldn't have any other
  non-trivial implementations)
2019-09-24 17:05:05 +03:00
Dmitry Savvinov 48719c4050 Minor: extract ResolverForProjectImpl into separate file 2019-09-24 17:05:05 +03:00
Mikhail Zarechenskiy 7bd65c0bcd [NI] Avoid collecting possible types for call expressions 2019-09-20 17:56:07 +03:00
Pavel Kirpichenkov f45a49b122 Remove uncapturing in type mismatch diagnostics
#KT-32587 Fixed
2019-09-20 17:05:03 +03:00
Steven Schäfer cdc5e1347b JVM: Avoid boxing in inline class equality 2019-09-18 18:52:58 +02:00
Steven Schäfer b85a475358 JVM IR: Generate equals-impl0 method for inline classes 2019-09-18 18:52:58 +02:00
Alexander Udalov 530c1411c3 Remove IR backend-specific code from KotlinTypeMapper
Add an assertion to check that we don't call mapType anymore in JVM IR.
2019-09-18 17:55:41 +02:00
Mikhail Zarechenskiy 0431c21f9a [NI] Remove unneeded computation of possible types for return type
This call was needed at some point for smartcasts on qualified
 expressions but become obsolete (most likely after
 daa27016ca).

 Now `ComplexDataFlowBenchmark` has similar results for NI and OI
2019-09-18 00:19:21 +03:00
Mikhail Zarechenskiy d47fc85868 [NI] Minor, small improvements around KotlinCall creation 2019-09-18 00:13:10 +03:00
Mikhail Zarechenskiy 971b02494c [NI] Minor, simplify code a bit for sub calls preparation 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
Igor Yakovlev 27accbb089 Fix KotlinLintTestGenerated.testParcel + extensions registrations fixes 2019-09-13 19:40:31 +03:00
Dmitry Petrov f06f6f4660 Allow 'break' and 'continue' inside 'when' in 1.4+ 2019-09-12 15:11:00 +03:00
Pavel Kirpichenkov 55cb9561c2 Provide better error messages for read-only delegate
Split error reporting into two parts for incorrect and missing candidates.
Missing function error is not reported on provideDelegate.
Update error factory and default message for error.
Update error texts in quick fix test data.

#KT-16526 Fixed
2019-09-12 14:58:21 +03:00
Igor Yakovlev 2b7dee6f8d Add CodegenApplicabilityCheckerExtension and use it to fallback to Heavy LigthClasses
+ Fixed #KT-33584
2019-09-11 15:29:12 +03:00
Vladimir Dolzhenko d1285d9dbf Fix performanceTests for 192; Add perfCounters 2019-09-10 14:02:56 +02:00
Mikhail Zarechenskiy e21da3a61a Avoid resolving array-set method several times
While origin problem was in NI, it's also nice to have this change in OI
 in order to slightly improve performance

 #KT-33125 Fixed
2019-09-09 11:04:18 +03:00
Mikhail Zarechenskiy f8449bf15a [NI] Clear partially resolved calls after resolve of top-level call
#KT-32433 Fixed
2019-09-09 11:04:17 +03:00
Mikhail Zarechenskiy f305475e3f Make "nothing to inline" diagnostic shorter
#KT-33421 Fixed
2019-09-09 11:04:17 +03:00
Roman Golyshev 9a938b07ba KT-17689: Fix TypeAliasQualifier to provide enum entries descriptors
- this adds enum entries to the completion on the typealiases
- we cannot use `unsubstitutedInnerClassesScope` instead of `EnumEntriesScope` because it allows to complete things that are not allowed to be resolved by the Kotlin compiler; see `EnumEntriesScope` doc for details
- ^KT-17689 Fixed
2019-09-06 12:11:23 +03:00
Dmitry Gridin 14ad6284d9 QualifiedExpressionResolver: add root prefix resolve for IDE analysis 2019-09-05 18:01:22 +07:00
Dmitry Gridin 68d20dae66 QualifierExpressionResolver: cleanup code 2019-09-05 18:01:22 +07:00
Dmitry Gridin 4224d109e2 AnalysisFlags: add flag ideMode for IDE specific analysis 2019-09-05 18:01:22 +07:00
Roman Artemev 1cdff7810e [Psi2Ir] Fix Lazy Fake override field
- add comment about problem with DeserializedPropertyDescriptor
2019-09-03 14:21:31 +03:00
Nikolay Krasko 372c6377e8 Remove AstLoadingUtil after removing 182
#KT-33536 Fixed
2019-08-30 12:13:50 +03:00
Vladimir Dolzhenko dd0e296af1 Use KotlinExceptionWithAttachments for ToFromOriginalFileMapper and MainFunctionDetector 2019-08-19 17:55:49 +02:00
Dmitriy Novozhilov 8bf61a12df Minor. Remove UNREACHABLE_CODE slice from BindingContext
There was no reading from that slice, so it is redundant
2019-08-09 09:56:37 +03:00
Mikhail Zarechenskiy 04e57f712e [NI] Introduce feature for passing function references with defaults
Relates to KT-8834, we continue reducing differences between old and new
 inference. Note that as for `SamConversionPerArgument`, this feature
 is enabled in the compiler and not in the IDE to avoid breaking code
 for those users that already enabled new inference in the compiler
2019-08-07 15:58:36 +03:00
Mikhail Zarechenskiy 0219b86d06 [NI] Fix poor performance of recursive types approximation
#KT-32407 Fixed
2019-08-07 15:21:16 +03:00
Mikhail Zarechenskiy 5f76918c90 [NI] Use approximator as a component, don't recreate it during resolve 2019-08-07 15:21:15 +03:00
Jim S 88db93853f Make context available to suppressors
We've found that the BindingContext is necessary for any meaningful suppressor.
This change adds the ability for suppressors to use the BindingContext when available.

Change-Id: I14d8148ef659eca273445bf0638bcdb8c3b21f02
2019-08-07 03:16:24 +03:00
Yan Zhulanow 0a092d6613 Debugger: Fix breakpoint firing in '$suspendImpl' (KT-27645) 2019-08-07 01:15:33 +09:00
Yan Zhulanow 79a5375ad1 Debugger: Fix NPE in CFA during evaluation (KT-32830) 2019-08-07 01:15:32 +09:00
Yan Zhulanow 780c0518e5 Debugger: Disallow breakpoints for @InlineOnly function bodies (KT-32687, KT-24408)
Kotlin compiler strips all debug information for @InlineOnly functions, making them non-debuggable.
This commit disables breakpoints inside @InlineOnly functions to prevent false expectations.
2019-08-07 01:15:28 +09:00
Nikolay Krasko ce3ad8f4da Use kotlin specific OOCB tracker for light classes inner cache
ClassInnerStuffCache from the platform caches everything with platform
OUT_OF_CODE_BLOCK tracker.
2019-08-01 18:16:35 +03:00
Denis Zharkov d042eb2cfb Fix type refinement for qualified expressions
Previously, type for "c.a"-receiver in "c.a.platformFun()"
has not been refined because typechecking of "c.a" doesn't go
through common facade org.jetbrains.kotlin.types.expressions.ExpressionTypingServices#getTypeInfo
where the most of expressions are expected to be type checked.

(see org.jetbrains.kotlin.resolve.calls.CallExpressionResolver#getUnsafeSelectorTypeInfo)
2019-07-30 12:41:41 +03:00
Dmitry Savvinov 2b4d70fcf0 [Resolve] Rewrite how built-ins are created
Under COMPOSITE mode we don't have a globally known way to create
built-ins, instead, we have to create them on per-module basis.

So, in this commit we:

1. Use builtInsProvider: (ModuleInfo) -> KotlinBuiltIns instead of
precomputed builtIns instance, in order to be able to calculate
builtIns on per-module basis

2. Introduce new entity, called BuiltInsCache, which, roughly
speaking, is a map of form ModuleInfo -> KotlinBuiltIns, to prevent
creation of multiple builtInsInstances
NB. Actually, it's of form BuiltInsCacheKey -> KotlinBuiltIns, because
we shouldn't create new builtIns for each module. Also, currently,
each platform has its own BuiltInsCacheKey implementation, because
parameters by which built-ins are created, are a bit different across
different platforms. Ideally, we should eliminate those differences
and they use one concrete implementation as a key.
2019-07-30 12:41:40 +03:00
Dmitry Savvinov 9f2a03947c [Resolve] Compute dependency on SDK properly
Under COMPOSITE resolution mode (see ResolutionModeComponent) we have
no fixed and globally known SDK, instead, for each module we have to
find SDK it it's transitive dependencies.

Currently, this is necessary in order to create proper JvmBuiltIns,
which need dependency on SDK to be present in immediate dependencies.
2019-07-30 12:41:40 +03:00
Dmitry Savvinov f9b8ab3a3a [Resolve] Introduce CompositeResolver
This commit introduces CompositeResolverForModuleFactory, which should
work under so-called "composite resolution mode", where sources of all
all modules are analyzed in one global facade.

This allows to:
- avoid re-analyzation of common sources
- avoid retaining memory for all platforms (which can be very bad as
soon as we'll start distinguishing various flavours of platforms,
especially "flavours" of common platform)
- support running platform-specific checks in common modules (e.g.,
report JVM_PLATFORM_DECLARATION_CLASH if common sources are going to have
it)
- support analysis of shared platform modules, like commonNative

This mode heavily depends on so-called "type refinement" support in the
compiler, which is introduced in other series of commits.

In this commit, CompositeResolver and related codepaths are left unused.
Also, this commit misses several important pieces of logic in
resolvers-setup code, which should be different for CompositeResolver
- computation of 'firstDependency'
- computation of built-ins
- computation of modules owned by facade

They will be covered in the following commits
2019-07-30 12:41:40 +03:00
Dmitry Savvinov b48218e722 [Resolve] Make ResolversForModule less static
As consequence, remove IdePlatformKindTooling.resolverForModule, because
it became more than just field, and it duplicates similar API in
IdePlatformKindResolution anyways
2019-07-30 12:41:40 +03:00
Dmitry Savvinov 68c1a7cedd Use stable order for dependsOn and related diagnostics 2019-07-30 12:41:39 +03:00