Commit Graph

1414 Commits

Author SHA1 Message Date
Dmitry Petrov 118a7d4e34 JVM_IR KT-43242 generate switch subject as primitive 'int' 2020-11-19 16:34:04 +03:00
Mads Ager 7b4e0b2f5d [JVM_IR] Deal with lowering ordering issues for JvmStatic function references.
Do not destructively update the @JvmStatic function, instead
create a copy on first access, and replace the original with
the copy in the jvm static lowering. This ensures that the original
function is seen in other lowerings independently of file lowering
order.
2020-11-18 17:13:00 +01:00
Dmitry Petrov 3d2f5f4bc1 KT-42018 explicitly cast inline class values in safe-as 2020-11-18 18:51:15 +03:00
Dmitry Petrov 5d76df6e1a KT-43045 mangle function name for fake override with default impl 2020-11-13 16:15:29 +03:00
Georgy Bronnikov 364773bf0f IR: fix IrClassSymbol.starProjectedType 2020-11-12 21:49:11 +03:00
Roman Artemev 01f3c06ec9 Add test for KT-40412 2020-11-11 17:00:25 +03:00
Alexander Udalov 116606ecd2 JVM IR: fix class kind of created java.lang.Deprecated symbol
If it isn't ANNOTATION_CLASS, the newly added code in
`FunctionCodegen.isDeprecatedHidden` (0e91d3fcb0) ends up transforming
IR annotation constructor calls to annotation descriptors, and an
assertion fails in `IrBasedDeclarationDescriptor.toAnnotationDescriptor`
which checks that the class has kind ANNOTATION_CLASS.

Specifically, this failed in the JVM IR bootstrap on
`CallResolutionInterceptorExtension.interceptCandidates` from module
'frontend'.
2020-11-11 12:53:32 +01:00
Ilmir Usmanov fa42a6ba58 Use non-local return target instead of inline site in suspend function
return type coercion.
 #KT-43226 Fixed
2020-11-10 20:08:45 +01:00
Juan Chen 9486f58fb1 [FIR] fix subtyping for definitely notnull types.
The current implementation doesn't consider Foo a subtype of Captured<in
Foo>!!, since AbstractTypeCheckerContext::checkSubtypeForSpecialCases
does not handle DefinitelyNotNullType cases. This PR adds handling of
DefinitelyNotNullType by looking at its original type.

^KT-42824 Fixed
2020-11-10 21:07:09 +03:00
Juan Chen eb804709da [FIR] fix subtyping for nullable captured types.
The issue is the type checker doesn't consider P? a subtype of
CapturedType<in P>?, whereas P a subtype of CapturedType<in P>?. In
AbstractTypeCheckerContext::checkSubtypeForSpecialCases, it checks if
P? is a subtype of the lower type of the captured type, which is
P, and returns false.

This fix uses nullable version of the lower type when the captured
type is marked nullable. To check if P? is a subtype of Captured<in
P>?, we check the LHS, P?, against the nullable lower type of RHS,
P?.

^KT-42825 Fixed
2020-11-10 21:07:09 +03:00
Roman Artemev 94acfa50bd [IR BE] Remap dispatch receiver for inner ctor too
- do not forget to add into mapping dispatch receiver
 - fix KT-40686 (at least part of it)
 - add test
2020-11-10 11:06:11 +03:00
Alexander Udalov 106ee1d1ff JVM IR: restore ability to suppress codegen-reported diagnostics
In the old backend, BindingContextSuppressCache is used (which is now
created explicitly in GenerationState), which looks up `@Suppress`
annotations on elements right before reporting the diagnostic. In JVM
IR, we clear the binding context after psi2ir, so this approach doesn't
work. This change provides another implementation of KotlinSuppressCache
which eagerly precomputes all suppressions on all annotated elements in
all source files at the point of creation of GenerationState (when the
binding context is still full).

 #KT-43047 Fixed
2020-11-09 19:55:31 +01:00
Svyatoslav Kuzmich bfd0f21e9d [Wasm] Major compiler and stdlib update 2020-11-09 16:04:43 +03:00
Dmitry Petrov b9c6267a63 KT-43217 Encode @EnhancedNullability types in IdSignature 2020-11-09 15:20:46 +03:00
Igor Chevdar 5e0f54a30b [IR] Fixed https://youtrack.jetbrains.com/issue/KT-43159 2020-11-09 11:37:37 +05:00
Steven Schäfer bd4e2a283c JVM IR: Don't generate null checks on value parameters of private operator functions
The null check on the extension receiver of private operator functions
is a special case and doesn't extend to value parameters.
2020-11-03 21:44:25 +01:00
Ilmir Usmanov 1376fed1d4 Support non-public inline class constructors
#KT-28056 Fixed
2020-11-03 12:10:21 +01:00
Alexander Udalov dd33ed9297 Fix suspend function with inline class types in reflection
#KT-34024 Fixed
2020-11-02 19:33:23 +01:00
Mikhael Bogdanov 7ec2d036ae Don't generate final modifier on static interface methods produced by @JvmStatic+@JvmOverloads from interface companion
#KT-35716 Fixed
2020-11-02 08:27:49 +01:00
Ilmir Usmanov 999604541e JVM_IR: Support init blocks in inline classes
Put their content to constructor-impl, so they are called during
constructor call, but they are not called during boxing, because
box-impl calls <init> and not constructor-impl.

 #KT-28055 In progress
2020-10-29 20:38:01 +01:00
Alexander Udalov ad5b6da273 JVM IR: substitute generic type for inline class replacement function calls
The main change here is in `JvmInlineClassLowering.visitFunctionAccess`,
where we now store the substituted return type of the function as the
type of the call expression. Without it, the call could have a
meaningless type, e.g. some `T` which is inaccessible at that place, and
that could backfire in subsequent lowerings in codegen. For example, in
the `stringPlus.kt` test, it would prevent the code in
`FlattenStringConcatenationLowering.isStringPlusCall` from recognizing
and replacing the `String.plus` call, leading to a codegen exception.

Other changes are mostly cosmetics to make the code similar to
`visitFunctionReference`, and preventive optimizations for the case when
the substitution map is empty.
2020-10-28 16:46:28 +01:00
Ilmir Usmanov a775fa195b Unbox inline class parameter of lambda if underlying type is Any or Any?
The inline class is boxed when we pass it as lambda argument, now we
unbox it. If the underlying type is not Any or Any?, bridge method does
the unboxing.

 #KT-32450 Fixed
 #KT-39923 Fixed
 #KT-32228 Fixed
 #KT-40282 Fixed
2020-10-26 17:34:37 +01:00
Dmitry Petrov b1629cc5f4 JVM KT-22465 don't generate accessor to private setter in other class 2020-10-26 14:56:07 +03:00
Ilya Goncharov 4479bf0933 [JS_IR] Enum constructor copy parameters with mapping by index
Previously mapping was by name, and there was clash in case of user
parameters named 'name' or 'ordinal'

^KT-39186 fixed
2020-10-23 11:42:43 +03:00
Alexander Gorshenev 7815529eed [Private fake overrides] Tests for private fake overrides construction 2020-10-22 13:23:29 +03:00
Juan Chen 620a5d404d [FIR2IR] Keep redundant cast on 'this' for local anonymous function
#KT-42517 Fixed
2020-10-22 10:51:23 +03:00
Ilya Goncharov 14d9aa1660 Add test on break in when without label
^KT-42262 fixed
2020-10-21 16:59:24 +03:00
pyos a4b67f007f JVM_IR: treat suspend-converted references as lambdas for inlining
Again, this is consistent with adapted function references, since
they're pretty much the same anyway.
2020-10-21 15:21:01 +02:00
Dmitry Petrov 3979cde738 Add box and PSI2IR tests for special cases listed in KT-35849 2020-10-20 19:31:40 +03:00
Ilmir Usmanov 70a4ed3ebc Box inline class returned from suspend lambda non-locally
All inline classes should be boxed coming in and out of lambdas,
however, if the inline class was returned non-locally, it was not boxed.
This change fixes the issue in Old JVM BE.
 #KT-41194 In progress
2020-10-19 14:28:36 +02:00
Roman Artemev d7db643422 Add box test for KT-33992 2020-10-16 16:02:02 +03:00
Roman Artemev 023a62395a Add box test for KT-36897 2020-10-16 16:02:01 +03:00
Dmitry Petrov ee5edf4caa JVM_IR fix 'remove' in inline class implementing MutableCollection 2020-10-16 00:02:12 +03:00
Mikhael Bogdanov b6dc99b98e Skip java defaults in EXPLICIT_OVERRIDE_REQUIRED_IN_MIXED_MODE check
#KT-42674 Fixed
2020-10-15 16:26:00 +02:00
Mikhail Zarechenskiy eacc94a89d Do not hide synthetic properties except isEmpty from Java
In order to hide synthetic property isEmpty from JDK 15, there was
 added additional logic in 5cc12b49fc but
 it also lead to the fact that now it's impossible to call synthetic
 property `declaringClass` on `Enum` as it's in the same list as method
 isEmpty(). Note that it's questionable behavior, probably we should
 also hide `declaringClass` as well but for now we turn it back to
 preserve compatibility

 #KT-42467 Fixed
2020-10-15 12:26:17 +03:00
Jinseong Jeon 65545a10c4 FIR: reproduce KT-42656 2020-10-15 08:47:46 +03:00
Alexander Udalov 1b39a235d8 JVM IR: sort multifile part names in metadata 2020-10-13 16:40:53 +02:00
Pavel Kirpichenkov 9dd3d8fb14 [NI] Fix extension function check after commonization
`isExtensionFunction` property is false for suspend functions
2020-10-13 11:00:21 +03:00
Victor Petukhov 0685beb765 NI: do substitution type variables during updating trace for lambda (these type variables can appear after the builder inference)
^KT-42450 Fixed
2020-10-13 10:21:55 +03:00
Alexander Udalov 1daeebcdd3 Minor, add regression test
#KT-42562
2020-10-12 21:37:37 +02:00
pyos 1663619606 JVM_IR: add local delegated property metadata to non-synthetic classes
Otherwise kotlin-reflect won't find it (and it won't even be serialized
anyway).

 #KT-42562 Fixed
2020-10-12 21:14:00 +02:00
Ilmir Usmanov 3b5706972e Extract effect from lambda argument if it is in parentheses
Otherwise, contracts on the parameter have no effect.
 #KT-42044 Fixed
 #KT-26229 Fixed
2020-10-12 20:16:19 +02:00
Alexander Udalov ac39e4d89c Minor, add regression test
#KT-42554
2020-10-09 22:11:37 +02:00
pyos e6c0575d3a JVM_IR: do not deep-copy suspend lambdas in initializers
This loses reflection metadata (and also sometimes fails). Which was
missing anyway - this is also fixed now.

 #KT-42554 Fixed
2020-10-09 22:11:00 +02:00
Mark Punzalan a093efde11 Add blackbox test for KT-42533. 2020-10-09 21:34:56 +02:00
Alexander Udalov 2f003bdcb5 Minor, add regression test
#KT-42527
2020-10-07 21:31:43 +02:00
pyos dd1682510f JVM_IR: generate accessors for inherited abstract members too
#KT-41468 Fixed
2020-10-07 21:23:18 +02:00
pyos 98088f739d PSI2IR: do not generate when subjects multiple times
`in x` is represented as `<subject expression> in x` in psi, so
generating the entire call and then replacing the argument with a read
of a temporary results in redundant regenerations of the subject.

 #KT-42054 Fixed
 #KT-42455 Fixed
2020-10-07 17:22:25 +03:00
Alexander Udalov e280416fe2 Minor, add regression test 2020-10-07 14:31:01 +02:00
pyos a6d5c02d9b JVM_IR: add a transformChildren call to PropertyReferenceLowering
#KT-42354 Fixed
2020-10-06 17:06:34 +02:00