Commit Graph

59 Commits

Author SHA1 Message Date
Ilya Chernikov 9ea775cbed K2 scripting: fix containing decl for last script expression
Generally the wrapping anonymous initializer can be used as a
"containing declaration" for some elements, but since the initialiser
for the last script expression could be dropped (the expression could
be converted to the result property), this may lead to the surprises,
e.g. as described in KT-65984
This fix marks the last initialiser as local, preventing it from being
referenced as "containing declaration".

#KT-65984
2024-02-23 22:03:44 +00:00
Ilya Chernikov cdf4b17052 K2 Scripting tests: adding tests on script decls visibility
fixes (makes it stable) behavior of the script top-level declarations
visibility in K2 scripts
2024-02-21 07:47:15 +00:00
Dmitrii Gridin e02c28c88a [LL FIR] support lazy resolve of destructuring declaration entries
^KT-62840 Fixed
^KT-65727
2024-02-14 16:16:01 +00:00
Dmitrii Gridin 39131a7f30 [LL FIR] rework FirDesignation collector
The main change – now we collect not only `FirRegularClass`, but also
`FirScript`.
This allows us to have a proper context collector for
diagnostics for scripts.
Also, this change fixes dangling files for scripts in `IGNORE_SELF`
as now we have the correct patcher for this case, so we won't resolve
the copied script

^KT-65345
^KT-62841 Fixed
2024-02-05 09:32:45 +00:00
Brian Norman 17a1871b83 [FIR] Make sure the primary constructor is first in class CFG
The primary constructor of a class needs to be the first subgraph of the
class control-flow graph. Based on the Kotlin specification, class
initialization order goes first primary constructor, in-place
declarations (properties and init blocks), and then secondary
constructors. If the class doesn't have a primary constructor, then it
is just skipped in the order.

Unfortunately, the class control-flow graph had in-place declarations
first and then all constructors. Instead, we should treat the primary
constructor as the first in-place declaration, and then continue with
the existing processing as secondary constructors. This will guarantee
that super constructor calls have the correct property initialization
information.

^KT-65093 Fixed
2024-01-23 23:16:00 +00:00
Ilya Chernikov a5c2eb66a2 K2 Scripting: add missing contracts resolving in scripts
#KT-64074 fixed
2024-01-19 15:54:53 +00:00
Ilya Chernikov d9f581c8b5 K2 Scripting: temporary mute test with LL divergence
#KT-64074
2023-12-12 09:58:19 +00:00
Ilya Chernikov db804b7f93 K2 Scripting: fix CFG processing related testdata in LL 2023-12-12 09:58:19 +00:00
Ilya Chernikov 90a7f7beac K2 Scripting: fix CFG processing related testdata in compiler 2023-12-12 09:58:19 +00:00
Brian Norman 0881910a1b [FIR] Rewind DFA after call arguments for correct receiver smartcasting
^KT-63709 Fixed
2023-12-08 14:32:22 +00:00
Brian Norman e92fab65aa [FIR] Support including flow information when dumping CFG dot file 2023-11-16 18:04:26 +00:00
Marco Pennekamp 730f98ba38 [FIR] Fix top-level property initialization checks in scripts
- While `collectionInitializationInfo` unwrapped a script's top-level
  declarations, `check` forgot to do it, so a script effectively had no
  top-level properties in the mind of the checker.

^KT-63286 fixed
2023-11-09 13:09:39 +00:00
Marco Pennekamp 1cc2390af6 [FIR] Add tests for top-level property initialization in scripts
- The test data is missing initialization checks and will be fixed with
  the subsequent commit.
- The test data is originally taken from
  `backingField/TopLevelPropertyInitialization` and has been simplified.
- I didn't add `const val` properties to the test data (compared to the
  original) due to KT-20110.

^KT-63286
2023-11-09 13:09:39 +00:00
Dmitrii Gridin 2f8026f335 [LL FIR] add missed diagnostic tests for scripts
^KT-62840
^KT-62841
^KT-62861
2023-10-24 19:32:54 +00:00
Dmitrii Gridin a1ee07603a [FIR] add cfg dump to script test
^KT-62834
2023-10-24 10:30:55 +00:00
Ilya Chernikov bf3a6f7678 K2 Scripting: support script top-level destructuring declarations 2023-07-05 19:46:04 +00:00
Ilya Chernikov 00211a5fc9 K2 Scripting: turn on implicit body resolve for scripts 2023-07-05 19:46:04 +00:00
Ilya Chernikov 1a735b0842 K2 scripting: support script-level typealiases 2023-07-05 19:46:04 +00:00
Ilya Chernikov 70d2fcd9c4 K2 Scripting: deprecate top level script inner classes
no LT support yet
2023-07-05 19:46:03 +00:00
Ilya Chernikov 7484ccb9ee K2 Scripting: allow script top level inline functions 2023-07-05 19:46:03 +00:00
Ilya Chernikov 86b3e65d19 K2 Scripting: enable script processing in diagnostics collector
and add scripts to containing decls in checker context te be able to
check for containing script in checkers
2023-07-05 19:46:03 +00:00
Ilya Chernikov 9adf24950a Fir2Ir scripts: fix declarations registration and processing 2023-07-05 19:46:03 +00:00
Kirill Rakhman 5abab2197b [FIR] Adapt positioning of NO_VALUE_FOR_PARAMETER to match K1 2023-07-04 16:00:45 +00:00
Kirill Rakhman 1eb18f13bd FIR: Fix test data after making LHS of assignment an expression
KT-54648
2023-01-31 08:39:43 +00:00
Ilya Chernikov 47448d779c K2 Scripting: enable script diagnostic tests for FIR
also add script scopes test
2022-11-26 18:01:49 +00:00
Nikolay Lunyak fcd3e4f4c5 [FIR JS] KT-51740: Alter positioning of NO_VALUE_FOR_PARAMETER 2022-09-30 21:39:20 +03:00
Victor Petukhov 27fa632630 [FE 1.0] Update test data with new error type representation 2022-03-23 21:13:33 +00:00
Ilya Muradyan 58831eacca [scripting] Make properties from destructing declarations available with reflection 2021-10-07 18:17:21 +03:00
Dmitriy Novozhilov cd890d5833 [Test] Disable UNUSED_* diagnostics in tests which are not belong to contolFlowAnalysis suite 2021-03-29 16:12:29 +03:00
Dmitriy Novozhilov 85949b387e [Test] Explicitly enable UNUSED_* diagnostics in tests which are not belong to contolFlowAnalysis suite 2021-03-29 16:12:28 +03:00
Dmitriy Novozhilov e6b5cb5216 [TD] Update diagnostics test data due to new test runners
Update includes:
- Changing syntax of `OI/`NI` tags from `<!NI;TAG!>` to `<!TAG{NI}!>`
- Fix some incorrect directives
- Change order of diagnostics in some places
- Remove ignored diagnostics from FIR test data (previously `DIAGNOSTICS` didn't work)
- Update FIR dumps in some places and add `FIR_IDENTICAL` if needed
- Replace all JAVAC_SKIP with SKIP_JAVAC directive
2020-12-16 19:52:25 +03:00
Mikhail Zarechenskiy bcc8802014 [NI] Avoid constraints from expected type for effectively empty system
Expression will be checked against expected type later.

 Theoretically, this is not very good, but it aligns with the old
 inference, plus it helps avoiding multiple type mismatch diagnostics.
2019-04-17 12:55:12 +03:00
Ilya Chernikov 2c02ee3d29 Rename test files to scripts to trigger proper scripting initialization
fix generation config accordingly
2019-02-10 13:31:57 +01:00
Mikhail Glukhikh e76debb12b Report UNUSED_PARAMETER in setter #KT-21129 Fixed 2018-05-04 18:04:57 +03:00
Mikhail Zarechenskiy 8757298994 Add diagnostics to test data from NI 2017-11-29 02:54:26 +03:00
Mikhail Zarechenskiy a71238bf94 Place !WITH_NEW_INFERENCE directive to diagnostics test data 2017-11-29 02:53:49 +03:00
Mikhail Glukhikh ecfc2236a6 Fix script properties kind in modifier checker #KT-18234 Fixed 2017-06-05 17:22:11 +03:00
Dmitry Petrov d850f01c39 Fix diagnostic for uninitialized extension property without accessors
#KT-8612 Fixed
2017-05-26 13:58:46 +03:00
Mikhail Zarechenskiy 400ecd5e13 Support destructuring declarations in scripts and REPL
#KT-5620 In Progress
 #KT-15810 In Progress
2017-05-25 16:46:04 +03:00
Dmitry Petrov 7600b6de52 Allow top-level type aliases in scripts 2017-05-24 11:20:22 +03:00
Dmitry Petrov a974ed1049 Support custom accessors for top-level properties in scripts. 2017-01-26 10:12:13 +03:00
Ilya Chernikov 846797ff61 Switch to templates in the separate script runtime 2016-10-12 15:38:52 +02:00
Mikhail Zarechenskiy 0ba2d374bc Create standard script definition from standard template
Now each script without specified template has a StandardSriptTemplate
class as a base one. This allows to generalize script codegen and
resolve.
2016-09-20 15:44:44 +03:00
Mikhael Bogdanov c06b51c1d1 Allow top-level local delegated properties in scripts 2016-05-13 19:11:23 +03:00
Dotlin fa523b9af4 Delegated Properties: Analysis adjustments for local delegated properties support 2016-05-13 19:11:18 +03:00
Pavel V. Talanov 337701670c Refactor script registering in frontend and jvm backend 2015-11-30 18:21:02 +03:00
Pavel V. Talanov 2b955bc6ec Script refactoring, frontend tests: changes according to semantic changes in scripts
Add checker tests for scripts
2015-11-19 22:56:57 +03:00
Mikhail Glukhikh 4b35e3b135 Preliminary declaration visitor for estimating local variable's predictability for smart casts
Predictability estimation algorithm is completely new, but backward compatibility should present.
A large set of tests. Some updated tests.
Smart casts allowed for captured variables if they are not modified in closure #KT-9051 Fixed
Also #KT-8643 Fixed
Also #KT-7976 Fixed
Correct handling of lambda arguments in functions #KT-9143 Fixed
2015-10-16 20:47:47 +03:00
Michael Nedzelsky bc5c9065d2 fix tests in org.jetbrains.kotlin.checkers 2015-09-08 02:04:32 +03:00
Andrey Breslav 0eee83b6ec Lazy logs removed 2014-11-21 18:59:45 +03:00