Commit Graph

80 Commits

Author SHA1 Message Date
Denis.Zharkov 2bafcddf7a K2: Avoid using Nothing? as inference result in the majority of cases
Namely, do not choose `Nothing?` result type when fixing a variable
that has other constraints besides the ones that came from
the relevant type parameter's upper bounds.

See more details in KT-55691.

In K1, the case from specialCallWithMaterializeAndExpectedType.kt
was working (inferred to String?) just because the branches
were analyzed independently with `String?` expected type.

This change became necessary after the previous commit when we united
inference subsystems for if/when branches (see motivation there).

NB: For K1, the behavior is left the same, but the code
was refactored a bit.

^KT-55691 Fixed
^KT-56448 Fixed
2023-02-15 08:13:50 +00:00
Ilya Kirillov 1bbcae5ed2 [FIR] fix resolve contract violation from scopes
We cannot call lazy resolve to STATUS phase from scopes as scopes may be accessed on a STATUS phase or earlier

^KT-54890
^KTIJ-23587 fixed
2023-01-13 21:32:51 +00:00
Ilya Kirillov 644d1bf0d0 [FIR] ignore tests which fail because of resolve contracts violation 2022-12-12 16:21:07 +00:00
Denis.Zharkov cd0d6d2773 Adjust test data for postponing ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated
^KT-55357 Related
^KT-36770 Related
2022-12-12 11:39:04 +00:00
Dmitriy Novozhilov ac7fddaad5 [FE] Always infer upper types to intersection types in K2...
...and always use old algorithm for K1

^KT-51221
2022-11-29 12:25:44 +00:00
Dmitriy Novozhilov eb8ce449e3 [FIR] Don't lose flexible types during capturing from expression 2022-11-22 15:46:22 +00:00
Dmitriy Novozhilov 01c6c7dc59 [FIR] Properly approximate return type of callable declarations
- approximate intersection types in all non-local declarations
- approximate local types in non-private non-local declarations
2022-11-22 15:46:20 +00:00
Dmitriy Novozhilov 07567d6748 [FIR] Always fix type variables with UNKNOWN direction 2022-11-22 15:46:18 +00:00
Dmitriy Novozhilov 1b27d60307 [FIR] Support @OnlyInputTypes annotation
^KT-54807 Fixed
2022-11-22 15:46:17 +00:00
Victor Petukhov 42e71f8c53 Remove explicit enabling the new type inference from test data 2022-07-22 16:03:52 +00:00
Ilya Chernikov bb996c1b27 Switch kotlin version to 1.8
with appropriate fixes in testdata, tests and other
places.
2022-06-29 10:20:30 +02:00
Mikhail Glukhikh 53d6ac24e5 Switch kotlin version to 1.7
* Change 1.6 to 1.7 constants
* Fix SAFE_CALL_WILL_CHANGE_NULLABILITY for testData
* Change EXPOSED_PROPERTY_TYPE_IN_CONSTRUCTOR_WARNING to EXPOSED_PROPERTY_TYPE_IN_CONSTRUCTOR_ERROR
* Change NON_EXHAUSTIVE_WHEN_STATEMENT to NO_ELSE_IN_WHEN
* Fix testData for SafeCallsAreAlwaysNullable
* Change T -> T & Any in test dumps
* Change INVALID_CHARACTERS_NATIVE_WARNING -> INVALID_CHARACTERS_NATIVE_ERROR
* TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_WARNING -> TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR
2022-02-25 11:46:27 +00:00
Sergej Jaskiewicz 599f705842 [stdlib] Make @LowPriorityInOverloadResolution applicable to ctors 2021-12-02 12:39:40 +00:00
Denis.Zharkov 883b18a0c6 FIR: Preserve non-custom attributes after substitution
The test is being fixed since synthetic call for elvis has @Exact-attribute on return type
2021-11-26 19:39:45 +03:00
Denis.Zharkov 4a9d4ed9fe Enable ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated since 1.7
^KT-36770 Fixed
2021-08-31 15:41:17 +03:00
Denis.Zharkov 62bef48f9d Adjust test data to changed rendering: T!! -> T & Any
^KT-26245 In Progress
2021-08-31 15:41:15 +03:00
Ivan Kochurkin 84c5f58cab [FIR] Implement UNRESOLVED_REFERENCE_WRONG_RECEIVER 2021-08-25 21:53:23 +00:00
Dmitriy Novozhilov d17f984edf [FE 1.0] Migrate most of warning/error pairs to DiagnosticFactoryForDeprecation 2021-08-03 00:17:33 +03:00
Denis.Zharkov d2ad421e0b Fix test data for definitelyNotNullType 2021-07-29 19:45:57 +02:00
Victor Petukhov d2a7434cff Update testdata 2021-07-29 19:45:56 +02:00
Dmitriy Novozhilov e316cd04b6 [FIR] Fix consistency of FE 1.0 and FIR test data 2021-07-29 19:45:56 +02:00
Victor Petukhov 95492f7370 [FE 1.0] Fix some diagnostic tests 2021-07-29 19:45:55 +02: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 00821bbc63 FIR: Update test data (repeated diagnostics)
They are a bit redundant, but it needs additional work to be done
to avoid them
2021-05-20 17:24:33 +03:00
Denis.Zharkov b94335dd1c FIR: Update diagnostics test data
Green code correctly became red
2021-05-20 17:24:30 +03:00
pyos e6d923f65c FIR: rename HIDDEN to INVISIBLE_REFERENCE
Some of them should be INVISIBLE_MEMBER though
2021-04-21 16:18:21 +03:00
Dmitriy Novozhilov 1f0ecade34 [FIR] Transform annotations of type refs in body resolve stage
Also fix building CFG for annotation calls
2021-04-14 18:30:56 +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
Victor Petukhov cc1cb463b2 Remove NonStrictOnlyInputTypesChecks LF and introduce opposite – StrictOnlyInputTypesChecks, set default as strict 2021-03-29 16:17:30 +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
Victor Petukhov 7f7bb70596 Don't fix a type variable into the intersection type if there is an explicit expected type
^KT-43303 Fixed
^KT-42396 Fixed
^KT-42472 Fixed
2021-03-12 14:36:53 +03:00
Jinseong Jeon f1d8a6e5d1 FIR checker: introduce DECLARATION_SIGNATURE_OR_DEFAULT positioning strategy
and fix CONFLICTING_OVERLOADS to use it
2021-01-21 16:06:09 +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
Nick 4669e019d1 [FIR] Add diagnostic CONFLICTING_OVERLOADS & REDECLARATION 2020-08-10 10:09:37 +03:00
Dmitriy Novozhilov 721b9b4d8c [FIR] Resolve annotations as calls 2020-08-04 08:59:14 +03:00
Denis Zharkov 037ff2fa52 Fix incorrect handling of @NotNull type parameters
^KT-36770 In progress
^KT-40114 Relates
^KT-28785 Relates
2020-07-22 10:16:14 +03:00
Mikhail Zarechenskiy 684ca5029f Add tests for obsolete issues
#KT-37734 Obsolete
 #KT-39824 Obsolete
2020-06-26 06:24:59 +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 296ee2da4a [FIR] Support @LowPriorityInOverloadResolution annotation 2020-03-02 09:49:28 +03:00
Mikhail Zarechenskiy cbbbf40b90 [NI] Fix isSuccessful property for member with LowPriority resolution
The problem was introduced in e40ba73950
2020-02-19 18:06:22 +03:00
Ilya Chernikov 6356807997 Reapply "Only create descriptors for candidates with lambda args"
#KT-36247 fixed
A lot of testdata changed because significanly less (error) descriptors
are created for unresolved types, so diagnostics became different.
2020-02-14 11:41:30 +01:00
Mikhail Glukhikh dc7621a112 [FIR] Fix Java override ambiguity (Kotlin type parameter VS Java Object) 2020-02-11 16:09:20 +03:00
Mikhail Glukhikh 22068dd6ad [FIR TEST] Update test data due to hardened receiver check (NB: broken)
In particular, nullable invoke extension call and some smart casts
are broken here
2020-02-03 16:45:21 +03:00
Pavel Kirpichenkov 2a4e235e34 [NI] Decrease only input types check diagnostic level to warning 2020-01-10 13:05:40 +03:00
Pavel Kirpichenkov 7ee71450bc [NI] Discriminate Nothing? result type from nullability constraints
Nullability constraints should not be chosen when proper
argument constraints for variables in contravariant position present.

^KT-32106 Fixed
^KT-33166 Fixed
2019-12-25 14:59:06 +03:00
Pavel Kirpichenkov ebb9f09656 [NI] Fix issues with star projection uncapturing
Prevent stack overflow during uncapturing of star projection
for parameter with recursive upper bound.
Uncapture star projections for flexible type parameters with
respect to flexible upper bound.

^KT-35210 Fixed
2019-12-18 16:19:33 +03:00
Pavel Kirpichenkov 86dc0925b1 [NI] Preserve constraint position for OnlyInputType during incorporation
Variable with complex dependency on other variable loses its
original constraint position when variable it depends on is fixed.
To prevent that, original input position is saved in incorporation
position.
2019-12-18 16:19:33 +03:00
Pavel Kirpichenkov 2fc79856a2 [NI] Fix OnlyInputTypes for captured types
Uncapture projections recursively for cases when captured type is not
top-level type or first level type argument
2019-12-18 16:19:32 +03:00