Commit Graph

42582 Commits

Author SHA1 Message Date
Ilya Gorbunov 012d3804f0 Rewrite Aggregates.kt to the new template DSL 2017-11-15 09:17:42 +03:00
Ilya Gorbunov dd0e04edd5 Switch production generated stdlib sources to the new DSL and remove old DSL 2017-11-15 09:17:42 +03:00
Ilya Gorbunov db049c0ab6 Introduce deprecated helpers to ease migration 2017-11-15 09:17:42 +03:00
Ilya Gorbunov 9f57a2c0d5 Make generated code ordered same as before
Allow to fix signature for sorting when overriding it
2017-11-15 09:17:42 +03:00
Ilya Gorbunov 31e00efa8f Legacy mode for non-multiplatform stdlib sources 2017-11-15 09:17:42 +03:00
Ilya Gorbunov 4404257329 Improve new stdlib generator DSL
- Add Kotlin/Native platform.
- Rename classes.
- Introduce TemplateGroup and TemplateGroupBase to group template values.
- MemberBuilder: add support for more properties.
2017-11-15 09:17:42 +03:00
Ilya Gorbunov e68a6651d2 Prototype new version of stdlib generator template DSL 2017-11-15 09:17:42 +03:00
Ilya Gorbunov 9e34e20338 Refactor stdlib generator: extract common types to be reused in new DSL 2017-11-15 09:17:42 +03:00
Ilya Gorbunov dcd0a94d76 Minor: fix extra space in return type of chunked and windowed 2017-11-15 09:17:42 +03:00
Pavel V. Talanov cf2e9c7002 Fix compilation: erroneous import 2017-11-14 20:30:13 +03:00
Pavel V. Talanov 70b22e7f85 Highlighting: never highlight errors for compiled files 2017-11-14 18:29:58 +03:00
Pavel V. Talanov 9db9750e67 Light classes: do not fail when classfile is in src root 2017-11-14 18:29:53 +03:00
Pavel V. Talanov 6667732dd4 Do not hide kotlin class files in source roots
This fixes a problem where file is indexed but querying
    index fails with an exception because file has no PSI

 #KT-21061 Fixed
2017-11-14 18:26:53 +03:00
Pavel V. Talanov 8696b37cdb Minor, tests: make collection synchronized
Attempt to fix flaky test test that use LightClassComputationControl
2017-11-14 17:47:55 +03:00
Denis Zharkov 1f9d56439a Fix KNPE caused by optimizations in control-flow analysis
The problem is that when performing full analysis we do it in
a backward order while result for trivial vals is filled
in a forward one.

It turns out that reversedInstuctions might return a superset of
forward traversed instructions, e.g. in case of dead code in lambda.

At the same time result for trivial vals is constant
for any instruction, thus we can just return its constant value
and use it in the full analysis

 #KT-20895 Fixed
2017-11-14 16:38:28 +03:00
Denis Zharkov 2a0b937aac Revert "Add diagnostic for unexpected KNPE in control-flow analysis"
This reverts commit f24f0017a0.
2017-11-14 16:37:24 +03:00
Denis Zharkov f24f0017a0 Add diagnostic for unexpected KNPE in control-flow analysis
See KT-20895
2017-11-14 16:32:34 +03:00
Pavel V. Talanov ae2b0325a3 Restore and deprecate old ScriptTemplatesProvider EP 2017-11-14 16:30:42 +03:00
Pavel V. Talanov 6fed779782 Reload gradle script definitions
Reloading in the following scenarios:
- Successful gradle sync following a failure to load definitions
- Gradle settings changed in IDE (via settings UI)
2017-11-14 16:30:40 +03:00
Pavel V. Talanov 4906c850af Reload script definitions on compiler settings changes
Provide API to track compiler settings changes
2017-11-14 16:30:37 +03:00
Pavel V. Talanov ef539bd89d Tests: use standard script definition in cli tests by default 2017-11-14 16:30:35 +03:00
Pavel V. Talanov cdfdc1d19b Refactor script definitions loading
Make ScriptDefinitionProvider an interface
    and provide different implementation for cli and IDEA
Rework ide extension point to a simpler interface (ScriptDefinitionContributor)
Move template loading logic into a top level function
Allow script definitions to be reloaded in IDE
2017-11-14 16:30:33 +03:00
Pavel V. Talanov f063254cc1 GradleScriptDefaultDependenciesProvider: better name filter 2017-11-14 16:30:30 +03:00
Pavel V. Talanov df74fb23f8 ScriptDependenciesCache: limit simultaneously cached script count
Do not schedule updates for dependencies of scripts that were not requested
   (opened in the editor or such) for some time
This fixes a problem when vcs updates changing scripts can trigger
   undesired script dependencies updates
   (probable cause of script files never highlighted correctly in some cases)
Refactor: use VirtualFile instead of String and move code from GradleScriptTemplateProvider
2017-11-14 16:30:28 +03:00
Dmitry Jemerov f67e01db1c Generate 'expectedBy' dependency instead of 'implement' (KT-21006) 2017-11-14 14:09:25 +01:00
Vyacheslav Gerasimov 64f29a7bd5 Move KDsl gradleFrameworkSupport and moduleBuilder to gradle.xml
#KT-21236 Fixed Target versions 1.2.20
2017-11-14 14:52:19 +03:00
Ilmir Usmanov f4e180556c Fix assignment codegen for suspend operators plus and plusAssign
KT-16079: Fixed
2017-11-14 14:49:26 +03:00
Mikhail Zarechenskiy fbe274ff09 [NI] Use less specific type for captured type approximation
This is needed to be more compatible with the old NI
2017-11-14 14:40:47 +03:00
Mikhail Zarechenskiy f3ef961be6 [NI] Report error about non-spread parameter from arguments mapper 2017-11-14 13:55:48 +03:00
Mikhail Zarechenskiy 13ee0f8eda [NI] Don't forget to report error about mixing different kinds of args
Also use more safe way to report errors: only if there is corresponding PSI element. This is not very useful for compiler, but in IDE we can get synthetic calls with null psi arguments
2017-11-14 13:54:58 +03:00
Mikhail Zarechenskiy 2aa8ceb005 [NI] Fix state for named arguments in arguments to parameters mapper 2017-11-14 13:54:51 +03:00
Dmitry Petrov 15ac471626 Treat accessors to JvmStatic methods as having no dispatch receiver
#KT-21246 Fixed
2017-11-14 09:59:16 +03:00
Dmitry Petrov db2aad1857 Rewrite correctContainerForLambda using uninitializedClasses 2017-11-14 09:33:28 +03:00
Dmitry Petrov e38bbbfc13 Drop local interfaces support in ExpressionCodegen
Local interfaces are prohibited since 1.0.
2017-11-14 09:33:28 +03:00
Dmitry Petrov 4365084645 Lookup for local variables taking into account uninitialized this
Consider a context with uninitialized this, e.g.:

  fun foo() {
    val x = "..."
    class Local(y: String) : Base(L@{ x + y })
  }

Lambda 'L' is an argument of a super class constructor call.
Here 'this@Local' is not initialized yet. Thus local variables captured
in 'Local' can't be used. Instead, they should be captured by lambda 'L'
itself.

Note that lambda 'L' sees both 'x' and 'y' as local variables that
should be captured.

When in context with uninitialized this (generating arguments for super
type constructor or delegating constructor call), and a variable in
question is not found in the current context, use enclosing local lookup
to determine whether a local variable should be captured by a closure.
2017-11-14 09:33:28 +03:00
Dmitry Petrov ff0a2562e0 Minor: LocalLookup: lookupLocal -> isLocal 2017-11-14 09:33:28 +03:00
Dmitry Petrov 2d56837409 Minor: answer -> capturedVariable 2017-11-14 09:33:28 +03:00
Dmitry Petrov 47b59496da Minor: CodegenContext.isContextWithUninitializedThis() 2017-11-14 09:33:28 +03:00
Dmitry Petrov bbb0389c51 Fix determining enclosing class for closure
Enclosing class for closure is a class whose instance is captured by
closure as an outer 'this', and stored in a field 'this$0'.
Usually enclosing class for closure is an immediate outer class,
including classes for nested closures. For example:

  class C {
    fun foo() {}
    val example1 = L1@ { foo() }
    // Enclosing class for lambda 'L1' is 'C'
    val example2 = L2a@ { L2b@ { foo() } }
    // Enclosing class for nested lambda 'L2b'
    // is a closure class for outer lambda 'L2a'
  }

However, if the closure is created in a super type constructor call for
the outer class, corresponding instance is considered "uninitialized",
and can't be used as a proper class instance, and can't be referenced:
corresponding code is rejected by front-end.

  class Outer {
    fun foo() {}
    inner class Inner : Base(L3@ { foo() })
    // Enclosing class for lambda 'L3' is 'Outer',
    // because 'Inner' is uninitialized in super type constructor call.
  }

In CodegenAnnotatingVisitor, we maintain a stack of currently
uninitialized classes, and chose enclosing class for closure
as an inner-most surrounding class with initialized instance.

When generating code for this or outer class instance, we skip
contexts corresponding to classes with uninitialized instances.

This fixes a number of bytecode verification errors caused by incorrect
enclosing class for closure.

 #KT-4174 Fixed Target versions 1.2.20
 #KT-13454 Fixed Target versions 1.2.20
 #KT-14148 Fixed Target versions 1.2.20
2017-11-14 09:33:28 +03:00
Dmitry Petrov 6648657e65 Override accept(...) in KtConstructorDelegationCall 2017-11-14 09:33:28 +03:00
Dmitry Petrov ac761a03c5 Minor: calleeContainingClass -> thisOrOuterClass 2017-11-14 09:33:28 +03:00
Dmitry Petrov 92e0ea2553 Minor: CodegenContext utils 2017-11-14 09:33:28 +03:00
Mikhael Bogdanov dff6e943bb Always do stack spilling during inline cause of dex problem
Dex issue: https://issuetracker.google.com/issues/68796377

  #KT-20844 Fixed
2017-11-13 16:50:24 +01:00
Mikhail Zarechenskiy 519e5c33d8 [NI] Support assigning single array elements in named form to varargs 2017-11-13 16:47:05 +03:00
Mikhail Zarechenskiy fe2499b47f [NI] Approximate flexible types with enhancement as usual ones
This is temporary and should be fixed later
2017-11-13 16:35:24 +03:00
Mikhail Zarechenskiy 82d43c23b6 [NI] Perform full type checking in NI if there is no contradiction
In NI type checking actually performs in constraint system. To be conservative, now we still perform full type cheking but only if there is no contradiction in constraint system
2017-11-13 16:33:20 +03:00
Mikhail Zarechenskiy f51f7a0fe4 [NI] Report diagnostic about receiver as super expression 2017-11-13 16:33:08 +03:00
Mikhail Zarechenskiy 1d6e9c244b [NI] Report diagnostic about spread argument to non vararg parameter 2017-11-13 16:32:58 +03:00
Mikhail Zarechenskiy d45f4e71de [NI] Don't try to search methods on undefined integer type 2017-11-13 16:31:22 +03:00
Mikhail Zarechenskiy 4ad885afb0 [NI] Correctly propagate base constraint system of invoke call
Consider the following example:

class A {
  operator fun <T> invoke(): Foo<T> = throw Exception()
}

fun foo(f: Foo<Int>) {}

fun test(a: A) {
  foo(a()) // after resolve of `invoke`, it has non-fixed type variable
}
2017-11-13 16:31:04 +03:00