Commit Graph

26501 Commits

Author SHA1 Message Date
Dmitriy Novozhilov cadc2dfe4d [FIR] Fix generating fir for invoke calls 2019-11-08 12:12:38 +03:00
Pavel Kirpichenkov ff32eab3d1 [NI] Run call checkers on resolved calls for callable references
#KT-34391 Fixed
2019-11-08 11:04:43 +03:00
Mark Punzalan f444702cf3 JVM: Always invoke get()/charAt() in optimized for-loop over
CharSequence.withIndex(), even if element variable is unused in
destructuring declaration.

#KT-34779 Fixed
2019-11-08 10:55:09 +03:00
Mikhail Glukhikh 411dc5d60e FIR nested classifier scope building: optimize companion search 2019-11-08 09:58:37 +03:00
Mikhail Glukhikh 48938a20a7 Raw FIR: add synthesized Enum.valueOf() function 2019-11-08 09:58:02 +03:00
Alexander Udalov 1978db9d0e Move codegen tests on old language versions under oldLanguageVersions/
This directory is skipped in JVM IR test generator, so they won't show
up as failed anymore.

Note that only failing tests are moved to oldLanguageVersions/. Tests
which already pass are still being run. It may be useful not to break
them in case we _do_ need to support some pre-1.3 language feature
switches in JVM IR.
2019-11-07 19:05:24 +01:00
Alexander Udalov c3729c8189 Reorganize codegen tests for old language versions
Put all files under a single "oldLanguageVersions" directory under test
data of each test
2019-11-07 18:49:27 +01:00
Steven Schäfer dcd72b06d8 JVM IR: Implement CHECK_NOT_NULL as a lowering 2019-11-07 18:47:53 +01:00
pyos fb9f43c119 JVM_IR: fix load check in inliner (should accept primitives too) 2019-11-07 15:58:44 +01:00
Alexander Udalov 4164b620e8 Minor, remove obsolete directives and suppressions from contracts test data 2019-11-07 15:20:34 +01:00
Alexander Udalov 66e19b13ce IR: create shared variables for val-variables when needed
This is possible when a lambda's contract guarantees initialization of a
variable.
2019-11-07 15:20:34 +01:00
Nikolay Krasko 155a760ee9 Revert "Revert [JS IR] commits that failed build"
This reverts commit 740f851a
2019-11-07 16:24:13 +03:00
Steven Schäfer 181d023e3c JVM IR: Remove JvmBackendContext.getTopLevelClass 2019-11-07 13:48:43 +01:00
Steven Schäfer 1ac753602e JVM IR: Avoid getTopLevelClass in CollectionStubMethodLowering 2019-11-07 13:48:43 +01:00
Steven Schäfer f9ff3771e5 JVM IR: Avoid getTopLevelClass in AddContinuationLowering 2019-11-07 13:48:43 +01:00
Steven Schäfer 481d4d72b9 JVM IR: Avoid getTopLevelClass in JvmSymbols 2019-11-07 13:48:43 +01:00
Mark Punzalan d0c261c779 Ensure the correct functions (with correct params) are being used in
ForLoopsLowering.
2019-11-07 13:43:24 +01:00
Mark Punzalan 21178a4f1a Fix issue getting the size property from Collection bounded type
parameters, when lowering for-loops over Collection.indices.
2019-11-07 13:43:24 +01:00
Mikhail Glukhikh 30679ebfaf FIR Java: implement correct type matching in SuperTypeScope 2019-11-07 15:07:41 +03:00
Georgy Bronnikov 688a2185fa Tests for Kapt3 with JVM_IR backend 2019-11-07 13:28:09 +03:00
Mikhail Glukhikh 4d9839a790 JavaClassUseSiteMemberScope: add mutable vs non-mutable type matching 2019-11-07 13:08:38 +03:00
Dmitriy Novozhilov 61c337588b Revert testdata accidentally committed in 665405c4 2019-11-07 10:41:15 +03:00
Dmitriy Novozhilov 4f8a8f84ba [FIR] Update some testdata in fir visualizer test 2019-11-07 10:39:22 +03:00
Dmitriy Novozhilov abf41f87a1 [FIR] Fix rendering of local variables in Visualizer 2019-11-07 10:39:21 +03:00
Dmitriy Novozhilov f0ba9c3c40 [FIR] Make file separator in AbstractVisualizer OS independent 2019-11-07 10:39:21 +03:00
Mikhail Glukhikh 581504aac5 Raw FIR: add synthesized Enum.values() function #KT-24076 Fixed 2019-11-07 09:29:00 +03:00
Mikhail Glukhikh 6e0148c7a8 FIR: cleanup of DataClassUtils: remove redundant status field assignments 2019-11-07 09:28:16 +03:00
Leonid Startsev 3b100e57f2 Change NO_EXPLICIT_VISIBILITY_IN_API_MODE diagnostic range to 'declaration modifiers + name'.
Motivation: missing visibility modifier is an error in visibility modifiers list, so we should highlight this list.
Including a name in the range is convenient for using alt+enter (you don't have to move cursor from name to fun/class/val keyword)

 Also change NO_EXPLICIT_RETURN_TYPE_IN_API_MODE diagnostic range to 'declaration name' to match corresponding IDE inspection.

Fix stylistic problems and typos after review
2019-11-06 19:54:00 +03:00
Leonid Startsev 24688f3503 Do not disable 'redundant visibility modifier' inspection completely in Explicit API mode.
Instead, disable it only for effectively public declarations.

Add tests for this IDE inspection.
2019-11-06 19:54:00 +03:00
Leonid Startsev 5ab262c977 Skip explicit API inspection for data class properties and add inspection for public API in interfaces
Add tests for almost all the cases
2019-11-06 19:54:00 +03:00
Leonid Startsev ebb7e434c8 Explicit Api mode: Renamings after design discussions
Change CLI flag to -Xexplicit-api=strict|warning. 'Disable' state and 'mode' suffix are left out as implementation details.

Change intention title to 'make X public explicitly'

Do not report 'no explicit visibility' on property accessors

Set DECLARATION_SIGNATURE as a range for report

Rename internal diagnostic from _MIGRATION to _WARNING
2019-11-06 19:53:59 +03:00
Leonid Startsev 7fada51c42 Add quickfix for setting explicit public visibility for diagnostic reported in API mode 2019-11-06 19:53:59 +03:00
Leonid Startsev 2b708093c0 Add explicit return type check for API mode
It will use the same SpecifyTypeExplicitlyIntention as in other places; to reuse check logic, some parts of code were moved from corresponding inspection (PublicApiImplicitTypeInspection) into ApiModeDeclarationChecker.

Also disable RedundantVisibilityModifierInspection when API mode is on.
2019-11-06 19:53:58 +03:00
Leonid Startsev 7058492b55 Explicit Api mode: prototype with check for missing explicit visibility
Add cli flag with 3-state switch
2019-11-06 19:53:58 +03:00
Alexander Udalov a7d60fbf2d JVM IR: minor, fix IR builder scope for multifile bridges 2019-11-06 17:05:49 +01:00
Alexander Udalov 7a2c467bb5 JVM IR: remove obsolete hack in JvmMultifileClass facade generation 2019-11-06 17:05:49 +01:00
pyos 5d8aac456f JVM_IR: create temporaries for complex super constructor arguments
As for SAM wrappers, the bytecode sequence

    new A
    dup
    new B
    dup
    invokespecial B.<init>
    invokespecial A.<init>

breaks the inliner, so instead we do

    new B
    dup
    invokespecial B.<init>
    store x
    new A
    dup
    load x
    invokespecial A.<init>
2019-11-06 15:54:40 +01:00
pyos 42f75b3247 JVM_IR: have SAM wrapper constructors accept FunctionN
Otherwise, the cached instances cannot be reused for different wrapped
types. Also, if the wrapped type is regenerated during inlining, the
inliner would produce a call to a nonexistent constructor that takes the
regenerated type as an argument.
2019-11-06 15:54:40 +01:00
pyos 862197d713 JVM_IR: create temporaries for complex SAM conversion arguments
To avoid bytecode sequences like

    new _1Kt$sam$i$java_lang_Runnable$0
    dup
    new _1Kt$f$1
    dup
    invokespecial _1Kt$f$1.<init>()V
    invokespecial _1Kt$sam$i$java_lang_Runnable$0.<init>(...)V

as the different order of `new` and `<init>` confuses the inliner.
2019-11-06 15:54:40 +01:00
Mikhail Zarechenskiy 650e2501bb [NI] Prioritize variables with trivial constraints over complex ones
Consider the following constraint system (from the test example):

Nothing? <: V1
F!! <: V2
Inv<V1> <: S
Inv<V2> <: S

Where V1, V2, S are type variables, and F has nullable upper bound.
Type variable fixation order should be: V2 -> V1 -> S, and the problem
was that previously after fixation of type variable V2 we were trying
to fix S (before V1), so we had the following constraints on S:
Inv<F!!> <: S
Inv<V1> <: S
=> S were fixed to Inv<F!!>

And after this V1 was fixed to F!! which is contradictory as Nothing?
is not a subtype of F!!.

 #KT-33033 Fixed
2019-11-06 15:20:17 +03:00
Mikhail Zarechenskiy 5582fd4056 [NI] Discard DefNotNull types inside invariant positions
#KT-30297 Fixed
 #KT-32168 Fixed
 #KT-27722 Fixed (actually, it was fixed with addition of DefNotNullTypes, and now test was added to save this behavior)
 #KT-32345 Fixed
2019-11-06 15:20:17 +03:00
pyos 4fc1bd9ec5 Support inlining functions with KT-28064 style objects
Namely, anonymous objects defined in lambdas that have all captured
variables as loose fields instead of a single reference to the parent.

The question is, when a lambda inside an inline function defines an
anonymous object, and that object is not regenerated during codegen for
the inline function itself, but then has to be regenerated at call site
anyway, do we use an outer `this` or loose capture fields? For example,
before KT-28064:

    inline fun f1(g: () -> Unit) = object { g() }
    // -> f1$1 { $g: () -> Unit }
    inline fun f2(g: () -> Unit) = f1 { object { g() } }
    // -> f2$$inlined$f1$1 { $g: () -> Unit }
    //    f2$$inlined$f1$1$lambda$1 { this$0: f2$$inlined$f1$1 }
    inline fun f3(g: () -> Unit) = f2 { object { g() } }
    // -> f3$$inlined$f2$1 { $g: () -> Unit }
    //    f3$$inlined$f2$1$1 { this$0: f3$$inlined$f2$1 }
    //    f3$$inlined$f2$1$1$lambda$1 { this$0: f3$$inlined$f2$1$1 }

After KT-28064:

    inline fun f2(g: () -> Unit) = f1 { object { g() } }
    // -> f2$$inlined$f1$1 { $g: () -> Unit }
    //    f2$1$1 { $g: () -> Unit }
    inline fun f3(g: () -> Unit) = f2 { object { g() } }
    // -> f3$$inlined$f2$1 { $g: () -> Unit }
    //    f3$$inlined$f2$2 { ??? }
    //    f3$1$1 { $g: () -> Unit }

Should `???` be `this$0: f3$$inlined$f2$1` or `$g: () -> Unit`? This
commit chooses the latter for KT-28064 bytecode and keeps `this$0` when
inlining the old bytecode.
2019-11-06 13:11:44 +01:00
Dmitriy Novozhilov 27e1a54d4e [FIR] Add descriptors.runtime as dependency to psi2fir test 2019-11-06 15:05:06 +03:00
Dmitriy Novozhilov 665405c435 [FIR] Add discriminating generics into ConeOverloadConflictResolver 2019-11-06 15:05:06 +03:00
Mikhail Zarechenskiy 86a8412b05 Don't try loading PSI tree in IDE mode via stubs (e.g. decompiled code)
Here we want getting trailing comma in order to check its correctness
  and then to report diagnostics. Now, note that if we have stub for
  some PSI element, it means that we're definitely not in the compiler as
  there are no stubs and we're definitely not in the current source file,
  because in the current file we have full PSI tree in IDE.

  Stubs are required, for example, for decompiled code and there is no
  need to report any diagnostics about trailing comma there.

  Also, because we don't have stubs for destructuring declarations,
  one check for trailing commas is left without similar guard (
  see resolveLocalVariablesFromDestructuringDeclaration method)

  This commit fixes several IDE-tests:
   MultiFileJvmBasicCompletionTestGenerated.testDoNotCompleteWithConstraints
   MultiFileJvmBasicCompletionTestGenerated.testInImport
   MultiFileJvmBasicCompletionTestGenerated.testInImportedFunctionLiteralParameter
   MultiFileJvmBasicCompletionTestGenerated.testMoreSpecificExtensionGeneric
   MultiFileJvmBasicCompletionTestGenerated.testNoGenericFunDuplication
   MultiFileJvmBasicCompletionTestGenerated.testNotImportedExtensionFunction2
2019-11-06 14:32:09 +03:00
Mikhail Glukhikh aff9ae2ecf FIR resolve bench: collect unique problems also from callee, ignore empty problems 2019-11-06 14:04:24 +03:00
Mikhail Glukhikh bd1127cfa3 FIR: resolve lambda arguments even if an outer call is unresolved 2019-11-06 13:19:20 +03:00
Mikhail Glukhikh 3b4edb3901 Don't recreate FirSpecificTypeResolverTransformer during type resolve stage 2019-11-06 13:19:20 +03:00
Mikhail Glukhikh 3dd3421437 Temporary: resolve type to kotlin/reflect/Function instead of kotlin/Function
This arises in callable reference resolve test due to incorrect fictitious symbols caching
2019-11-06 13:19:19 +03:00
Mikhail Glukhikh 60e6d2e521 Resolve local declaration statuses & types inside bodies in FirBodyResolveTransformer 2019-11-06 13:19:10 +03:00