Commit Graph

1319 Commits

Author SHA1 Message Date
Alexander Udalov 4c9afb9d20 Move testable IS_PRE_RELEASE flag to KotlinCompilerVersion
It'll be used in the JS back-end as well soon, so
DeserializedDescriptorResolver is not the best place for it
2017-02-13 12:11:15 +03:00
Alexander Udalov 6d16ea0a3a Fix reflection on top level declarations from other modules
The main problem here is that moduleName that is being passed to KPackageImpl
is useless: as can be seen in
ClosureCodegen.generateCallableReferenceDeclarationContainer, the name of the
current module is always written to the class file for a callable reference,
not the name of the module of the referenced declaration. This resulted in
reflection not loading the correct .kotlin_module file and subsequently not
finding the required file facade for a top-level function.

The commit does not fix the issue with the incorrect module name written in the
back-end, but workarounds it. It turns out, reflection can figure out the name
of the module of the referenced declaration itself by parsing the header from
the given java.lang.Class object for a single-file/multi-file package facade
and extract the package_module_name protobuf extension. Similar code was
already there in Member.getKPackage() in ReflectJvmMapping.kt but it did not
support multi-file classes, of which there are a lot in the standard library;
this is now supported

 #KT-12630 Fixed
 #KT-14731 Fixed
2017-02-08 19:23:18 +03:00
Denis Zharkov 1bb40afada Simplify compatibility mode with ll=1.0 on JDK dependent built-ins
A lot of problem arise with current solution
(loading them with lowpriority annotation + additional call checkers):
- We errorneously treated ArrayList.stream as an existing method, while
  it's just a fake override from List
- The same problem arises when creating a class delegating to List.
  Also the latter case is failing with codegen internal error
  (see issue KT-16171)

The negative side of this solution is that instead of reporting meaningful
diagnostic, there will be UNRESOLVED_REFERENCE.
But it seems to be better than having strange problems like ones described above.

 #KT-16073 Fixed
 #KT-16171 Fixed
2017-02-08 16:04:19 +03:00
Stanislav Erokhin a4272caa8c Fix serialization for suspend function types.
Since now `suspend (Int) -> String` will be serialized as `(Int, Continuation<String>) -> Any?` + suspend flag.

Before this change such type serialized like this: Function2<Int, String> + suspend flag. And yes, type `Function2<Int, String>` isn't correct, because Function2 expect 3 type arguments.
We have special logic for this case and we deserialize such error-written types correctly.

(cherry picked from commit 3518cbe)
2017-02-02 16:48:59 +03:00
Dmitry Jemerov bc9c40883c Avoid repeated reading of file contents from disk while building stubs 2017-02-01 18:14:57 +01:00
Simon Ogorodnik c2ba4e3ab9 KT-14252 Completion could suggest constructors available via typealiases
#KT-14252 fixed
2017-01-31 15:14:18 +03:00
Alexander Udalov 268d10d3f0 Advance JvmMetadataVersion to 1.1.4, change IS_PRE_RELEASE to false
Kotlin 1.1 is no longer considered a pre-release
2017-01-30 16:00:05 +03:00
Stanislav Erokhin e38ca44595 Create different KotlinBuiltIns for modules with different language feature settings.
For sdkModule we create builtIns with default language feature settings.
Also when we create sdkModuleResolverProvider we create builtIns cache.
Then for every other module we get builtIns cached by value isAdditionalBuiltInsFeatureSupported.
2017-01-28 19:13:48 +01:00
Denis Zharkov 0e132b9857 Move all coroutine-related declarations from built-ins to stdlib
Also move internal declarations from runtime.jvm module into new package
kotlin.coroutines.jvm.internal in stdlib

The necessity of these declarations being in built-ins is controversial,
but also it will complicate the migration of current coroutine runtime
to a separate jar if we ever need this
2017-01-27 23:24:13 +03:00
Alexey Tsvetkov b9dbe69232 Rebuild all kotlin files when EAP flag is changed 2017-01-26 13:38:52 +03:00
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