Commit Graph

242 Commits

Author SHA1 Message Date
Tianyu Geng d3e8cc577c FIR checker: fix local type approximation on delegated property
Previously types of delegated property is not approximated, which can
cause local types to leak through public APIs.
2021-09-16 22:38:08 +03:00
Tianyu Geng 76e192fc8a FIR Checker: check AMBIGUOUS_ANONYMOUS_TYPE_INFERRED
Also change
org.jetbrains.kotlin.fir.types.TypeUtilsKt#hideLocalTypeIfNeeded to skip
approximating anonymous objects if there are multiple super type refs so
that resolution behaves the same (for uncompilable code).

Note that this change does not implement check for
ApproximateAnonymousReturnTypesInPrivateInlineFunctions as the check is
already turned on in 1.5 and will likely not needed when FIR becomes
stable.
2021-09-16 22:38:06 +03:00
Mark Punzalan 580f1d51f6 FIR checker: report LOCAL_VARIABLE_WITH_TYPE_PARAMETERS 2021-08-26 12:25:07 +03:00
Ivan Kochurkin 84c5f58cab [FIR] Implement UNRESOLVED_REFERENCE_WRONG_RECEIVER 2021-08-25 21:53:23 +00: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
Andrey Zinovyev 1b81018b69 [FIR] Fix overloading of renamed jvm methods
#KT-48102 Fixed
2021-08-09 15:22:06 +03:00
Ivan Kochurkin 10d9988824 [FIR] Implement DANGEROUS_CHARACTERS 2021-07-30 16:58:06 +00:00
Andrey Zinovyev b706e776ad [FIR] Add VARIABLE_WITH_NO_TYPE_NO_INITIALIZER diagnostic 2021-07-28 16:56:53 +03:00
Ivan Kochurkin dd54338ec0 [FIR] Fix positioning and detecting of WRONG_NUMBER_OF_TYPE_ARGUMENTS
Refactor code and fix compilation errors caused by changes to symbol.fir
2021-07-15 19:02:58 +03:00
Ivan Kochurkin 5741374883 [FIR] Report UPPER_BOUND_VIOLATED only on checkers stage, fix detection of missing cases and testData 2021-06-25 20:57:45 +03:00
Denis.Zharkov 0aca3a3737 FIR: Adjust test data after introduction of INFERENCE_NO_INFORMATION_FOR_PARAMETER
See previous commits for details
2021-06-07 15:25:47 +03:00
Ivan Kochurkin f081a6b4fa [FIR] Implement REDUNDANT_PROJECTION diagnostics, rename FirConflictingProjectionChecker -> FirProjectionRelationChecker, fix tests 2021-06-03 18:24:34 +03:00
Ivan Kochurkin b85846c0c0 [FIR] Fix location for CONFLICTING_PROJECTION diagnostics, extend conflictingProjection.kt with test sample 2021-06-03 18:24:29 +03:00
Mark Punzalan af99ad0736 FIR checker: Report VAL_OR_VAR_ON_*_PARAMETER. 2021-05-25 20:39:34 +03:00
Denis.Zharkov ddbdfafa79 Remove OI/NI attributes from test data 2021-05-25 13:28:27 +03:00
Denis.Zharkov 2ecba6ac39 Remove WITH_NEW_INFERENCE directive from all tests
This directive anyway does not make test run twice with OI, and with NI
It only once run the test with specific settings (// LANGUAGE)
and ignores irrelevant (OI or NI tags)
2021-05-25 13:28:26 +03:00
Denis.Zharkov b94335dd1c FIR: Update diagnostics test data
Green code correctly became red
2021-05-20 17:24:30 +03:00
Mikhail Glukhikh 4608ca15eb FIR: don't allow SEALED callable modality anymore 2021-05-12 17:50:29 +03:00
Mikhail Glukhikh 67d1c35f19 FIR: report MANY_INTERFACES_MEMBER_NOT_IMPLEMENTED also on interfaces 2021-05-12 17:50:27 +03:00
Ivan Kochurkin ea2d9f7c0c [FIR] Implement UNDERSCORE_IS_RESERVED, UNDERSCORE_USAGE_WITHOUT_BACKTICKS diagnostics (psi only) 2021-04-27 17:03:52 +03:00
Tianyu Geng b5caa658d6 FIR: introduce delegate diagnostics
This commit adds diagnostics for the following

* DELEGATE_SPECIAL_FUNCTION_MISSING
* DELEGATE_SPECIAL_FUNCTION_AMBIGUITY
* DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE
2021-04-19 15:11:16 +03:00
Mikhail Glukhikh 2e14b65644 Introduce FirForLoopChecker 2021-04-19 15:10:58 +03:00
Mikhail Glukhikh eb831b9afc FIR: support separate ANONYMOUS_FUNCTION_WITH_NAME 2021-04-19 15:10:38 +03:00
Mikhail Glukhikh 9894b97058 FIR: rename EXPRESSION_REQUIRED to EXPRESSION_EXPECTED 2021-04-19 15:09:50 +03:00
Andrey Zinovyev 14fe570a00 [FIR] Add more type params checks
VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED
BOUND_ON_TYPE_ALIAS_PARAMETER_NOT_ALLOWED
2021-04-14 18:11:09 +03:00
vldf 57d2eb5da2 Introduce FirFunctionReturnTypeMismatchChecker 2021-04-13 21:36:33 +03:00
vldf 24f1f1221e Introduce FirInitializerTypeMismatchChecker 2021-04-13 21:36:31 +03:00
Ivan Kochurkin ad9b962536 [FIR] Fix tests (ARGUMENT_TYPE_MISMATCH instead of INCOMPATIBLE_CANDIDATE) 2021-04-12 23:49:55 +03:00
Jinseong Jeon 87c50235ed FIR checker: report COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH 2021-04-09 12:32:44 +03:00
Dmitriy Novozhilov 3cb17ac2f0 [FIR] Implement FirReturnAllowedChecker
Supported diagnostics:
- RETURN_NOT_ALLOWED
- RETURN_IN_FUNCTION_WITH_EXPRESSION_BODY
2021-04-06 12:30:41 +03:00
Tianyu Geng 761a0a7d0d FIR checkers: report specific errors instead of INAPPLICABLE_CANDIDATE
Specifically, the report the following 4 errors.

* NON_VARARG_SPREAD
* ARGUMENT_PASSED_TWICE
* TOO_MANY_ARGUMENTS
* NO_VALUE_FOR_PARAMETER

Also added/updated the following position strategies.
* NAME_OF_NAMED_ARGUMENT
* VALUE_ARGUMENTS
2021-04-02 14:36:14 +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
Tianyu Geng d6907222cd FIR: pass the qualified access source when reporting ErrorNamedReference
Currently if there is an error in a function call, FIR would report the
entire expression if this call is qualified, but *only* the name if it's
not qualified. For example, assume the following two calls are all
contains some errors.

```
a.foo(1,2,3)
^^^^^^^^^^^^
bar(1,2,3)
^^^
```

The entire call of `foo` is reported since it's qualified. But only the
reference `bar` is reported since it's not qualified. This limits the
usage of position strategies because the IDE does not allow position
strategies to go outside of the initially reported PSI element
(org.jetbrains.kotlin.idea.fir.highlighter.KotlinHighLevelDiagnosticHighlightingPass#addDiagnostic).

This change passes both the original error named reference and the
surrounding qualified access expression and defer the decision of which
to use to the reporting logic.

For unresolved reference and checks on `super` keyword, the position
strategy should not highlight the surrounding parentheses. Hence a new
position strategy `REFERENCED_NAME_BY_QUALIFIED` is added.

In addition, this change also has the following side effect

* some diagnostics are no longer reported when there is a syntax error
  since the higher level structure does not exist when there is a syntax
  error
2021-03-29 12:45:27 +03:00
Mikhail Glukhikh 449a79151a FirNotImplementedOverrideChecker: check also anonymous objects / enums 2021-03-24 16:07:30 +03:00
Mikhail Glukhikh 9ce8420491 FIR: introduce not implemented checker 2021-03-24 16:07:25 +03:00
Jinseong Jeon 7fff4108b6 FIR checker: report KClass with incorrect type argument 2021-03-16 21:56:10 +03:00
Jinseong Jeon bc2228d434 FIR checker: don't report errors on type parameter as LHS of class literals
If a type paramter is not reified or nullable, different errors will
be reported by FirGetClassCallChecker.

When determining whether type parameter wrapped in qualified access is a
standalone expression or not, we examine whether the checker context has
other qualified accesses in stack. Class literals (::class) is desugared
to FirGetClassCall, and thus not stacked as qualified access. Since
class literals are a special type of callable reference (a subtype of
qualified access), we should keep track of FirGetClassCall in a similar
way.
2021-03-16 21:56:09 +03:00
Jinseong Jeon 33c5b49632 FIR checker: report non-typed LHS of callable references 2021-03-16 21:56:08 +03:00
Jinseong Jeon e8028e7825 FIR checker: report nullable/non-class LHS of class literals 2021-03-04 17:09:52 +03:00
Mikhail Glukhikh d7a6fc80b0 FIR: don't report CONST_VAL_NOT_TOP_LEVEL_OR_OBJECT on variables 2021-03-04 16:13:50 +03:00
Br0mm dd3bc1a964 FIR: Introduce CONST_VAL_NOT_TOP_LEVEL_OR_OBJECT diagnostic 2021-03-04 16:13:50 +03:00
Jinseong Jeon f1fa290d49 FIR checker: report val reassignment 2021-03-03 12:27:11 +03:00
Tianyu Geng bdeecfc188 FIR: check multiple vararg param and forbidden vararg type 2021-02-24 13:50:46 +03:00
Mikhail Glukhikh 34c90aab3b FIR: introduce & use REFERENCE_BY_QUALIFIER positioning strategy 2021-02-19 18:24:46 +03:00
Mark Punzalan 2f450549ab FIR IDE: Update FIR diagnostic test data for
INAPPLICABLE_LATEINIT_MODIFIER.
2021-02-15 19:37:14 +01:00
Mikhail Glukhikh 0ee4f1f393 FIR: more exact nullability determination in potential UNSAFE_CALL check 2021-01-29 16:55:09 +03:00
Jinseong Jeon e72ddbcbfe FIR checker: differentiate UNSAFE_CALL from INAPPLICABLE_CANDIDATE
To do so, inside the root cause of inapplicable candidate errors,
we will record expected/actual type of receiver, if any.
That will help identifying inapplicable calls on nullable receiver.
2021-01-29 16:54:23 +03:00
Jinseong Jeon fa0b933bc8 FIR checker: add diagnostics for missing/ambiguous component calls 2021-01-21 16:06:10 +03:00