Allow multiple bases with default
implementations as long as there's a
non-abstract symbol from a class.
Our rules for Kotlin are stricter than
those in Java.
Check all members for `Visibility.Unknown`,
otherwise we miss them when they come
from supertypes. This is the reason why
the FP intellij build failed with a
cryptic stacktrace instead of a
human-readable diagnostic.
Also, do report the diagnostic at all
cases of `Visibilities.Unknown`. Turns
out, there are no "simple to reason
about" situations here :(
Also, an interesting detail:
`retrieveDirectOverriddenOf` returns an
empty list for intersection overrides.
But this doesn't seem to break anything...
Replacing `CANNOT_INFER_VISIBILITY`'s
type `KtDeclaration` with
`PsiNameIdentifierOwner` and the related
changes in `PositioningStrategies`
were needed to prevent an exception saying that
`PsiClassImpl` is not a subtype of
`KtDeclaration`.
All existing tests use custom test data for FIR because the diagnostic
text in FIR has to have a dot at the end. Also, the K2 checker doesn't
check usages in imports because there are no "import checkers" in K2
right now, this will need to be fixed later if necessary.
#KT-60797 Fixed
When a declaration with an ObjC annotation is stored in a different
module, the annotation arguments are not resolved by default. This leads
to a bug in the checker. Before attempting to find the objCName, it is
necessary to resolve the annotation first.
#KT-64276
There's been a change in the error message for
INCOMPATIBLE_OBJC_NAME_OVERRIDE in K2 which makes it much more difficult
to diagnose the underlying issue. Previously in K1 the symbol that had
an incompatible objc name would be output, but in K2 only the class
declaration is output making it difficult to determine which member is
causing the error.
#KT-65572 Fixed
`testIntersectionOfPrimitiveBasedFunctions`
is fine, because we deprecate this
already in ^KT-63243.
`CANNOT_INFER_VISIBILITY` is
positioned as `DECLARATION_NAME`,
just in case we decide for
some reason that we do want to
report it along with
`MANY_*_NOT_IMPLEMENTED`. In that
case, we'd get a problem that
their bounds overlap, but not
completely contain one another.
^KT-63741 Fixed
^KT-59400 Fixed
Even though SO may not be correct
overrides sometimes, it feels more
natural to treat fake overrides as...
well, "overrides". And without it
we'd need to make the code in
`FirOverrideChecker` less intuitive.
The change in
`FirOptInUsageBaseChecker` is needed
to prevent `OPT_IN_OVERRIDE` on
intersection overrides where one
of the base functions requires opt-in.
We never designed this in such
a way that it's an error.
See:
`FirPsiOldFrontendDiagnosticsTestGenerated.testIncorrectTargetsForExperimentalAnnotation`.
According to KT-63741, the case like
`kt40510.fir.kt` should, in fact,
be an error. It will be addressed
separately.
In general, overrides should not
contain default values, and it's
better to make fake overrides be close
to proper overrides as much as
possible. It will be important when
we begin running `FirOverrideChecker`
for fake overrides.
^KT-63879 Fixed
^KT-65534
This annotation leads to conflicting overloads error supression,
in case where several function with the same argument types,
but different argument names are inherited from ObjC class.
We need to implement it in both K1 and K2 to make the IDE experience
better.
But the annotation itself wouldn't be available in K1.
^KT-61323
Intersections for interfaces and generic interfaces work differently.
`FirIntersectionCallableSymbol.getNonSubsumedOverriddenSymbols()`
does not retrieve the original symbol for a symbol inherited from
generic interfaces.
The patch explicitly obtains original symbols if they exist.
^KT-65216 Fixed
Some FIR checkers were placed into the wrong directories either
by accident or minor oversight. This commit contains fixes
for such cases that were made during work on an internal KCCQA utility
to simplify its workings.
This commit is expected not to affect much (if anything).
Suggest removing explicit type arguments when the upper bound is a
captured type since the only way to satisfy the upper bounds is
by letting the type variable be inferred to its bound.
#KT-65681 Fixed
It was supposed to check only function types...
Also note that it's probably impossible
to write a simpler test right now,
because we have a massive problem that
we ignore `FirTypeRef`s with `null`
sources despite having a dedicated
family of checkers for them
specifically. This will be fixed
separately as KT-65647.
^KT-65584 Fixed
^KT-65647
The diagnostic target source element
type was changed to prevent crash due
to `checkPsiTypeConsistency()` in
`duplicateParameterNameSimplified.fir.kt`
^KT-65584
Review: https://jetbrains.team/p/kt/reviews/14224/timeline
Timeline:
**(1)** Kotlin 1.1.60 https://github.com/JetBrains/kotlin/commit/59efedf610a25b004edf3d19897ce4dfca28ddb2 `header` keyword is introduced (committed on Dec 13, 2016)
**(2)** Kotlin `header`/`impl` has been deprecated (warning) at least since 1.1.60 https://github.com/JetBrains/kotlin/commit/5d251062677e09d607f295189b7978d5833e448f (committed on Sep 15, 2017)
**(3)** 1.1.60 release https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-compiler/1.1.60/ Nov 13, 2017
It sounds stupid but it looks like `header` was introduced and
deprecated right in the same release. Though it may be possible that we
had a release between **(1)** and **(2)** that I couldn't find
Anyway the keywords have been deprecated since basically forever
The fix is not perfect
"The perfect fix" would be:
1. Introduce a separate `DEPRECATED_MODIFIER_ERROR` diagnostic
2. Introduce LanguageVersionSettings for the `DEPRECATED_MODIFIER_ERROR`
diagnostic
But "the perfect fix" requires:
1. Adopting `ReplaceModifierFix` in the IDE to make it work with the new
diagnostic. `ReplaceModifierFix` is only implemented in K1 IDE. So
there are two ways:
1. Create a KTIJ ticket to port the diagnostic to K2 IDE (it needs to
be ported anyway), and **mention** in the ticket that
`DEPRECATED_MODIFIER_ERROR` also needs to be supported in K2 IDE.
It's the ticket that nobody will probably find and fix
2. Go and port `ReplaceModifierFix` to K2 IDE myself. It's fairly
simple task, but I've not worked in intellij for quite a while,
and it will take me too much time to index and compile
Considering that DEPRECATED_MODIFIER diagnostic is used only to report
`header`/`impl`, and there are literally 0 known cases when people use
it. It's just easier to convert the diagnostic to error in K2
Related tests:
- compiler/testData/diagnostics/tests/multiplatform/deprecated/header.kt
^KT-59839 Fixed
- remove ENABLE/COMPATIBILITY because they can no longer be used
- remove forAllMethodsWithBody because its behavior is now equivalent to
isEnabled
- inline isCompatibility
- inline DEFAULT
- rename ALL_INCOMPATIBLE -> ALL
This only affects delegation operators as well as the for-loop-related
next and hasNext operators.
All the other operators worked correctly before.
In K2, the previously mentioned operator calls will be flagged with a
deprecation error and will become and error in 2.1.
#KT-59782 Fixed
The problem arises when retrieveDirectOverriddenOf returns a
substitution override member. For such members, it is impossible to get
the first base member. For a correct result, it is required to find
originalForSubstitutionOverride for all substitutionOverrides.
#KT-64276 Fixed
This diagnostic is reported on an explicitly-declared function which
overrides a regular Java function with the same signature as a hidden
one from the same scope.
#KT-64846 Fixed
Local properties defined within the body of a do-while loop can be used
in the condition of the loop. However, use of a `continue` may mean the
property isn't always initialized, even if it is initialized when it is
defined. So while a local property may be within scope and has an
initializer, this doesn't always mean that the property is initialized.
As such, properties that are defined within a do-while loop and also
used in the condition of the same do-while loop should be tracked. Then,
these properties should still be checked for proper initialization even
if they have an initializer.
^KT-64872 Fixed