Commit Graph

9716 Commits

Author SHA1 Message Date
Pavel Kirpichenkov 2d21b82501 [NI] Remove hack for special functions
Treating special functions for `if`, `when`, `try`, `?:` as not accepting `Nothing` result type is incorrect.
Making so leads to cases with uninferred `Nothing` result type for inner calls and lost data flow info.
2019-12-27 18:40:42 +03:00
Denis Zharkov caf02806d5 NI: Fix resolution ambiguity for references returned from lambda
^KT-32267 Fixed
2019-12-27 11:36:19 +03:00
Denis Zharkov 534718794c Minor. Extract PSICallResolver::createCallableReferenceKotlinCallArgument 2019-12-27 11:36:18 +03:00
Denis Zharkov 840acbac68 Minor. Make properties in KotlinResolutionCallbacksImpl private 2019-12-27 11:36:18 +03:00
Dmitriy Novozhilov 04e567dbf9 [NI] Don't replace context dependency for blocks with expected type
#KT-35702 Fixed
2019-12-26 20:31:06 +03:00
Dmitriy Novozhilov 5dfe100ae5 Allow use reference to reified type parameters in contracts since 1.4 2019-12-26 17:43:28 +03:00
Dmitriy Novozhilov 9c1b68f839 Prohibit using references to this from outer scope in contract declarations 2019-12-26 17:43:28 +03:00
Dmitriy Novozhilov f083edfac2 Allow contracts on final non-override members since 1.4 2019-12-26 17:43:27 +03:00
Denis Zharkov ae4397fbfb Fix bare typed smartcasts in NI
Star projections should be replaced with star projections
not for their expansions

See the test
2019-12-26 12:35:34 +03:00
Dmitriy Novozhilov 7728102a77 Cleanup and reformart DelegatedPropertyResolver.kt 2019-12-26 10:54:07 +03:00
Dmitriy Novozhilov c8a1b876e8 [NI] Fix completion of error delegates with receiver with type parameters 2019-12-26 10:54:07 +03:00
Dmitriy Novozhilov e83941a98e [NI] Don't resolve delegates twice
#KT-31219 Fixed
#KT-31679 Fixed
#KT-32249 Fixed
2019-12-26 10:54:06 +03:00
Dmitriy Novozhilov b54169d312 [NI] Fix substitution in completion of callable references in coroutine inference 2019-12-25 16:19:19 +03:00
Pavel Kirpichenkov a9391c8dfb [NI] Remove Nothing result type restriction in most cases
Make Nothing as result type not suitable only for if, when, try and ?: special functions.
2019-12-25 14:59:05 +03:00
Sergey Igushkin ed6034e449 Support generating a klib from common code with K2MetadataCompiler 2019-12-25 12:09:08 +03:00
Mikhail Zarechenskiy c3ffef1840 Fix incorrect use of language feature
See #KT-34889 for details
2019-12-20 12:06:17 +03:00
Nikolay Krasko 2dcc617774 Minor: reformat 2019-12-20 02:39:05 +03:00
Nikolay Krasko e99dc0f87f Show only unique diagnostics in psi checker (KT-35578)
MissingDependencyClassChecker.collectDiagnostics now show only unique diagnostics

As per-file analyzer trace used in checker delegates to resolve session trace, diagnostics might be duplicated because of race condition:
 1. If a non-checker thread performs analyze first, diagnostics for global elements will be stored in the resolve session trace only once.
 2 If the checker threads comes to the analyze first, diagnostics will be stored in the local trace, and after that might be duplicated in the resolve session trace by other analyzers.

 #KT-35578 Fixed
2019-12-20 02:39:05 +03:00
Denis Zharkov e8131d6e30 Choose Java field during overload resolution with a pure Kotlin property
^KT-31244 Fixed
2019-12-19 10:53:31 +03:00
Dmitriy Novozhilov aa8578b675 Allow null operators for result and using Result as return type with enabled InlineClasses 2019-12-19 10:22:45 +03:00
Dmitriy Novozhilov ee36fb903f Allow use expression of array type as named argument for vararg 2019-12-19 10:22:44 +03:00
Denis Zharkov c486fa6189 NI: Report incompatible receiver of callable reference
^KT-35535 Fixed
2019-12-18 19:33:55 +03:00
Alexander Gorshenev dc8240c24e Expect/actual support in klibs under -Xklib-mpp 2019-12-18 19:29:56 +03:00
Alexander Udalov cdbabf224f Introduce RequiresOptIn and OptIn annotations
RequiresOptIn should be used now instead of Experimental, OptIn instead
of UseExperimental. See https://github.com/Kotlin/KEEP/pull/201.

This change adds the new declarations only to the stdlib, and supports
them in the compiler. Because of the way compiler loads annotations, we
need to bootstrap it first before deprecating the old annotations and
updating tests.

 #KT-34647 Fixed
2019-12-17 18:17:48 +01:00
Victor Petukhov 07269661b4 NI: Allow to resolve to functions with SAM conversion and passing array without spread as vararg (with warning)
^KT-35224 Fixed
2019-12-12 23:46:16 +03:00
Dmitriy Novozhilov e9c02a1cca [FIR-TEST] Add fir diagnostics test based on diagnostics tests from old frontend 2019-12-12 16:11:46 +03:00
Pavel Kirpichenkov 3de6289c6c [NI] Run completion on subatoms of error calls
Call transformer previously ran completion of argument atoms
only for non-error candidates. This led to missing diagnostics,
i.e. from collection literal resolver.

Now arguments of calls resolved to error descriptor are completed,
with exception to not found provideDelegate calls.
provideDelegate's subatoms are not completed after failure, because
it is a part of delegate competion, which does not end with
unresolved provideDelegate.
Completing after provideDelegate failure removes constraint system
from resolved arguments, which breaks resolve for get/setValue.

^KT-33592 Fixed
2019-12-03 18:19:32 +03: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
Mikhael Bogdanov df96841c9d Prohibit protected method calls from inline function
#KT-21178 Fixed
2019-12-02 08:04:26 +01:00
Ilya Chernikov b3c5362003 [NI] Fix diagnostic reporting for missing type parameter info
#KT-31975 fixed
2019-11-29 13:44:42 +01:00
victor.petukhov e246c23a46 Fix prematurely analyzing a lambda while fixing a type variable for another argument
^KT-35168 Fixed
2019-11-28 19:03:30 +03:00
Pavel Kirpichenkov cf82efb49f [NI] Add missing diagnostic on callable references in fake calls
Unresolved reference diagnositc was not reported on callable references
returned from if or when expression because of additional block wrapper.

^KT-30953 Fixed
2019-11-26 11:02:25 +03: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
Pavel Kirpichenkov 55b3637f03 Fix case of inner object usage in missing supertypes checker
FakeCallableDescriptorForObject instance, which is not ConstructorDescriptor,
is checked with call checkers when object's contents are being used.
Checker of missing supertypes should not be run against this fake descriptor.
Object's members belong to separate member scope, so their resolution doesn't
force containing class' supertypes evaluation. I.e. object's methods
may work fine even if some supertypes of containing class are missing.
2019-11-25 10:57:52 +03:00
Mikhail Zarechenskiy 63e62dcf42 Add checkCanceled check on resolving imports path
Imports resolution is a rather time consuming task and doesn't have
 `checkCanceled` on its computation path. So, if a thread is resolving
 imports it will do it until the end of computation, which can lead to
 unnecessary work and some IDE freezes.

 #KT-34990 Fixed
2019-11-20 18:14:57 +03:00
Pavel Kirpichenkov 3e8c15c62a Introduce component for caching missing supertypes
Profiling has shown, that supertype hierarchy scan for all calls has considerable
performance cost. However, missing supertypes may be calculated only once per
descriptor which would help avoiding multiple supertype hierarchy scans for
resolved calls from the same class. New memoizer is injected into call completers
and checker contexts and then used for retrieving missing super classifiers.

#KT-19234 Fixed
2019-11-18 12:06:41 +03:00
Pavel Kirpichenkov 8c52bb4212 Add frontend checks for missing dependency supertypes
Call checker and declaration checker are used in order to preserve backward compatibility.
Attempt to use classifier usage checker was not good enouth,
since not all errors found with it would actually be reported before.
For example types and constructor calls don't cause supertypes to resolve,
so missing supertypes would not lead to errors in case they are the only use of class name.

Updated tests failing due to missing Java dependencies in superclasses.
2019-11-18 12:06:41 +03:00
Ilya Chernikov 27ff2d7816 Prohibit using array based on non-reified type parameters as reified type arguments
#KT-31227 fixed
2019-11-18 09:32:52 +01:00
Pavel Kirpichenkov 92dae5d8a9 [NI] Split substitution of inferred type parametes into two steps
Substituting inferred type parameters with single substitutor leads
to incorrect behaviour in cases, when class' type parameters are used in constructor.
As a side effect of two-step substitution, intermediate descriptor is created,
which prevents incorrect substitution. To preserve this side effect, single
resulting substitutor was split into two substitutors: one for substituting fresh
variables and another for substituting inferred variables and known parameters.

^KT-32415 Fixed
2019-11-15 16:58:32 +03:00
Pavel Kirpichenkov b6af13f18d [NI] Add missing substitution of known type parameters
Known type parameters appear after inheriting from class with type
parameters. Their substitution matters for inner class constructor,
because without substitution it's parameters will be type checked
against incorrect (original) parameter descriptor with unsubstituted
type parameters.

Skip creation of composite substitutor, if old substitutor is empty.

New substitutors return null in case they don't substitute a type,
but old type substitutors have explicit isEmpty method. Composite
substitutor with empty old substitutor leads to creation
of incorrect descriptor copies.
2019-11-15 16:58:07 +03:00
Pavel Kirpichenkov 3122f2704c [Minor] Refactor resulting descriptor substitution in call transformer 2019-11-15 16:58:07 +03:00
Pavel Kirpichenkov ea66f02035 [Minor] Rename fresh variable substitutor in resolved atom 2019-11-15 16:58:07 +03:00
Mikhail Zarechenskiy 455b9f852d [NI] Disable caching of LHS expression types for "+=" operators
New behavior was introduced in ab506c1579 which breaks compilation on IDE module (see test example) for new inference.

 Now we temporarily disable this optimisation. This is temporarily restriction which will be fixed once we'll have the same rules for lambdas completion

 #KT-34889 Open
2019-11-13 15:07:39 +03:00
Ilya Chernikov 808000e458 Implement warning when non-abstract classes containing abstract members invisible from that classes
#KT-27825 fixed
2019-11-12 19:08:53 +01:00
Steven Schäfer ab506c1579 Frontend: Avoid retypechecking the right hand side of assignment operators 2019-11-08 14:02:56 +03:00
Pavel Kirpichenkov ff32eab3d1 [NI] Run call checkers on resolved calls for callable references
#KT-34391 Fixed
2019-11-08 11:04:43 +03:00
Leonid Startsev 3b100e57f2 Change NO_EXPLICIT_VISIBILITY_IN_API_MODE diagnostic range to 'declaration modifiers + name'.
Motivation: missing visibility modifier is an error in visibility modifiers list, so we should highlight this list.
Including a name in the range is convenient for using alt+enter (you don't have to move cursor from name to fun/class/val keyword)

 Also change NO_EXPLICIT_RETURN_TYPE_IN_API_MODE diagnostic range to 'declaration name' to match corresponding IDE inspection.

Fix stylistic problems and typos after review
2019-11-06 19:54:00 +03:00
Leonid Startsev 5ab262c977 Skip explicit API inspection for data class properties and add inspection for public API in interfaces
Add tests for almost all the cases
2019-11-06 19:54:00 +03:00
Leonid Startsev ebb7e434c8 Explicit Api mode: Renamings after design discussions
Change CLI flag to -Xexplicit-api=strict|warning. 'Disable' state and 'mode' suffix are left out as implementation details.

Change intention title to 'make X public explicitly'

Do not report 'no explicit visibility' on property accessors

Set DECLARATION_SIGNATURE as a range for report

Rename internal diagnostic from _MIGRATION to _WARNING
2019-11-06 19:53:59 +03:00
Leonid Startsev 7fada51c42 Add quickfix for setting explicit public visibility for diagnostic reported in API mode 2019-11-06 19:53:59 +03:00