Commit Graph

36693 Commits

Author SHA1 Message Date
Alexander Udalov ebd577e52a Introduce KProperty{1,2}.getExtensionDelegate
These two functions are supposed to fix an inconvenience in the design of
KProperty{1,2}.getDelegate for extension properties, where you have to pass an
instance of the extension receiver which is going to be completely ignored

 #KT-8384 Fixed
2017-01-23 12:25:36 +03:00
Alexander Udalov 78f2515e95 Introduce KProperty{0,1,2}.getDelegate
#KT-8384 In Progress
2017-01-23 12:25:35 +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
Alexander Udalov 76fc3b40d5 Do not consider Kotlin compiler as library in runtime versions checker
Otherwise because there's no Kotlin-Version in its manifest, it's regarded as a
1.0 runtime library which conflicts with 1.1 libraries
2017-01-23 11:30:53 +03:00
Dmitry Petrov e31e12474f KT-15844
Property with type inferred from getter could access primary constructor parameters inside the getter
(which is incorrect, and caused problems in compilation).
Fix scopes for property descriptor resolution.
'getScopeForMemberDeclarationResolution' in AbstractLazyMemberScope should always return member declaration resolution scope.
Two scopes are required, because both property initializer and property accessors should see property type parameters.
2017-01-23 10:22:34 +03:00
Denis Zharkov 2edcd369a8 Fix inference issue with Stream.collect
See doNotCaptureSupertype test for clarification:
When resolving b.collect(toList()) we're building a common system with
two variables T and R.

The problem was that when introducing the constraint
C<T, Inv<T>> <: C<in String, R> we then were seeing the constraint
T <= in String, and add the constaint T=Captured(in String)

That lead to R=Inv<T>=Inv<Captured(in String)>, and after approximation
R=Inv<in String>, that is not the desirable result (Inv<String> suits here)

But the root problem was that we add captured constaint when projection was from supertype,
that seems to be wrong, and for example Java doesn't do that in the similar situation.

 #KT-11259 Fixed
2017-01-22 13:29:08 +03:00
Alexander Udalov a18720154c Fix diagnostic test data 2017-01-21 12:59:01 +03:00
Alexander Udalov fc637eb420 Change runtime component from "Core" to "Main"
This is needed to allow the old compiler have the new runtime libraries in the
classpath. See the previous commit for a more elaborate explanation
2017-01-21 12:57:15 +03:00
Alexander Udalov 139d37cfd0 Support "Main" component in JVM runtime version consistency checker
The point here is to disable the "checkNotNewerThanCompiler" check because it
breaks a real life use case of compiling with an old compiler against the new
runtime library (that may come implicitly as a transitive dependency of another
library). However, to keep the possibility of restoring this check in the
future without backporting the needed changes into the old branches, we now
only perform this check for the "Core" runtime components, and all other checks
-- for "Core" and "Main" runtime components. In the follow-up commit, we change
the runtime component of our libraries to "Main". If we decide we need the
"checkNotNewerThanCompiler" behavior in the future, we can change the runtime
component to "Core", effectively restoring this check in the old compilers
2017-01-21 12:57:14 +03:00
Alexander Udalov 7b4e826650 Enable JVM runtime version consistency checker in 1.1 2017-01-21 12:57:14 +03:00
Ilya Gorbunov 3a1ed41436 Create deprecated MutableList.sort extensions to guide how to replace them.
#KT-15790 Fixed
2017-01-21 03:14:42 +03:00
Dmitry Petrov 6e2ebaa300 KT-12846 Forbid vararg of type 'Nothing' and 'Nothing?' 2017-01-20 17:50:19 +03:00
Mikhail Glukhikh 1f573bb115 EA-92388: Fix of exception in import action creation 2017-01-20 17:39:14 +03:00
Mikhael Bogdanov 818773b7e2 Updated android test configuration 2017-01-20 13:16:58 +01:00
Mikhael Bogdanov da1b8a02ed Exclude builtins members mapped to java default methods from delegation 2017-01-20 13:16:58 +01:00
Dmitry Petrov 03a697a707 Prohibit renaming operator to another operator on import. 2017-01-20 13:01:39 +03:00
Mikhail Glukhikh 9625c32527 Exhaustive when on sealed trees implemented #KT-13130 Fixed
Also #KT-13227 Fixed
2017-01-20 11:04:54 +03:00
Ilya Gorbunov 3d7bcbdff9 Minor: add two cases for Map.getOrDefault test
Relates to #KT-15610
2017-01-19 22:33:20 +03:00
Ilya Gorbunov 3ec48ab244 Add kotlin.comparisons package to default imports. 2017-01-19 18:21:14 +03:00
shiraji ad9bf1626f Fix the problem with ConvertPrimaryConstructorToSecondaryIntention for enum #KT-15406 Fixed 2017-01-19 17:57:33 +03:00
Alexey Andreev 245f23e7c2 JS: fix translation of references to external nested classes in files marked with @JsModule. See KT-15797 2017-01-19 16:30:57 +03:00
Dmitry Petrov 5fc8208504 KT-13355: fix Kotlin compilation. 2017-01-19 16:09:29 +03:00
Dmitry Petrov b36e3bc083 KT-13355
An overridden abstract member with a more specific "return type" than an overridden concrete member
should be explicitly overridden even if the class in question can have abstract members.
2017-01-19 16:09:29 +03:00
Dmitry Petrov f89de02ff0 OverrideResolver: convert to Kotlin & cleanup. 2017-01-19 16:09:29 +03:00
Dmitry Petrov 7f2085b4e4 OverrideResolver: .java -> .kt 2017-01-19 16:09:29 +03:00
Denis Zharkov bbb5d4eb0f Fix 1.0-compatibility mode for JDK dependendent built-ins
Do not report UNSUPPORTED_FEATURE if there is no overridden descriptors
E.g. in case of property accessors
2017-01-19 15:20:57 +03:00
Ilya Gorbunov 7696d20adf Deprecate moved reflection 1.1 api with ERROR 2017-01-19 14:07:17 +03:00
Alexey Andreev af1b7c49b4 JS: insert dummy initializers for property that initialized on init block or in secondary constructors. See KT-8211 2017-01-19 13:20:24 +03:00
Alexey Andreev a927770935 JS: fix scope of function generated for primary constructor. See KT-15678 2017-01-19 13:09:59 +03:00
Alexey Andreev daac24b62e JS: prohibit referencing noImpl property from non-external declarations. See KT-15306 2017-01-19 13:09:06 +03:00
Alexey Andreev 199790276b JS: prohibit dynamic values as handlers of property delegates. Prohibit delegation of classes by dynamic values. See KT-15283 2017-01-19 13:07:58 +03:00
Alexey Andreev a4b2abc7d5 JS: prohibit spread operator and destructuring declaration in dynamic values. See KT-15283 2017-01-19 13:07:57 +03:00
Alexey Andreev 31d0e0b7c4 JS: prohibit .. operation on dynamic type. See KT-15184 2017-01-19 13:07:56 +03:00
Alexey Andreev e6be418dd3 JS: prevent optimizer from removing access to dynamic property access. See KT-15278 2017-01-19 13:07:56 +03:00
Mikhael Bogdanov e1bec0df2e Proper generate interval for catch block variable; Fix for KT-15646: InconsistentDebugInfoException when stepping over throw
#KT-15646 Fixed
2017-01-19 09:33:10 +01: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
Dmitry Petrov b9f9894310 KT-15677 KT-15775
Update parser & descriptor renderer to handle parenthesized types and function types properly.
Resolve annotations in parenthesized types.

AnnotationsImpl.isEmpty() returned false for targeted annotations only
(e.g., 'fun @receiver:Ann C?.foo()').
Properly keep track of targeted annotations.
2017-01-19 09:53:17 +03:00
Ilya Gorbunov a429992e81 Do not generate headers for JS-only functions. 2017-01-18 22:16:49 +03:00
Łukasz Wojtów be15dea6b5 Fix typo 2017-01-18 21:51:31 +03:00
Ilya Gorbunov ed9b9d972c Make 'add' function abstract in AbstractMutableSet in JVM 2017-01-18 20:07:24 +03:00
Mikhail Glukhikh b6443eed9e Data flow information: stable complex expressions introduced back for brackets / elvis / if / when #KT-13468 Fixed
This reverts commit e515d7f773 and
also commit 1c9f08e986

(cherry picked from commit 9fa155b)
2017-01-18 18:54:08 +03:00
Mikhail Glukhikh 86bc49558d Tests for KT-13468 / KT-13765
(cherry picked from commit 2e4c0b4)
2017-01-18 18:53:55 +03:00
Nikolay Krasko ffc1624484 Stop using idea isNullOrEmpty function (KT-15786)
#KT-15786 Fixed
2017-01-18 18:36:19 +03:00
Alexander Udalov 4f36376291 Do not report KCLASS_WITH_NULLABLE_ARGUMENT_IN_SIGNATURE anymore
It was only reported in already erroneous cases
2017-01-18 18:21:30 +03:00
Alexander Udalov d02404b07b Report error on expression of nullable type in class literal
#KT-15740 Fixed
2017-01-18 18:21:29 +03:00
Alexander Udalov 6a352a1da7 Report error on nullable type alias in class literal
#KT-15736 Fixed
2017-01-18 18:21:28 +03:00
Zalim Bashorov 284b9d2ba6 KJS: make deep copy of additional arguments before expose them in KotlinFunctionIntrinsic 2017-01-18 14:43:33 +03:00
Zalim Bashorov ca2930600a KJS: introduce $kotlin_test_internal$ to expose some helper functions in the tests 2017-01-18 14:42:40 +03:00
Zalim Bashorov bbd69a05dc KJS: make JSON object and allow to pass null to stringify methods 2017-01-18 14:41:22 +03:00