Commit Graph

3540 Commits

Author SHA1 Message Date
Alexey Andreev e9a2c8c0f1 Prevent JS AST nodes of several types to be shared 2017-05-30 12:48:47 +03:00
Denis Zharkov 2c98bd053a Fix super calls to suspend functions in abstract classes 2017-05-29 10:58:18 +03:00
Alexey Andreev dde50a34db Fix comparison of boolean values in JS BE
See KT-16984
2017-05-26 18:26:08 +03:00
Dmitry Petrov a86fe89aae Include file name for package-level members in diagnostics 2017-05-26 13:58:46 +03:00
Dmitry Petrov 902d3af280 Prohibit extending kotlin.Enum directly
#KT-7773 Fixed
2017-05-26 13:58:46 +03:00
Valentin Kipyatkov 40bbf82a41 Hint action to update usages on cut/paste of top-level declarations 2017-05-24 16:49:37 +03:00
Alexander Udalov bfb3b38ebc Do not try to load Java classes from incorrect packages
#KT-11474 Fixed
2017-05-18 13:30:06 +03:00
Dmitry Petrov a2db4dc0d5 Fix incremental compilation problems related to type alias constructors
1. Determine source element for descriptors with NO_SOURCE recursively.

2. Always provide type abbreviation for type alias constructor
return type.

 #KT-15495 Fixed
2017-05-18 10:55:16 +03:00
Denis Zharkov 63c5d85cf4 Optimize memory footprint for generated protobuf code
The problem was that an overload of CodedOutputStream.newInstance
without size uses 4000 as a default value, thus allocating
a 4k-sized byte array.
At the same time the array remained effectively unused
in the most cases since it only used for storing data
for unknown fields.

Because such arrays are being created for each read of
protobuf message, during compilation of IntelliJ project
it was producing 25% of redundant memory traffic.

Of course these arrays were all in the young gen, but still
they have some effect on GC
2017-05-17 14:34:11 +03:00
Pavel V. Talanov 798c80ed07 Use wrappers around java.util.* to emulate kotlin.collection.* behaviour
Backend: If kotlin class extends kotlin.collection.List
    write it as it's super interface (light class mode only)
IDE: Provide wrapper classes to java resolve
    that try to emulate backend behaviour

For example if kotlin class implements kotlin.collections.Map,
    we provide a superinterface that has abstract 'getEntries' method
    and 'entrySet' method that is considered default.
In reality all those methods are generated in the class itself.

In IDE supporting this case without hacks is not feasible performance-wise
    since kotlin.collection.* may not be an immediate supertype and we need
    to compute all supertypes just to calculate own methods of the class
2017-05-16 22:01:03 +03:00
Pavel V. Talanov 1a04960ff0 J2K class map: expose classes having mutable/readonly kotlin equivalents
Refactor JavaToKotlinClassMap a little bit
2017-05-16 22:00:59 +03:00
Pavel V. Talanov 40561dabed J2K JavaToKotlinClassMap 2017-05-16 22:00:58 +03:00
Denis Zharkov d24d3a73d7 Support open suspend members and super-calls
The problem was that the resume call (from doResume) for open members
was based on common INVOKEVIRTUAL to the original function
that lead to the invocation of the override when it was expected
to be the overridden (after super-call being suspended)

The solution is to generate method bodies for open members into
the special $suspendImpl synthetic function that may be called
from the doResume implementation

 #KT-17587 Fixed
2017-05-16 11:38:59 +03:00
Mikhail Zarechenskiy e821b25288 Resolve type alias SAM constructors in synthetic scope 2017-05-05 21:30:36 +03:00
Mikhail Zarechenskiy 7541a3754d Move SAM constructors to synthetic scope 2017-05-05 21:30:35 +03:00
Mikhail Zarechenskiy 429f0e4f68 Adapt changes in IDE after moving SAM adapters to synthetic scope
The main change is that now to get static sam adapters one should do it using synthetic scopes and static scope of container
2017-05-05 21:30:10 +03:00
Mikhail Zarechenskiy 95ede7fb67 Move SAM adapters from static scope to synthetic one 2017-05-05 21:30:10 +03:00
Denis Zharkov 7c6a15ddfe Treat inline suspend functions as inline-only
Now their bodies don't have real state machines, thus they cannot
be called correctly from Java

 #KT-17585 In progress
 #KT-16603 In progress
2017-05-05 14:14:38 +03:00
Anton Bannykh 2e9a59819a JS: support internal visibility from friend modules
Friend modules should be provided using the -Xfriend-modules flag
in the same format as -libraries. No manual configuration required for
JPS, Gradle and Maven plugins.

Friend modules could be switched off using the -Xfriend-modules-disabled
flag. Doing that will
  * prevent internal declarations from being exported,
  * values provided by -Xfriend-modules ignored,
  * raise a compilation error on attemps to use internal declarations from other modules

Fixes #KT-15135 and #KT-16568.
2017-05-04 21:44:17 +03:00
Yan Zhulanow 254e8156ac NoArg: Initialize properties in noarg constructor (KT-16692) 2017-05-04 18:46:42 +03:00
Mikhail Glukhikh e53c548ead Consider property external if all accessors are external #KT-13997 Fixed 2017-05-04 14:17:40 +03:00
Mikhail Glukhikh b8af0f5922 J2K: move isEffectivelyExternal to kt-file, parameter -> receiver 2017-05-04 14:17:38 +03:00
Pavel V. Talanov 55a0e138fc Refactor: extract AnnotationDescriptor.annotationClass utility 2017-05-02 15:40:20 +03:00
Alexander Udalov 15efbcae02 Use Class->KClass cache in Class.kotlin extension
#KT-17594 Fixed
2017-04-27 20:34:45 +03:00
Ilya Gorbunov 99504eb753 Support rendering receiver parameters
Otherwise generated coroutine implementation class could not be rendered since one of its members corresponds to receiver parameter descriptor.
2017-04-27 16:38:25 +03:00
Alexander Udalov e2c62cbded Support serialization of built-in ranges as error types
This will be needed to move ranges and progressions out of builtins.
Currently they're only used in signatures of "rangeTo" functions on
primitives
2017-04-26 18:10:54 +03:00
Alexander Udalov f648f0235c Move ErrorUtils.ErrorTypeImpl to top level ErrorType and J2K 2017-04-26 18:10:53 +03:00
Alexander Udalov 38ea9986ab Make KotlinType.isError extension instead of member 2017-04-26 18:10:49 +03:00
Stanislav Erokhin 1af733da05 Added isAllowedTypeVariable inside KotlinTypeChecker 2017-04-26 13:47:51 +03:00
Stanislav Erokhin 53ccfcf195 Add util functions getKPropertyType for both receivers and isNumberedKFunction 2017-04-26 13:47:50 +03:00
Alexey Tsvetkov 50085722d1 Fix internal visibility check for deserialized typealiases
#KT-15495 fixed
2017-04-25 16:27:23 +03:00
Denis Zharkov 62a55b7b00 Fix false-positive resolution ambiguity when using akka
com.typesafe.akka:akka-cluster-sharding_2.12:2.5
akka.cluster.sharding.ClusterSharding  has the following methods:

    public static ClusterSharding get(ActorSystem var0) {
        return ClusterSharding$.MODULE$.get(var0);
    }

    public static Extension get(ActorSystem var0) {
        return ClusterSharding$.MODULE$.get(var0);
    }

NB: ClusterSharding  <: Extension
None of these methods is synthetic or something, but javac allows
calls like ClusterSharding.get(null)  and they get resolved
to the first method returning ClusterSharding

It seems that both javac and IntelliJ resolution algorithms filter out
such clashing declarations choosing the one that has the most
specific return type, the same idea is applied in the change

 #KT-17560 Fixed
2017-04-24 17:54:01 +03:00
Denis Zharkov 513655239d Introduce initializer-related properties into JavaField
It's much more convenient to use and implement these
properties instead of manual "pattern matching" in the
JavaPropertyInitializerEvaluatorImpl
2017-04-21 12:56:30 +03:00
Denis Zharkov 506d7ab3d2 Replace JavaClass.innerClasses with innerClassNames
Also add a findInnerClass method that can find an inner class
by its name

This change helps to avoid loading all the inner class files
eagerly (that may be rather slow), while all the names are available
in InnerClass attribute
2017-04-21 12:48:31 +03:00
Denis Zharkov 5936424659 Replace JavaClassifierType.canonicalText with classifierQualifiedName
The reason is that canonicalText requires some additional
computations to be done when reading class files, while
in fact we only need a class name of the type
2017-04-21 12:48:31 +03:00
Denis Zharkov 06ffbb7b93 Minor. Avoid repeating calls to isRaw 2017-04-21 12:48:31 +03:00
Denis Zharkov e4cb5496b8 Optimize getSingleAbstractMethodOrNull
Searching for the single abstract method leads to computing
whole member scopes of given intrefaces, especially when
they contain a lot of methods (i.e. they're definitely not SAMs)

On the other side this method is very hot because it's called
for each Java interface used as a type for some value parameter
(for building SAM adapters)

The idea is to apply some heuristics to understand using only
JavaMethod and supertypes that this interface is definitely not a SAM
2017-04-21 12:48:31 +03:00
Alexander Udalov ea727ff3f0 Use header->impl mapping in HeaderImplDeclarationChecker.areCompatibleTypes
Construct a special TypeCheckingContext that is aware of the magic
behind the "impl typealias" that implements a "header class"

 #KT-16986 Fixed
2017-04-20 22:33:25 +03:00
Christopher Horner 8df40eaa46 Add support for RxJava's nullability annotations. 2017-04-20 17:20:39 +03:00
Dmitry Petrov a3985bbdd3 Substitute underlying constructor when substituting type alias constructor
KT-17426 Constructor call of typealiased class gets suspicious type arguemnts
2017-04-20 10:20:36 +03:00
Ilya Gorbunov a87da4338f arrayIterators: Restore index to the previous value after NoSuchElementException has been thrown
Relates to #KT-17453
2017-04-19 18:12:58 +03:00
Vyacheslav Gerasimov 5b58a6f9e8 Add intentions Add/Remove/Redo parcelable implementation
#KT-17465 Fixed
#KT-12049 Fixed
2017-04-18 19:04:14 +03:00
Ilya Gorbunov 4a5d8534c1 Fix array iterators to adhere to Iterator contract
#KT-17453 Fixed

Change expected exceptions in tests.
2017-04-18 18:51:20 +03:00
Alexander Udalov bbdff8c7ce Move DeclarationDescriptor.substitute to separate interface Substitutable
To get rid of pointless/confusing implementations in ModuleDescriptor,
PackageViewDescriptor, TypeParameterDescriptor and others.

Note that there are still implementations that do not make sense, for
example in those subclasses of VariableDescriptor which are not also
subclasses of CallableMemberDescriptor (e.g. ValueParameterDescriptor).
Those can be removed by making CallableMemberDescriptor (instead of
CallableDescriptor) inherit from Substitutable. However, that would
require more changes in the compiler because CallableDescriptor is used
rather often in places where in fact only CallableMemberDescriptor
instances can appear.

Explicit return types and casts are required in some places now because
there's no single non-trivial supertype for
ClassifierDescriptorWithTypeParameters and CallableDescriptor.
Previously it was DeclarationDescriptorWithVisibility, now it's both
that and Substitutable<...>
2017-04-13 14:16:07 +03:00
Alexander Udalov f594a4c018 Drop ModuleDescriptor.sourceKind, move this code to IDE modules
This information is only used in IDE and it can easily be computed there
2017-04-12 14:22:34 +03:00
Zalim Bashorov 5f0e896843 Minor: simplify isVisible of Visibilities.INTERNAL and write comment on non-obvious line 2017-04-11 15:47:02 +03:00
Ilya Gorbunov f5647fb27f Delete temporary proguard configuration for gradle, change the primary one. 2017-04-08 08:32:05 +03:00
Ilya Gorbunov f619dbe631 Build and package reflection with gradle 2017-04-06 20:32:37 +03:00
Ilya Gorbunov 4645fc4b7b Build reflection classes with gradle 2017-04-06 20:32:37 +03:00
Alexey Sedunov c1066b98f0 Move: Fix warning on companion used as implicit dispatch receiver
Do not report conflict if target class is a sublcass of
companion object's containing class
2017-04-06 18:54:02 +03:00