Commit Graph

1309 Commits

Author SHA1 Message Date
Alexander Udalov f1cd2ee6fd Introduce PropertyDescriptor.isDelegated, write new flag to metadata
#KT-8384 In Progress
2017-01-23 12:25:34 +03:00
Denis Zharkov 4ab6b6954d Fix false positive "Null can not be a value of a non-null type"
Inferred type of receiver of orElse  is Optional<T & Any>
Generic descriptor is orElse(E!): E!
Substituted descriptor is orElse(T): T , and that is the problem.

Seems that E!  => (T & Any)!  gets expanded to just T  or T & Any , however it should be expanded to
(T & Any) .. (T & Any)?  => T & Any .. T & Any

T & Any is NotNullTypeParameter(T)

The problem is that (T & Any)?  is expanded to T & Any,
that is seems to be wrong.

 #KT-15236 Fixed
2017-01-19 10:20:35 +03:00
Denis Zharkov 5d4f51d9b6 Refine 1.0-compatibility mode for JDK dependent members
- calls must be prohibited iff they refer to some additonal built in member
- override must be prohibited iff all of the overridden descriptors are additional

Other usages were able to be successfully compiled by 1.0.x

Solution with @Deprecated(level=Error) doesn't work properly, because
deprecation propagates to overridden, thus call 'java.util.ArrayList<String>().stream()'
becomes invalid, while it was correct in 1.0.x

 #KT-15794 Fixed
2017-01-19 10:20:35 +03:00
Denis Zharkov 22ddfed911 Do not load PlatformDependent annotated built-in members with lv=1.0
#KT-15780 Fixed
2017-01-18 13:00:32 +03:00
Alexander Udalov 8499db1f42 Update JvmMetadataVersion to 1.1.3
This is needed because 1.1.2 binaries are considered pre-release (see
DeserializedDescriptorResolver), so it wasn't possible to compile
non-pre-release binaries with -language-version 1.0
2017-01-17 15:00:52 +03:00
Alexander Udalov 6ffa56b640 Move name sanitization utilities to module 'descriptors' 2017-01-12 11:24:23 +03:00
Alexander Udalov f4d59304e2 Fix JvmPackageTableTest by preserving package order in ModuleMapping.create 2017-01-12 11:08:23 +03:00
Alexander Udalov edb4fd1dfd Do not emit pre-release flag if -Xskip-metadata-version-check is used
The -Xskip-metadata-version-check command line argument is supposed to be used
to avoid getting errors only; the side effect that it also caused compiler to
write the pre-release flag to binaries was a mistake and is fixed now
2017-01-11 19:28:52 +03:00
Alexander Udalov e860d620c6 Add script flag to kotlin.Metadata
This will allow to distinguish compiled scripts from ordinary classes in the
compiler, reflection, IDE, etc.

 #KT-13382 Fixed
2017-01-11 19:28:51 +03:00
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