Commit Graph

85 Commits

Author SHA1 Message Date
Victor Petukhov 1e5998e0ba Add constraints between two different stub variables instead of creating constraint error due to T1 isn't subtype of T2
^KT-44241 Fixed
2021-06-03 19:18:09 +03:00
Dmitriy Novozhilov 6f54e9fd5c Revert "FIR: add smartcast stability to FIR"
This reverts commit 96bd2c54
2021-06-03 09:54:02 +03:00
Tianyu Geng 96bd2c54f0 FIR: add smartcast stability to FIR 2021-06-02 13:19:12 +03:00
Mads Ager f846dd8ea2 [JVM_IR] Avoid using special names in static inline class replacements.
Fixes KT-46952
2021-06-01 16:22:14 +02:00
Victor Petukhov 0c427555cf Support definitely not null stub types and proper subtyping on them 2021-05-28 15:36:19 +03:00
Victor Petukhov 5a11450d77 Split stub types into stub type for subtyping and for builder inference and use them in the proper way 2021-05-28 15:36:17 +03:00
Victor Petukhov ac7b459f2a Do subtyping with stub types properly
1) Return stub type if we are calculating super type between two same stub types
2) Return nullable Any if those stub types are different
2021-05-28 15:36:15 +03:00
Tianyu Geng e1b542314a FIR IDE: quickfix for WrapWithSafeLetCall
There is some behavior change regarding the new WrapWithSafeLetCall quickfix

1. it now works correctly on binary expressions by wrapping it with `()`
2. it now looks for a nullable position upward and do the modification there,
   if possible. For example, consider the following code

   ```
   fun bar(s: String): String = s

   fun test(s: String?) {
     bar(bar(bar(<caret>s)))
   }
   ```

   After applying this fix, FE1.0 yields

   ```
   bar(bar(s?.let { bar(it) }))
   ```

   while the new implementation yields

   ```
   s?.let { bar(bar(bar(it))) }
   ```

   This behavior aligns with FE1.0 if `bar` accepts nullable values.
2021-05-20 20:33:00 +02:00
Denis.Zharkov c4862fb124 FIR: Unwrap type aliases in type arguments 2021-05-20 17:24:42 +03:00
Denis.Zharkov faa5e46396 FIR: Fix inference case with flexible captured types
Previsously, errors have been ignored because we ignored errors raised
from the completion phase

See the comment above the createConstraintPartForLowerBoundAndFlexibleTypeVariable
2021-05-20 17:24:28 +03:00
Mikhail Glukhikh 7675ea3c23 Move AnnotationTargetLists & KotlinTarget to common compiler code 2021-05-20 12:22:21 +03:00
Victor Petukhov 2239404085 Extract type preparation during type checking to a separate component 2021-05-18 17:52:23 +03:00
Mikhail Glukhikh 632a9d66d1 FIR: introduce isPrimitive / isPrimitiveOrNullablePrimitive helpers 2021-05-13 16:13:42 +03:00
Alexander Udalov 54befa769f IR: add IrClass.getInlineClassRepresentation, serialize/deserialize it
The change in FirDeclarationUtil is needed because in case of unsigned
types loaded from the standard library, the primary constructor for some
reason is not the first, but the second in the list of constructors.
2021-05-13 13:56:59 +02:00
Alexander Udalov 7fb3f48c67 Add ClassDescriptor.getInlineClassRepresentation
This will be used at least in the JVM backend instead of the current
approach where we're loading the primary constructor's first parameter,
which isn't good enough since primary constructor can be private, and
we can't rely on private declarations in case they're declared in
another module.
2021-05-13 13:54:02 +02:00
Andrey Zinovyev 07e47140a6 [FIR] Treat unsigned numbers as primitives in constant checker 2021-05-13 10:11:59 +03:00
Tianyu Geng 00031c8eb1 FIR IDE: add action to override/implement missing members
This commit adds the following actions:

- quickfix to implement missing members
- quickfix to implement missing members as constructor parameters
- action to implement members (Code - Generate - Implement)
- action to override members (Code - Generate - Override)

The current implementation is still missing some pieces, which will be
addressed in future changes.

- fully qualified names are not shorten
- some Kotlin types are not rendered correctly
2021-05-07 00:40:40 +03:00
Victor Petukhov 8dd71ec5c8 Build recursive raw types and raw types which contain type parameters properly
1) Substitute erasure of other type parameters
2) Use star projection at top level for recursive raw types

^KT-46126 Fixed
2021-04-30 10:49:47 +03:00
Dmitriy Novozhilov 07b15f9de6 [FIR] Support effective visibility with @PublishedApi
#KT-46270 Fixed
2021-04-27 18:39:10 +03:00
Dmitriy Novozhilov 2a08923c51 [FIR] Add more utilities for builtin functional types 2021-04-27 18:39:06 +03:00
Victor Petukhov 867d7b5bca Allow type variable fixation into intersection type if it isn't meaningless (i.e. has one or more final classes, or two or more open classes)
^KT-46186 Fixed
2021-04-23 15:12:13 +03:00
Ilya Gorbunov 8041c3aa1d Support Char.code in constant evaluator, KT-46036
But do not consider Char.code a pure integer constant.
2021-04-16 03:58:34 +03:00
Victor Petukhov d804e73c22 Avoid subtype checking between type variable of self type and captured star projection only for invariant positions
Subtyping with non-invariant positions may produce useful constraints

^KT-46001 Fixed
2021-04-12 13:44:09 +03:00
Mikhail Glukhikh 6ee169c01e Rename EffectiveVisibility.Private to PrivateInClass 2021-04-08 09:41:26 +03:00
Mikhail Glukhikh 4bd44fa61b FE 1.0: introduce PrivateInFile effective visibility #KT-20094 Fixed 2021-04-08 09:41:25 +03:00
Abduqodiri Qurbonzoda 40d1849f33 Migrate compiler, idea and others to new case conversion api 2021-04-08 03:22:02 +03:00
Igor Yakovlev 7d3be9eafa [FIR IDE] Implement fir renderer for IDE 2021-04-07 11:25:22 +02:00
Igor Yakovlev d05ef3a635 [FIR] Move standard class id's into common module 2021-04-07 11:25:21 +02:00
Dmitriy Novozhilov 220f8a9169 Make EffectiveVisibility methods take typeContext instead initializing it in constructor
This is needed to reuse EffectiveVisibility in FIR, because typeContext
  in it is used to call `isSubtypeOf`, and in FIR it's required to use
  context from use site session (to see all declaration which are
   available in module)
2021-04-06 12:30:44 +03:00
Alexander Udalov b59ac5d8f6 JVM IR: do not use old KotlinTypeMapper when coercing inline classes
KotlinTypeMapper.mapInlineClassTypeAsDeclaration and
mapUnderlyingTypeOfInlineClassType invoked mapType which is defined in
descriptorBasedTypeSignatureMapping.kt and works on KotlinType.

It didn't lead to any problems, other than the fact that we were
constructing IrBasedClassDescriptor in JVM IR, and then KotlinType to
pass it to mapType, on each call to StackValue.boxInlineClass or
unboxInlineClass, which seems wasteful.

Instead of this, refactor these utilities to use type markers instead,
pass IrType and IrTypeMapper directly from JVM IR, and move the "static
type mapper" logic (which is used only in the old backend) out of
KotlinTypeMapper.
2021-04-01 20:17:45 +02:00
Victor Petukhov bbf5c4412e Do subtyping between self types with captured type in special way 2021-03-29 16:30:58 +03:00
Ilya Kirillov 6e31ff4fb1 Introduce CallableId.asSingleFqName and use it instead CallableId.asFqNameForDebugInfo 2021-03-24 18:13:21 +01:00
Ilya Kirillov 6f887896ff FIR IDE: use CallableId for KtCallableSymbol instead of FqName 2021-03-24 18:13:04 +01:00
Mikhail Glukhikh 9ce8420491 FIR: introduce not implemented checker 2021-03-24 16:07:25 +03:00
Ilya Chernikov 32d0c99289 Implement metadata handling for IR scripts 2021-03-11 15:49:45 +01:00
Alexander Udalov bf844aa8e4 JVM IR: prevent behavior change with operator dot calls on literals
#KT-42321 Fixed
2021-03-10 18:46:30 +01:00
Dmitriy Novozhilov 523d37b0f5 [Test] Implement handler which dumps overrides tree of specified classes 2021-03-02 19:11:14 +03:00
Dmitriy Novozhilov 4299794de2 Move SmartPrinter to :core:compiler.common 2021-03-02 19:11:10 +03:00
Ilya Kirillov 83f8650e80 Move CallableId from fir module to compiler.common to use in IDE 2021-02-24 20:13:41 +01:00
Dmitriy Novozhilov 3626008ed2 [Inference] Add ability to approximate local types in AbstractTypeApproximator 2021-02-19 12:47:27 +03:00
Dmitriy Novozhilov df42868874 [Inference] Fix subtyping on classes with same FQN but with different number of arguments
Such situations may appear if there are multiple classes with same
  names from different modules in dependencies
2021-02-17 16:23:08 +03:00
Simon Ogorodnik 83836037f8 Add documentation on type checker context / type system context 2021-02-15 18:29:00 +03:00
Simon Ogorodnik 3909e3c54c Decouple TypeCheckerContext and TypeSystemContext 2021-02-15 18:28:58 +03:00
Alexander Udalov e0b6d4d917 Add -Xsuppress-deprecated-jvm-target-warning to modules compiled with 1.6
Currently this leads to an unknown argument warning, but it'll be
removed automatically on the next bootstrap.
2021-02-03 12:51:39 +01:00
Victor Petukhov 9efac8f68b Propagate all annotations during creating simple functional types
^KT-44563 Fixed
2021-01-29 13:50:46 +03:00
Victor Petukhov f06a5321a6 Approximate definitely not-null types for type parameter's types if they are already not-null (has not-null upper bounds)
^KT-44440 Fixed
2021-01-25 14:17:58 +03:00
Ilya Kirillov a52674f181 FIR: use more meaningful error messages 2021-01-15 17:23:00 +01:00
Stanislav Erokhin d24331955e Rename FirConstKind to ConstantValueKind and move it to compiler.common 2021-01-14 12:12:25 +01:00
Alexander Udalov 77a9d14f93 Capitalize/decapitalize only ASCII characters across project
Use {de,}capitalizeAsciiOnly and to{Lower,Upper}CaseAsciiOnly where
possible, and stdlib's functions with Locale.US everywhere else.

Otherwise, if the default system locale is Turkish, the capital latin
letter "I" is transformed in toLowerCase to "ı" (see
https://github.com/JetBrains/kotlin/blob/66bc142f92085047a1ca64f9a291f0496e33dd98/libraries/stdlib/jvm/test/text/StringJVMTest.kt#L119),
which for example breaks the codegen for `intArrayOf` in
KT-25400/KT-43405.

Similarly, lower case latin letter "i" is transformed to "İ".

 #KT-13631 Fixed
 #KT-25400 Fixed
 #KT-43405 Fixed
2020-12-28 16:10:30 +01:00
Alexander Udalov eef06cded3 JVM IR: output stable ABI binaries by default
#KT-43592 Fixed
2020-12-20 23:14:54 +01:00