Commit Graph

53 Commits

Author SHA1 Message Date
zhelenskiy ea10b4a781 Synchronizing by values and primitives is forbidden
Signed-off-by: zhelenskiy <zhelenskiy2000@yandex.ru>
2021-10-29 18:50:30 +02:00
Ivan Kochurkin 2c1c24c042 [FIR] Implement WRONG_MODIFIER_CONTAINING_DECLARATION, DEPRECATED_MODIFIER_CONTAINING_DECLARATION 2021-08-13 18:32:28 +03:00
Ivan Kochurkin cd6384eb20 [FIR] Fix handling of WRONG_MODIFIER_TARGET
Implement DEPRECATED_MODIFIER, DEPRECATED_MODIFIER_FOR_TARGET, REDUNDANT_MODIFIER_FOR_TARGET
2021-08-13 18:32:27 +03:00
Tianyu Geng 7bb81ef157 FIR: add equality call checker
Added checker for FirEqualityOperatorCall. It's surfaced as one of the
following diagnostics depending on the PSI structure and types under
comparison:

* INCOMPATIBLE_TYPES(_WARNING)
* EQUALITY_NOT_APPLICABLE(_WARNING)
* INCOMPATIBLE_ENUM_COMPARISON_ERROR

Comparing with FE1.0, the current implementation is more conservative
and only highlights error if the types are known to follow certain
contracts with `equals` method. Otherwise, the checker reports warnings
instead.

However, the current checker is more strict in the following situations:
1. it now rejects incompatible enum types like `Enum<E1>` and
  `Enum<E2>`, which was previously accepted
2. it now rejects incompatible class types like `Class<String>` and
  `Class<Int>`, which was previously accepted
3. the check now takes smart cast into consideration, so
  `if (x is String) x == 3` is now rejected
2021-05-06 17:50:32 +03:00
Ilmir Usmanov 64abb2501f Minor. Add FIR_IDENTICAL directive 2021-03-15 06:19:22 +01:00
Ilmir Usmanov d3b42709fd Revert "Value Classes: Forbid var properties with value class receivers"
This reverts commit f43899086a.
2021-03-12 17:51:24 +01:00
Mikhail Glukhikh 15c3269e38 FIR: don't report error on inline nested classes 2021-03-06 09:22:35 +03:00
eugenpolytechnic f6e564ffa6 FIR: introduce inline classes checks 2021-03-06 09:22:34 +03:00
Ilmir Usmanov 62123d72e2 IC: Add inline class -> @JvmInline value class warning 2021-02-25 16:06:47 +01:00
Tianyu Geng bdeecfc188 FIR: check multiple vararg param and forbidden vararg type 2021-02-24 13:50:46 +03:00
Tianyu Geng 6b453d9b23 FIR: implement checker for open members
Specifically,

1. NON_FINAL_MEMBER_IN_FINAL_CLASS
2. NON_FINAL_MEMBER_IN_OBJECT
2021-02-19 10:17:18 +03:00
Dmitriy Novozhilov f3a8fcaea6 [FE] Make constructors of sealed classes protected instead of internal 2021-02-12 13:36:38 +03:00
Dmitriy Novozhilov f14bd87ecc [Test] Update testdata of diagnostic tests during to change language to 1.5
Mostly this commit contains changes of descriptor dump of sealed classes
  tests according to changed visibility of sealed class constructor
2021-01-28 13:19:24 +03:00
Jinseong Jeon 8b4f2b269c FIR checker: introduce PARAMETER_* positioning strategies
and use them to add support diagnostics:
ANONYMOUS_FUNCTION_PARAMETER_WITH_DEFAULT_VALUE
USELESS_VARARG_ON_PARAMETER
2021-01-27 19:46:05 +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
Ilmir Usmanov 775d610045 Value classes: Forbid any identity equality check on value class
#KT-31130 Fixed
2020-12-10 08:24:48 +01:00
Ilmir Usmanov f43899086a Value Classes: Forbid var properties with value class receivers 2020-12-04 09:45:56 +01:00
Ilmir Usmanov 0d55c9108d IC: Forbid inner classes inside inline classes
#KT-43067 Fixed
2020-12-04 05:45:53 +01:00
Ilmir Usmanov 15c325cf10 Value classes: Allow nested inline classes 2020-12-04 05:45:51 +01:00
Ilmir Usmanov c62093f54c IC mangling: Change mangling rules
1. Use 'x' for each parameter, which is not an inline class, every
possible clash is handled by signature rather than name. This change
makes more API changes binary-compatible. So, the changes are in line
with the vision of inline classes are value classes, like primitives.

2. Take return type into account when mangling a function if the return
type is inline class. Otherwise, boxing bridge will not be generated,
which leads to CCE at runtime.
2020-11-19 17:39:24 +01:00
Ilmir Usmanov 326768e8b5 Minor. Update test data 2020-11-04 00:20:39 +01:00
Ilmir Usmanov 1376fed1d4 Support non-public inline class constructors
#KT-28056 Fixed
2020-11-03 12:10:21 +01:00
Ilmir Usmanov 5f8fabed61 Minor. Update test data 2020-11-03 02:20:44 +01:00
Ilmir Usmanov 999604541e JVM_IR: Support init blocks in inline classes
Put their content to constructor-impl, so they are called during
constructor call, but they are not called during boxing, because
box-impl calls <init> and not constructor-impl.

 #KT-28055 In progress
2020-10-29 20:38:01 +01:00
Mikhail Likholetov 80cd26c9df [FIR] Support several annotation class diagnostics 2020-05-21 18:01:36 +03:00
FenstonSingel b7d8e879a6 [FIR] Support 4 diagnostics for pairs of modifiers
In particular, this commit includes:
* Attempt to abstract access to FirSourceElement via FirModifier
* Add more visit functions to DeclarationCheckersDiagnosticComponent
* Add messages+factories for 4 modifier-related errors and warnings
* Introduce FirModifierChecker
2020-03-27 12:34:29 +03:00
Mikhail Glukhikh 8884cbe415 Introduce FIR_IDENTICAL for FIR vs old frontend tests #KT-36879 Fixed 2020-03-05 09:39:40 +03:00
Dmitriy Novozhilov 2536fa0cd5 [FIR-TEST] Add new testdata generated after changes in previous commit 2019-12-12 16:11:46 +03:00
Dmitry Petrov f68ce4b35b Support default parameter values for inline class constructors and funs
#KT-26908
 #KT-26554

Move default parameter value tests to separate directory
2018-10-15 12:21:14 +03:00
Dmitry Petrov 7ff72e9d90 Fix inline class recursion through type parameters
Note that inline class such as
  inline class Id<T>(val x: T)
is prohibited in 1.3.0.
2018-09-19 14:51:50 +03:00
Dmitry Petrov 006c0aa740 Hide constructors accepting inline class parameters 2018-09-07 15:57:59 +03:00
Mikhail Zarechenskiy b4674a172e Reserve secondary constructors with bodies inside inline classes
#KT-26575 Fixed
2018-09-06 10:22:01 +03:00
Mikhail Zarechenskiy 002a66fec1 Reserve box/unbox/equals/hashCode methods inside inline classes
#KT-26573 Fixed
2018-09-06 10:20:03 +03:00
Dmitry Petrov a56d1d3ce8 Mangle function names with inline class parameters
Avoid name clashes in cases such as

  inline class Login(val login: String)
  inline class Password(val password: String)

  fun validate(login: Login) { ... }
  fun validate(password: Password) { ... }
2018-08-30 14:58:50 +03:00
Dmitry Petrov 5045fa446a Prohibit recursive inline classes 2018-08-20 10:08:10 +03:00
Dmitry Petrov 948e72f653 Inline classes can only implement interfaces 2018-08-15 15:32:50 +03:00
Dmitry Petrov b7df36643b Implement additional declaration checks for inline classes
- Implementation by delegation is prohibited
- Delegated properties are prohibited
2018-08-13 08:49:09 +03:00
Mikhail Zarechenskiy d3280252f9 Prohibit inline data classes
`CONFLICTING_JVM_DECLARATIONS` diagnostics are reported because we're
 trying to generate functions from `Any` once for inline class and
 once for data class

 #KT-25760 Fixed
2018-08-08 15:47:26 +03:00
Mikhail Zarechenskiy ddf6c37e0e Prohibit inline classes with special underlying types
#KT-25328 Fixed
 #KT-23819 Fixed
2018-08-06 10:56:05 +03:00
Mikhail Zarechenskiy 6244846107 Add functions from Any to the member scopes of inline classes 2018-08-06 10:19:43 +03:00
Mikhail Zarechenskiy 17243c08c1 Forbid lateinit variables of inline class types
Proper support of lateinit inline class values will be added later,
 see #KT-23814

 #KT-25603 Fixed
2018-07-20 13:58:33 +03:00
Mikhail Zarechenskiy 6431934c13 Fix signature mapping for built-in methods inside erased inline class 2018-06-18 18:55:18 +03:00
Mikhail Zarechenskiy b2d9015723 Prohibit identity equals on inline class types 2018-06-07 18:22:05 +03:00
Mikhail Zarechenskiy 0da3ae328e Handle case when u-literals are using without unsigned declarations 2018-06-04 18:37:39 +03:00
Mikhail Zarechenskiy 656f6cbded Support constant evaluation of unsigned type constructors
#KT-23816 In Progress
2018-06-04 18:37:34 +03:00
Mikhail Zarechenskiy 043c3d9a97 Prohibit properties with backing fields inside inline classes 2018-05-07 15:25:43 +03:00
Mikhail Zarechenskiy 29d15b9990 Prohibit varargs on parameters of inline class types 2018-05-07 15:25:42 +03:00
Mikhail Zarechenskiy d3c1c11dc5 Prohibit initializer blocks inside inline classes 2018-05-07 15:25:40 +03:00
Mikhail Zarechenskiy 6a120d2f85 Require presence of public primary constructor for inline class 2018-05-07 15:25:38 +03:00
Mikhail Zarechenskiy 096fe1c411 Don't report diagnostics on the whole declaration, use main keyword 2018-05-07 15:25:37 +03:00