Commit Graph

3244 Commits

Author SHA1 Message Date
Dmitry Petrov 3d2696c81b KT-13440 Bound callable references in reflection 2016-11-25 16:11:18 +03:00
Dmitry Petrov 5879e201cd Proper equality comparison for bound callable references represented as reflection objects
(including references to property accessors).
2016-11-25 14:49:24 +03:00
Dmitry Petrov 3dd0c9d1c7 Equality comparison for bound callable references takes into account bound receiver.
Fixed KT-14939: use expected receiver type when generating receiver code in get/set methods for bound property references.
Otherwise we have VerifyError for bound receiver 'null' of type 'Nothing?', which is mapped to 'java.lang.Void'.

TODO: proper equality comparison for property accessors ('x::prop.getter', 'x::prop.setter').
2016-11-25 14:49:24 +03:00
Ilya Gorbunov 03bbe875d4 Fix the links to the language docs from JvmStatic and JvmName annotations. Add a link from JvmField annotation.
#KT-14953 Fixed
2016-11-23 23:41:16 +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
Alexander Udalov 525e6e53fe Do not report unhelpful diagnostic for unresolved call inside inline function
#KT-14887 Fixed
2016-11-22 18:19:01 +03:00
Dmitry Petrov fc2a965d2a Fix decompiler tests. 2016-11-22 14:40:02 +03:00
Denis Zharkov 5276c3c755 Support 'interceptResume' operator in frontend
#KT-14891 In Progress
2016-11-22 14:33:40 +03:00
Dmitry Petrov 063bce23d2 Prohibit constructing projected types via type aliases. 2016-11-22 10:04:47 +03:00
Dmitry Petrov d665193c20 Type alias constructors for inner classes in expressions ans supertype lists. 2016-11-21 10:25:51 +03:00
Dmitry Petrov 0205a122f4 Treat nested mock type aliases as inner (same as for mock classes). 2016-11-17 14:42:32 +03:00
Ilya Gorbunov b556adf8db Move/alias Appendable and StringBuilder to kotlin.text
#KT-2084
2016-11-16 18:47:42 +03:00
Stanislav Erokhin 3d7d6e4204 Fix EA-86841 and EA-79267.
(cherry picked from commit fcf9bfd)
2016-11-16 18:13:05 +03:00
Dmitry Petrov 718e8ebf9e Inner type aliases.
Type alias is considered "inner" if it captures outer class type parameters (implicitly or explicitly).
2016-11-16 14:11:14 +03:00
Alexander Udalov eedad9194e Drop KParameter.isNoinline, KParameter.isCrossinline
There seems to be no valuable use cases for them at the moment
2016-11-15 11:01:17 +03:00
Alexander Udalov 7e82d139cf Drop KFunction.isTailrec
The fate of this modifier seems unclear, and there doesn't seem to be any
valuable use cases for it in reflection
2016-11-15 11:01:16 +03:00
Denis Zharkov e21ecbe702 Minor. Split method VariableTypeResolver.process
It looks much natural to differ type resolution and setting
compile time initializer to descriptor
2016-11-15 09:30:13 +03:00
Ilya Gorbunov b96deac09c Annotate TYPEALIAS annotation target being available since Kotlin 1.1 2016-11-14 01:04:31 +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 65882579bc Minor, add toString() for debug 2016-11-11 19:00:08 +03:00
Dmitry Petrov 94d7bd7a6b KT-14641: Nested type alias reference via an instance is an error. 2016-11-10 14:54:11 +03:00
Mikhail Glukhikh ce72337ebd Effective visibility is now considered private for invisible fake #KT-14469 Fixed 2016-11-10 13:42:58 +03:00
Denis Zharkov 24819a079b Change resolution scope for componentX in lambda parameters
Component-functions are resolved in the same scope as the first statement of the lambda, but lambda receiver was not available

 #KT-14692 Fixed
2016-11-10 10:33:42 +03:00
Denis Zharkov 50a5c08603 Optimize visibility for controller field in CoroutineImpl
While it's impossible to declare a property with protected field and public
getter we split these entities

- `_controller` field is used inside coroutines
- `controller` getter is used for accesing controller from noinline lambdas
 (also it can be used to obtain controller from continuation by explicit cast)
2016-11-09 12:25:31 +03:00
Denis Zharkov 7e49db8768 Introduce CoroutineImpl as a common super class for coroutines
The main benefit are class-files sizes for them
(not repeating the same declaration for each coroutine)
Also it helped to simplify coroutine codegen code a little

Note that controller/label field become non-volatile (see KT-14636)

 #KT-14636 In Progress
2016-11-09 12:25:31 +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 5adb22ed65 Do not evaluate anything eagerly in KotlinBuiltIns constructor 2016-11-08 12:14:23 +03:00
Ilya Gorbunov 1a471d7f6b Annotate new enum-related API with SinceKotlin. 2016-11-04 04:18:51 +03:00
Ilya Gorbunov 11bb10e7f7 Annotate new DslMarker annotation with SinceKotlin 2016-11-03 22:34:59 +03:00
Michael Bogdanov fd6d4c352c Special enum function support; Fix for KT-10569: Cannot iterate over values of an enum class when it is used as a generic parameter
#KT-10569 Fixed
2016-11-03 14:27:13 +03:00
Valentin Kipyatkov 23c22984e8 Optimization: look for callables at first when prefix starts uppercase and the opposite otherwise 2016-11-02 19:25:25 +03:00
Denis Zharkov 7553d3f72b Intoduce and support DslMarker annotation
#KT-11551 In Progress
2016-11-01 15:58:14 +03:00
Ilya Ryzhenkov f79116a6d8 Optimize reflection by using Class.getName instead of Class.getCanonicalName 2016-10-31 20:17:33 +03:00
Dmitry Petrov ed60674d13 KT-14498: Properly check variance in expanded types. 2016-10-28 18:02:15 +03:00
Simon Ogorodnik f8b7ce1011 Fix for KT-13695, KT-13159 J2K: Invalid conversion context setup for plain text pastes
Extending, Implementing, imports from paste target file previously not implemented
2016-10-27 20:02:26 +03:00
Ilya Gorbunov 62fb47d137 Introduce bitwise operations and/or/xor/inv for Byte and Short. #KT-13554
Annotate new bitwise operations with SinceKotlin.
2016-10-26 16:35:46 +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 9ce211fe87 Use FQ names instead of descriptor equality in RangeCodegenUtil
This is safer in cases when descriptors for the same declaration can come from
different package fragment providers
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 0e9f29fdba Make ClassDescriptor#classId nullable
Local classes or anonymous objects do not have a class id. Use "!!" almost
everywhere to make assertion explicit
2016-10-25 15:42:32 +03:00
Alexander Udalov 17e54b6d2d Add ClassDescriptorFactory#getAllContributedClassesIfPossible
Currently a no-op, will be used soon to make Cloneable a synthesized class,
visible in scope's getContributedDescriptors()
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
Alexander Udalov 3f5d3e5dbc Fix errors and indent in built-ins sources 2016-10-24 15:30:40 +03:00