Commit Graph

42549 Commits

Author SHA1 Message Date
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
Mikhail Zarechenskiy 28e539b158 Simplify CompilerTestLanguageVersionSettings: merge two maps into one 2017-11-13 16:27:26 +03:00
Mikhail Zarechenskiy cd2d32d92a Set up specific LV settings for compiler tests
For example, to configure NI

(cherry picked from commit e0c6aec)
2017-11-13 16:27:25 +03:00
Mikhail Zarechenskiy 91a6591b70 Load compiler language version settings for resolved calls tests 2017-11-13 16:27:24 +03:00
Mikhail Zarechenskiy 20bf238006 Load compiler language version settings for codegen tests 2017-11-13 16:27:23 +03:00
Mikhail Zarechenskiy 85d442133d Load compiler language version settings for foreign annotations tests
To set specific features for compiler tests
2017-11-13 16:27:22 +03:00
Mikhail Zarechenskiy 63b13027df Configure pseudocode tests with !LANGUAGE directive
Except all, it's also useful to use one class of language version settings for compiler tests to configure it specially for tests
2017-11-13 16:27:20 +03:00
Mikhail Zarechenskiy ef1d1ef946 Enable new inference feature by system property for tests only 2017-11-13 16:27:19 +03:00
Mikhail Zarechenskiy fbbe396881 Add configuration key to enable new inference for compiler tests 2017-11-13 16:27:18 +03:00
Mikhail Zarechenskiy 0b484771dd Add compiler key to enable new inference 2017-11-13 16:24:34 +03:00
Mikhail Zarechenskiy 84ac5a3e22 Use separate directive to check results of descriptor renderer for NI 2017-11-13 16:24:33 +03:00
Mikhail Zarechenskiy b6542caf47 Setup system property for NI tests with parameter -PnewInferenceTests 2017-11-13 16:23:05 +03:00
Mikhail Zarechenskiy 0410287cf9 Add flag to force loading old inference diagnostics 2017-11-13 16:23:05 +03:00
Mikhail Zarechenskiy 6486c8dccc Add ability to reuse one diagnostic test file for old and new inference 2017-11-13 16:23:05 +03:00
Mikhail Zarechenskiy 73b4e24d54 Introduce language feature for NI, remove old setting 2017-11-13 16:23:04 +03:00
Toshiaki Kameyama 27e7f13335 Fix AssertionError on completing after template in string literal
#KT-16402 Fixed
2017-11-13 16:01:34 +03:00
Simon Ogorodnik 0560ba7929 KT-19943: Remove redundant type conversions in J2kPostProcessing
Don't remove them in converter itself
2017-11-13 15:54:33 +03:00
a2kaido 083c3d8a5d KT-19943: Remove redundant special type unboxing calls in J2K
#KT-19943 Fixed
2017-11-13 15:54:33 +03:00
Konstantin Bulenkov 65cc5f1589 Change run icon in gutter to standard one from IJ Platform 2017-11-13 13:16:22 +01:00
Alexander Udalov 6f276c623b Do not use IntelliJ extensions for uninitialized variable suppressor in JS 2017-11-13 13:04:54 +01:00
Alexander Udalov 6f90a0545c Do not use IntelliJ extensions for declaration without body suppressor in JS 2017-11-13 13:04:54 +01:00
Alexander Udalov 7f81601123 Do not use IntelliJ extensions for unused parameter suppressor in JS 2017-11-13 13:04:54 +01:00
Alexander Udalov d782c8a644 Use ServiceLoader instead of IntelliJ extensions for ScriptHelper 2017-11-13 13:04:54 +01:00
Alexander Udalov 20d13411e0 Remove obsolete extension point implementations
- There's no class with FQ name
  org.jetbrains.kotlin.resolve.jvm.AnalyzeCompleteHandlerExtension anymore
- There's no substring classBuilderInterceptorExtension anywhere else in
  the project
2017-11-13 13:04:54 +01:00
Toshiaki Kameyama 2be27d5380 KT-19390: Fix char + String in Java is converted to code with multiple type errors in Kotlin (#1235)
#KT-19390 Fixed
2017-11-13 14:13:34 +03:00
Mikhail Glukhikh 1e940bde01 Lookup element factory: do not use outdated descriptor
Probably #KT-20986 Fixed
2017-11-13 14:10:58 +03:00
Mikhail Glukhikh f43360177a Minor refactoring of ResolveElementCache #KT-21132 Fixed
Get rid of SoftValueMap.containsKey
2017-11-13 14:10:58 +03:00
Ilya Gorbunov f51974b271 Minor fix in comparison samples #KT-20357 2017-11-10 23:32:20 +03:00
scache 96e322c7d5 Add samples for Comparisons #KT-20357 2017-11-10 23:32:06 +03:00
Ilya Gorbunov e16a0ba650 Improve and group samples for operations on Iterables #KT-20357 2017-11-10 23:31:50 +03:00
kenji tomita 75348dd0c0 Add samples for Iterables #KT-20357 2017-11-10 23:31:31 +03:00
Alexey Belkov 5da1b4c566 Minor: fix sample name (KT-20357) 2017-11-10 23:29:39 +03:00
Alexander Udalov 2572d27921 Regenerate tests 2017-11-10 20:01:48 +01:00
Alexander Udalov b5fa520aa5 Remove obsolete version override mechanism and increment-version.kts 2017-11-10 18:58:32 +01:00