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.
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.
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.
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
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
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
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
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
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
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
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.
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