Commit Graph

59649 Commits

Author SHA1 Message Date
Ilya Chernikov f2a4a835e7 Improve script cli diagnostics 2019-12-02 16:46:55 +01:00
Ilya Chernikov 49de5e19fb Implement repl, script and expressions evaluation support in kotlin runner 2019-12-02 16:46:54 +01:00
Ilya Chernikov 531ff92791 Implement support for expression evaluation in jvm cli compiler 2019-12-02 16:46:54 +01:00
Ilya Chernikov 7bb9f97b11 Allow to separate top-level script declarations and statements with semicolon
This fix allows to write one-liner scripts like "val x = 3; println(x)", which
were previously rejected by the parser.
2019-12-02 16:46:54 +01:00
Ilya Chernikov b8034567ef Change script definition lookup key from File to ScriptSource
to make it more generic and allow easier implementation fo the
non-file based scripts.
2019-12-02 16:46:54 +01:00
Ilya Chernikov 615624802c Add kotlinx-html test
Among other things it tests the packagePartProvider fix above
2019-12-02 16:46:53 +01:00
Ilya Chernikov 4439582d23 Remove unnecessary update of the source roots, simplify interface accordingly
The update became unnecessary after the packagePartProvider fix above.
2019-12-02 16:46:53 +01:00
Ilya Chernikov 02a71d2cda Save updated roots before a packagePartProvider is created
Since the function createPackagePartProvider uses initialRoots for
creating packagePartsProvider, if the updateClasspath function
was called before createPackagePartProvider, the provider was created
with incomplete list of roots, that leaded to the unresolved top-level
functions.
Now if no providers are created yet, the initialRoots is updated.
This still may lead to the inconsistencies, when/if we'll have several
providers.
2019-12-02 16:46:53 +01:00
Ilya Chernikov a190ab260e Load main-kts jar automatically from scripting plugin, if available 2019-12-02 16:46:52 +01:00
Ilya Goncharov 22cb6fa836 [Gradle, JS] Fix case with null distribution 2019-12-02 17:44:26 +03:00
Ilya Goncharov c267357596 [Gradle, JS] Add distribution DSL 2019-12-02 17:44:26 +03:00
Ilya Goncharov fe9ddd9f22 [Gradle, JS] Check if resourcesDir exists and resourceDir is input directory 2019-12-02 17:44:26 +03:00
Ilya Goncharov 053469dcec [Gradle, JS] Copy index.html from resources to dist 2019-12-02 17:44:26 +03:00
Mikhael Bogdanov b9dee4e93a Remove assertion on sorted ranges: it could be empty if lambda doesn't contain any linenumber
#KT-35101 Fixed
2019-12-02 12:08:36 +01:00
Ilya Goncharov ae4a1e3cca [Gradle, JS] Fix check on Kotlin/JS modules from NPM in DCE
#KT-35198 fixed
2019-12-02 14:06:41 +03:00
Nikolay Krasko 0380380de4 More cleanups after tests execution 2019-12-02 13:29:37 +03:00
Nikolay Krasko 0cbb3a3956 Remove unused ProjectRootModificationTrackerFixer.kt 2019-12-02 13:29:37 +03:00
Nikolay Krasko c12599a045 Fix test data for testParamTypeLambdaMismatch in >= 192 2019-12-02 13:29:36 +03:00
Ilya Goncharov 408f958273 [Gradle, JS] Add idle run for debug node tests
Source maps can be loaded by NodeJS
2019-12-02 13:23:03 +03:00
Andrey Uskov 38de98429d Fix importing tests in bunch 183 2019-12-02 13:17:21 +03:00
Andrey Uskov 9643d5d28e Added import-resolve integration tests 2019-12-02 13:17:17 +03:00
Alexander Udalov e9946b21b5 JVM IR: do not hide constructor with inline class types and defaults
This corresponds to the ABI generated by the old backend. Moreover, when
compiling the module 'ir.tree' with JVM IR (could not reproduce on a
small sample), this led to a codegen crash when trying to reassign
parameter value to the default stub, which is an error expression and
can't be generated by ExpressionCodegen.
2019-12-02 10:19:55 +01:00
Mikhail Glukhikh 4e1cd6bcd5 Mute 2 black-box FIR test due to disallowed Kotlin synthetic properties problem
Yet FIR allows synthetic properties both in Kotlin & Java code.
It's unclear how to forbid them in Kotlin fast. Subject to discussion.
2019-12-02 11:33:22 +03:00
Kristoffer Andersen 18e8896c08 [JVM IR] Leave private @JvmDefault methods on interface
Like the old backend, always leave private @JvmDefault annotated
interface members (properties, methods) on the interface, just like
the old backend. Fix naming, and introduce test to document the naming
scheme.
2019-12-02 08:19:52 +01:00
Kristoffer Andersen 6f8682c950 [JVM IR] Stabilize accesor names in IR Backend
- introduce a scoped counter instead of a global one for name
  generation for accessors. Naive solution not working.

- Introduced hardcoded "jd" suffix for accessors on interfaces, under
  the assumption that the only such accessors are due to JvmDefault
  and their bridges from `$DefaultImpls`. Removed all associated
  templated tests, so the old and IR backend correspond on this matter
  again.

- Respecialized writeFlags from regexps to string-equality: we are
  going for exact matches now!

- Fixed package calculation in `IrUtils.kt`.

- Accessors for static members must be due to accessing super
  classes. Actual super-qualified calls are naturally also accessing
  super classes. Hence the `$s+{hashcode(superClassName)}`
  suffix. Added test to affirm this naming scheme.

- Field getters/setters for static fields must be companion accessors,
  otherwise just labelled as accessors. They are also tagged with `s`
  suffix when accessing static fields.

- For naming of accessors to coincide with the old backend, field
  renaming to avoid JVM signature clashes must be done _after_
  generation of accessors for those fields.
2019-12-02 08:19:52 +01:00
Kristoffer Andersen d1c2862e27 IR: Align Interface Defaults with Old Backend
Change the treatment of default implementations on interfaces in JVM
compatibility mode. Previously, the IR backend moved the actual
default implementation to the DefaultImpls class, and then bridged to
it from the interface default. The old backend did the reverse, at the
cost of an additional accessor, in order to gain better binary
compatibility properties. See #2612 for discussion.

The accessor needs to call a specific implementation, so must be
performed through an `invokespecial`. We trick the
SyntheticAccessorLowering into doing this for us, by marking the
bridging call as a super call. We do this in want of an explicit
`invokespecial` Ir Node.

InterfaceDefaultCallsPhase previously assumed the old behaviour of the
IR backend (that calls to default implementations, e.g. `foo$default`
should target `DefaultImpls.foo$default`). But now the bridge to
foo$default resides on `DefaultImpls` already, causing that pass to
create a recursive loop. We cut that loop with a simple check.
2019-12-02 08:19:52 +01:00
Kristoffer Andersen b5de625350 Minor refactor: lifting common code 2019-12-02 08:19:52 +01:00
Kristoffer Andersen 6a41700689 [JVM_IR] Fix interface method resolution
The JVM IR was too agressive in delegating statically to $DefaultImpls
class.

Consider the following library, compiled separately, and then client,
compiled against that library:

```
//library
interface A { @JvmDefault fun foo() = "A" }

interface Left : A { }
interface Right : A { @JvmDefault override fun foo() = "Right" }

//client
interface C : Left, Right {}

fun main() {
  val x = object : C {}
  println(x.foo())
}
```

Previously, the IR backend generates an overriding bridge in C, which
calls C$DefaultImpls which calls statically into Right$DefaultImpls.

When then library is recompilerd with an override of foo in Left, the
existing binary of the client continues to run against the recompiled
library erroneously running Right.foo().

The old backend throws an IncompatibleClassChange exception due to
ambiguity of multiple inherited default implementations. kotlinc indeed
rejects the client when recompiled against the new library.

We have no tests constraining this behaviour, but we could conceivably
strap something together in CustomBinaries tests.
2019-12-02 08:19:52 +01:00
Mikhael Bogdanov df96841c9d Prohibit protected method calls from inline function
#KT-21178 Fixed
2019-12-02 08:04:26 +01:00
Mads Ager 8383274144 Add explicit irReturn when transforming expression body to block body. 2019-12-02 07:10:50 +01:00
Vladimir Dolzhenko 7fede87825 Performance tests DSL is added 2019-12-01 22:54:00 +01:00
Vladimir Dolzhenko 1b075340f8 Fixed dependencies for performance tests 2019-12-01 09:35:32 +01:00
Vladimir Dolzhenko f8a6217fb5 Fix compilation for 183 after adding support incremental analysis of comment and kdoc
Relates to #KT-35189
2019-11-30 18:50:44 +01:00
Alexander Gorshenev a923e0d130 Only allow version triples for klib metadata and ir versions 2019-11-30 18:37:38 +03:00
Alexander Gorshenev b0f077ff4b Plumbing KlibMetadataVersion and KlibIrVersion values to klib manifest 2019-11-30 18:37:38 +03:00
Alexander Udalov bf12f7eee0 JVM IR: do not lower trimIndent/trimMargin if API version is too high
We cannot be sure that we won't change behavior of these functions in
some corner cases, so only perform this optimization if the API version
specified by the user is not greater than the compiler's own stdlib
version it was compiled against. This is the same as the similar code in
the old backend in IntrinsicMethods.
2019-11-29 19:39:55 +01:00
Ilya Gorbunov 555d503ff9 Improve indexOf sample to showcase return value handling
Remove sample reference from indexOf(Char) overload: both overloads are on
the same page, and showing the sample for indexOf(String) under indexOf(Char)
is redundant and misleading.
2019-11-29 21:34:49 +03:00
Burak Eregar e30d87ee01 KT-20357: Add samples for indexOf 2019-11-29 21:34:49 +03:00
Vladimir Dolzhenko a6f829f267 Add secondary ctors to incremental analysis
Relates to #KT-35121
2019-11-29 18:30:01 +01:00
Kerooker c16b89d770 Fix XorWowRandom documentation
This commit changes XorWowRandom.kt documentation to include a HTTPS link instead of a HTTP link, for security purposes.

This commit also changes the same documentation to reflect the real cycles from the `xorwow` algorithm:

    Simple and very fast (125 million/sec), the elements in its cycle of 2^192 − 2^32 easily pass all the tests in Diehard.

 Marsaglia, G. 2003. Xorshift RNGs. J. Statis. Soft. 8, 14, p. 5

 At last, this commit explicits which part of the code is the implementation of the mentioned algorithm.

 Closes KT-35175
2019-11-29 19:31:55 +03:00
pyos 3e67ff097e JVM_IR: keep offsets of const val reads when inlining them 2019-11-29 16:49:52 +01:00
pyos e4b1599457 JVM_IR: do not erase constant non-static field initializers...
...unless in 1.4 mode.
2019-11-29 16:49:52 +01:00
pyos fc6b03b08f JVM_IR: move const initialization handling to lowering
Had to edit some bytecodeText tests to account for the fact that JVM_IR
no longer generates explicit initializations for ConstantValue fields,
but NoConstantValueAttributeForNonConstVals is not the default yet.
2019-11-29 16:49:52 +01:00
pyos 2ebe269448 IR: refactor InitializersLoweringBase and descendants 2019-11-29 16:49:51 +01:00
Mikhail Glukhikh a6f8859a49 FIR Java: generate accessors only in override Kotlin case, make them non-synthetic 2019-11-29 18:11:27 +03:00
Mikhail Glukhikh 5275b4d0fc Move possibleGetterNamesByPropertyName to FirSyntheticPropertiesScope 2019-11-29 18:11:26 +03:00
Mikhail Glukhikh d15dae6ac6 FIR: use SyntheticPropertySymbol & synthetic scope instead of FirAccessorSymbol
Before this commit, we used FirAccessorSymbol to emulate synthetic properties.
These symbols were generated in Java use-site scope.
Now, we use synthetic scope instead which is above MemberScopeTowerLevel.
This is more performance-friendly and does not require override matching.
However, accessor symbols should be used in situation when Java accessor
overrides Kotlin property which is broken in this commit
(that's why MapEntry test is corrupted here).
Also, we should not create synthetics for pure Kotlin accessors
(that's why javaAccessorConversion test is corrupted here).
2019-11-29 18:11:25 +03:00
Mikhail Glukhikh ae62ccb76d [FIR TEST]: add test with synthetic on Java getter overridden in Kotlin 2019-11-29 18:11:24 +03:00
Mikhail Glukhikh 88e260269f FIR resolve: consider SYNTHETIC_RESOLVED as tower-stopper 2019-11-29 18:11:23 +03:00
Mikhail Glukhikh 8bcae80877 [FIR TEST]: add test with Map.Entry-based J/K hierarchy 2019-11-29 18:11:22 +03:00