Commit Graph

1424 Commits

Author SHA1 Message Date
Mikhail Glukhikh 6fb88102a5 K2: add test for KT-56520, cases (1), (5), (6), type references
In both these situations, we have some.HashMap & java.util.HashMap
from explicit star importing scope, and kotlin.collections.HashMap
from implicit star importing scope after it.
K1 ignores both explicitly imported classifiers due to their ambiguity,
and then resolves to kotlin.collections.HashMap at the next level.
In contrast, K2 takes explicitly imported classifiers and
properly reports ambiguity.
2023-12-04 21:50:40 +00:00
Mikhail Glukhikh d07f3a14e6 K2: add test for KT-56520, case (2), constructors, Space subcase
In this test, both frontends resolve to fun Semaphore.
Both work this way because interface/class Semaphore classifiers are
clashed (ambiguity) and ignored.
K2 reports ambiguity for some similar cases,
but constructor resolve still ignores ambiguous classifiers when found.
(see FirScope.processConstructorsByName in ConstructorProcessing.kt)
2023-12-04 21:50:40 +00:00
Mikhail Glukhikh 6049f8657b K2: add test for KT-56520, case (2), constructors
In this test, K1 resolves to kotlin.collections.HashMap /* = java.util.HashMap */
K2 does the similar, but fun processConstructors from ConstructorProcessing.kt
makes a type alias substitution, so in fact constructor of expanded
java.util.HashMap is processed.

Pay attention that both frontends ignore some.HashMap and java.util.HashMap
due to ambiguous classifiers in explicit star importing scope.
See FirScope.processConstructorsByName in ConstructorProcessing.kt
2023-12-04 21:50:39 +00:00
Simon Ogorodnik d46075a9db K2: Use correct position for substitution constrains in builder inference
Before, we were wrapping the original constraint position into
ConeBuilderInferenceSubstitutionConstraintPosition twice during the
constraint substitution in builder inference.

It was causing problems with diagnostic reporting.

Remove TODOs about diagnostic reporting from FirBuilderInferenceSession.
Propagation of errors from the common system is now implemented
Diagnostic reporting in updateCalls isn't needed, since we
report errors after the system completion unlike K1

Relates to KT-53749
2023-12-04 15:27:21 +00:00
Simon Ogorodnik 2f367b013a K2: Don't lose constraint errors in the builder inference session
Pass constraint errors from the integration system into a candidate to
make sure it is reported later.

Related to KT-59426, KT-59437, KT-53749
#KT-55168 Submitted
2023-12-04 15:27:20 +00:00
Anastasia.Nekrasova 85cff98a38 [K2] Disappeared UNSUPPORTED
Prohibit Array<Nothing>

^KT-59881
2023-12-01 12:05:12 +00:00
Simon Ogorodnik 299d279915 K2: Don't report BUILDER_INFERENCE_STUB_RECEIVER for members of Any
This commit actually does two things:
- Adds Any scope to stub type
- Makes CheckDispatchReceiver treat stub types
as non-null for the unsafe call check to make such candidates viable

Related to KT-59369
2023-12-01 10:54:29 +00:00
Mikhail Glukhikh 0ed6256bcc K2: implement BUILDER_INFERENCE_STUB_RECEIVER
#KT-59369 Fixed
2023-12-01 10:54:29 +00:00
Anastasia.Nekrasova 7787b53b4a [K2] Disappeared UNSUPPORTED
Forbid callable reference to coroutineContext

^KT-59881
2023-11-24 15:59:04 +00:00
Ivan Kochurkin 115d685d91 [FIR] Fix ambiguity of Throws and other std annotations importing
Including `SharedImmutable` and `ThreadLocal`

Simplify code, remove `DefaultImportPriority.KOTLIN_THROWS`

Introduce `FirNativeClassMapper`
2023-11-23 23:51:23 +00:00
Anastasia.Nekrasova 97ef2de6e3 [K2] OPT_IN_USAGE_ERROR is absent when calling the enum primary constructor
^KT-63459
2023-11-23 13:16:05 +00:00
Anastasia.Nekrasova c6d391c632 [K2] OPT_IN_MARKER_CAN_ONLY_BE_USED_AS_ANNOTATION_OR_ARGUMENT_IN_OPT_IN on an annotation import
Only tests added

^KT-59582
2023-11-23 13:14:42 +00:00
Anastasia.Nekrasova 6471080c48 [K2] Disappeared UNSUPPORTED
Mark as UNSUPPORTED suspension points in default parameters

^KT-59881
2023-11-23 09:29:07 +00:00
Evgeniy.Zhelenskiy 5096fd266e [FIR] Forbid generic type checks inside contracts in K2 as it is done in K1.
#KT-59922
2023-11-21 18:00:10 +00:00
Mikhail Glukhikh a2dc4f155f K2: drop obsolete TODO about multiple WasExperimental
In certain situations like constructor calls, it's possible
to have different WasExperimental/SinceKotlin pairs associated
with one use-site, e.g. a constructor call is associated both
with a constructor declaration and a class declaration.
However, looks like it make no sense to handle this situation
in FirSinceKotlinHelpers, because FirOptInUsageBaseChecker already
handles them.

#KT-59825 Fixed
2023-11-15 09:36:06 +00:00
Nikolay Lunyak 425d5e808b [FIR] Link some tests with issues
Just in case.

^KT-59874
2023-11-14 15:19:33 +00:00
Nikolay Lunyak 41c5934d4e [FIR] Don't forget to ignore hidden imports
^KT-59874
2023-11-14 15:19:33 +00:00
Nikolay Lunyak c656a83a02 [FIR] Don't miss non-const annotation args
This code with `b()` crashes the JVM
backend.

^KT-59822 Fixed
^KT-59874
2023-11-14 15:19:33 +00:00
Mikhail Glukhikh 9903b70e0a K2: add test to confirm KT-58874 now works properly
#KT-58874 Obsolete
2023-11-13 12:26:28 +00:00
Kirill Rakhman d91000e39c [FIR] Report INAPPLICABLE_CANDIDATE or more specific diagnostic for callable references
... instead of just UNRESOLVED_REFERENCE when something went wrong
during resolution.

#KT-59401 related
2023-11-08 15:45:48 +00:00
Anastasia.Nekrasova 93ebd83ecd [K2] Disappeared OPT_IN_MARKER_CAN_ONLY_BE_USED_AS_ANNOTATION_OR_ARGUMENT_IN_OPT_IN (4)
Added checking usages of markers as qualifiers in properties and function calls.

^KT-59998
2023-11-07 13:12:46 +00:00
Anastasia.Nekrasova 72d69e16c4 [K2] Disappeared OPT_IN_MARKER_CAN_ONLY_BE_USED_AS_ANNOTATION_OR_ARGUMENT_IN_OPT_IN (3)
Added checking usages of markers as qualifiers in imports.

^KT-59998
2023-11-07 13:12:46 +00:00
Anastasia.Nekrasova 97f09acc92 [K2] Disappeared OPT_IN_MARKER_CAN_ONLY_BE_USED_AS_ANNOTATION_OR_ARGUMENT_IN_OPT_IN (2)
Added checking usages of markers as qualifiers.

KT-59998
2023-11-07 13:12:46 +00:00
Anastasia.Nekrasova 445ed7abc9 [K2] Disappeared OPT_IN_MARKER_CAN_ONLY_BE_USED_AS_ANNOTATION_OR_ARGUMENT_IN_OPT_IN (1)
Added error propagation for the type-aliased type.

^KT-59998
2023-11-07 13:12:46 +00:00
Dmitriy Novozhilov c5d1c4e816 [Test] Add test for KT-62137 2023-11-06 15:24:39 +00:00
Brian Norman 3327bed5bd [FIR] Report more occurrences of NON_LOCAL_RETURN_NOT_ALLOWED
When an inline lambda is invoked or passed to another inline function,
make sure non-local returns are allowed by all surrounding declarations.
Otherwise, NON_LOCAL_RETURN_NOT_ALLOWED must be reported.

^KT-59884 Fixed
^KT-55319 Fixed
2023-11-02 12:33:56 +00:00
Nikolay Lunyak f5d859f209 [FIR] Don't miss smartcast info on equalities with when subjects
Since they are not `FirSmartCastExpression`s,
they are treated as proper original types,
thus leading to reporting errors instead of
warnings.

^KT-60095 Fixed
2023-10-31 10:40:43 +00:00
Nikolay Lunyak ed8935899c [FIR] Relax incompatibleEnumAndUnrelatedInterface 2023-10-30 06:58:40 +00:00
Nikolay Lunyak 8ec7d128f5 [FIR] Add one more missed case 2023-10-30 06:58:40 +00:00
Nikolay Lunyak c6bec2fa75 [FIR] Relax incompatibleEnumAndUnrelatedInterfaceThroughTypeParameter 2023-10-30 06:58:40 +00:00
Nikolay Lunyak 3058f2eaff [FIR] Relax incompatibleEnumComparisonWithTypeParameters 2023-10-30 06:58:40 +00:00
Nikolay Lunyak ae521524d6 [FIR] Add tests highlighting false errors in K2 regarding equalities
Some overlooked corner-cases found by Denis.
2023-10-30 06:58: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 a60777b9a7 [FIR] move annotation recheck logic to ANNOTATIONS_ARGUMENTS_MAPPING phase
ARGUMENTS_OF_ANNOTATIONS will be dropped, so this check should be moved
This commit also drops class annotations resolution from implicit type
phase and provides the correct scope during argument mapping phase.
This code was effectively unreachable before

^KT-62679
2023-10-19 14:34:35 +00:00
Nikolay Lunyak a68a2409d3 [FIR] Remove the applicability filtering when reporting diagnostics
In case we don't want to introduce any new
abstractions like "user relevance for
applicability", we can just remove the
filtering.

^KT-62541 Fixed
2023-10-19 09:27:45 +00:00
Nikolay Lunyak fedadfb8db [FIR] Show ARGUMENTS_MAPPING_ERROR diagnostics along with INAPPLICABLE
K1 reports `ARGUMENT_TYPE_MISMATCH`
and `TOO_MANY_ARGUMENTS` together, and
one way to do it in K2 is to say that
their kinds of inapplicability difference
is not relevant to the user.

Note that K1 doesn't do such filtering,
so this change "makes K2 closer to K1",
but still different.

^KT-62541 Fixed

fixup! [FIR] Show ARGUMENTS_MAPPING_ERROR diagnostics along with INAPPLICABLE
2023-10-19 09:27:45 +00:00
Alejandro Serrano Mena b231e69cd3 Remove unneeded K1/K2 split in test 2023-10-18 12:34:58 +00:00
Alejandro Serrano Mena b9b15cba08 [K2] Warn about deprecation and opt-in markers for overrides of Any
^KT-62620 Fixed

Include opt-in markers in the diagnostics
2023-10-18 12:34:58 +00:00
Dmitriy Novozhilov 43929398da [FIR] Pass implications from subject of safe call in DFA
^KT-59689 Fixed
2023-10-18 12:17:44 +00:00
Anastasia.Nekrasova 9ad4cf4c55 [K2] Disappeared OPT_IN_USAGE_ERROR for a data class property during the destructuring declaration
^KT-62450
2023-10-17 21:27:13 +00:00
Anastasia.Nekrasova 4c9ad970ff [K2] Violation of OPT_IN_USAGE_ERROR non-propagating opt-in rules for typealias
^KT-62451
2023-10-12 09:03:39 +00:00
Anastasia.Nekrasova 6d446abe12 [K2] Disappeared OPT_IN_USAGE_ERROR for typealias
^KT-62451
2023-10-12 09:03:39 +00:00
Nikolay Lunyak 2e7dcd6096 [FIR] Require overrides to have matching isSuspend flag value
^KT-57100 Fixed
2023-10-09 06:55:43 +00:00
Nikolay Lunyak 4e58715760 [FIR] Check conflicting overloads via scopes
Scopes may return private symbols from
supertypes, they should not clash with
symbols from the current class.

For example, see:
`FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.FakeOverride#testPrivateFakeOverrides1`

Lombok shouldn't generate functions if the
user has defined explicit ones.

In K1 generated functions are not really
added to the declared members scope.

^KT-61243 Fixed
2023-10-09 06:55:43 +00:00
Mikhail Glukhikh aea7b8f00a Common supertypes: unwrap captured type from DNN type during recursion control
This commit handles subtle situation when K1 represents flexible type
arguments as just T..T?, but K2 does it as T&Any..T?.
This can provoke a type like Captured(*)&Any..Captured(*)?,
and before this commit we couldn't find recursion inside Captured(*)&Any.
This could lead to explosions inside type system and inference errors

#KT-60581 Fixed
2023-10-05 12:17:17 +00:00
Vladimir Sukharev 7b3e661776 [FIR] Fix Disappeared ANNOTATION_PARAMETER_DEFAULT_VALUE_MUST_BE_CONSTANT
^KT-59942 Fixed
2023-10-05 10:18:09 +00:00
Kirill Rakhman fbf68a5bcc [FIR] Narrow down range of NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER
This uses the same approach as
INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION where we use a visitor
to find a call to a symbol that contains the type variable in question.

#KT-56140 Fixed
2023-09-22 13:49:59 +00:00
Ilya Kirillov d98da87278 [FIR] Render dot-separated FQNs instead of slash-separated ones in diagnostics
^KT-62030 fixed
2023-09-22 10:48:31 +00:00
Kirill Rakhman e996760e7e [FIR] Fix rendering of SUSPENSION_POINT_INSIDE_CRITICAL_SECTION
#KT-61826 Fixed
2023-09-21 07:18:19 +00:00
Kirill Rakhman 0d279dd652 [FIR] Fix false negative JVM_STATIC_ON_CONST_OR_JVM_FIELD
... in presence of typealias.

#KT-61921
2023-09-18 12:13:02 +00:00