Commit Graph

59669 Commits

Author SHA1 Message Date
Denis Zharkov ae01d050c9 FIR: Abstract parts for type alias constructors resolution
It's necessary to support combination of type aliases + SAM
2019-12-03 15:49:22 +03:00
Denis Zharkov fbe7db5471 FIR: Move constructor processing parts to a separate file 2019-12-03 15:49:22 +03:00
Denis Zharkov bf68e85a5c FIR: Support SAM conversion for interfaces containing Object methods 2019-12-03 15:49:22 +03:00
pyos 7cd55c85e6 JVM/JVM_IR: fix mapping of KClass in annotation classes
* JVM incorrectly mapped T<KClass<...>> to T<Class<...>> because the
   annotation-ness of the type mapping mode was inherited one level
   down into a generic signature independent of T

 * JVM_IR was even worse as it did not use VALUE_FOR_ANNOTATION at all,
   mapping T<T<KClass<...>> to T<T<Class<...>> as well.

The correct behavior is to map KClass to Class only at top level or as
an argument of Array.
2019-12-03 11:42:23 +01:00
Alexander Udalov f869be6a71 JVM IR: do not mangle synthetic methods with inline class parameters
For example, synthetic `$annotations` methods for properties were
previously mangled to `$annotations-...`, which breaks annotation
loader, and fails an assert in ClassCodegen.generateMethod.
2019-12-03 11:34:55 +01:00
Roman Golyshev 66ffdf1b2d KT-33979 KT-34150 Remove filtering overridden object members and nested objects
- ^KT-33979 Fixed
- ^KT-34150 Fixed
- Also, in extension completion check descriptor instance first
2019-12-03 13:29:30 +03:00
Alexander Udalov 2552540f71 IR: wrap exceptions and add file path in per-file lowerings
Also add file path to the wrapped exception in JVM IR codegen
2019-12-03 11:06:54 +01:00
Alexander Udalov fd627603a0 Refactor CompilationErrorHandler
It only had one implementation THROW_EXCEPTION, inline it everywhere
with a call to a static method
2019-12-03 10:48:34 +01:00
Dmitry Petrov 2435b8d9fa Update testData for enum constructor result type in IR 2019-12-03 11:54:41 +03:00
pyos 35c2573b33 PSI2IR: generate IrEnumConstructorCalls with correct return type
Normally, the fact that is was Unit was not visible as enum constructors
are lowered to normal class constructors anyway. The exception is when
the arguments are reordered, causing the incorrect return type to leak
into the block that holds temporary variables.
2019-12-03 11:54:41 +03:00
Denis Zharkov 145ad1a6fa FIR: Minor. Extract common parts in FirCallCompletionResultsWriterTransformer 2019-12-03 11:52:21 +03:00
Dmitriy Novozhilov 71bf8a14e8 [FIR] Make ConeTypeCheckerContext implements ConeInferenceContext 2019-12-03 11:36:34 +03:00
pyos 69033b7b15 JVM_IR: handle @JvmName on annotation getters 2019-12-03 10:53:49 +03:00
pyos ac7d9fa90d JVM_IR: implement -Xpolymorphic-signature 2019-12-03 08:31:46 +01:00
Mikhail Glukhikh fe6be0f436 Fix failed FIR multi-module test (forgotten test data update) 2019-12-03 10:25:53 +03:00
Igor Yakovlev 0ff77bd3c5 Add UL support for const fields initializers
Fixed #KT-34081
2019-12-02 20:41:47 +03:00
Victor Petukhov 775eb67219 NI: Add constraints which contain constraining type without projection
^KT-32243 Fixed
^KT-35172 Fixed
2019-12-02 19:42:18 +03:00
pyos 65cc0fa463 PSI2IR: have GeneratorExtensions implement StubGeneratorExtensions 2019-12-02 17:10:04 +01:00
pyos a950df3c80 PSI2IR: copy isPropertyWithPlatformField to GeneratorExtensions 2019-12-02 17:10:04 +01:00
Ilya Chernikov 3cae90dd26 [minor] fix source root creation from imported scripts:
make the usages of KotlinSourceRoot consistent everywhere
2019-12-02 16:46:55 +01:00
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