Commit Graph

4334 Commits

Author SHA1 Message Date
Alexander Udalov d257285c86 Load Java enums as final classes
In case Java enum has an abstract member, it has the ACC_ABSTRACT flag
set in the bytecode. However, we should still load it with final
modality to be consistent with Kotlin enums which are always considered
final

 #KT-23426 Fixed
2019-04-10 14:39:16 +03:00
Alexander Udalov 5bafd4008f Use correct class loader to load .kotlin_builtins in reflection
#KT-30749 Fixed
2019-04-08 12:43:53 +03:00
Dmitry Petrov 1c0c01725b Preserve original for constructors of LazySubstitutingClassDescriptor
We would like DeclarationDescriptor.getOriginal() to always point to a
(preferably unique) unsubstituted descriptors for the given possibly
substituted descriptor. In case of LazySubstitutingClassDescriptor
(which can be observed for nested generic Java classes), this invariant
was broken, because 'getOriginal()' for constructors of substituted
class returned a copy created for this particular substituted class.
2019-04-04 14:42:23 +03:00
Mikhail Zarechenskiy 63bdabcfae [NI] Clean up after merge with 3998e842 2019-04-02 12:21:15 +03:00
Simon Ogorodnik 3998e842f1 Abstract NewInference & related from KotlinType
Cleanup TypeConstructors & KotlinTypes in VariableFixationFinder
Cleanup TypeConstructors & KotlinTypes in TypeVariableDirectionCalculator
Cleanup KotlinTypes in TypeCheckerContext for ConstraintSystem
Cleanup KotlinTypes in NewCommonSuperTypeCalculator
Cleanup KotlinTypes in TypeApproximator
Cleanup type substitution
Cleanup NewTypeVariable
Cleanup StubType
Cleanup TypeCheckerContext creation, extract common supertype context
Provide TypeSystemInferenceExtensionContext via dependency injection
2019-04-01 22:08:04 +03:00
Ilmir Usmanov 6f14dcfacb Put suspend lambda's parameters to LVT
#KT-26412 Fixed
 #KT-28534 Fixed
2019-03-30 04:18:50 +03:00
Dmitry Petrov 8be7f7f1f7 IR: Make sure that symbols refer to original descriptors only
If a descriptor is a WrappedDeclarationDescriptor, it SHOULD NOT be
substituted.
2019-03-29 16:00:56 +03:00
Alexander Udalov cd6c88fa2c Do not use .kotlin_module files in reflection
Previously, we used a pretty roundabout way to load a MemberScope from a
single file facade represented by KPackageImpl, which involved going
through ModuleDescriptor, PackageFragmentProvider, PackagePartProvider
etc. The only advantage of this approach was that it sort of works
similarly as in the compiler, however mutable state in
RuntimePackagePartProvider and the fact that .kotlin_module files were
required for this to work diminished this advantage.

In this change, we load MemberScope from a KPackageImpl pretty much
directly, by using the existing method
`DeserializedDescriptorResolver.createKotlinPackagePartScope` and
caching the result in the new component PackagePartScopeCache.

 #KT-30344 Fixed
2019-03-29 13:44:23 +01:00
Alexander Udalov b32241c967 JVM IR: build all needed stdlib symbols in JvmSymbols manually
This removes the mandatory dependency of all JVM IR tests on
kotlin-stdlib (ConfigurationKind.ALL in all IR test cases) and speeds up
tests which don't need kotiln-stdlib by about 20%. Another advantage of
this method is that all required dependencies are listed in one file,
are easy to grasp, and changes to the related code generation can be
done independently of the corresponding changes in the actual library,
which may help in bootstrapping the compiler
2019-03-29 12:07:11 +01:00
Mikhail Zarechenskiy 1ac25259e8 [NI] Support callable references to suspend functions
#KT-30658 Fixed
2019-03-29 12:32:01 +03:00
Mikhail Zarechenskiy d6db1a1b35 [NI] Relax requirement for stub types in builder-inference
For functions with implicit return type annotations will be replaced
 anyway in order to initialize return type, so this restriction in
 `StubType` was too strong

 #KT-30656 Fixed
2019-03-29 12:32:01 +03:00
Ilya Kirillov f1f6740ec9 Show warnings for Java methods with external annotations when they called from Kotlin code 2019-03-27 20:10:46 +03:00
Ting-Yuan Huang 4ff2825de0 Fix an assertion for type parameters 2019-03-26 10:44:06 +03:00
Dmitriy Novozhilov ca0e66bafc [NI] Refactor compiler representation of integer literals types
Add `IntegerLiteralTypeConstructor` that holds types, that can take
  integer literal with given value. It has two supertypes
  (`Number` and `Comparable<IntegerLiteralType>`) and have
  special rules for subtyping, `intersect` and `commonSuperType`
  functions with primitive number:

Example (assuming that ILT holds Int type):
* ILT <: Int
* Int :> ILT
* ILT intersect Int = Int
* commonSuperType(ILT, Int) = Int

#KT-30293 Fixed
#KT-30446 Fixed
2019-03-25 18:55:36 +03:00
Abduqodiri Qurbonzoda 636ed025da Replace "binary representation of" with "bits of" 2019-03-22 21:18:27 +03:00
Abduqodiri Qurbonzoda 960797b926 Replace mistaken "bit sign" with "sign bit" 2019-03-22 21:18:27 +03:00
Abduqodiri Qurbonzoda f36a8db8eb More detailed Primitive.toChar conversion documentation 2019-03-22 21:18:27 +03:00
Alexander Udalov 87c6b723f0 Add JvmBuiltIns.Kind instead of boolean flags in constructor 2019-03-22 14:59:03 +01:00
Alexander Udalov c32d7ef116 Do not create additional module for built-ins in reflection 2019-03-22 14:59:03 +01:00
Alexander Udalov ed86757817 Rework how built-in types are loaded in compiler for JVM
In TopDownAnalyzerFacadeForJVM, we now always use the "load built-ins
from module dependencies" behavior that was previously only enabled with
the dedicated CLI argument -Xload-builtins-from-dependencies. However,
sometimes we compile code without kotlin-stdlib in the classpath, and we
don't want everything to crash because some standard type like
kotlin.Unit hasn't been found.

To mitigate this, we add another module at the end of the dependencies
list, namely a "fallback built-ins" module. This module loads all
built-in declarations from the compiler's class loader, as was done by
default previously. This prevents the compiler from crashing if any
built-in declaration is not found, but compiling the code against
built-ins found in the compiler is still discouraged, so we report an
error if anything is resolved to a declaration from this module, via a
new checker MissingBuiltInDeclarationChecker.

Also introduce a new CLI argument -Xsuppress-missing-builtins-error
specifically to suppress this error and to allow compiling code against
compiler's own built-ins.

 #KT-19227 Fixed
 #KT-28198 Fixed
2019-03-22 14:59:03 +01:00
Alexander Udalov 8ce7742e7c Inject DeserializationConfiguration into JvmBuiltInsPackageFragmentProvider 2019-03-22 14:59:03 +01:00
Simon Ogorodnik 2118f6008a Extract TypeArgumentListMarker.all 2019-03-22 16:25:12 +03:00
Dmitry Gridin 403801b0b3 Fix exception when add import
#KT-30524 Fixed
2019-03-21 16:35:43 +07:00
romanart 5b5f3a7468 [IR] Fix classes TypeParameter [de]serialization 2019-03-20 11:57:57 +03:00
Alexander Udalov 29d32b213e Cleanup modules descriptors.jvm, descriptors.runtime
Fix warnings and inspections
2019-03-19 13:01:03 +01:00
Alexander Udalov b89d7029b2 Reformat modules descriptors.jvm, descriptors.runtime
Also remove several unused files (BuiltinOverridabilityCondition.kt,
PackageMappingProvider.kt)
2019-03-19 13:01:02 +01:00
pyos 330c4648cb Implement property references in JVM_IR 2019-03-19 12:00:29 +01:00
Ilya Gorbunov b0a234ec74 Minor: collection docs formatting 2019-03-19 03:12:09 +03:00
Ilya Gorbunov bc444df20c Clarify behavior of MutableSet.add (KT-29373) 2019-03-19 03:12:04 +03:00
Alexander Udalov c730de13df Minor, add missing copyright to compiler modules 2019-03-15 19:27:46 +01:00
Abduqodiri Qurbonzoda 814d6cf39c Document Array and String get() function behavior (KT-30141) 2019-03-15 17:40:19 +03:00
Mikhail Glukhikh fb788dc4c0 Fix null Java type argument problem & add relevant test 2019-03-14 17:56:23 +03:00
Mikhail Glukhikh f31faafd72 Introduce initial version of FIR Java type enhancement
Java type enhancement is performed by a special scope kind
Java FIR dump was added for multiplatform tests to look at enhancements
Overrides, J2K mapping, special cases does not work yet

Related to KT-29937
2019-03-14 17:51:00 +03:00
Mikhail Glukhikh 8ac34e1a0f Reformat: context (Java resolve) 2019-03-14 17:39:25 +03:00
Ilmir Usmanov 0c0f035241 Set default value of releaseCoroutines in TypeSignatureMapping to true 2019-03-14 15:06:07 +03:00
Ilya Gorbunov ffe8b4419c Docs: use consistent kotlinlang.org url in references 2019-03-13 17:53:37 +03:00
Abduqodiri Qurbonzoda a0e2ca669b Write docs for primitive types conversions 2019-03-13 13:14:37 +03:00
Nikolay Krasko 213b98fefe Review changes: revert compiler behaviour, add test, remove inner classes 2019-03-12 14:28:31 +03:00
Harry Billinis 6ba134b1be Better names suggestion for constant like reference expressions (KT-28485)
Code was simplified after @igorwojda suggestions

 #KT-28485 Fixed
2019-03-12 14:28:31 +03:00
Dmitry Gridin 57040f6f9d Minor: refactoring & fix warnings 2019-03-11 23:38:19 +07:00
Alexander Udalov d8b364ea40 Mark KAnnotatedElement.hasAnnotation as experimental
#KT-29041 Fixed
2019-03-08 14:57:01 +01:00
Kerooker a342f844b8 Implements KAnnotatedElement.hasAnnotation()
This commit fixes KT-29041, by adding a convenience method to verify if a certain `KAnnotatedElement` has an annotation or not
2019-03-08 14:53:51 +01:00
Alexander Udalov 59fda8d7ce Support JvmPackageName with JvmMultifileClass
This is an internal feature of our standard library needed to compile
new API for unsigned types
2019-03-06 15:34:23 +01:00
Simon Ogorodnik 85cd4f3cdf Extract common code (TypeSystemContext) 2019-03-06 13:33:29 +03:00
Yan Zhulanow eb1543c71a Minor: Fix a few compilation warnings in compiler and compiler tests, fix formatting 2019-03-06 03:30:55 +03:00
Alexander Udalov d1e33534db Implement typeOf intrinsic on JVM
#KT-29915 Fixed
2019-03-05 18:16:31 +01:00
Alexander Udalov 4d817aa6cf Minor, simplify/optimize FunctionTypeConstructor.computeSupertypes 2019-03-05 16:28:53 +01:00
Mikhail Zarechenskiy c4b69b65bc Gradually prohibit comparison of incompatible enums
#KT-22043 Fixed
2019-03-05 13:33:23 +03:00
Mikhail Zarechenskiy 82c8289666 Refactoring: move getRepresentativeUpperBound method to core
Plus prettify it a bit
2019-03-05 13:33:23 +03:00
Simon Ogorodnik 4882627712 Make type-system KotlinType-independent
- Port NewKotlinTypeChecker.equalTypes
- Decouple new-type transform from isSubtypeOf
- Port isSubtypeForSameConstructor
- Port checkSubtypeForSpecialCases
- Port isSubTypeOf without internals
- Port anySupertype
- Port isSubtypeForSameConstructor, findCorrespondingSupertypes
- Port isSubtypeOfForSingleClassifierType
- Port NullabilityChecker
- Reorder checks for performance
2019-03-04 17:27:45 +03:00