Commit Graph

4543 Commits

Author SHA1 Message Date
Zac Sweers 482874fdc1 Embed proguard/R8 rules in kotlin-reflect artifact jar
The Android build pipeline can extract embedded proguard configurations
from dependencies and merge them automatically. This adds a conservative
proguard configuration to the kotlin-reflect JVM artifact in support of
that. This focuses mostly on just retaining what's necessary for
kotlin-reflect's own functionality to operate, but could be expanded if
community feedback discovers other good candidate rules.

With this in place - most Android projects using R8 or Proguard should
Just Work™️ with kotlin-reflect.
2020-01-17 20:03:52 +01:00
Mikhail Zarechenskiy 76a78fe918 FIC: render fun before interfaces in descriptor renderer 2020-01-17 19:37:48 +03:00
Mikhail Zarechenskiy 70094884ca FIC: support suspend conversions in jvm codegen 2020-01-17 19:36:11 +03:00
Mikhail Zarechenskiy 0e90d538df FIC: propagate info about conversions for deserialized classes 2020-01-17 19:36:08 +03:00
Mikhail Zarechenskiy 0fdebdfeba Refactoring: move SamConversionResolverImpl to core module 2020-01-17 19:36:07 +03:00
Mikhail Zarechenskiy cd5c1b96bb Refactoring: move SamConversionResolver to more applicable package 2020-01-17 19:36:07 +03:00
Mikhail Zarechenskiy 562f0e62a3 FIC: Move sam related methods to ClassDescriptor, fix JVM backend part 2020-01-17 19:36:03 +03:00
Mikhail Zarechenskiy 87e79e72a9 Refactoring: move SamConversionResolver to core.descriptors 2020-01-17 19:36:02 +03:00
Mikhail Zarechenskiy c71c1d45c6 FIC: Make SAM conversions also for fun interfaces, add base test 2020-01-17 19:36:01 +03:00
Mikhail Zarechenskiy 193d807a1e Refactoring: make parameters of getFunctionTypeForSamType not null 2020-01-17 19:36:01 +03:00
Mikhail Zarechenskiy 303811cbd9 FIC: Increase JVM metadata version 2020-01-17 19:35:06 +03:00
Mikhail Zarechenskiy f7ce1c669b FIC: Introduce isFun property for descriptors and proto 2020-01-17 19:35:06 +03:00
Alexander Udalov 0815ed2cbd JVM IR: do not load KDeclarationContainer from builtins
Like other classes declared in the standard library, construct a mock of
it in JvmSymbols. This is needed to move classes in kotlin.reflect out
from builtins and to the JVM part of the standard library.
2020-01-16 15:33:15 +03:00
Ilya Gorbunov 427e34fe5a Do not serialize JVM kotlin.reflect to builtins
Serialize common types from kotlin-reflect as builtins instead.
2020-01-16 15:32:29 +03:00
Denis Zharkov 676c99b933 NI: Fix exception during callable references overload resolution
^KT-35847 Fixed
2020-01-16 10:49:49 +03:00
Denis Zharkov d6b01f1007 NI: In subtyping do not intersect arguments for non-covariant types
It partially reverts 7898922066
because it's not obvious that it's a safe operation
for invariant/contravariant types.

Also, there's a necessary fix in prepareReceiverRegardingCaptureTypes
to make types order stable
Otherwise test bareTypesWithStarProjections becomes flaky.

Also, the changes in bareTypesWithStarProjections.kt are also expected
because the type of the expression `coneSymbol` after the second "if" is
FirVariableSymbol<*> & FirPropertySymbol & AbstractFirBasedSymbol<*>
thus we fix D in the call `coneSymbol.phasedFir()` to FirVariableSymbol<*>
because it's the first type in the list
(see the next line after the last changed in AbstractTypeChecker)
2020-01-14 17:35:24 +03:00
Denis Zharkov 4202c9c1a4 NI: Fix regression for star-projections approximation
See the test added

^KT-35703 Fixed
2020-01-14 17:35:24 +03:00
Alexander Udalov e0b9ffa780 Regenerate builtins sources 2020-01-03 13:09:43 +01:00
Alexander Udalov 8a4510c21b Regenerate tests 2020-01-02 10:31:00 +01:00
Dmitriy Novozhilov 5dfe100ae5 Allow use reference to reified type parameters in contracts since 1.4 2019-12-26 17:43:28 +03:00
Denis Zharkov 7898922066 NI: Fix type mismatch caused by smartcast
^KT-25434 Fixed
2019-12-26 12:35:35 +03:00
Denis Zharkov abee908b94 Remove effectively dead code in AbstractTypeCheckerContext 2019-12-26 12:35:33 +03:00
Victor Petukhov 4309f53e11 NI: don't filter flexible types during CST calculation and force return as result the first of such types
^KT-35658 Fixed
2019-12-25 18:00:23 +03:00
Alexander Gorshenev dc8240c24e Expect/actual support in klibs under -Xklib-mpp 2019-12-18 19:29:56 +03:00
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
Denis Zharkov 0064429339 Avoid using TypeSystemInferenceExtensionContextDelegate in FIR
It's only needed in old FE to avoid clashes when initializing DI

The main idea is gettind rid of intermediate interfaces because
each of them adds another intermediate DefaultImpls call
2019-12-13 14:39:06 +03:00
victor.petukhov 71cb65c064 NI: Add flexible Nothing to trivial constraints to filter it 2019-12-12 18:45:11 +03:00
Dmitriy Novozhilov e7f8c8e155 [TEST] Regenerate tests after previous commit 2019-12-12 16:11:45 +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
Denis Zharkov 692442d7a2 Do not look into captured star projection as types 2019-12-04 10:52:19 +03:00
pyos 7cd55c85e6 JVM/JVM_IR: fix mapping of KClass in annotation classes
* JVM incorrectly mapped T<KClass<...>> to T<Class<...>> because the
   annotation-ness of the type mapping mode was inherited one level
   down into a generic signature independent of T

 * JVM_IR was even worse as it did not use VALUE_FOR_ANNOTATION at all,
   mapping T<T<KClass<...>> to T<T<Class<...>> as well.

The correct behavior is to map KClass to Class only at top level or as
an argument of Array.
2019-12-03 11:42:23 +01:00
Ilya Chernikov 7dd9ed7e38 [NI] Fix loosing type annotations on extension functions
#KT-32138 fixed
2019-11-29 13:44:41 +01:00
victor.petukhov dbacae94d0 Fix common super type calculation for captured dynamic types
^KT-32499 Fixed
2019-11-27 15:48:00 +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
Roman Golyshev a18da68171 Remove redundant toList call in LazyJavaPackageScope 2019-11-11 16:01:23 +03:00
Alexey Tsvetkov 6e9cd85b54 Exclude some proto messages from proto comparison in IC 2019-11-08 14:14:58 +03:00
Alexey Tsvetkov 28e6219b0b Fix proto comparison for fields mapped to type table 2019-11-08 14:14:58 +03:00
Ilmir Usmanov ca527444cb Return Unit manually in callSuspend and callSuspendBy if callable
returns Unit. The reason is the same as in the previous commit.
If the callable is tail-call and its callee returns something other that
Unit and suspends, on resume the result of the call will not be Unit.
 #KT-34703
2019-11-01 17:48:04 +03:00
Alexander Udalov e8e04ca98e Do not use new stdlib API in reflection implementation
Otherwise this brings incompatibility between kotlin-reflect 1.3.70+ and
kotlin-stdlib 1.3.60-.

This commit reverts the relevant parts of c164745301, 5c89f2fa54 and
896512f7cd.
2019-10-31 17:39:34 +01:00
Mikhail Zarechenskiy b30a9e1d3e [NI] Remove capturing from supertypes during computation of CST 2019-10-31 11:32:05 +03:00
Mikhail Zarechenskiy 01ad9c47c8 [NI] Fix subtyping between integer literal types and intersection ones
Consider a call like `select(1, "")`, the resulting type for it is
 Comparable<Int & String> & Serializable.

 After variable fixation, the compiler incorporates this type into the
 constraint system to check for a contradiction, so it checks
 applicability of argument to the resulting type.

 In other words, for the above call it checks is
 `Comparable<Int & String> & Serializable` subtype of `IntegerLiteralType`?
 Which ends up in checking is `IntegerLiteralType` subtype of `Int & String`.

 Before this commit, such check was leading to the false result, but
 because of losing diagnostic (which was fixed in the previous commit:
 29f591b1), there was no error
2019-10-31 11:32:02 +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
Alexander Udalov 896512f7cd Support KClass.isInstance/cast/safeCast in stdlib-only reflection implementation
#KT-14720 Fixed
2019-10-29 15:52:00 +01:00
Alexander Udalov 5c89f2fa54 Support KClass.qualifiedName in stdlib-only reflection implementation
#KT-34586 Fixed
2019-10-29 15:51:25 +01:00
Alexander Udalov c164745301 Support KClass.simpleName in stdlib-only reflection implementation
#KT-33646 Fixed
2019-10-29 15:51:21 +01:00
Nikolay Krasko 620898c73e Use local single-thread cached value instead of thread locals (KT-28940)
It looks like thread locals are not needed here as their global state
is not utilized but creates troubles with memory management.
2019-10-29 13:40:34 +03:00