Commit Graph

49 Commits

Author SHA1 Message Date
Mikhael Bogdanov 2ed0cb2a89 Support type annotations
#KT-35843 Fixed
2020-01-09 14:00:11 +01:00
pyos 6b5d92a693 IR: work around a bug in interface delegation descriptors
interface I {
        fun f(x: Int = 1)
    }
    class C(val y: I) : I by y {
        // implicit `override fun f(x: Int) = y.f(x)` has a default value for `x`
    }

-- the only case where a function with overridden symbols has defaults.
2020-01-03 17:09:31 +01:00
Alexander Udalov 8a4510c21b Regenerate tests 2020-01-02 10:31:00 +01:00
Alexander Udalov 218d7c31ed Remove muted tests on automatic experimental->release coroutine migration 2019-12-18 17:21:44 +01:00
Dmitriy Novozhilov e7f8c8e155 [TEST] Regenerate tests after previous commit 2019-12-12 16:11:45 +03:00
pyos 9182f2c796 IR: don't attempt to move defaults to actual in another module
May happen when a function in an `expect` class is aliased through an
`actual typealias`; the matching declaration is filtered out in
`ExpectedActualResolver.findActualForExpected` as it has no source.
2019-11-18 18:41:21 +01:00
Steven Schäfer 23dfade24f JVM IR: Fix inlining of inline class properties in external modules 2019-11-15 17:30:16 +01:00
Alexander Udalov 6be9101675 JVM IR: add jvmLocalClassExtractionPhase to lift out local classes from initializers
Otherwise a local class in a field initializer or anonymous init block
is copied into each constructor of the containing class (because
InitializersLowering calls deepCopy).

Since the code structure no longer resembles the original source code
here, record a custom EnclosingMethod mapping before moving such
classes, and use it in codegen.
2019-11-13 19:26:39 +01:00
Nikolay Krasko 4ed64b0283 Regenerate tests with TargetBackend.ANY remove and using runTest with this 2019-10-23 12:49:48 +03:00
nikita.movshin 65244b4bea Update copyright.
Change the copyright from "JetBrains s.r.o." to
"JetBrains s.r.o. and Kotlin Project contributors"
Update only 2 lines copyright.
2019-04-23 20:09:22 +03:00
Alexander Udalov 59fda8d7ce Support JvmPackageName with JvmMultifileClass
This is an internal feature of our standard library needed to compile
new API for unsigned types
2019-03-06 15:34:23 +01:00
Mikhail Zarechenskiy 617bed1bf1 Fix nested typealiases expansion and as a result fix serialization
Consider the following situation:
 ```
 class Inv<T>
 typealias A<K> = Inv<K>
 typealias B<V> = Inv<A<K>>

 fun <U> materialize(): B<U> = TODO()
 ```

 Type `B<U>` is expanding to `Inv<Inv<U>>` and for this type `B<U>` and
 `Inv<A<U>>` are abbreviated types, but due to a bug we forgot to make
 substitution for `Inv<A<U>>` and were getting abbreviated type
 `Inv<A<K>>` where `K` is a type parameter from the typealias declaration.

 This bug didn't affect subtyping anyhow but the incorrect type was
 serialized and caused problems during deserialization as there wasn't
 `K` in deserialization context.

 #KT-24964 Fixed
 #KT-20780 Fixed
 #KT-20065 Fixed
 #KT-28236 Fixed
 #KT-21775 Fixed
2019-02-25 00:28:45 +03:00
Mikhael Bogdanov cf47bc0130 Update copyright in generated compiler tests 2019-01-02 12:37:06 +01:00
Alexander Udalov a0a70dd60d Remove LANGUAGE_VERSION from compileKotlinAgainstKotlin tests
Support test directives not at the beginning of the test file for
multi-file tests where separate files need separate language features
2018-12-20 12:53:23 +01:00
Mikhael Bogdanov 78fe9d8eee Move 'compileKotlinAgainstKotlin' java 8 tests to common 2018-10-23 16:27:51 +02:00
Dmitry Petrov 006c0aa740 Hide constructors accepting inline class parameters 2018-09-07 15:57:59 +03:00
Dmitry Petrov 4c7430e990 Test: inline class in binary dependencies 2018-09-07 09:29:55 +03:00
Alexander Udalov 5f18439442 Use correct module name when calling internal members from other module
This is needed to avoid using the same module name for test root as for
the main source root in the Gradle plugin, which is needed to fix
KT-18955
2018-08-31 13:42:57 +02:00
Mikhael Bogdanov 1d283d243e Support @JvmField on interface properties
#KT-15807 Fixed
2018-07-16 16:13:15 +02:00
Ilmir Usmanov d13e2ef32e Add tests 2018-07-11 14:20:42 +03:00
Ilmir Usmanov dbc3ddc578 Support loading function types 2018-07-11 14:20:41 +03:00
Ilmir Usmanov 5b7e099842 Read old suspend functions in 1.3 2018-07-11 14:20:41 +03:00
Mikhail Zarechenskiy 0c6757a8b0 Write is_unsigned flag into metadata for an annotation arguments
Instead of adding new kind of types, we'll use flag to disambiguate
 usual types from unsigned ones, this approach has two advantages:
 - less changes in the metadata format
 - it allows naturally extend format for unsigned arrays,
  which will be supported later

 #KT-25310 Fixed
 #KT-25273 Fixed
2018-07-09 20:06:05 +03:00
Alexander Udalov 4f2fdd1c01 Load all resources in RuntimePackagePartProvider; optimize code
The issue was reproducible when the same package is present in different
modules with the same -module-name (which is a popular case of src/test
roots in simple IDEA projects). The problem was in the fact that several
resource files containing package name mapping with the same name were
present in the classpath, but RuntimePackagePartProvider only considered
the first one. The fix is to use getResources instead of
getResourceAsStream and handle each returned resource.

Also, optimize internal representation to store the mapping in the form
which is the most convenient for findPackageParts, which should be
faster than registerModule because in theory, it's called more often.

 #KT-21973 Fixed
 #KT-24651
2018-07-02 18:49:09 +02:00
Roman Artemev c887b88ed9 Fix coroutine test generator 2018-07-02 15:35:02 +03:00
Alexander Udalov 1951d38f40 Retain optional expected annotations when compiling platform code
After this change, optional expected annotations will be compiled to
physical class files on JVM, and stored to metadata on other platforms,
to allow their usages from dependent platform modules. For example:

    @OptionalExpectation
    expect annotation class A

When compiling this code on JVM, A.class will be produced as if the
class A did neither have the 'expect' modifier, nor had it been
annotated with OptionalExpectation. Note that if there's no actual
annotation class for A, then usages (which can only be usages as
annotation entries) are simply skipped.

Class A will be public from Kotlin's point of view (since it should
be possible to use it in Kotlin sources), but _package-private_ in Java
to disallow its usages outside of the declaring module.

 #KT-18882 Fixed
 #KT-24617 Fixed
2018-06-26 10:23:55 +02:00
Mikhail Zarechenskiy 3f462659d2 Determine underlying property of inline class by its name
Previous way to distinguish "primary constructor properties" from other
 properties wasn't correct for deserialized properties, because currently
 we don't have special information about this in metadata
2018-06-25 17:11:59 +03:00
Ilmir Usmanov f60787d57c Move coroutines to kotlin.coroutines package: tests
Introduce COMMON_COROUTINES_TEST directive.
Every test with this directive is run twice: one time with
language version 1.2 and kotlin.coroutines.experimental package
and the other time with language version 1.3 and kotlin.coroutines
package. Each run is a separate method: with suffixes _1_2 and _1_3
respectively.
However, since codegen of release coroutines is not supported in JS
backend, we generate only one method: with suffix _1_2.
 #KT-23362
2018-04-23 21:51:59 +03:00
Zalim Bashorov ab03ab84bb Regenerate tests 2018-04-19 13:17:27 +03:00
Zalim Bashorov 9970dd051f Fix copyright's start year in generated tests 2018-03-14 15:04:58 +03:00
Dmitry Petrov 31996f1139 Update "defaultness" for property accessor with inherited visibility
Property accessor that overrides a non-default property accessor with
visibility different from the property visibility was incorrectly
considered "default". Corresponding metadata was written incorrectly,
and 'internal' setter call caused NSME

 #KT-23044 Fixed Target versions 1.2.40
2018-03-02 10:54:32 +03:00
Mikhael Bogdanov 0954d1ab1b Don't generate hash in sam wrapper class name
#KT-17091 Fixed
2018-02-08 10:11:48 +01:00
Dmitry Jemerov e80dae1802 Update copyright in generated tests 2018-01-10 11:55:28 +01:00
Mikhael Bogdanov f4f7c83eeb Copy nested objects of default lambda during inline 2017-12-21 12:52:28 +01:00
Mikhael Bogdanov edefb45585 Copy sam wrappers during inline
#KT-21671 Fixed
2017-12-07 12:57:43 +01:00
Alexander Udalov 7f8634d9ef Revert "Temporarily remove JvmPackageName and tests, but keep the implementation"
This reverts commit 9ae6feb2c5.
2017-10-11 19:20:24 +03:00
Dmitry Petrov 67a50e92d0 Load annotations for default getter and setter
#KT-14697 Fixed
2017-10-05 10:24:29 +03:00
Alexander Udalov 23d6690581 Fix codegen for multifile class parts with type aliases only
#KT-20337 Fixed
2017-09-25 11:58:20 +03:00
Alexander Udalov 9ae6feb2c5 Temporarily remove JvmPackageName and tests, but keep the implementation
This is needed because we want the compiler code to stay as much the
same in master and in 1.2 as possible
2017-09-13 23:23:36 +03:00
Alexander Udalov 70ae1596fb Support JvmPackageName annotation in binary format
The main changes are in jvm_package_table.proto and ModuleMapping.kt.
With JvmPackageName, package parts can now have a JVM package name that
differs from their Kotlin name. So, in addition to the old package parts
which were stored as short names + short name of multifile facade (we
can't change this because of compatibility with old compilers), we now
store separately those package parts, which have a different JVM package
name. The format is optimized to avoid storing any package name more
than once as a string.

Another notable change is in KotlinCliJavaFileManagerImpl, where we now
load .kotlin_module files when determining whether or not a package
exists. Before this change, no PsiPackage (and thus, no JavaPackage and
eventually, no LazyJavaPackageFragment) was created unless there was at
least one file in the corresponding directory. Now we also create
packages if they are "mapped" to other JVM packages, i.e. if all package
parts in them have been annotated with JvmPackageName.

Most of the other changes are refactorings to allow internal names of
package parts/multifile classes where previously there were only short
names.
2017-09-13 22:59:03 +03:00
Alexander Udalov 7107ee2eeb Write/load subclasses of sealed classes in metadata
Note that now DeserializedClassDescriptor.getSealedSubclasses works a lot
faster than before, for all newly compiled sealed classes except empty ones. It
may be optimized further if we look at the metadata version of the file the
class was loaded from, however it's not easy currently because
DeserializedClassDescriptor is declared in common (non-JVM) code and has no
direct access to the binary version information.

This will also allow to add a reflection API to get subclasses of a sealed
class

 #KT-12795 Fixed
2017-01-10 12:23:26 +03:00
Mikhail Zarechenskiy 6cccad9647 Update year in license and regenerate tests 2017-01-10 12:01:17 +03:00
Zalim Bashorov 1dedb38481 Regenerate tests 2016-11-09 21:41:12 +03:00
Michael Bogdanov d48ef2efc7 Fix for KT-14012: Back-end (JVM) Internal error every first compilation after the source code change
#KT-14012 Fixed
2016-10-18 10:46:51 +03:00
Dmitry Petrov 3d0288ffed Annotations on type aliases: generate synthetic method for type alias annotations. 2016-10-13 17:52:21 +03:00
Dmitry Petrov e0cdad30e4 KT-13181 Unresolved reference when referencing a type alias from a different module
Add corresponding resolution code.
2016-09-02 10:18:23 +03:00
Denis Zharkov 75e112e752 Implement basic support for coroutines in JVM backend 2016-06-08 18:53:16 +03:00
Alexander Udalov 9f67fe2fe3 Adapt CompileKotlinAgainstKotlin test to black box format
Rename/remove some obsolete test cases
2016-03-02 15:47:35 +03:00
Alexander Udalov 2d5b7a8768 Minor, move CompileKotlinAgainstKotlin tests to codegen/ 2016-02-27 16:31:46 +03:00