Commit Graph

1300 Commits

Author SHA1 Message Date
Alexander Udalov 69bfc5b4bb Write multifile part->facade mapping to .kotlin_module 2017-01-11 13:15:57 +03:00
Alexander Udalov 6c1cadf273 Refactor PackageParts: add explicit mutating methods 2017-01-11 13:15:57 +03:00
Alexander Udalov db3fa8eaca Refactor JvmPackagePartProvider
Make code more imperative than functional, preserve the information about the
original root where the module mapping was discovered
2017-01-11 13:15:56 +03:00
Alexander Udalov 75a4958144 Introduce ClassDescriptor.getSealedSubclasses
#KT-12795 In Progress
2017-01-10 12:23:25 +03:00
Denis Zharkov 2dd7d89048 Fix built-ins overridability issue
See the comment for clarification

 #KT-15097 Fixed
2016-12-20 16:35:26 +03:00
Stanislav Erokhin 04fddc7139 Discriminate header classes in member scope.
We made it because of non-stable name resolution when project is multi platform. For such projects in platform module we have two classifiers with the same name, but impl class or type alias should win!
2016-12-19 22:43:10 +03:00
Stanislav Erokhin 42440f50dc Remove soft keyword coroutine & isCoroutine from ValueParameterDescriptor. 2016-12-15 23:57:56 +03:00
Stanislav Erokhin 642ea81625 Remove annotation Suspend. Use modificator instead. 2016-12-15 23:57:47 +03:00
Denis Zharkov 6649f64e9f Support new coroutine convention in JVM backend 2016-12-15 23:57:40 +03:00
Stanislav Erokhin 59efedf610 Rename platform to header. 2016-12-13 18:00:00 +03:00
Roman Elizarov 8affb2726f Pluggable Synthetic Objects 2016-12-12 18:43:26 +03:00
Yan Zhulanow 3f8accc2bf Kapt3: Fix '$' in function generic signatures (KT-15148) 2016-12-09 20:29:23 +03:00
Yan Zhulanow cbef0250aa Allow to turn the first parameter of a SAM-converted lambda into the receiver (KT-12848) 2016-12-09 20:01:21 +03:00
Mikhael Bogdanov 00e2463014 Effective visibility refactoring: calculate parent decriptor lazily, support checkPublishedApi flag 2016-12-09 11:55:15 +01:00
Mikhael Bogdanov 7af327c567 Added 'checkPublishedApi' to effective visibility checker 2016-12-09 11:55:15 +01:00
Alexander Udalov 88f0c32b2c Treat binaries with version 1.1.2 as pre-release
Metadata version is 1.1.2 since the start of Kotlin 1.1 EAP. Because the
pre-release flag was not written to class files compiled with 1.1 EAP, there's
no other way to figure out that they're pre-release except than to look at the
metadata version. This assumes that the version will be advanced to 1.1.3 once
Kotlin 1.1 is released
2016-12-09 01:59:37 +03:00
Alexander Udalov 830d2f6603 Do not fail when deserializing incompatible metadata
Catch all exceptions when deserializing metadata with an incompatible version
to prevent the compiler from failing on discovering incompatible classes on the
classpath. Note that this is not the perfect solution: any invariant may be
broken in the incompatible metadata and it may result in a later exception
2016-12-09 01:59:36 +03:00
Alexander Udalov 789483e1eb Remove old mechanism of metadata version error reporting 2016-12-09 01:59:36 +03:00
Alexander Udalov b943ed26f3 Report incompatible metadata version error correctly
Similarly to pre-release classes, load metadata for the class anyway and allow
the resolution to select it as the result and prohibit its usage in the end
with the special diagnostic reported in MissingDependencyClassChecker
2016-12-09 01:59:36 +03:00
Alexander Udalov 7de0cfde16 Report error on pre-release top level members 2016-12-09 01:59:34 +03:00
Alexander Udalov 4e99349f1f Write "pre-release" flag to class files, do not allow usages in release 2016-12-09 01:59:33 +03:00
Alexander Udalov 1342743001 Add KotlinVersion.IS_PRE_RELEASE and a flag to kotlin/Metadata 2016-12-09 01:59:33 +03:00
Ilya Gorbunov 459c5fed8c Tweak checks and type parameter heuristics in LazyJavaClassDescriptor.getPurelyImplementedSupertype to support cases of UnaryOperator and BinaryOperator enhancements. 2016-12-08 20:34:55 +03:00
Ilya Gorbunov f66b4201d1 Refactor FakePureImplementationsProvider to use single map 2016-12-08 20:34:52 +03:00
Ilya Gorbunov c66b3b8ef9 Nullability for java.lang.ref.Reference.get 2016-12-08 20:22:17 +03:00
Ilya Gorbunov 15061ff125 Add known methods of collections and maps. 2016-12-08 20:22:17 +03:00
Ilya Gorbunov 14ec4c7acc Minor: refactor expression in signatureEnhancement for better debugging 2016-12-08 20:22:17 +03:00
Ilya Gorbunov 253a901bd3 Evolve DSL for defining enhanced nullability info for known JDK functions. Enhance nullability for java.util.Optional. 2016-12-08 20:22:17 +03:00
Alexey Andreev ba2443bcb3 Add external property to class and property descriptors 2016-12-08 15:41:38 +03:00
Alexander Udalov 921694e13a Deduplicate code in JavaClassDataFinder 2016-12-08 12:20:36 +03:00
Alexander Udalov 41f2048f96 Minor, introduce DeserializedContainerSource 2016-12-07 21:46:37 +03:00
Yan Zhulanow fc0b17c453 Kapt3: Replace "my/package/Class$Inner" to "my/package/Class/Inner" in kapt3 class builder mode 2016-12-05 19:57:21 +03:00
Alexander Udalov ce9691cd2b Support platform/impl modifiers for properties
Do not allow platform properties to have backing fields, initializers, be
delegated, lateinit or const, or have accessors with bodies
2016-11-25 20:50:18 +03:00
Alexander Udalov 6e2ef9b1d2 Add platform/impl soft keywords, add isPlatform/isImpl to MemberDescriptor 2016-11-25 20:50:17 +03:00
Alexander Udalov bfb7b21472 Load definitions of symbols from .kotlin_metadata files
Extract AbstractDeserializedPackageFragmentProvider out of
JvmBuiltInsPackageFragmentProvider and implement it a little bit differently in
MetadataPackageFragmentProvider. The main difference is in how the package
fragment scope is constructed: for built-ins, it's just a single scope that
loads everything from one protobuf message. For metadata, package scope can
consist of many files, some of which store information about classes and others
are similar to package parts on JVM, so a ChainedMemberScope instance is
created.

Introduce a bunch of interfaces/methods to deliver the needed behavior to the
'deserialization' module which is not JVM-specific and does not depend on the
compiler code: MetadataFinderFactory,
PackagePartProvider#findMetadataPackageParts, KotlinMetadataFinder#findMetadata.
Note that these declarations are currently only implemented in the compiler; no
metadata package parts/fragments will be found in IDE or reflection
2016-11-25 20:50:13 +03:00
Alexander Udalov 32792c5ce4 Store .kotlin_module files in MetadataSerializer
Compilation of top level functions/properties/typealiases results in a bunch of
different .kotlin_metadata files, so we need to store names of these files to
avoid scanning the file system in the compiler when loading code compiled by
K2MetadataCompiler.

For this, we reuse the PackageTable protobuf message, which is already used for
exactly the same purpose in the JVM back-end
2016-11-25 20:50:12 +03:00
Alexander Udalov c0b5fd193a Refactor DeserializedPackageFragment and subclasses
Push loadResource and loadResourceSure down to KotlinJavascriptPackageFragment,
as it's no longer needed in BuiltInsPackageFragment
2016-11-22 18:19:02 +03:00
Alexander Udalov 19520bf29c Extract KotlinMetadataFinder interface out of KotlinClassFinder 2016-11-22 18:19:02 +03:00
Dmitry Petrov fc2a965d2a Fix decompiler tests. 2016-11-22 14:40:02 +03:00
Alexander Udalov 61767bb0ea Minor, annotate visibility constants with NotNull
To avoid nullability warnings on ClassDescriptor#getVisibility and
implementations
2016-11-11 19:00:08 +03:00
Alexander Udalov 8c65379711 Support injecting custom module into KotlinBuiltIns
Provide a command-line option to load built-ins from the module and its
dependencies instead of looking for them in kotlin-compiler.jar; built-ins must
be found this way, or an error will be reported (or, most likely at this
moment, an exception will be thrown).

Note that this does not affect whether built-ins (loaded from one place or the
other) are added to the _dependencies_ of the module, this is controlled by
another option. The option added in this commit only makes the KotlinBuiltIns
instance which is used via ModuleDescriptor throughout the compiler front-end
(and also injected in a bunch of places) a sort of "helper" which always goes
to that same module to find descriptors for built-in classes
2016-11-08 12:14:24 +03:00
Alexander Udalov 5cd9e11f44 Refactor initialization of JvmBuiltIns instance
Use lazy val instead of lateinit var + implicit dependency on the code in
KotlinBuiltIns constructor
2016-11-08 12:14:23 +03:00
Alexander Udalov e0989caf46 Load built-ins from module dependencies in JVM compiler
Introduce a new method KotlinClassFinder#findBuiltInsData, which is only
implemented correctly in the JvmCliVirtualFileFinder because it's only used in
the compiler code at the moment.

Introduce JvmBuiltInsPackageFragmentProvider, the purpose of which is to look
for .kotlin_builtins files in the classpath and provide definitions of
built-ins from those files.

Also exclude script.runtime from compilation because, as other excluded
modules, it has no dependency on the stdlib and is no longer compilable from
the IDE now, because it cannot resolve built-ins from anywhere
2016-10-26 16:31:09 +03:00
Alexander Udalov 484b0e36fb Add KotlinBuiltIns#isBuiltIn, use it instead of other utilities 2016-10-26 16:31:05 +03:00
Alexander Udalov 2b34d62848 Extract superclass from FunctionClassScope and CloneableClassScope 2016-10-26 16:31:03 +03:00
Alexander Udalov 4e7542b07d Filter out non-builtin package fragments from module when needed
In subsequent commits, a JVM module will be able to have up to two package
fragments for a given package FQ name. For example, for package "kotlin" in
kotlin-runtime.jar there will be a LazyJavaPackageFragment with binary
(Kotlin+Java) dependencies, and a BuiltInsPackageFragment for built-ins
metadata (which is loaded from kotlin/kotlin.kotlin_builtins)
2016-10-25 15:42:33 +03:00
Alexander Udalov 035d6156a7 Drop Cloneable in JS, synthesize it at compile-time on JVM
Use the same approach that is used for creating function type classes
(Function{0,1,...}) + add Cloneable to supertypes of Array and primitive arrays

 #KT-5537 Fixed
2016-10-25 15:42:33 +03:00
Alexander Udalov 0f4b10d37d Add JavaToKotlinClassMap#isJavaPlatformClass
Use it instead of mapPlatformClass where we only need to check emptiness
because mapPlatformClass requires built-ins and it's not always easy to come up
with the correct instance of built-ins.

In KotlinEvaluationBuilder, use the nullable function
findClassAcrossModuleDependencies instead of mapPlatformClass which uses the
throwing resolveClassByFqName. This is necessary because DefaultBuiltIns, which
are used there, are not always able to find classes mapped by a _Java_ to
Kotlin class map. (The correct solution would be not to use DefaultBuiltIns at
all, instead obtaining the correct instance of built-ins, which are almost
certainly going to be JvmBuiltIns, from the project configuration.)
2016-10-25 15:42:32 +03:00
Alexander Udalov 2f81d48f5e Use ClassId instead of FqName in JavaToKotlinClassMap
Extract mapJavaToKotlin which returns ClassId and needs no KotlinBuiltIns
instance
2016-10-25 15:42:32 +03:00
Alexander Udalov c0147860bd Allow multiple ClassDescriptorFactory instances in deserialization 2016-10-25 15:42:32 +03:00