Compare commits

...

249 Commits

Author SHA1 Message Date
Ilya Muradyan
8b385fe2c7 [Scripting] Fix Bintray-dependant test 2021-03-29 16:55:06 +03:00
Ilya Muradyan
dd3d6a86a9 [REPL] Fix syntax errors analysis and incompleteness detection 2021-03-29 16:55:05 +03:00
Victor Petukhov
bbf5c4412e Do subtyping between self types with captured type in special way 2021-03-29 16:30:58 +03:00
Victor Petukhov
7f2c5cde55 Propagate input type position across incorporation properly
^KT-45719 Fixed
2021-03-29 16:17:31 +03:00
Victor Petukhov
d06031ece3 Approximate types when only input types check is done. Otherwise given types are inconsistent with types obtained by ResultTypeResolver
^KT-45714 Fixed
2021-03-29 16:17:30 +03:00
Victor Petukhov
cc1cb463b2 Remove NonStrictOnlyInputTypesChecks LF and introduce opposite – StrictOnlyInputTypesChecks, set default as strict 2021-03-29 16:17:30 +03:00
Victor Petukhov
b60056f11e Turn only input type warning to error
^KT-45482 Fixed
2021-03-29 16:17:22 +03:00
Dmitriy Novozhilov
c73c73e85e [Test] Simplify DiagnosticsService 2021-03-29 16:12:29 +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
Dmitriy Novozhilov
a9ff030c73 [Test] Add ability to configure tests by negative test location regex 2021-03-29 16:12:27 +03:00
Matthew Gharrity
2cb9d1f287 KT-45676: fix backing field annotation resolve 2021-03-29 15:36:05 +03:00
Yahor Berdnikau
6a586fb731 Ensure Android SDK license files always have all license.
Sometime on CI it may happen that file already exists, but does not
contain all required licenses.
2021-03-29 13:59:05 +03:00
Ilya Kirillov
75bf5fdbfe FIR IDE: replace custom KtSymbolModality with compiler Modality 2021-03-29 12:22:20 +02:00
Tianyu Geng
253c389f4a FIR checker: fix failed test files after sync 2021-03-29 12:45:27 +03:00
Tianyu Geng
ae902e6fe5 FIR: fix source of callee reference in delegated constructor call
Previously the callee reference of a delegated constructor call is
always the same as the call itself. This violates the contract that no
two FIR elements can have identical sources.  In addition, this sets the
entire call expression as the source of the callee expression.

This change instead sets the proper constructor ref as the callee.

Also fixed EXPLICIT_DELEGATION_CALL_REQUIRED type. It should be an error
instead of a warning.
2021-03-29 12:45:27 +03:00
Tianyu Geng
fb14b03824 FIR checker: skip error named reference if receiver is unresolved
Currently, FIR reports errors caused by previous resolution failure. For
example with unresolved `a` and `b` in code `a.b`, both `a` and `b` are
highlighted. FE1.0 only highlights `a` since it's the root cause. This
change applies this heuristics when reporting FirDiagnostics.
2021-03-29 12:45:27 +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
Tianyu Geng
8805675539 FIR IDE: Enforce an order on subclasses of sealed class
Currently the order is non-determinstic, causing non-determinstic
behavior in the IDE diagnostics. This change enforces an alphabetic
order.
2021-03-29 12:45:27 +03:00
Tianyu Geng
c198c57e62 FIR checker: fix diagnostic parameter renderer
Some of the current renderer is fallbacking to `toString` and output the
fully qualified class name with hash code.
2021-03-29 12:45:27 +03:00
Tianyu Geng
f38c0cf348 FIR IDE: run FIR highlighting test on all test data
Similarly to FIR diagnostic tests. This commit enable all available test
data and check the reported error messages by FIR. This helps identify
some issues in formatting of FIR diagnostics.

The changes on the test file are mechanically generated. Failed tests
are disabled with `// IGNORE_FIR` and are re-enabled in the second
commit.
2021-03-29 12:45:27 +03:00
Dmitriy Novozhilov
6592407492 [Test] Fix jdk target for BB test 2021-03-29 12:42:54 +03:00
Dmitriy Novozhilov
051e2b0869 [FIR] Update diagnostic test forgotten in dd20dd98 2021-03-29 11:14:53 +03:00
Dmitriy Novozhilov
a9399535fb [FIR2IR] Change receiver of field of base class in derived class in property reference 2021-03-29 11:14:52 +03:00
Dmitriy Novozhilov
38ab37d7eb [FIR2IR] Properly handle callable references to static functions 2021-03-29 11:14:52 +03:00
Dmitriy Novozhilov
37db27da58 Add dependency on :compiler:visualizer to generate-all-tests module 2021-03-29 10:25:51 +03:00
Sergey Bogolepov
f1280a63d3 Remove -target-cpu flag from Mac targets
Because this option is unsupported in
bitcode embedding.
2021-03-29 12:17:12 +07:00
Mark Punzalan
dd20dd9806 Report WRONG_MODIFIER_TARGET on the modifier instead of the declaration
in ExternalFunChecker.

This allows RemoveModifierFix to provide a quickfix to remove it.
2021-03-27 22:27:36 +01:00
Nikolay Krasko
c680ee8525 Fix build of benchmarks module
Fix after 998a65d1cb
2021-03-27 17:33:25 +03:00
Tianyu Geng
0d9991ebcd FIR IDE: allow HLDiagnosticFixFactory creating any intention
It seems unnecessary to force all quickfixes to fit the `HLQuickfix`
API, especially for those existing trivial fixes that simply modifies
PSI tree. This change further loosen the API of `HLDiagnosticFixFactory`
to allow it to create arbitrary `IntentionAction` objects. This also
avoids code duplication (for example, specify the family name again in
`ReplaceCallFixFactories`).

`HLQuickfix` and the input/target paradighm can still be used where
applicable.
2021-03-27 13:44:41 +01:00
Tianyu Geng
5609645156 FIR IDE: tweak nullability of applyTo
It looks like `project` can never be null
2021-03-27 13:44:41 +01:00
Tianyu Geng
f795a9c4ff FIR IDE: remove type parameter DIAGNOSTIC_PSI
This information is already determined by `DIAGNOSTIC` so there is no
need to repeat it.
2021-03-27 13:44:41 +01:00
Tianyu Geng
6c52d95342 FIR IDE: remove type parameter TARGET_PSI and INPUT
The factory does not need to care about what target PSI and input a
quick fix should need. We only need to ensure these two types match when
an `HLQuickfix` is created. With this constraint loosened, now one
factory can register multiple quickfixes applied on different targets
and different input. This makes it much more flexible when implementing
quickfixes.
2021-03-27 13:44:41 +01:00
Nikolay Krasko
a5e445492f Move Bintray js-externals to Space (KTI-528) 2021-03-26 21:08:46 +03:00
Nikolay Krasko
b903f87704 Drop kotin/kotlinx and kotlin/kotlinx.html bintray usages (KTI-528) 2021-03-26 21:08:45 +03:00
Nikolay Krasko
998a65d1cb Bump version of kotlinx.benchmark plugin 0.2.0-dev-7 -> 0.3.0 (KTI-528) 2021-03-26 21:08:43 +03:00
Nikolay Krasko
455773299b Minor: investigate j2objc-annotations:1.1 verification trace 2021-03-26 21:08:41 +03:00
Alexander Udalov
c17b6c59f8 JVM IR: add isInlineClassType, use it instead of isInlined 2021-03-26 18:57:01 +01:00
Alexander Shabalin
770401801b Implement freezing in the new MM
Currently, it uses suboptimal storage for the freeze bit. This'll be revised later when we finalize stack objects handling in the new MM.
2021-03-26 15:00:14 +00:00
Mikhail Glukhikh
295858cf5c Rename FIR diagnostic to METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE 2021-03-26 17:06:00 +03:00
Mikhail Glukhikh
7d4b8587a3 Unite checks around supertypes in FirPrimaryConstructorSuperTypeChecker 2021-03-26 17:05:58 +03:00
Mikhail Glukhikh
221b6bd184 Drop usages of FirErrors.TYPE_PARAMETER_AS_SUPERTYPE 2021-03-26 17:05:57 +03:00
Aleksei.Cherepanov
c74f471a82 Fix performance problem in KotlinTargetsIndex creation
Creation of KotlinTargetsIndex takes too long,
even if Java project doesn't have any Kotlin files.
Remove function hasJsStdLib, as it takes too much time
because of recursively checking all dependencies (migrate to facets)
Also fix tests: Add Kotlin JS facet, where its needed

#KT-34351 Fixed
2021-03-26 15:46:56 +03:00
Jinseong Jeon
bfc7eb7bab FIR checker: fix REFERENCE_BY_QUALIFIED positioning strategy to consider callable reference 2021-03-26 15:19:10 +03:00
Jinseong Jeon
8d8ed4cc18 FIR checker: check if callable reference targets are allowed members 2021-03-26 15:19:10 +03:00
Tianyu Geng
6769ce0e2b FIR checker: check TOPLEVEL_TYPEALIASES_ONLY 2021-03-26 15:19:10 +03:00
Tianyu Geng
6ca005cd70 FIR IDE: fix IDE exception in presence of non-top-level type alias
Finding type alias doesn't work if it's not top level because the class
ID doesn't match. There doesn't seem to be a easy way to make it work
so this commit simply makes the IDE tolerate it.
2021-03-26 15:19:09 +03:00
Ivan Gavrilovic
19708cfa87 KAPT: Avoid evaluating apOptions from AGP too early
This is causing issues such as https://issuetracker.google.com/183423660.
Annotation processor options that are provided by the Android Gradle plugin
may contain references to files and file collections that are safe to
evaluate only at execution time. This change avoids eagerly creating
compiler plugin options for these options, as they are already a task input.

Test: AbstractKotlinAndroidGradleTests.testAgpNestedArgsNotEvaluatedDuringConfiguration

^KT-39715 In Progress
2021-03-26 15:14:35 +03:00
Ilya Kirillov
1123f97a15 FIR: ensure declaration is resolved to types in FirStandardOverrideChecker 2021-03-26 12:54:28 +01:00
Anton Yalyshev
f7829d0bea Add change-notes for 1.5-M2 release 2021-03-26 14:08:58 +03:00
sebastian.sellmair
e232a2be6c CommonizeLibcurlTest: Provide necessary native distribution dependencies 2021-03-26 10:55:25 +00:00
sebastian.sellmair
2b7866402d [Commonizer] Move KonanDistribution to :native:kotlin-klib-commonizer-api 2021-03-26 10:55:24 +00:00
sebastian.sellmair
6e3b1fd919 [Commonizer] RootMerger: Change priorities for typeResolver
This will prioritize classifiers from the following sources
in the provided order

1) Classifiers from the target's modulesProvider
2) Classifiers from the traget's direct dependencies
3) Classifiers from the more common dependencies
2021-03-26 10:55:24 +00:00
sebastian.sellmair
914ce22f6b [Minor] CommonizerIT: Optimize imports 2021-03-26 10:55:23 +00:00
sebastian.sellmair
a0557ad937 CommonizerIT: Implement test commonizeInterop using posix APIs
^KT-45497
2021-03-26 10:55:22 +00:00
sebastian.sellmair
7f9fe6b332 [Commonizer] CInteropCommonizerTask: Provide custom/commonized native distribution dependencies
^KT-45497 Fixed
2021-03-26 10:55:22 +00:00
sebastian.sellmair
e44877f562 [Commonizer] LibraryCommonizer: Allow passing dependencies for a shared target 2021-03-26 10:55:21 +00:00
sebastian.sellmair
096e715652 [Commonizer] Split CirTreeMerger into composable 'Mergers' 2021-03-26 10:55:21 +00:00
Ilya Chernikov
2f49e8e0af Fix parameter index on IR script generation in REPL scenario
Before it, the wrong index lead to the validation error when repl
script definition had c-tor parameters (see test)
2021-03-26 11:41:24 +01:00
Mikhail Glukhikh
648bf99842 FIR: temporarily drop parent manipulation code around super type entries 2021-03-26 13:05:42 +03:00
Jinseong Jeon
ff4d193891 FIR checker: utilize unsubstitutedScope creation 2021-03-26 13:05:41 +03:00
Jinseong Jeon
9934cfbb00 FIR2IR: minimize scope processing in fake override generation 2021-03-26 13:05:41 +03:00
Jinseong Jeon
c830aed946 FIR2IR: minimize scope processing in data class synthetic member generation 2021-03-26 13:05:41 +03:00
Ilya Matveev
22d6433cf6 [K/N][Gradle plugin] Do not propagate user.dir property to tools
In a Gradle process, the user.dir property is set to the directory
where the build was started. By default, if we start a child process
via project.javaexec, Gradle sets its working directory to the
directory of the current project. But passing Gradle's value of user.dir
to that process overrides this setting.

This makes tools started in a such way sensitive to directory the build
is started from.

This patch fixes this issue for K/N-related tools started
out-of-process by the MPP Gradle plugin. But this issue is still
relevant to in-process tool execution.
2021-03-26 12:38:28 +03:00
Ilya Matveev
e56ac775ca [K/N][tests] Do not propagate user.dir property to compiler/cinterop
In a Gradle process, the user.dir property is set to the directory
where the build was started. By default, if we start a child process
via project.javaexec, Gradle sets its working directory to the
directory of the current project. But passing Gradle's value of user.dir
to that process overrides this setting.

This makes tools started in a such way sensitive to directory the build
is started from. Thus a test using relative paths may fail if it is
started from a wrong directory.

This patch fixes this issue for Kotlin/Native tests.
2021-03-26 12:38:27 +03:00
Victor Petukhov
9c38db754e Add compiler flag to enable strict mode for improvements in the type enhancement
^KT-45674 Fixed
2021-03-26 11:04:01 +03:00
Victor Petukhov
731e3ebae1 Rename LV ImprovementsAroundTypeEnhancement into TypeEnhancementImprovementsInStrictMode 2021-03-26 11:03:49 +03:00
nataliya.valtman
df08ed2ac0 Recompile files which import companion constant
#KT-44741 Fixed
2021-03-26 10:27:52 +03:00
Ilya Kirillov
5485c372e8 FIR IDE: stop on fist exception in project perf tests 2021-03-25 20:53:53 +01:00
Ilya Kirillov
211ddd307c FIR IDE: highlight file before completion in perf test 2021-03-25 20:53:52 +01:00
Ilya Kirillov
49a4ec7f92 FIR IDE: add perf tests for completion 2021-03-25 20:53:51 +01:00
Ilya Kirillov
a4cf21adef Add perf the same project perf tests used for FIR for fe10 plugin 2021-03-25 20:53:50 +01:00
Roman Golyshev
a22a6b4338 FIR IDE: add basic project performance test 2021-03-25 20:53:49 +01:00
Ilya Kirillov
baad0d698f FIR IDE: do not create KtFunctionalType by type-aliased functional type 2021-03-25 20:53:29 +01:00
Nikolay Krasko
ddc12834cb Add dependency verification description to ReadMe.md 2021-03-25 21:53:27 +03:00
Vladimir Dolzhenko
51393d2d0f Fix compilation 2021-03-25 16:23:01 +01:00
Ilmir Usmanov
5e6f52009f JVM IR: IC coroutines: return boxed type from suspend function if
the function overrides function, returning type argument
 #KT-45451 Fixed
2021-03-25 16:21:55 +01:00
Simon Ogorodnik
0aca68e7c7 FIR: Add init time measurement to full pipeline 2021-03-25 18:05:51 +03:00
Pavel Punegov
991e5210ba Simplify further support for simulators by using target family 2021-03-25 13:06:13 +00:00
Pavel Punegov
5acd72d5a5 Update simulators: use fresh targets 2021-03-25 13:06:13 +00:00
Pavel Punegov
39b11f6ef0 Create simulator device in case it is missing on the host 2021-03-25 13:06:12 +00:00
sebastian.sellmair
ad7c8b7a07 KotlinToolingMetadata: Disable 'kotlin.mpp.enableKotlinToolingMetadataArtifact' by default 2021-03-25 15:16:08 +03:00
sebastian.sellmair
37aedba7ef KotlinToolingMetadata: Handle incompatible schemaVersions during json parsing 2021-03-25 15:16:07 +03:00
sebastian.sellmair
0406659ac8 BuildKotlinToolingMetadataTask: Strip _Decorated classes from target name 2021-03-25 15:16:06 +03:00
sebastian.sellmair
24ce6957a9 testProject/new-mpp-published: Replace jcenter with mavenCentral 2021-03-25 15:16:05 +03:00
sebastian.sellmair
0a732869e9 KotlinToolingMetadata: Add schemaVersion property 2021-03-25 15:16:04 +03:00
sebastian.sellmair
0119541462 KotlinToolingMetadata: Use Project property accessor for task 2021-03-25 15:16:03 +03:00
sebastian.sellmair
0a59301f8a KotlinToolingMetadata: Add stronger typing for target extras 2021-03-25 15:16:01 +03:00
sebastian.sellmair
896e77cd32 KotlinToolingMetadata.json: Add konanVersion and abiVersion as extras to KotlinNativeTarget 2021-03-25 15:16:00 +03:00
sebastian.sellmair
ac8b4c1b79 Implement kotlin-tooling-metadata.json artifact
- Introduce new :kotlin-tooling-metadata project
- Create new buildKotlinToolingMetadata task by default
- Add `kotlin-tooling-metadata.json` to root mpp publications
- Add kotlin.mpp.enableKotlinToolingMetadataArtifact flag to disable kotlin-tooling-metadata.json artifact

^KT-44584 Verification Pending
2021-03-25 15:15:58 +03:00
Vladimir Dolzhenko
88058ca2c8 Fix non-default constructors for service and extension class violation 2021-03-25 12:57:07 +01:00
Svyatoslav Scherbina
7b639235a2 Update Kotlin/Native: 1.5.20-dev-3553 2021-03-25 12:43:02 +03:00
Vladimir Dolzhenko
ae4dd80254 Regenerate missed test
Relates to #KT-45339
2021-03-25 10:19:24 +01:00
Ilya Chernikov
9ac6d30953 Fix arguments processing with scripting with old backend by default 2021-03-24 22:38:59 +01:00
Ilya Chernikov
bcd7bc5fd7 Fix arguments processing with scriting with old backend by default 2021-03-24 21:26:57 +01:00
Ilya Chernikov
c3ec94ff82 FIR: copied 2 more gradle incremental IT for FIR
temporary, we need a proper test infrastructure to run all gradle IT
with FIR
2021-03-24 21:24:20 +01:00
Ilya Chernikov
2d9c0e137f Add gradle ITs witn IC and FIR 2021-03-24 21:24:20 +01:00
Ilya Chernikov
a11f6d2e50 Add support for gradle option useFir and appropriate property...
`kotlin.useFir`
2021-03-24 21:24:20 +01:00
Ilya Chernikov
3400911d97 [minor] unmute fixed FIR tests 2021-03-24 21:24:20 +01:00
Ilya Chernikov
4a79f544f7 FIR: Mute IC test due to java tracking peculiarities
should be fixed after implementing proper java tracking for FIR
2021-03-24 21:24:20 +01:00
Ilya Chernikov
7e08820009 FIR: Mute IC tests with missing FIR diagnostics 2021-03-24 21:24:20 +01:00
Ilya Chernikov
14121a1d9a FIR: Disable java tracking in FIR IC
until it is properly implemented,
fixes some IC tests for now, making it less pecise
2021-03-24 21:24:19 +01:00
Ilya Chernikov
20fdad87ec FIR: support direct use of typealias with friend-paths
also fixes one IC test
2021-03-24 21:24:19 +01:00
Ilya Chernikov
ef2bb48706 FIR: fix fir-specific incremental compilation testdata 2021-03-24 21:24:19 +01:00
Ilya Chernikov
51a1cec08b FIR: Reimplement conflicts checker to detect conflicts in different files
also pass correct ScopeSession to checkers
fixes some IC tests
2021-03-24 21:24:19 +01:00
Ilya Chernikov
3e458a1efb FIR: Add IncrementalPackagePartsProvider usage in cli...
also refactor IncrementalPackagePartsProvider and parents to simplify
usage
2021-03-24 21:24:18 +01:00
Ilya Chernikov
f8d50d585d FIR: Implement lookup tracking 2021-03-24 21:24:18 +01:00
Ilya Chernikov
7d29ae7cce FIR: add incremental compilation tests 2021-03-24 21:24:18 +01:00
Ilya Chernikov
6cc39788fd FIR: Fix main fn mangling (without proper detection)
proper main function detector has to be implemented in addition
to that
2021-03-24 21:24:18 +01:00
Ilya Chernikov
88e7ba2a3b FIR: Report syntax errors in cli compilation 2021-03-24 21:24:18 +01:00
Ilya Chernikov
ed78183dbd FIR: use more specific cone error for unresolved user type ref
replaces diagnostic with <No name> with specific qualifier
2021-03-24 21:24:18 +01:00
Ivan Kylchik
77539fe2db Add visitExpressionBody method to IrCompileTimeChecker
This method is needed to explicitly indicate that IrExpressionBody can
be interpreted in any evaluation mode.
2021-03-24 21:24:17 +01:00
Ilya Chernikov
e0297cf207 [minor] implement automatic stdlib-jdkX jars handling in KotlinPaths
fixes some local testing scenarios
2021-03-24 21:24:17 +01:00
Ilya Chernikov
76b2ca2e96 [minor] FIR: add missing error message 2021-03-24 21:24:17 +01:00
Alexander Udalov
81a8566763 Fix verification-metadata.xml after updating r8 to 2.1.96 2021-03-24 20:16:16 +01:00
Mads Ager
41f5ac393a Update D8 used for dexing tests to version 2.1.96. 2021-03-24 20:16:15 +01:00
Yahor Berdnikau
48599e3768 Bump advance Gradle version in tests to '7.0-rc-1'.
- Add missing dependency on ':kotlin-serialization' required
 by some tests.
- Add additional location for libcurl on Linux machines.
2021-03-24 21:14:48 +03:00
Ilya Kirillov
6e31ff4fb1 Introduce CallableId.asSingleFqName and use it instead CallableId.asFqNameForDebugInfo 2021-03-24 18:13:21 +01:00
Ilya Kirillov
6f887896ff FIR IDE: use CallableId for KtCallableSymbol instead of FqName 2021-03-24 18:13:04 +01:00
Ilya Kirillov
f66a155683 FIR IDE: use common spelling for analyse functions family 2021-03-24 18:12:25 +01:00
Igor Chevdar
a618791ff0 [K/N][IR] Removed unnecessary hack
The hack has been rendered redundant due to the recent fixes in psi2ir
2021-03-24 20:42:40 +05:00
Igor Chevdar
246a907753 [FE][PSI2IR] Generalized SamType
Operations regarding <fun interface> are common for all backends
2021-03-24 20:42:40 +05:00
Tianyu Geng
56bec6997c FIR checker: report SUPERTYPE_NOT_INITIALIZED
Combined this and the checker of
SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR together.

Also fixed SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR incorrectly
repoted as warning instead of error.
2021-03-24 17:48:39 +03:00
Tianyu Geng
6134c00698 FIR: track KtSuperTypeCallEntry in FirDelegatedConstructorCall
In PSI world, a call to super type constructor is represented by a
KtSuperTypeCallEntry. Currently FIR tracks the callee reference to this
constructor call.

This is undesirable because

1. We may want to report issues on the call arguments, so FIR must track
   the entire call rather than just the callee reference

2. Light tree actually reports the KtSuperTypeCallEntry.

3. Both the FirDelegatedConstructorCall and its `calleeReference` are
   currently referencing the same KtConstructorCalleeExpression PSI
   element as the source.

This change makes FirDelegatedConstructorCall track the entire
KtSuperTypeCallEntry as the source, if possible.
2021-03-24 17:48:39 +03:00
Sergey Bogolepov
5243720043 Add support for android and wasm on macos_arm64 2021-03-24 17:37:51 +03:00
Sergey Bogolepov
3a008f6236 Cleanup ClangArgs.kt a little bit 2021-03-24 17:37:50 +03:00
Sergey Bogolepov
273b43d227 Simplify setting apple os version in ClangArgs
Use `osVersionMinFlagClang` from konan.properties
instead of manual setup in ClangArgs.
This simplification will make it easier to add support
for future targets.
2021-03-24 17:37:49 +03:00
Sergey Bogolepov
51d3d1f1a8 ClangArgs: Set stdlib for apple targets in a single place 2021-03-24 17:37:48 +03:00
Sergey Bogolepov
f339e9cc66 ClangArgs: Set arch for apple targets in a single place 2021-03-24 17:37:47 +03:00
Sergey Bogolepov
30863cd184 Support the rest of Linux targets on macos_arm64 2021-03-24 17:37:45 +03:00
Sergey Bogolepov
0e1276fc6c Support the rest of Apple targets on macos_arm64 2021-03-24 17:37:44 +03:00
Sergey Bogolepov
58e0cc1c7c Specify linker for macos_arm64-linux_x64 2021-03-24 17:37:42 +03:00
Sergey Bogolepov
579c1eb7db Remove libffi from target dependencies
Technically, it is a dependency of a compiler itself.
Thus, we can simplify konan.properties a little bit
by applying the same approach as we did for LLVM.
2021-03-24 17:37:40 +03:00
Tianyu Geng
e1c80ac75c FIR checker: introduce NO_(GET|SET)_METHOD
Besides introducing new diagnostics, this commit unifies source usages
for array accesses in PSI & LT.
2021-03-24 16:25:01 +03:00
pyos
651fd4ad9f FIR: load Java annotation defaults after binding the class symbol
as they can refer to the class itself.
2021-03-24 16:09:25 +03:00
Mikhail Glukhikh
449a79151a FirNotImplementedOverrideChecker: check also anonymous objects / enums 2021-03-24 16:07:30 +03:00
Mikhail Glukhikh
82b8cc333e FIR: introduce INVISIBLE_ABSTRACT_MEMBER_FROM_SUPER 2021-03-24 16:07:28 +03:00
Mikhail Glukhikh
47d2a914bc FIR: add bad test data changes related to not implemented checker 2021-03-24 16:07:26 +03:00
Mikhail Glukhikh
9ce8420491 FIR: introduce not implemented checker 2021-03-24 16:07:25 +03:00
Mikhail Glukhikh
9ae41f5c07 FIR: store substitution for properties with implicit return type 2021-03-24 16:07:21 +03:00
Mikhail Glukhikh
4768700600 FIR error repro: property type mismatch in override from light classes 2021-03-24 16:07:20 +03:00
Mikhail Glukhikh
b6f1a442fb FIR checkers: use ScopeSession from resolve when possible 2021-03-24 16:07:19 +03:00
Mikhail Glukhikh
a26a195c35 Add FIR_IDENTICAL to some tests 2021-03-24 16:02:09 +03:00
Jinseong Jeon
c6298398ef FIR checker: rework VAL_REASSIGNMENT_VIA_BACKING_FIELD(_ERROR) 2021-03-24 16:02:08 +03:00
Victor Petukhov
4f1ed2f112 Don't generate tests on top-down completion of the builder inference for WASM 2021-03-24 15:57:48 +03:00
Victor Petukhov
178910a2e5 Proper taking top level trace to pass it into completion 2021-03-24 15:57:47 +03:00
Victor Petukhov
e0a8e9a664 Do updating calls for all nested builder inference sessions including at the same level 2021-03-24 15:57:47 +03:00
Victor Petukhov
999d1f982e Introduce hierarchy of inference sessions 2021-03-24 15:57:47 +03:00
Victor Petukhov
80ac62864d Don't lose inference session in all the possible locations 2021-03-24 15:57:47 +03:00
Victor Petukhov
b5d3f9ee31 Rename CoroutineInferenceSession to BuilderInferenceSession 2021-03-24 15:57:46 +03:00
Victor Petukhov
7a66e22bb2 Implement top-down completion for nested builder inference calls
^KT-42742 Fixed
2021-03-24 15:57:36 +03:00
Vladimir Dolzhenko
8068a5439f Fix handling non ctor elements in SECONDARY_CONSTRUCTOR_DELEGATION_CALL
#KT-45339 Fixed
2021-03-24 12:27:53 +00:00
Vladimir Dolzhenko
3d236b7171 Simplify reportOnElement
Relates to #KT-38959
2021-03-24 12:27:52 +00:00
Ilya Goncharov
b385650bf0 [Gradle, JS] Use patch only for webpack 5
^KT-45621 fixed
2021-03-24 15:17:12 +03:00
Ilya Goncharov
4107378d2c [Gradle, JS] Add workaround for debugging with webpack 5
^KT-45621 fixed
2021-03-24 15:17:11 +03:00
Ilya Goncharov
fef1892219 [Gradle, JS] Changed API for warnings filter in Webpack 5
^KT-45621 fixed
2021-03-24 15:17:10 +03:00
Ilya Goncharov
a113df8c43 [Gradle, JS] Use karma 6.0 API to set ping timeout
^KT-45621 fixed
2021-03-24 15:17:09 +03:00
Ilya Goncharov
f318951b64 [Gradle, JS] Fix packages with hardcoded display name
^KT-45621 fixed
2021-03-24 15:17:07 +03:00
Dmitriy Novozhilov
fae0aa42c4 [FIR] Update testdata broken in de03124f 2021-03-24 14:11:11 +03:00
Svyatoslav Scherbina
940774caaf Native: remove README.md from binary distributions
It is outdated, and the presumed contents are covered by other docs.
2021-03-24 10:56:35 +00:00
Ilya Muradyan
14d386223b [REPL] Fix unresolved imports caching
Before this fix, if some imports were not resolved during compilation,
this result had been saved in caches, and this import couldn't been
resolved during following compilations even if it was added to the
module dependencies. This commit adds special handling of resolution
caches for the REPL compiler.
2021-03-24 13:35:33 +03:00
Ilya Muradyan
ae5fefce51 [REPL] Fix performance problem
Configuration updating was done incorrectly,
and it led to performance degradation.
2021-03-24 13:35:33 +03:00
Dmitriy Novozhilov
e00e726bcb [FIR] Add test for KT-45584 2021-03-24 12:56:17 +03:00
Dmitriy Novozhilov
f4afc2ef44 [FIR] Map dispatch receiver type of function in JvmMappedScope 2021-03-24 12:56:16 +03:00
Dmitriy Novozhilov
b0969f626e [FIR] Rename SyntheticPropertySymbol to FirSyntheticPropertySymbol 2021-03-24 12:56:15 +03:00
Dmitriy Novozhilov
714871e4a5 [FIR2IR] Add proper toString to Fir2IrBindableSymbol 2021-03-24 12:56:15 +03:00
Dmitriy Novozhilov
7dc3be3b9b [FIR2IR] Replace star projections with upper bounds for SAM conversion types 2021-03-24 12:56:15 +03:00
Dmitriy Novozhilov
50f2666eba [IR] Properly render type arguments in error messages 2021-03-24 12:56:14 +03:00
Dmitriy Novozhilov
ee7c90791e Add workaround for KT-45553
This is needed to compile this code with FIR
2021-03-24 12:56:14 +03:00
Dmitriy Novozhilov
de03124f50 [FIR] Fix reporting EXPOSED_PROPERTY_TYPE_IN_CONSTRUCTOR warning 2021-03-24 12:56:14 +03:00
Dmitriy Novozhilov
21b1d97b30 Add predefined run configuration for FIR tree generation 2021-03-24 12:56:13 +03:00
Dmitriy Novozhilov
3b6d3e5a08 [FIR] Don't record isFromVararg attribute to all properties from constructor 2021-03-24 12:56:13 +03:00
Dmitriy Novozhilov
094287741c [FIR] Add FirSourceElement.text extension for debug purposes 2021-03-24 12:56:13 +03:00
Dmitriy Dolovov
9aa16faa27 Test integer overflow on div/rem of Int.MIN_VALUE by -1
^KT-45136
2021-03-24 09:55:52 +03:00
Dmitriy Dolovov
dfd3b54ee4 Native: Handle integer overflow on div/rem of Int.MIN_VALUE by -1
^KT-45136
2021-03-24 09:55:46 +03:00
Vyacheslav Gerasimov
7fe0df2816 Build: Drop include/* project previously used in composite build 2021-03-23 22:52:40 +03:00
Dmitry Petrov
4f250ed498 JVM_IR KT-45377 rewrite constants again after AddContinuationLowering 2021-03-23 16:05:24 +03:00
Ilya Kirillov
0f2aca3280 FIR: use session symbolProvider from symbol for getting it's file 2021-03-23 13:41:03 +01:00
Yahor Berdnikau
d46ad6c0ad Fix kapt creates output directories on configuration phase.
Gradle will create such directories itself. Also it should fix build
cache issue with kapt tasks - build cache was disabled
 due to the 'overlapping outputs'.

 ^KT-45532 Fixed
2021-03-23 15:20:35 +03:00
Ilmir Usmanov
5abc45e6ff IC IDE: Add description of intention to add @JvmInline to value class
#KTIJ-5663
2021-03-23 12:13:05 +01:00
Ilmir Usmanov
823d2d0748 IC IDE: Add intention to add @JvmInline annotation to value class on JVM
#KTIJ-5663 Fixed
2021-03-23 12:13:03 +01:00
Alexander Udalov
ea01c97a8e Write underlying property name & type for inline class to metadata
This will be used in the compiler starting from 1.5.20 instead of the
currently used approach of looking for the single value parameter of the
primary constructor. The problem with the current approach is that
primary constructor can be private (since 1.4.30) and the property could
always be private. Relying on private declarations from metadata is
dangerous; for example lazy IR doesn't usually create stubs for private
declarations, and it didn't create stubs for private inline class
constructors before b5f9b1df, which led to the problem reported in
KT-44723.
2021-03-23 11:45:22 +01:00
Mark Punzalan
5baa2e0e7c FIR IDE: Simplify the diagnosticFixFactory() API by removing
HLApplicatorWithTargetAndInput and making HLQuickFix public.
2021-03-23 11:04:33 +01:00
Mark Punzalan
062adf21de FIR IDE: Use KtFirExpressionTypeProvider.getExpectedType() in
ReplaceCallFix.
2021-03-23 11:04:33 +01:00
Mark Punzalan
e9298d1d71 FIR IDE: Allow FIR-specific "after" files for
AbstractHighLevelQuickFixTest.
2021-03-23 11:04:33 +01:00
Mark Punzalan
14ca2d207d FIR IDE: Additional support for
KtFirExpressionTypeProvider.getExpectedType():

- Infix function parameter
- Variable assignment
- Property declaration
- Function expression body
2021-03-23 11:04:33 +01:00
Mark Punzalan
164d7d80b6 FIR IDE: Enable ReplaceCallFix for UNSAFE_CALL. 2021-03-23 11:04:33 +01:00
Mark Punzalan
3ebdfa3850 FIR IDE: Implement applicatorByQuickFix() to re-use quick fix actions
from idea-frontend-independent.
2021-03-23 11:04:33 +01:00
Mark Punzalan
1b649fa4cb FIR IDE: Generate quickfix tests related to ReplaceCallFix. 2021-03-23 11:04:33 +01:00
Mark Punzalan
05deecaafa FIR IDE: Move ReplaceCallFix to idea-frontend-independent. 2021-03-23 11:04:33 +01:00
Andrei Klunnyi
482c677274 KT-44299 [Sealed Interfaces]: when exhaustiveness in IDE considers java inheritor
^KT-44299 fixed
2021-03-23 10:55:20 +01:00
hungvietnguyen
7c4225b9d1 [Kapt] Ensure flag names and default values are consistent
Group flag names and default values in one place to make the code easier
to read and prevent mistakes and inconsistencies.
2021-03-23 10:41:28 +03:00
Igor Chevdar
752be27557 [K/N][tests] Disabled failing test for now 2021-03-23 11:57:56 +05:00
Svyatoslav Scherbina
818659f2bb Native: fix bug in KType support affecting only stdlib
Don't use IrClass.declarations to find enum entries during lowerings,
because this enum might already be lowered and thus have all entries
removed.
2021-03-23 09:45:40 +03:00
Ilmir Usmanov
886e3e6655 Update tests, which check -X... flag in LauncherScriptTest
Previously, -Xallow-result-return-type was used to test, whether the
launcher parses -X... flags correctly, however, it has no effect -
returning Result is allowed anyway. So, instead, use -Xno-inline and
check runtime behavior.
2021-03-22 23:14:23 +00:00
Vyacheslav Karpukhin
499ffd610a AndroidDependencyResolver: codestyle fixes after review 2021-03-22 22:29:12 +01:00
Vyacheslav Karpukhin
ac8d135a21 AndroidDependencyResolver:
1. Correctly process project dependencies
2. Don't include variant-specific dependencies into more generic sourcesets
2021-03-22 22:29:12 +01:00
Vyacheslav Karpukhin
3ce00f6eb4 AndroidDependencyResolver: when operating without Android IDE plugin, don't duplicate dependencies for Android sourcesets 2021-03-22 22:29:12 +01:00
Alexander Udalov
b5f9b1dfc0 JVM IR: support inline classes with private constructors from other modules
#KT-44723 Fixed
2021-03-22 21:57:07 +01:00
Alexander Udalov
dac218dc39 Minor, regroup compileKotlinAgainstKotlin tests on inline classes 2021-03-22 21:57:04 +01:00
Ilmir Usmanov
3124a4ddae Minor. Update test data 2021-03-22 17:35:08 +01:00
Mads Ager
571971c5db JVM: Fix local variable ranges in state machine transform.
When a suspension point is inlined, the inlining local spans
unspilling code where the local slot has not been initialized.

The transformer already inserted initialization code for the local,
however, it did not split the local variable table. Therefore,
the inlining local is defined on instructions where the local
slot has no value (namely the instructions that initialize
the local slot on the unspilling path).

This change adds splitting of the local variable table as well.
When updating to a new version of D8, the uninitialized local
slot showed up. D8 will repair it in this case, but it is
better to not generate such code.
2021-03-22 17:35:06 +01:00
Aleksei.Cherepanov
911c24d594 Additional trust artifacts for JPS build 2021-03-22 19:08:36 +03:00
Svyatoslav Scherbina
0730833135 Remove kotlin-native/common/src/hash
It is no longer used.
2021-03-22 16:03:31 +00:00
Svyatoslav Scherbina
ce239ccc3e Native runtime: remove unused dependency on common/src/hash
No longer required after c8633d8bda.
2021-03-22 16:03:30 +00:00
Svyatoslav Scherbina
2a7ccb11e8 Native compiler: remove unused dependency on common/src/hash 2021-03-22 16:03:29 +00:00
Svyatoslav Scherbina
a471bbc185 Native compiler: remove unused hashing code
It was used to compute hashes for class names, but this is no longer
required after c6ac807034.
2021-03-22 16:03:28 +00:00
Svyatoslav Scherbina
39d748dbbb Native compiler: replace C++ CityHash64 impl by Kotlin one 2021-03-22 16:03:28 +00:00
Ilya Kirillov
32be3cc703 FIR IDE: do not require read action to collect diagnostics 2021-03-22 16:18:24 +01:00
Ilya Kirillov
58a5f4f90b FIR IDE: do not fail on building anonymous function symbol 2021-03-22 16:15:33 +01:00
Ilmir Usmanov
b838ba8c62 Check whether backend is IR instead of distinct ones 2021-03-22 15:08:59 +00:00
Ilmir Usmanov
9c97f1ce35 Allow Result return type and nullability operators on Result type
by default
2021-03-22 14:56:16 +00:00
Yahor Berdnikau
6473d2a7c8 Bump advanced Gradle version to 7.0-milestone-3.
Fixed test setup that causes test failures.

^KT-44949 In Progress
2021-03-22 17:02:27 +03:00
Ilya Kirillov
c38a793352 FIR IDE: replace custom KtSymbolVisibility with compiler common Visibility 2021-03-22 14:02:20 +01:00
Ilya Kirillov
3154234107 FIR IDE: do not run STATUS phase under lock 2021-03-22 14:02:20 +01:00
Ivan Gavrilovic
093c8bfbb6 Register KAPT incremental apt cache as local state
This is so that incremental caches are removed on
non-incremental task run.
2021-03-22 15:59:20 +03:00
Br0mm
75e4c74256 [FIR] Add FirConstValWithGetterOrDelegateChecker 2021-03-22 15:05:40 +03:00
Ilya Kirillov
93f711e2b8 FIR: extract initializing of containingClassAttr into fun 2021-03-22 12:30:59 +01:00
Ilya Kirillov
9f0af3faba FIR: fix containigClassAttr for property accessor without body in light tree builder 2021-03-22 12:30:58 +01:00
Ilya Kirillov
801d4a0c77 FIR: initialize containingClassAttr in light tree builder to match RawFirBuilder 2021-03-22 12:30:58 +01:00
Ilya Kirillov
dcf64779a9 FIR: add declaration attributes checking to rawFirBuilder/lightTree tests 2021-03-22 12:30:58 +01:00
Ilmir Usmanov
3bcc2fe476 Minor. Add IDE MPP test 2021-03-22 11:13:14 +00:00
Ilmir Usmanov
164e9034d1 IC MPP: Allow expect value classes without @JvmInline
#KT-45525 Fixed
2021-03-22 11:13:13 +00:00
Sergey Bogolepov
8ba4f060f0 Enable linuxX64 target on macOsArm64 host
Because tests for Gradle plugin assumes that linuxX64
is available on all hosts.
2021-03-22 14:02:43 +03:00
Sergey Bogolepov
7e18b69e7d Add initial support for macos_arm64 host 2021-03-22 14:02:41 +03:00
Sergey Bogolepov
4222fb9629 Remove unused filterGradleNativeSoftwareFlags method 2021-03-22 14:02:40 +03:00
Sergey Bogolepov
ec23ebd1c5 Fix workerAutoreleasePool test on macos_arm64 using __autoreleasing
Also merge `createAutorelease` and `create. There is no need in
such separation since it was originally added to prevent
optimization `result`'s lifetime.
Turned out, it was still happening on Apple Silicon,
and only addition of __autoreleasing attribute solves the problem.
2021-03-22 14:02:39 +03:00
Ilya Kirillov
4826e3278f FIR IDE: get rid of constructor value parameter symbols 2021-03-22 11:27:31 +01:00
Ilya Kirillov
7b482bf70a FIR IDE: merge symbol building tests and symbol restoring tests 2021-03-22 11:27:30 +01:00
Ilya Kirillov
1d63dccfae FIR IDE: fix symbol pointer creation for non direct member symbols 2021-03-22 11:27:29 +01:00
Ilya Kirillov
a7b0c6c821 FIR IDE: fix symbol pointer creation for KtAnonymousObjectSymbol 2021-03-22 11:27:28 +01:00
Ilya Kirillov
0bb37db4bf FIR IDE: introduce AbstractSymbolByReferencePointerRestoreTest 2021-03-22 11:27:27 +01:00
Ilya Kirillov
846dc1b9b9 FIR IDE: add more info to require calls KtSymbolByFirBuilder 2021-03-22 11:27:26 +01:00
Ilya Kirillov
ae6eeb2501 FIR IDE: introduce KtBackingFieldSymbol 2021-03-22 11:27:25 +01:00
Ilya Kirillov
443a14756f FIR IDE: change KtPropertySymbol inheritors cratePointer to return specific symbols 2021-03-22 11:27:25 +01:00
Ilya Kirillov
ceed3e7355 FIR IDE: separate KtSymbolByFirBuilder.buildVariableSymbol into functions 2021-03-22 11:27:24 +01:00
Ilya Kirillov
010f1cb634 FIR IDE: build KtJavaFieldSymbol only for Java fields 2021-03-22 11:27:22 +01:00
Ilya Kirillov
8bf339a7cf FIR IDE: refactor, extract throwing unexpected element error into function 2021-03-22 11:27:20 +01:00
Ilya Kirillov
502087a3c7 FIR IDE: extract KtType building from KtSymbolByFirBuilder 2021-03-22 11:27:19 +01:00
Ilya Kirillov
b6d334b303 FIR IDE: extract callable symbol building from KtSymbolByFirBuilder 2021-03-22 11:27:19 +01:00
Ilya Kirillov
c06bcbad39 FIR IDE: extract variable-like symbol building from KtSymbolByFirBuilder 2021-03-22 11:27:18 +01:00
Ilya Kirillov
bafc61b56f FIR IDE: extract function-like symbol building from KtSymbolByFirBuilder 2021-03-22 11:27:17 +01:00
Ilya Kirillov
db64884bd0 FIR IDE: refactor callable symbol building in KtSymbolByFirBuilder 2021-03-22 11:27:16 +01:00
Ilya Kirillov
439e54aee6 FIR IDE: extract class-like symbol building to separate class 2021-03-22 11:27:15 +01:00
Ilya Kirillov
cf30be5957 FIR IDE: make KtAnonymousObject symbol to extend KtClassObjectSymbol 2021-03-22 11:27:14 +01:00
Ilya Kirillov
08433b9ac9 FIR IDE: fix constructor symbol building for type alias constructors 2021-03-22 11:27:13 +01:00
Ilya Kirillov
4d5da26696 FIR IDE: get rid of KtFirSetterParameterSymbol 2021-03-22 11:27:12 +01:00
Ilya Kirillov
5e14aa34ec FIR IDE: add more info to CCE in symbol builder 2021-03-22 11:27:12 +01:00
scaventz
0dc5ed53f8 Provide sensible toString for getter/setter in reflection. 2021-03-22 11:21:54 +01:00
2357 changed files with 24269 additions and 12432 deletions

View File

@@ -0,0 +1,21 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Generate FIR tree" type="GradleRunConfiguration" factoryName="Gradle" folderName="Generators">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$/compiler/fir/tree" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="generateTree" />
</list>
</option>
<option name="vmOptions" value="" />
</ExternalSystemSettings>
<GradleScriptDebugEnabled>true</GradleScriptDebugEnabled>
<method v="2" />
</configuration>
</component>

View File

@@ -147,6 +147,27 @@ From this root project there are Run/Debug Configurations for running `IDEA` or
* Run the `IDEA` run configuration in the project
* A child IntelliJ IDEA with the Kotlin plugin will then startup
### Dependency verification
We have a [dependencies verification](https://docs.gradle.org/current/userguide/dependency_verification.html) feature enabled in the
repository for all Gradle builds. Gradle will check hashes (md5 and sha256) of used dependencies and will fail builds with
`Dependency verification failed` errors when local artifacts are absent or have different hashes listed in the
[verification-metadata.xml](https://github.com/JetBrains/kotlin/blob/master/gradle/verification-metadata.xml) file.
It's expected that `verification-metadata.xml` should only be updated with the commits that modify the build. There are some tips how
to perform such updates:
- Use auto-generation for getting an initial list of new hashes (verify updates relate to you changes).
`./gradlew -M sha256,md5 help`
*(any other task may be used instead of `help`)*
- Consider removing old versions from the file if you are updating dependencies.
- Leave meaningful `origin` attribute (instead of `Generated by Gradle`) if you did some manual verification of the artifact.
- Always do manual verification if several hashes are needed and a new `also-trust` tag has to be added.
- If youre adding a dependency with OS mentioning in an artifact name (`darwin`, `mac`, `osx`, `linux`, `windows`), remember to add
counterparts for other platforms.
# License
Kotlin is distributed under the terms of the Apache License (Version 2.0). See [license folder](license/README.md) for details.

View File

@@ -1,36 +1,11 @@
import kotlinx.benchmark.gradle.benchmark
val benchmarks_version = "0.2.0-dev-7"
buildscript {
val benchmarks_version = "0.2.0-dev-7"
repositories {
val cacheRedirectorEnabled = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() == true
if (cacheRedirectorEnabled) {
maven("https://cache-redirector.jetbrains.com/dl.bintray.com/kotlin/kotlinx")
} else {
maven("https://dl.bintray.com/kotlin/kotlinx")
}
}
dependencies {
classpath("org.jetbrains.kotlinx:kotlinx.benchmark.gradle:$benchmarks_version")
}
}
apply(plugin = "kotlinx.benchmark")
val benchmarks_version = "0.3.0"
plugins {
java
kotlin("jvm")
}
repositories {
val cacheRedirectorEnabled = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() == true
if (cacheRedirectorEnabled) {
maven("https://cache-redirector.jetbrains.com/dl.bintray.com/kotlin/kotlinx")
} else {
maven("https://dl.bintray.com/kotlin/kotlinx")
}
id("org.jetbrains.kotlinx.benchmark") version "0.3.0"
}
dependencies {
@@ -42,7 +17,7 @@ dependencies {
compile(jpsStandalone()) { includeJars("jps-model") }
compile(intellijPluginDep("java"))
compile(intellijDep()) { includeIntellijCoreJarDependencies(project) }
compile("org.jetbrains.kotlinx:kotlinx.benchmark.runtime-jvm:$benchmarks_version")
compile("org.jetbrains.kotlinx:kotlinx-benchmark-runtime:$benchmarks_version")
}
sourceSets {

View File

@@ -33,6 +33,7 @@ import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmProtoBufUtil
import org.jetbrains.kotlin.metadata.jvm.deserialization.ModuleMapping
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.SpecialNames.DEFAULT_NAME_FOR_COMPANION_OBJECT
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
import org.jetbrains.org.objectweb.asm.*
@@ -399,7 +400,9 @@ open class IncrementalJvmCache(
}
for (const in oldMap.keys + newMap.keys) {
changesCollector.collectMemberIfValueWasChanged(kotlinClass.scopeFqName(), const, oldMap[const], newMap[const])
//Constant can be declared via companion object or via const field declaration
changesCollector.collectMemberIfValueWasChanged(kotlinClass.scopeFqName(companion = true), const, oldMap[const], newMap[const])
changesCollector.collectMemberIfValueWasChanged(kotlinClass.scopeFqName(companion = false), const, oldMap[const], newMap[const])
}
}
@@ -599,11 +602,12 @@ sealed class ChangeInfo(val fqName: FqName) {
}
}
private fun LocalFileKotlinClass.scopeFqName() =
when (classHeader.kind) {
KotlinClassHeader.Kind.CLASS -> className.fqNameForClassNameWithoutDollars
else -> className.packageFqName
private fun LocalFileKotlinClass.scopeFqName(companion: Boolean = false) = when (classHeader.kind) {
KotlinClassHeader.Kind.CLASS -> {
className.fqNameForClassNameWithoutDollars.let { if (companion) it.child(DEFAULT_NAME_FOR_COMPANION_OBJECT) else it }
}
else -> className.packageFqName
}
fun ByteArray.md5(): Long {
val d = MessageDigest.getInstance("MD5").digest(this)!!

View File

@@ -182,6 +182,21 @@ open class ProtoCompareGenerated(
if (!checkEqualsClassSealedSubclassFqName(old, new)) return false
if (old.hasInlineClassUnderlyingPropertyName() != new.hasInlineClassUnderlyingPropertyName()) return false
if (old.hasInlineClassUnderlyingPropertyName()) {
if (!checkStringEquals(old.inlineClassUnderlyingPropertyName, new.inlineClassUnderlyingPropertyName)) return false
}
if (old.hasInlineClassUnderlyingType() != new.hasInlineClassUnderlyingType()) return false
if (old.hasInlineClassUnderlyingType()) {
if (!checkEquals(old.inlineClassUnderlyingType, new.inlineClassUnderlyingType)) return false
}
if (old.hasInlineClassUnderlyingTypeId() != new.hasInlineClassUnderlyingTypeId()) return false
if (old.hasInlineClassUnderlyingTypeId()) {
if (!checkEquals(oldTypeTable.getType(old.inlineClassUnderlyingTypeId), newTypeTable.getType(new.inlineClassUnderlyingTypeId))) return false
}
if (!checkEqualsClassVersionRequirement(old, new)) return false
if (old.hasVersionRequirementTable() != new.hasVersionRequirementTable()) return false
@@ -266,6 +281,9 @@ open class ProtoCompareGenerated(
TYPE_ALIAS_LIST,
ENUM_ENTRY_LIST,
SEALED_SUBCLASS_FQ_NAME_LIST,
INLINE_CLASS_UNDERLYING_PROPERTY_NAME,
INLINE_CLASS_UNDERLYING_TYPE,
INLINE_CLASS_UNDERLYING_TYPE_ID,
VERSION_REQUIREMENT_LIST,
VERSION_REQUIREMENT_TABLE,
JVM_EXT_CLASS_MODULE_NAME,
@@ -314,6 +332,21 @@ open class ProtoCompareGenerated(
if (!checkEqualsClassSealedSubclassFqName(old, new)) result.add(ProtoBufClassKind.SEALED_SUBCLASS_FQ_NAME_LIST)
if (old.hasInlineClassUnderlyingPropertyName() != new.hasInlineClassUnderlyingPropertyName()) result.add(ProtoBufClassKind.INLINE_CLASS_UNDERLYING_PROPERTY_NAME)
if (old.hasInlineClassUnderlyingPropertyName()) {
if (!checkStringEquals(old.inlineClassUnderlyingPropertyName, new.inlineClassUnderlyingPropertyName)) result.add(ProtoBufClassKind.INLINE_CLASS_UNDERLYING_PROPERTY_NAME)
}
if (old.hasInlineClassUnderlyingType() != new.hasInlineClassUnderlyingType()) result.add(ProtoBufClassKind.INLINE_CLASS_UNDERLYING_TYPE)
if (old.hasInlineClassUnderlyingType()) {
if (!checkEquals(old.inlineClassUnderlyingType, new.inlineClassUnderlyingType)) result.add(ProtoBufClassKind.INLINE_CLASS_UNDERLYING_TYPE)
}
if (old.hasInlineClassUnderlyingTypeId() != new.hasInlineClassUnderlyingTypeId()) result.add(ProtoBufClassKind.INLINE_CLASS_UNDERLYING_TYPE_ID)
if (old.hasInlineClassUnderlyingTypeId()) {
if (!checkEquals(oldTypeTable.getType(old.inlineClassUnderlyingTypeId), newTypeTable.getType(new.inlineClassUnderlyingTypeId))) result.add(ProtoBufClassKind.INLINE_CLASS_UNDERLYING_TYPE_ID)
}
if (!checkEqualsClassVersionRequirement(old, new)) result.add(ProtoBufClassKind.VERSION_REQUIREMENT_LIST)
if (old.hasVersionRequirementTable() != new.hasVersionRequirementTable()) result.add(ProtoBufClassKind.VERSION_REQUIREMENT_TABLE)
@@ -1728,6 +1761,18 @@ fun ProtoBuf.Class.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) ->
hashCode = 31 * hashCode + fqNameIndexes(getSealedSubclassFqName(i))
}
if (hasInlineClassUnderlyingPropertyName()) {
hashCode = 31 * hashCode + stringIndexes(inlineClassUnderlyingPropertyName)
}
if (hasInlineClassUnderlyingType()) {
hashCode = 31 * hashCode + inlineClassUnderlyingType.hashCode(stringIndexes, fqNameIndexes, typeById)
}
if (hasInlineClassUnderlyingTypeId()) {
hashCode = 31 * hashCode + typeById(inlineClassUnderlyingTypeId).hashCode(stringIndexes, fqNameIndexes, typeById)
}
for(i in 0..versionRequirementCount - 1) {
hashCode = 31 * hashCode + getVersionRequirement(i)
}

View File

@@ -290,6 +290,11 @@ class DifferenceCalculatorForClass(
isClassAffected = true
areSubclassesAffected = true
}
ProtoBufClassKind.INLINE_CLASS_UNDERLYING_PROPERTY_NAME,
ProtoBufClassKind.INLINE_CLASS_UNDERLYING_TYPE,
ProtoBufClassKind.INLINE_CLASS_UNDERLYING_TYPE_ID -> {
isClassAffected = true
}
}
}

View File

@@ -23,7 +23,8 @@ data class BuildLogFinder(
private val isGradleEnabled: Boolean = false,
private val isJsEnabled: Boolean = false,
private val isScopeExpansionEnabled: Boolean = false,
private val isKlibEnabled: Boolean = false
private val isKlibEnabled: Boolean = false,
private val isFirEnabled: Boolean = false
) {
companion object {
private const val JS_LOG = "js-build.log"
@@ -32,6 +33,8 @@ data class BuildLogFinder(
private const val GRADLE_LOG = "gradle-build.log"
private const val DATA_CONTAINER_LOG = "data-container-version-build.log"
const val JS_JPS_LOG = "js-jps-build.log"
private const val FIR_LOG = "fir-build.log"
private const val GRADLE_FIR_LOG = "gradle-fir-build.log"
private const val SIMPLE_LOG = "build.log"
fun isJpsLogFile(file: File): Boolean =
@@ -45,6 +48,8 @@ data class BuildLogFinder(
isScopeExpansionEnabled && SCOPE_EXPANDING_LOG in files -> SCOPE_EXPANDING_LOG
isKlibEnabled && KLIB_LOG in files -> KLIB_LOG
isJsEnabled && JS_LOG in files -> JS_LOG
isGradleEnabled && isFirEnabled && GRADLE_FIR_LOG in files -> GRADLE_FIR_LOG
isFirEnabled && FIR_LOG in files -> FIR_LOG
isGradleEnabled && GRADLE_LOG in files -> GRADLE_LOG
isJsEnabled && JS_JPS_LOG in files -> JS_JPS_LOG
isDataContainerBuildLogEnabled && DATA_CONTAINER_LOG in files -> DATA_CONTAINER_LOG

View File

@@ -10347,6 +10347,37 @@ public final class DebugProtoBuf {
*/
int getSealedSubclassFqName(int index);
/**
* <code>optional int32 inline_class_underlying_property_name = 17;</code>
*/
boolean hasInlineClassUnderlyingPropertyName();
/**
* <code>optional int32 inline_class_underlying_property_name = 17;</code>
*/
int getInlineClassUnderlyingPropertyName();
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
boolean hasInlineClassUnderlyingType();
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
org.jetbrains.kotlin.metadata.DebugProtoBuf.Type getInlineClassUnderlyingType();
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeOrBuilder getInlineClassUnderlyingTypeOrBuilder();
/**
* <code>optional int32 inline_class_underlying_type_id = 19;</code>
*/
boolean hasInlineClassUnderlyingTypeId();
/**
* <code>optional int32 inline_class_underlying_type_id = 19;</code>
*/
int getInlineClassUnderlyingTypeId();
/**
* <code>optional .org.jetbrains.kotlin.metadata.TypeTable type_table = 30;</code>
*/
@@ -10585,9 +10616,32 @@ public final class DebugProtoBuf {
input.popLimit(limit);
break;
}
case 136: {
bitField0_ |= 0x00000008;
inlineClassUnderlyingPropertyName_ = input.readInt32();
break;
}
case 146: {
org.jetbrains.kotlin.metadata.DebugProtoBuf.Type.Builder subBuilder = null;
if (((bitField0_ & 0x00000010) == 0x00000010)) {
subBuilder = inlineClassUnderlyingType_.toBuilder();
}
inlineClassUnderlyingType_ = input.readMessage(org.jetbrains.kotlin.metadata.DebugProtoBuf.Type.PARSER, extensionRegistry);
if (subBuilder != null) {
subBuilder.mergeFrom(inlineClassUnderlyingType_);
inlineClassUnderlyingType_ = subBuilder.buildPartial();
}
bitField0_ |= 0x00000010;
break;
}
case 152: {
bitField0_ |= 0x00000020;
inlineClassUnderlyingTypeId_ = input.readInt32();
break;
}
case 242: {
org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeTable.Builder subBuilder = null;
if (((bitField0_ & 0x00000008) == 0x00000008)) {
if (((bitField0_ & 0x00000040) == 0x00000040)) {
subBuilder = typeTable_.toBuilder();
}
typeTable_ = input.readMessage(org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeTable.PARSER, extensionRegistry);
@@ -10595,13 +10649,13 @@ public final class DebugProtoBuf {
subBuilder.mergeFrom(typeTable_);
typeTable_ = subBuilder.buildPartial();
}
bitField0_ |= 0x00000008;
bitField0_ |= 0x00000040;
break;
}
case 248: {
if (!((mutable_bitField0_ & 0x00004000) == 0x00004000)) {
if (!((mutable_bitField0_ & 0x00020000) == 0x00020000)) {
versionRequirement_ = new java.util.ArrayList<java.lang.Integer>();
mutable_bitField0_ |= 0x00004000;
mutable_bitField0_ |= 0x00020000;
}
versionRequirement_.add(input.readInt32());
break;
@@ -10609,9 +10663,9 @@ public final class DebugProtoBuf {
case 250: {
int length = input.readRawVarint32();
int limit = input.pushLimit(length);
if (!((mutable_bitField0_ & 0x00004000) == 0x00004000) && input.getBytesUntilLimit() > 0) {
if (!((mutable_bitField0_ & 0x00020000) == 0x00020000) && input.getBytesUntilLimit() > 0) {
versionRequirement_ = new java.util.ArrayList<java.lang.Integer>();
mutable_bitField0_ |= 0x00004000;
mutable_bitField0_ |= 0x00020000;
}
while (input.getBytesUntilLimit() > 0) {
versionRequirement_.add(input.readInt32());
@@ -10621,7 +10675,7 @@ public final class DebugProtoBuf {
}
case 258: {
org.jetbrains.kotlin.metadata.DebugProtoBuf.VersionRequirementTable.Builder subBuilder = null;
if (((bitField0_ & 0x00000010) == 0x00000010)) {
if (((bitField0_ & 0x00000080) == 0x00000080)) {
subBuilder = versionRequirementTable_.toBuilder();
}
versionRequirementTable_ = input.readMessage(org.jetbrains.kotlin.metadata.DebugProtoBuf.VersionRequirementTable.PARSER, extensionRegistry);
@@ -10629,7 +10683,7 @@ public final class DebugProtoBuf {
subBuilder.mergeFrom(versionRequirementTable_);
versionRequirementTable_ = subBuilder.buildPartial();
}
bitField0_ |= 0x00000010;
bitField0_ |= 0x00000080;
break;
}
}
@@ -10670,7 +10724,7 @@ public final class DebugProtoBuf {
if (((mutable_bitField0_ & 0x00001000) == 0x00001000)) {
sealedSubclassFqName_ = java.util.Collections.unmodifiableList(sealedSubclassFqName_);
}
if (((mutable_bitField0_ & 0x00004000) == 0x00004000)) {
if (((mutable_bitField0_ & 0x00020000) == 0x00020000)) {
versionRequirement_ = java.util.Collections.unmodifiableList(versionRequirement_);
}
this.unknownFields = unknownFields.build();
@@ -11225,13 +11279,64 @@ public final class DebugProtoBuf {
}
private int sealedSubclassFqNameMemoizedSerializedSize = -1;
public static final int INLINE_CLASS_UNDERLYING_PROPERTY_NAME_FIELD_NUMBER = 17;
private int inlineClassUnderlyingPropertyName_;
/**
* <code>optional int32 inline_class_underlying_property_name = 17;</code>
*/
public boolean hasInlineClassUnderlyingPropertyName() {
return ((bitField0_ & 0x00000008) == 0x00000008);
}
/**
* <code>optional int32 inline_class_underlying_property_name = 17;</code>
*/
public int getInlineClassUnderlyingPropertyName() {
return inlineClassUnderlyingPropertyName_;
}
public static final int INLINE_CLASS_UNDERLYING_TYPE_FIELD_NUMBER = 18;
private org.jetbrains.kotlin.metadata.DebugProtoBuf.Type inlineClassUnderlyingType_;
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
public boolean hasInlineClassUnderlyingType() {
return ((bitField0_ & 0x00000010) == 0x00000010);
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
public org.jetbrains.kotlin.metadata.DebugProtoBuf.Type getInlineClassUnderlyingType() {
return inlineClassUnderlyingType_;
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
public org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeOrBuilder getInlineClassUnderlyingTypeOrBuilder() {
return inlineClassUnderlyingType_;
}
public static final int INLINE_CLASS_UNDERLYING_TYPE_ID_FIELD_NUMBER = 19;
private int inlineClassUnderlyingTypeId_;
/**
* <code>optional int32 inline_class_underlying_type_id = 19;</code>
*/
public boolean hasInlineClassUnderlyingTypeId() {
return ((bitField0_ & 0x00000020) == 0x00000020);
}
/**
* <code>optional int32 inline_class_underlying_type_id = 19;</code>
*/
public int getInlineClassUnderlyingTypeId() {
return inlineClassUnderlyingTypeId_;
}
public static final int TYPE_TABLE_FIELD_NUMBER = 30;
private org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeTable typeTable_;
/**
* <code>optional .org.jetbrains.kotlin.metadata.TypeTable type_table = 30;</code>
*/
public boolean hasTypeTable() {
return ((bitField0_ & 0x00000008) == 0x00000008);
return ((bitField0_ & 0x00000040) == 0x00000040);
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.TypeTable type_table = 30;</code>
@@ -11286,7 +11391,7 @@ public final class DebugProtoBuf {
* <code>optional .org.jetbrains.kotlin.metadata.VersionRequirementTable version_requirement_table = 32;</code>
*/
public boolean hasVersionRequirementTable() {
return ((bitField0_ & 0x00000010) == 0x00000010);
return ((bitField0_ & 0x00000080) == 0x00000080);
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.VersionRequirementTable version_requirement_table = 32;</code>
@@ -11315,6 +11420,9 @@ public final class DebugProtoBuf {
typeAlias_ = java.util.Collections.emptyList();
enumEntry_ = java.util.Collections.emptyList();
sealedSubclassFqName_ = java.util.Collections.emptyList();
inlineClassUnderlyingPropertyName_ = 0;
inlineClassUnderlyingType_ = org.jetbrains.kotlin.metadata.DebugProtoBuf.Type.getDefaultInstance();
inlineClassUnderlyingTypeId_ = 0;
typeTable_ = org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeTable.getDefaultInstance();
versionRequirement_ = java.util.Collections.emptyList();
versionRequirementTable_ = org.jetbrains.kotlin.metadata.DebugProtoBuf.VersionRequirementTable.getDefaultInstance();
@@ -11371,6 +11479,12 @@ public final class DebugProtoBuf {
return false;
}
}
if (hasInlineClassUnderlyingType()) {
if (!getInlineClassUnderlyingType().isInitialized()) {
memoizedIsInitialized = 0;
return false;
}
}
if (hasTypeTable()) {
if (!getTypeTable().isInitialized()) {
memoizedIsInitialized = 0;
@@ -11443,12 +11557,21 @@ public final class DebugProtoBuf {
output.writeInt32NoTag(sealedSubclassFqName_.get(i));
}
if (((bitField0_ & 0x00000008) == 0x00000008)) {
output.writeInt32(17, inlineClassUnderlyingPropertyName_);
}
if (((bitField0_ & 0x00000010) == 0x00000010)) {
output.writeMessage(18, inlineClassUnderlyingType_);
}
if (((bitField0_ & 0x00000020) == 0x00000020)) {
output.writeInt32(19, inlineClassUnderlyingTypeId_);
}
if (((bitField0_ & 0x00000040) == 0x00000040)) {
output.writeMessage(30, typeTable_);
}
for (int i = 0; i < versionRequirement_.size(); i++) {
output.writeInt32(31, versionRequirement_.get(i));
}
if (((bitField0_ & 0x00000010) == 0x00000010)) {
if (((bitField0_ & 0x00000080) == 0x00000080)) {
output.writeMessage(32, versionRequirementTable_);
}
extensionWriter.writeUntil(19000, output);
@@ -11544,6 +11667,18 @@ public final class DebugProtoBuf {
sealedSubclassFqNameMemoizedSerializedSize = dataSize;
}
if (((bitField0_ & 0x00000008) == 0x00000008)) {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeInt32Size(17, inlineClassUnderlyingPropertyName_);
}
if (((bitField0_ & 0x00000010) == 0x00000010)) {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeMessageSize(18, inlineClassUnderlyingType_);
}
if (((bitField0_ & 0x00000020) == 0x00000020)) {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeInt32Size(19, inlineClassUnderlyingTypeId_);
}
if (((bitField0_ & 0x00000040) == 0x00000040)) {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeMessageSize(30, typeTable_);
}
@@ -11556,7 +11691,7 @@ public final class DebugProtoBuf {
size += dataSize;
size += 2 * getVersionRequirementList().size();
}
if (((bitField0_ & 0x00000010) == 0x00000010)) {
if (((bitField0_ & 0x00000080) == 0x00000080)) {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeMessageSize(32, versionRequirementTable_);
}
@@ -11678,6 +11813,7 @@ public final class DebugProtoBuf {
getPropertyFieldBuilder();
getTypeAliasFieldBuilder();
getEnumEntryFieldBuilder();
getInlineClassUnderlyingTypeFieldBuilder();
getTypeTableFieldBuilder();
getVersionRequirementTableFieldBuilder();
}
@@ -11742,20 +11878,30 @@ public final class DebugProtoBuf {
}
sealedSubclassFqName_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00001000);
inlineClassUnderlyingPropertyName_ = 0;
bitField0_ = (bitField0_ & ~0x00002000);
if (inlineClassUnderlyingTypeBuilder_ == null) {
inlineClassUnderlyingType_ = org.jetbrains.kotlin.metadata.DebugProtoBuf.Type.getDefaultInstance();
} else {
inlineClassUnderlyingTypeBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00004000);
inlineClassUnderlyingTypeId_ = 0;
bitField0_ = (bitField0_ & ~0x00008000);
if (typeTableBuilder_ == null) {
typeTable_ = org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeTable.getDefaultInstance();
} else {
typeTableBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00002000);
bitField0_ = (bitField0_ & ~0x00010000);
versionRequirement_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00004000);
bitField0_ = (bitField0_ & ~0x00020000);
if (versionRequirementTableBuilder_ == null) {
versionRequirementTable_ = org.jetbrains.kotlin.metadata.DebugProtoBuf.VersionRequirementTable.getDefaultInstance();
} else {
versionRequirementTableBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00008000);
bitField0_ = (bitField0_ & ~0x00040000);
return this;
}
@@ -11877,18 +12023,34 @@ public final class DebugProtoBuf {
if (((from_bitField0_ & 0x00002000) == 0x00002000)) {
to_bitField0_ |= 0x00000008;
}
result.inlineClassUnderlyingPropertyName_ = inlineClassUnderlyingPropertyName_;
if (((from_bitField0_ & 0x00004000) == 0x00004000)) {
to_bitField0_ |= 0x00000010;
}
if (inlineClassUnderlyingTypeBuilder_ == null) {
result.inlineClassUnderlyingType_ = inlineClassUnderlyingType_;
} else {
result.inlineClassUnderlyingType_ = inlineClassUnderlyingTypeBuilder_.build();
}
if (((from_bitField0_ & 0x00008000) == 0x00008000)) {
to_bitField0_ |= 0x00000020;
}
result.inlineClassUnderlyingTypeId_ = inlineClassUnderlyingTypeId_;
if (((from_bitField0_ & 0x00010000) == 0x00010000)) {
to_bitField0_ |= 0x00000040;
}
if (typeTableBuilder_ == null) {
result.typeTable_ = typeTable_;
} else {
result.typeTable_ = typeTableBuilder_.build();
}
if (((bitField0_ & 0x00004000) == 0x00004000)) {
if (((bitField0_ & 0x00020000) == 0x00020000)) {
versionRequirement_ = java.util.Collections.unmodifiableList(versionRequirement_);
bitField0_ = (bitField0_ & ~0x00004000);
bitField0_ = (bitField0_ & ~0x00020000);
}
result.versionRequirement_ = versionRequirement_;
if (((from_bitField0_ & 0x00008000) == 0x00008000)) {
to_bitField0_ |= 0x00000010;
if (((from_bitField0_ & 0x00040000) == 0x00040000)) {
to_bitField0_ |= 0x00000080;
}
if (versionRequirementTableBuilder_ == null) {
result.versionRequirementTable_ = versionRequirementTable_;
@@ -12132,13 +12294,22 @@ public final class DebugProtoBuf {
}
onChanged();
}
if (other.hasInlineClassUnderlyingPropertyName()) {
setInlineClassUnderlyingPropertyName(other.getInlineClassUnderlyingPropertyName());
}
if (other.hasInlineClassUnderlyingType()) {
mergeInlineClassUnderlyingType(other.getInlineClassUnderlyingType());
}
if (other.hasInlineClassUnderlyingTypeId()) {
setInlineClassUnderlyingTypeId(other.getInlineClassUnderlyingTypeId());
}
if (other.hasTypeTable()) {
mergeTypeTable(other.getTypeTable());
}
if (!other.versionRequirement_.isEmpty()) {
if (versionRequirement_.isEmpty()) {
versionRequirement_ = other.versionRequirement_;
bitField0_ = (bitField0_ & ~0x00004000);
bitField0_ = (bitField0_ & ~0x00020000);
} else {
ensureVersionRequirementIsMutable();
versionRequirement_.addAll(other.versionRequirement_);
@@ -12200,6 +12371,12 @@ public final class DebugProtoBuf {
return false;
}
}
if (hasInlineClassUnderlyingType()) {
if (!getInlineClassUnderlyingType().isInitialized()) {
return false;
}
}
if (hasTypeTable()) {
if (!getTypeTable().isInitialized()) {
@@ -14258,6 +14435,186 @@ public final class DebugProtoBuf {
return this;
}
private int inlineClassUnderlyingPropertyName_ ;
/**
* <code>optional int32 inline_class_underlying_property_name = 17;</code>
*/
public boolean hasInlineClassUnderlyingPropertyName() {
return ((bitField0_ & 0x00002000) == 0x00002000);
}
/**
* <code>optional int32 inline_class_underlying_property_name = 17;</code>
*/
public int getInlineClassUnderlyingPropertyName() {
return inlineClassUnderlyingPropertyName_;
}
/**
* <code>optional int32 inline_class_underlying_property_name = 17;</code>
*/
public Builder setInlineClassUnderlyingPropertyName(int value) {
bitField0_ |= 0x00002000;
inlineClassUnderlyingPropertyName_ = value;
onChanged();
return this;
}
/**
* <code>optional int32 inline_class_underlying_property_name = 17;</code>
*/
public Builder clearInlineClassUnderlyingPropertyName() {
bitField0_ = (bitField0_ & ~0x00002000);
inlineClassUnderlyingPropertyName_ = 0;
onChanged();
return this;
}
private org.jetbrains.kotlin.metadata.DebugProtoBuf.Type inlineClassUnderlyingType_ = org.jetbrains.kotlin.metadata.DebugProtoBuf.Type.getDefaultInstance();
private org.jetbrains.kotlin.protobuf.SingleFieldBuilder<
org.jetbrains.kotlin.metadata.DebugProtoBuf.Type, org.jetbrains.kotlin.metadata.DebugProtoBuf.Type.Builder, org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeOrBuilder> inlineClassUnderlyingTypeBuilder_;
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
public boolean hasInlineClassUnderlyingType() {
return ((bitField0_ & 0x00004000) == 0x00004000);
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
public org.jetbrains.kotlin.metadata.DebugProtoBuf.Type getInlineClassUnderlyingType() {
if (inlineClassUnderlyingTypeBuilder_ == null) {
return inlineClassUnderlyingType_;
} else {
return inlineClassUnderlyingTypeBuilder_.getMessage();
}
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
public Builder setInlineClassUnderlyingType(org.jetbrains.kotlin.metadata.DebugProtoBuf.Type value) {
if (inlineClassUnderlyingTypeBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
inlineClassUnderlyingType_ = value;
onChanged();
} else {
inlineClassUnderlyingTypeBuilder_.setMessage(value);
}
bitField0_ |= 0x00004000;
return this;
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
public Builder setInlineClassUnderlyingType(
org.jetbrains.kotlin.metadata.DebugProtoBuf.Type.Builder builderForValue) {
if (inlineClassUnderlyingTypeBuilder_ == null) {
inlineClassUnderlyingType_ = builderForValue.build();
onChanged();
} else {
inlineClassUnderlyingTypeBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00004000;
return this;
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
public Builder mergeInlineClassUnderlyingType(org.jetbrains.kotlin.metadata.DebugProtoBuf.Type value) {
if (inlineClassUnderlyingTypeBuilder_ == null) {
if (((bitField0_ & 0x00004000) == 0x00004000) &&
inlineClassUnderlyingType_ != org.jetbrains.kotlin.metadata.DebugProtoBuf.Type.getDefaultInstance()) {
inlineClassUnderlyingType_ =
org.jetbrains.kotlin.metadata.DebugProtoBuf.Type.newBuilder(inlineClassUnderlyingType_).mergeFrom(value).buildPartial();
} else {
inlineClassUnderlyingType_ = value;
}
onChanged();
} else {
inlineClassUnderlyingTypeBuilder_.mergeFrom(value);
}
bitField0_ |= 0x00004000;
return this;
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
public Builder clearInlineClassUnderlyingType() {
if (inlineClassUnderlyingTypeBuilder_ == null) {
inlineClassUnderlyingType_ = org.jetbrains.kotlin.metadata.DebugProtoBuf.Type.getDefaultInstance();
onChanged();
} else {
inlineClassUnderlyingTypeBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00004000);
return this;
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
public org.jetbrains.kotlin.metadata.DebugProtoBuf.Type.Builder getInlineClassUnderlyingTypeBuilder() {
bitField0_ |= 0x00004000;
onChanged();
return getInlineClassUnderlyingTypeFieldBuilder().getBuilder();
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
public org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeOrBuilder getInlineClassUnderlyingTypeOrBuilder() {
if (inlineClassUnderlyingTypeBuilder_ != null) {
return inlineClassUnderlyingTypeBuilder_.getMessageOrBuilder();
} else {
return inlineClassUnderlyingType_;
}
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
private org.jetbrains.kotlin.protobuf.SingleFieldBuilder<
org.jetbrains.kotlin.metadata.DebugProtoBuf.Type, org.jetbrains.kotlin.metadata.DebugProtoBuf.Type.Builder, org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeOrBuilder>
getInlineClassUnderlyingTypeFieldBuilder() {
if (inlineClassUnderlyingTypeBuilder_ == null) {
inlineClassUnderlyingTypeBuilder_ = new org.jetbrains.kotlin.protobuf.SingleFieldBuilder<
org.jetbrains.kotlin.metadata.DebugProtoBuf.Type, org.jetbrains.kotlin.metadata.DebugProtoBuf.Type.Builder, org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeOrBuilder>(
getInlineClassUnderlyingType(),
getParentForChildren(),
isClean());
inlineClassUnderlyingType_ = null;
}
return inlineClassUnderlyingTypeBuilder_;
}
private int inlineClassUnderlyingTypeId_ ;
/**
* <code>optional int32 inline_class_underlying_type_id = 19;</code>
*/
public boolean hasInlineClassUnderlyingTypeId() {
return ((bitField0_ & 0x00008000) == 0x00008000);
}
/**
* <code>optional int32 inline_class_underlying_type_id = 19;</code>
*/
public int getInlineClassUnderlyingTypeId() {
return inlineClassUnderlyingTypeId_;
}
/**
* <code>optional int32 inline_class_underlying_type_id = 19;</code>
*/
public Builder setInlineClassUnderlyingTypeId(int value) {
bitField0_ |= 0x00008000;
inlineClassUnderlyingTypeId_ = value;
onChanged();
return this;
}
/**
* <code>optional int32 inline_class_underlying_type_id = 19;</code>
*/
public Builder clearInlineClassUnderlyingTypeId() {
bitField0_ = (bitField0_ & ~0x00008000);
inlineClassUnderlyingTypeId_ = 0;
onChanged();
return this;
}
private org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeTable typeTable_ = org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeTable.getDefaultInstance();
private org.jetbrains.kotlin.protobuf.SingleFieldBuilder<
org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeTable, org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeTable.Builder, org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeTableOrBuilder> typeTableBuilder_;
@@ -14265,7 +14622,7 @@ public final class DebugProtoBuf {
* <code>optional .org.jetbrains.kotlin.metadata.TypeTable type_table = 30;</code>
*/
public boolean hasTypeTable() {
return ((bitField0_ & 0x00002000) == 0x00002000);
return ((bitField0_ & 0x00010000) == 0x00010000);
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.TypeTable type_table = 30;</code>
@@ -14290,7 +14647,7 @@ public final class DebugProtoBuf {
} else {
typeTableBuilder_.setMessage(value);
}
bitField0_ |= 0x00002000;
bitField0_ |= 0x00010000;
return this;
}
/**
@@ -14304,7 +14661,7 @@ public final class DebugProtoBuf {
} else {
typeTableBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00002000;
bitField0_ |= 0x00010000;
return this;
}
/**
@@ -14312,7 +14669,7 @@ public final class DebugProtoBuf {
*/
public Builder mergeTypeTable(org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeTable value) {
if (typeTableBuilder_ == null) {
if (((bitField0_ & 0x00002000) == 0x00002000) &&
if (((bitField0_ & 0x00010000) == 0x00010000) &&
typeTable_ != org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeTable.getDefaultInstance()) {
typeTable_ =
org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeTable.newBuilder(typeTable_).mergeFrom(value).buildPartial();
@@ -14323,7 +14680,7 @@ public final class DebugProtoBuf {
} else {
typeTableBuilder_.mergeFrom(value);
}
bitField0_ |= 0x00002000;
bitField0_ |= 0x00010000;
return this;
}
/**
@@ -14336,14 +14693,14 @@ public final class DebugProtoBuf {
} else {
typeTableBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00002000);
bitField0_ = (bitField0_ & ~0x00010000);
return this;
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.TypeTable type_table = 30;</code>
*/
public org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeTable.Builder getTypeTableBuilder() {
bitField0_ |= 0x00002000;
bitField0_ |= 0x00010000;
onChanged();
return getTypeTableFieldBuilder().getBuilder();
}
@@ -14376,9 +14733,9 @@ public final class DebugProtoBuf {
private java.util.List<java.lang.Integer> versionRequirement_ = java.util.Collections.emptyList();
private void ensureVersionRequirementIsMutable() {
if (!((bitField0_ & 0x00004000) == 0x00004000)) {
if (!((bitField0_ & 0x00020000) == 0x00020000)) {
versionRequirement_ = new java.util.ArrayList<java.lang.Integer>(versionRequirement_);
bitField0_ |= 0x00004000;
bitField0_ |= 0x00020000;
}
}
/**
@@ -14463,7 +14820,7 @@ public final class DebugProtoBuf {
*/
public Builder clearVersionRequirement() {
versionRequirement_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00004000);
bitField0_ = (bitField0_ & ~0x00020000);
onChanged();
return this;
}
@@ -14475,7 +14832,7 @@ public final class DebugProtoBuf {
* <code>optional .org.jetbrains.kotlin.metadata.VersionRequirementTable version_requirement_table = 32;</code>
*/
public boolean hasVersionRequirementTable() {
return ((bitField0_ & 0x00008000) == 0x00008000);
return ((bitField0_ & 0x00040000) == 0x00040000);
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.VersionRequirementTable version_requirement_table = 32;</code>
@@ -14500,7 +14857,7 @@ public final class DebugProtoBuf {
} else {
versionRequirementTableBuilder_.setMessage(value);
}
bitField0_ |= 0x00008000;
bitField0_ |= 0x00040000;
return this;
}
/**
@@ -14514,7 +14871,7 @@ public final class DebugProtoBuf {
} else {
versionRequirementTableBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00008000;
bitField0_ |= 0x00040000;
return this;
}
/**
@@ -14522,7 +14879,7 @@ public final class DebugProtoBuf {
*/
public Builder mergeVersionRequirementTable(org.jetbrains.kotlin.metadata.DebugProtoBuf.VersionRequirementTable value) {
if (versionRequirementTableBuilder_ == null) {
if (((bitField0_ & 0x00008000) == 0x00008000) &&
if (((bitField0_ & 0x00040000) == 0x00040000) &&
versionRequirementTable_ != org.jetbrains.kotlin.metadata.DebugProtoBuf.VersionRequirementTable.getDefaultInstance()) {
versionRequirementTable_ =
org.jetbrains.kotlin.metadata.DebugProtoBuf.VersionRequirementTable.newBuilder(versionRequirementTable_).mergeFrom(value).buildPartial();
@@ -14533,7 +14890,7 @@ public final class DebugProtoBuf {
} else {
versionRequirementTableBuilder_.mergeFrom(value);
}
bitField0_ |= 0x00008000;
bitField0_ |= 0x00040000;
return this;
}
/**
@@ -14546,14 +14903,14 @@ public final class DebugProtoBuf {
} else {
versionRequirementTableBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00008000);
bitField0_ = (bitField0_ & ~0x00040000);
return this;
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.VersionRequirementTable version_requirement_table = 32;</code>
*/
public org.jetbrains.kotlin.metadata.DebugProtoBuf.VersionRequirementTable.Builder getVersionRequirementTableBuilder() {
bitField0_ |= 0x00008000;
bitField0_ |= 0x00040000;
onChanged();
return getVersionRequirementTableFieldBuilder().getBuilder();
}
@@ -34382,7 +34739,7 @@ public final class DebugProtoBuf {
"Variance:\003INV\0228\n\013upper_bound\030\005 \003(\0132#.org" +
".jetbrains.kotlin.metadata.Type\022\036\n\016upper" +
"_bound_id\030\006 \003(\005B\006\020\001\240\265\030\001\"$\n\010Variance\022\006\n\002I" +
"N\020\000\022\007\n\003OUT\020\001\022\007\n\003INV\020\002*\005\010d\020\350\007\"\250\007\n\005Class\022\020" +
"N\020\000\022\007\n\003OUT\020\001\022\007\n\003INV\020\002*\005\010d\020\350\007\"\327\010\n\005Class\022\020" +
"\n\005flags\030\001 \001(\005:\0016\022\025\n\007fq_name\030\003 \002(\005B\004\220\265\030\001\022",
"#\n\025companion_object_name\030\004 \001(\005B\004\210\265\030\001\022D\n\016" +
"type_parameter\030\005 \003(\0132,.org.jetbrains.kot" +
@@ -34398,122 +34755,127 @@ public final class DebugProtoBuf {
"brains.kotlin.metadata.TypeAlias\022<\n\nenum" +
"_entry\030\r \003(\0132(.org.jetbrains.kotlin.meta" +
"data.EnumEntry\022\'\n\027sealed_subclass_fq_nam" +
"e\030\020 \003(\005B\006\020\001\220\265\030\001\022<\n\ntype_table\030\036 \001(\0132(.or" +
"g.jetbrains.kotlin.metadata.TypeTable\022\033\n" +
"\023version_requirement\030\037 \003(\005\022Y\n\031version_re" +
"quirement_table\030 \001(\01326.org.jetbrains.ko" +
"tlin.metadata.VersionRequirementTable\"x\n" +
"\004Kind\022\t\n\005CLASS\020\000\022\r\n\tINTERFACE\020\001\022\016\n\nENUM_",
"CLASS\020\002\022\016\n\nENUM_ENTRY\020\003\022\024\n\020ANNOTATION_CL" +
"ASS\020\004\022\n\n\006OBJECT\020\005\022\024\n\020COMPANION_OBJECT\020\006*" +
"\006\010d\020\270\224\001\"\335\002\n\007Package\0229\n\010function\030\003 \003(\0132\'." +
"org.jetbrains.kotlin.metadata.Function\0229" +
"\n\010property\030\004 \003(\0132\'.org.jetbrains.kotlin." +
"metadata.Property\022<\n\ntype_alias\030\005 \003(\0132(." +
"org.jetbrains.kotlin.metadata.TypeAlias\022" +
"<\n\ntype_table\030\036 \001(\0132(.org.jetbrains.kotl" +
"in.metadata.TypeTable\022Y\n\031version_require" +
"ment_table\030 \001(\01326.org.jetbrains.kotlin.",
"metadata.VersionRequirementTable*\005\010d\020\310\001\"" +
"`\n\tTypeTable\0221\n\004type\030\001 \003(\0132#.org.jetbrai" +
"ns.kotlin.metadata.Type\022\032\n\016first_nullabl" +
"e\030\002 \001(\005:\002-1:\004\240\273\030\001\"\214\001\n\013Constructor\022\020\n\005fla" +
"gs\030\001 \001(\005:\0016\022F\n\017value_parameter\030\002 \003(\0132-.o" +
"rg.jetbrains.kotlin.metadata.ValueParame" +
"ter\022\033\n\023version_requirement\030\037 \003(\005*\006\010d\020\270\224\001" +
"\"\246\004\n\010Function\022\020\n\005flags\030\t \001(\005:\0016\022\024\n\told_f" +
"lags\030\001 \001(\005:\0016\022\022\n\004name\030\002 \002(\005B\004\210\265\030\001\0228\n\013ret" +
"urn_type\030\003 \001(\0132#.org.jetbrains.kotlin.me",
"tadata.Type\022\034\n\016return_type_id\030\007 \001(\005B\004\240\265\030" +
"\001\022D\n\016type_parameter\030\004 \003(\0132,.org.jetbrain" +
"s.kotlin.metadata.TypeParameter\022:\n\rrecei" +
"ver_type\030\005 \001(\0132#.org.jetbrains.kotlin.me" +
"tadata.Type\022\036\n\020receiver_type_id\030\010 \001(\005B\004\240" +
"\265\030\001\022F\n\017value_parameter\030\006 \003(\0132-.org.jetbr" +
"ains.kotlin.metadata.ValueParameter\022<\n\nt" +
"ype_table\030\036 \001(\0132(.org.jetbrains.kotlin.m" +
"etadata.TypeTable\022\033\n\023version_requirement" +
"\030\037 \003(\005\0229\n\010contract\030 \001(\0132\'.org.jetbrains",
".kotlin.metadata.Contract*\006\010d\020\270\224\001\"\345\003\n\010Pr" +
"operty\022\022\n\005flags\030\013 \001(\005:\003518\022\027\n\told_flags\030" +
"\001 \001(\005:\0042054\022\022\n\004name\030\002 \002(\005B\004\210\265\030\001\0228\n\013retur" +
"n_type\030\003 \001(\0132#.org.jetbrains.kotlin.meta" +
"data.Type\022\034\n\016return_type_id\030\t \001(\005B\004\240\265\030\001\022" +
"D\n\016type_parameter\030\004 \003(\0132,.org.jetbrains." +
"kotlin.metadata.TypeParameter\022:\n\rreceive" +
"r_type\030\005 \001(\0132#.org.jetbrains.kotlin.meta" +
"data.Type\022\036\n\020receiver_type_id\030\n \001(\005B\004\240\265\030" +
"\001\022M\n\026setter_value_parameter\030\006 \001(\0132-.org.",
"jetbrains.kotlin.metadata.ValueParameter" +
"\022\024\n\014getter_flags\030\007 \001(\005\022\024\n\014setter_flags\030\010" +
" \001(\005\022\033\n\023version_requirement\030\037 \003(\005*\006\010d\020\270\224" +
"\001\"\357\001\n\016ValueParameter\022\020\n\005flags\030\001 \001(\005:\0010\022\022" +
"\n\004name\030\002 \002(\005B\004\210\265\030\001\0221\n\004type\030\003 \001(\0132#.org.j" +
"etbrains.kotlin.metadata.Type\022\025\n\007type_id" +
"\030\005 \001(\005B\004\240\265\030\001\022@\n\023vararg_element_type\030\004 \001(" +
"\0132#.org.jetbrains.kotlin.metadata.Type\022$" +
"\n\026vararg_element_type_id\030\006 \001(\005B\004\240\265\030\001*\005\010d" +
"\020\310\001\"\226\003\n\tTypeAlias\022\020\n\005flags\030\001 \001(\005:\0016\022\022\n\004n",
"ame\030\002 \002(\005B\004\210\265\030\001\022D\n\016type_parameter\030\003 \003(\0132" +
",.org.jetbrains.kotlin.metadata.TypePara" +
"meter\022<\n\017underlying_type\030\004 \001(\0132#.org.jet" +
"brains.kotlin.metadata.Type\022 \n\022underlyin" +
"g_type_id\030\005 \001(\005B\004\240\265\030\001\022:\n\rexpanded_type\030\006" +
" \001(\0132#.org.jetbrains.kotlin.metadata.Typ" +
"e\022\036\n\020expanded_type_id\030\007 \001(\005B\004\240\265\030\001\022=\n\nann" +
"otation\030\010 \003(\0132).org.jetbrains.kotlin.met" +
"adata.Annotation\022\033\n\023version_requirement\030" +
"\037 \003(\005*\005\010d\020\310\001\"&\n\tEnumEntry\022\022\n\004name\030\001 \001(\005B",
"\004\210\265\030\001*\005\010d\020\310\001\"\225\003\n\022VersionRequirement\022\017\n\007v" +
"ersion\030\001 \001(\005\022\024\n\014version_full\030\002 \001(\005\022M\n\005le" +
"vel\030\003 \001(\01627.org.jetbrains.kotlin.metadat" +
"a.VersionRequirement.Level:\005ERROR\022\022\n\nerr" +
"or_code\030\004 \001(\005\022\025\n\007message\030\005 \001(\005B\004\230\265\030\001\022e\n\014" +
"version_kind\030\006 \001(\0162=.org.jetbrains.kotli" +
"n.metadata.VersionRequirement.VersionKin" +
"d:\020LANGUAGE_VERSION\"+\n\005Level\022\013\n\007WARNING\020" +
"\000\022\t\n\005ERROR\020\001\022\n\n\006HIDDEN\020\002\"J\n\013VersionKind\022" +
"\024\n\020LANGUAGE_VERSION\020\000\022\024\n\020COMPILER_VERSIO",
"N\020\001\022\017\n\013API_VERSION\020\002\"a\n\027VersionRequireme" +
"ntTable\022F\n\013requirement\030\001 \003(\01321.org.jetbr" +
"ains.kotlin.metadata.VersionRequirement\"" +
"\217\002\n\017PackageFragment\022;\n\007strings\030\001 \001(\0132*.o" +
"rg.jetbrains.kotlin.metadata.StringTable" +
"\022J\n\017qualified_names\030\002 \001(\01321.org.jetbrain" +
"s.kotlin.metadata.QualifiedNameTable\0227\n\007" +
"package\030\003 \001(\0132&.org.jetbrains.kotlin.met" +
"adata.Package\0223\n\005class\030\004 \003(\0132$.org.jetbr" +
"ains.kotlin.metadata.Class*\005\010d\020\310\001\"A\n\010Con",
"tract\0225\n\006effect\030\001 \003(\0132%.org.jetbrains.ko" +
"tlin.metadata.Effect\"\306\003\n\006Effect\022E\n\013effec" +
"t_type\030\001 \001(\01620.org.jetbrains.kotlin.meta" +
"data.Effect.EffectType\022N\n\033effect_constru" +
"ctor_argument\030\002 \003(\0132).org.jetbrains.kotl" +
"in.metadata.Expression\022S\n conclusion_of_" +
"conditional_effect\030\003 \001(\0132).org.jetbrains" +
".kotlin.metadata.Expression\022B\n\004kind\030\004 \001(" +
"\01624.org.jetbrains.kotlin.metadata.Effect" +
".InvocationKind\"C\n\nEffectType\022\024\n\020RETURNS",
"_CONSTANT\020\000\022\t\n\005CALLS\020\001\022\024\n\020RETURNS_NOT_NU" +
"LL\020\002\"G\n\016InvocationKind\022\020\n\014AT_MOST_ONCE\020\000" +
"\022\020\n\014EXACTLY_ONCE\020\001\022\021\n\rAT_LEAST_ONCE\020\002\"\245\003" +
"\n\nExpression\022\020\n\005flags\030\001 \001(\005:\0010\022!\n\031value_" +
"parameter_reference\030\002 \001(\005\022O\n\016constant_va" +
"lue\030\003 \001(\01627.org.jetbrains.kotlin.metadat" +
"a.Expression.ConstantValue\022=\n\020is_instanc" +
"e_type\030\004 \001(\0132#.org.jetbrains.kotlin.meta" +
"data.Type\022!\n\023is_instance_type_id\030\005 \001(\005B\004" +
"\240\265\030\001\022?\n\014and_argument\030\006 \003(\0132).org.jetbrai",
"ns.kotlin.metadata.Expression\022>\n\013or_argu" +
"ment\030\007 \003(\0132).org.jetbrains.kotlin.metada" +
"ta.Expression\".\n\rConstantValue\022\010\n\004TRUE\020\000" +
"\022\t\n\005FALSE\020\001\022\010\n\004NULL\020\002*9\n\010Modality\022\t\n\005FIN" +
"AL\020\000\022\010\n\004OPEN\020\001\022\014\n\010ABSTRACT\020\002\022\n\n\006SEALED\020\003" +
"*b\n\nVisibility\022\014\n\010INTERNAL\020\000\022\013\n\007PRIVATE\020" +
"\001\022\r\n\tPROTECTED\020\002\022\n\n\006PUBLIC\020\003\022\023\n\017PRIVATE_" +
"TO_THIS\020\004\022\t\n\005LOCAL\020\005*Q\n\nMemberKind\022\017\n\013DE" +
"CLARATION\020\000\022\021\n\rFAKE_OVERRIDE\020\001\022\016\n\nDELEGA" +
"TION\020\002\022\017\n\013SYNTHESIZED\020\003B\017B\rDebugProtoBuf"
"e\030\020 \003(\005B\006\020\001\220\265\030\001\0223\n%inline_class_underlyi" +
"ng_property_name\030\021 \001(\005B\004\210\265\030\001\022I\n\034inline_c" +
"lass_underlying_type\030\022 \001(\0132#.org.jetbrai" +
"ns.kotlin.metadata.Type\022-\n\037inline_class_" +
"underlying_type_id\030\023 \001(\005B\004\240\265\030\001\022<\n\ntype_t" +
"able\030\036 \001(\0132(.org.jetbrains.kotlin.metada",
"ta.TypeTable\022\033\n\023version_requirement\030\037 \003(" +
"\005\022Y\n\031version_requirement_table\030 \001(\01326.o" +
"rg.jetbrains.kotlin.metadata.VersionRequ" +
"irementTable\"x\n\004Kind\022\t\n\005CLASS\020\000\022\r\n\tINTER" +
"FACE\020\001\022\016\n\nENUM_CLASS\020\002\022\016\n\nENUM_ENTRY\020\003\022\024" +
"\n\020ANNOTATION_CLASS\020\004\022\n\n\006OBJECT\020\005\022\024\n\020COMP" +
"ANION_OBJECT\020\006*\006\010d\020\270\224\001\"\335\002\n\007Package\0229\n\010fu" +
"nction\030\003 \003(\0132\'.org.jetbrains.kotlin.meta" +
"data.Function\0229\n\010property\030\004 \003(\0132\'.org.je" +
"tbrains.kotlin.metadata.Property\022<\n\ntype",
"_alias\030\005 \003(\0132(.org.jetbrains.kotlin.meta" +
"data.TypeAlias\022<\n\ntype_table\030\036 \001(\0132(.org" +
".jetbrains.kotlin.metadata.TypeTable\022Y\n\031" +
"version_requirement_table\030 \001(\01326.org.je" +
"tbrains.kotlin.metadata.VersionRequireme" +
"ntTable*\005\010d\020\310\001\"`\n\tTypeTable\0221\n\004type\030\001 \003(" +
"\0132#.org.jetbrains.kotlin.metadata.Type\022\032" +
"\n\016first_nullable\030\002 \001(\005:\002-1:\004\240\273\030\001\"\214\001\n\013Con" +
"structor\022\020\n\005flags\030\001 \001(\005:\0016\022F\n\017value_para" +
"meter\030\002 \003(\0132-.org.jetbrains.kotlin.metad",
"ata.ValueParameter\022\033\n\023version_requiremen" +
"t\030\037 \003(\005*\006\010d\020\270\224\001\"\246\004\n\010Function\022\020\n\005flags\030\t " +
"\001(\005:\0016\022\024\n\told_flags\030\001 \001(\005:\0016\022\022\n\004name\030\002 \002" +
"(\005B\004\210\265\030\001\0228\n\013return_type\030\003 \001(\0132#.org.jetb" +
"rains.kotlin.metadata.Type\022\034\n\016return_typ" +
"e_id\030\007 \001(\005B\004\240\265\030\001\022D\n\016type_parameter\030\004 \003(\013" +
"2,.org.jetbrains.kotlin.metadata.TypePar" +
"ameter\022:\n\rreceiver_type\030\005 \001(\0132#.org.jetb" +
"rains.kotlin.metadata.Type\022\036\n\020receiver_t" +
"ype_id\030\010 \001(\005B\004\240\265\030\001\022F\n\017value_parameter\030\006 ",
"\003(\0132-.org.jetbrains.kotlin.metadata.Valu" +
"eParameter\022<\n\ntype_table\030\036 \001(\0132(.org.jet" +
"brains.kotlin.metadata.TypeTable\022\033\n\023vers" +
"ion_requirement\030\037 \003(\005\0229\n\010contract\030 \001(\0132" +
"\'.org.jetbrains.kotlin.metadata.Contract" +
"*\006\010d\020\270\224\001\"\345\003\n\010Property\022\022\n\005flags\030\013 \001(\005:\00351" +
"8\022\027\n\told_flags\030\001 \001(\005:\0042054\022\022\n\004name\030\002 \002(\005" +
"B\004\210\265\030\001\0228\n\013return_type\030\003 \001(\0132#.org.jetbra" +
"ins.kotlin.metadata.Type\022\034\n\016return_type_" +
"id\030\t \001(\005B\004\240\265\030\001\022D\n\016type_parameter\030\004 \003(\0132,",
".org.jetbrains.kotlin.metadata.TypeParam" +
"eter\022:\n\rreceiver_type\030\005 \001(\0132#.org.jetbra" +
"ins.kotlin.metadata.Type\022\036\n\020receiver_typ" +
"e_id\030\n \001(\005B\004\240\265\030\001\022M\n\026setter_value_paramet" +
"er\030\006 \001(\0132-.org.jetbrains.kotlin.metadata" +
".ValueParameter\022\024\n\014getter_flags\030\007 \001(\005\022\024\n" +
"\014setter_flags\030\010 \001(\005\022\033\n\023version_requireme" +
"nt\030\037 \003(\005*\006\010d\020\270\224\001\"\357\001\n\016ValueParameter\022\020\n\005f" +
"lags\030\001 \001(\005:\0010\022\022\n\004name\030\002 \002(\005B\004\210\265\030\001\0221\n\004typ" +
"e\030\003 \001(\0132#.org.jetbrains.kotlin.metadata.",
"Type\022\025\n\007type_id\030\005 \001(\005B\004\240\265\030\001\022@\n\023vararg_el" +
"ement_type\030\004 \001(\0132#.org.jetbrains.kotlin." +
"metadata.Type\022$\n\026vararg_element_type_id\030" +
"\006 \001(\005B\004\240\265\030\001*\005\010d\020\310\001\"\226\003\n\tTypeAlias\022\020\n\005flag" +
"s\030\001 \001(\005:\0016\022\022\n\004name\030\002 \002(\005B\004\210\265\030\001\022D\n\016type_p" +
"arameter\030\003 \003(\0132,.org.jetbrains.kotlin.me" +
"tadata.TypeParameter\022<\n\017underlying_type\030" +
"\004 \001(\0132#.org.jetbrains.kotlin.metadata.Ty" +
"pe\022 \n\022underlying_type_id\030\005 \001(\005B\004\240\265\030\001\022:\n\r" +
"expanded_type\030\006 \001(\0132#.org.jetbrains.kotl",
"in.metadata.Type\022\036\n\020expanded_type_id\030\007 \001" +
"(\005B\004\240\265\030\001\022=\n\nannotation\030\010 \003(\0132).org.jetbr" +
"ains.kotlin.metadata.Annotation\022\033\n\023versi" +
"on_requirement\030\037 \003(\005*\005\010d\020\310\001\"&\n\tEnumEntry" +
"\022\022\n\004name\030\001 \001(\005B\004\210\265\030\001*\005\010d\020\310\001\"\225\003\n\022VersionR" +
"equirement\022\017\n\007version\030\001 \001(\005\022\024\n\014version_f" +
"ull\030\002 \001(\005\022M\n\005level\030\003 \001(\01627.org.jetbrains" +
".kotlin.metadata.VersionRequirement.Leve" +
"l:\005ERROR\022\022\n\nerror_code\030\004 \001(\005\022\025\n\007message\030" +
"\005 \001(\005B\004\230\265\030\001\022e\n\014version_kind\030\006 \001(\0162=.org.",
"jetbrains.kotlin.metadata.VersionRequire" +
"ment.VersionKind:\020LANGUAGE_VERSION\"+\n\005Le" +
"vel\022\013\n\007WARNING\020\000\022\t\n\005ERROR\020\001\022\n\n\006HIDDEN\020\002\"" +
"J\n\013VersionKind\022\024\n\020LANGUAGE_VERSION\020\000\022\024\n\020" +
"COMPILER_VERSION\020\001\022\017\n\013API_VERSION\020\002\"a\n\027V" +
"ersionRequirementTable\022F\n\013requirement\030\001 " +
"\003(\01321.org.jetbrains.kotlin.metadata.Vers" +
"ionRequirement\"\217\002\n\017PackageFragment\022;\n\007st" +
"rings\030\001 \001(\0132*.org.jetbrains.kotlin.metad" +
"ata.StringTable\022J\n\017qualified_names\030\002 \001(\013",
"21.org.jetbrains.kotlin.metadata.Qualifi" +
"edNameTable\0227\n\007package\030\003 \001(\0132&.org.jetbr" +
"ains.kotlin.metadata.Package\0223\n\005class\030\004 " +
"\003(\0132$.org.jetbrains.kotlin.metadata.Clas" +
"s*\005\010d\020\310\001\"A\n\010Contract\0225\n\006effect\030\001 \003(\0132%.o" +
"rg.jetbrains.kotlin.metadata.Effect\"\306\003\n\006" +
"Effect\022E\n\013effect_type\030\001 \001(\01620.org.jetbra" +
"ins.kotlin.metadata.Effect.EffectType\022N\n" +
"\033effect_constructor_argument\030\002 \003(\0132).org" +
".jetbrains.kotlin.metadata.Expression\022S\n",
" conclusion_of_conditional_effect\030\003 \001(\0132" +
").org.jetbrains.kotlin.metadata.Expressi" +
"on\022B\n\004kind\030\004 \001(\01624.org.jetbrains.kotlin." +
"metadata.Effect.InvocationKind\"C\n\nEffect" +
"Type\022\024\n\020RETURNS_CONSTANT\020\000\022\t\n\005CALLS\020\001\022\024\n" +
"\020RETURNS_NOT_NULL\020\002\"G\n\016InvocationKind\022\020\n" +
"\014AT_MOST_ONCE\020\000\022\020\n\014EXACTLY_ONCE\020\001\022\021\n\rAT_" +
"LEAST_ONCE\020\002\"\245\003\n\nExpression\022\020\n\005flags\030\001 \001" +
"(\005:\0010\022!\n\031value_parameter_reference\030\002 \001(\005" +
"\022O\n\016constant_value\030\003 \001(\01627.org.jetbrains",
".kotlin.metadata.Expression.ConstantValu" +
"e\022=\n\020is_instance_type\030\004 \001(\0132#.org.jetbra" +
"ins.kotlin.metadata.Type\022!\n\023is_instance_" +
"type_id\030\005 \001(\005B\004\240\265\030\001\022?\n\014and_argument\030\006 \003(" +
"\0132).org.jetbrains.kotlin.metadata.Expres" +
"sion\022>\n\013or_argument\030\007 \003(\0132).org.jetbrain" +
"s.kotlin.metadata.Expression\".\n\rConstant" +
"Value\022\010\n\004TRUE\020\000\022\t\n\005FALSE\020\001\022\010\n\004NULL\020\002*9\n\010" +
"Modality\022\t\n\005FINAL\020\000\022\010\n\004OPEN\020\001\022\014\n\010ABSTRAC" +
"T\020\002\022\n\n\006SEALED\020\003*b\n\nVisibility\022\014\n\010INTERNA",
"L\020\000\022\013\n\007PRIVATE\020\001\022\r\n\tPROTECTED\020\002\022\n\n\006PUBLI" +
"C\020\003\022\023\n\017PRIVATE_TO_THIS\020\004\022\t\n\005LOCAL\020\005*Q\n\nM" +
"emberKind\022\017\n\013DECLARATION\020\000\022\021\n\rFAKE_OVERR" +
"IDE\020\001\022\016\n\nDELEGATION\020\002\022\017\n\013SYNTHESIZED\020\003B\017" +
"B\rDebugProtoBuf"
};
org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
@@ -34587,7 +34949,7 @@ public final class DebugProtoBuf {
internal_static_org_jetbrains_kotlin_metadata_Class_fieldAccessorTable = new
org.jetbrains.kotlin.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_org_jetbrains_kotlin_metadata_Class_descriptor,
new java.lang.String[] { "Flags", "FqName", "CompanionObjectName", "TypeParameter", "Supertype", "SupertypeId", "NestedClassName", "Constructor", "Function", "Property", "TypeAlias", "EnumEntry", "SealedSubclassFqName", "TypeTable", "VersionRequirement", "VersionRequirementTable", });
new java.lang.String[] { "Flags", "FqName", "CompanionObjectName", "TypeParameter", "Supertype", "SupertypeId", "NestedClassName", "Constructor", "Function", "Property", "TypeAlias", "EnumEntry", "SealedSubclassFqName", "InlineClassUnderlyingPropertyName", "InlineClassUnderlyingType", "InlineClassUnderlyingTypeId", "TypeTable", "VersionRequirement", "VersionRequirementTable", });
internal_static_org_jetbrains_kotlin_metadata_Package_descriptor =
getDescriptor().getMessageTypes().get(6);
internal_static_org_jetbrains_kotlin_metadata_Package_fieldAccessorTable = new
@@ -34696,6 +35058,8 @@ public final class DebugProtoBuf {
registry.add(org.jetbrains.kotlin.metadata.DebugExtOptionsProtoBuf.typeIdInTable);
registry.add(org.jetbrains.kotlin.metadata.DebugExtOptionsProtoBuf.nameIdInTable);
registry.add(org.jetbrains.kotlin.metadata.DebugExtOptionsProtoBuf.fqNameIdInTable);
registry.add(org.jetbrains.kotlin.metadata.DebugExtOptionsProtoBuf.nameIdInTable);
registry.add(org.jetbrains.kotlin.metadata.DebugExtOptionsProtoBuf.typeIdInTable);
registry.add(org.jetbrains.kotlin.metadata.DebugExtOptionsProtoBuf.skipMessageInComparison);
registry.add(org.jetbrains.kotlin.metadata.DebugExtOptionsProtoBuf.nameIdInTable);
registry.add(org.jetbrains.kotlin.metadata.DebugExtOptionsProtoBuf.typeIdInTable);

View File

@@ -183,7 +183,7 @@ extra["versions.jflex"] = "1.7.0"
extra["versions.markdown"] = "0.1.25"
extra["versions.trove4j"] = "1.0.20181211"
extra["versions.completion-ranking-kotlin"] = "0.1.3"
extra["versions.r8"] = "2.1.75"
extra["versions.r8"] = "2.1.96"
val immutablesVersion = "0.3.1"
extra["versions.kotlinx-collections-immutable"] = immutablesVersion
extra["versions.kotlinx-collections-immutable-jvm"] = immutablesVersion
@@ -192,7 +192,7 @@ extra["versions.kotlinx-collections-immutable-jvm"] = immutablesVersion
extra["versions.ktor-network"] = "1.0.1"
if (!project.hasProperty("versions.kotlin-native")) {
extra["versions.kotlin-native"] = "1.5-dev-17775"
extra["versions.kotlin-native"] = "1.5.20-dev-3553"
}
val intellijUltimateEnabled by extra(project.kotlinBuildProperties.intellijUltimateEnabled)

View File

@@ -28,6 +28,7 @@ val kotlinGradlePluginAndItsRequired = arrayOf(
":kotlin-noarg",
":kotlin-sam-with-receiver",
":kotlin-android-extensions",
":kotlin-android-extensions-runtime",
":kotlin-parcelize-compiler",
":kotlin-build-common",
":kotlin-compiler-embeddable",
@@ -40,6 +41,7 @@ val kotlinGradlePluginAndItsRequired = arrayOf(
":kotlin-gradle-plugin-api",
":kotlin-gradle-plugin",
":kotlin-gradle-plugin-model",
":kotlin-tooling-metadata",
":kotlin-reflect",
":kotlin-annotation-processing-gradle",
":kotlin-test",
@@ -55,9 +57,11 @@ val kotlinGradlePluginAndItsRequired = arrayOf(
":kotlin-scripting-jvm",
":kotlin-scripting-compiler-embeddable",
":kotlin-scripting-compiler-impl-embeddable",
":kotlin-serialization",
":kotlin-test-js-runner",
":native:kotlin-klib-commonizer-embeddable",
":native:kotlin-klib-commonizer-api"
":native:kotlin-klib-commonizer-api",
":native:kotlin-native-utils"
)
fun Task.dependsOnKotlinGradlePluginInstall() {

View File

@@ -0,0 +1,90 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.backend.common
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.resolve.sam.getAbstractMembers
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.typeUtil.replaceArgumentsWithNothing
class SamType constructor(val type: KotlinType) {
val classDescriptor: ClassDescriptor
get() = type.constructor.declarationDescriptor as? ClassDescriptor ?: error("Sam/Fun interface not a class descriptor: $type")
val kotlinFunctionType: KotlinType
get() = classDescriptor.defaultFunctionTypeForSamInterface!!
val originalAbstractMethod: SimpleFunctionDescriptor
get() = getAbstractMembers(classDescriptor)[0] as SimpleFunctionDescriptor
override fun equals(other: Any?): Boolean {
return other is SamType && type == other.type
}
override fun hashCode(): Int {
return type.hashCode()
}
override fun toString(): String {
return "SamType($type)"
}
}
open class SamTypeFactory {
fun createByValueParameter(valueParameter: ValueParameterDescriptor): SamType? {
val singleArgumentType: KotlinType
val originalSingleArgumentType: KotlinType?
val varargElementType = valueParameter.varargElementType
if (varargElementType != null) {
singleArgumentType = varargElementType
originalSingleArgumentType = valueParameter.original.varargElementType
assert(originalSingleArgumentType != null) {
"Value parameter and original value parameter have inconsistent varargs: " +
valueParameter + "; " + valueParameter.original
}
} else {
singleArgumentType = valueParameter.type
originalSingleArgumentType = valueParameter.original.type
}
if (singleArgumentType.isError || originalSingleArgumentType!!.isError) {
return null
}
// This can be true in case when the value parameter is in the method of a generic type with out-projection.
// We approximate Inv<Captured#1> to Nothing, while Inv itself can be a SAM interface safe to call here
// (see testData genericSamProjectedOut.kt for details)
// In such a case we can't have a proper supertype since wildcards are not allowed there,
// so we use Nothing arguments instead that leads to a raw type used for a SAM wrapper.
// See org.jetbrains.kotlin.codegen.state.KotlinTypeMapper#writeGenericType to understand how
// raw types and Nothing arguments relate.
val originalTypeToUse =
if (KotlinBuiltIns.isNothing(singleArgumentType))
originalSingleArgumentType.replaceArgumentsWithNothing()
else singleArgumentType
return create(originalTypeToUse.removeExternalProjections())
}
open fun isSamType(type: KotlinType): Boolean {
val descriptor = type.constructor.declarationDescriptor
return descriptor is ClassDescriptor && descriptor.isFun
}
fun create(originalType: KotlinType): SamType? {
return if (isSamType(originalType)) SamType(originalType) else null
}
private fun KotlinType.removeExternalProjections(): KotlinType {
val newArguments = arguments.map { TypeProjectionImpl(Variance.INVARIANT, it.type) }
return replace(newArguments)
}
companion object {
val INSTANCE = SamTypeFactory()
}
}

View File

@@ -40,6 +40,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver;
import org.jetbrains.kotlin.serialization.DescriptorSerializer;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.types.SimpleType;
import org.jetbrains.kotlin.backend.common.SamType;
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils;
import org.jetbrains.kotlin.util.OperatorNameConventions;
import org.jetbrains.org.objectweb.asm.MethodVisitor;

View File

@@ -92,6 +92,7 @@ import org.jetbrains.kotlin.types.model.KotlinTypeMarker;
import org.jetbrains.kotlin.types.model.TypeParameterMarker;
import org.jetbrains.kotlin.types.typesApproximation.CapturedTypeApproximationKt;
import org.jetbrains.kotlin.util.OperatorNameConventions;
import org.jetbrains.kotlin.backend.common.SamType;
import org.jetbrains.org.objectweb.asm.Label;
import org.jetbrains.org.objectweb.asm.MethodVisitor;
import org.jetbrains.org.objectweb.asm.Opcodes;

View File

@@ -0,0 +1,14 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.codegen
import org.jetbrains.kotlin.load.java.sam.JavaSingleAbstractMethodUtils
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.backend.common.SamTypeFactory
object JvmSamTypeFactory : SamTypeFactory() {
override fun isSamType(type: KotlinType) = JavaSingleAbstractMethodUtils.isSamType(type)
}

View File

@@ -1,117 +0,0 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.codegen;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
import org.jetbrains.kotlin.codegen.state.TypeMapperUtilsKt;
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor;
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor;
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor;
import org.jetbrains.kotlin.load.java.sam.JavaSingleAbstractMethodUtils;
import org.jetbrains.kotlin.resolve.sam.SamConversionResolverImplKt;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.types.KotlinTypeKt;
import org.jetbrains.kotlin.types.typeUtil.TypeUtilsKt;
public class SamType {
@Nullable
public static SamType createByValueParameter(@NotNull ValueParameterDescriptor valueParameter) {
KotlinType singleArgumentType;
KotlinType originalSingleArgumentType;
KotlinType varargElementType = valueParameter.getVarargElementType();
if (varargElementType != null) {
singleArgumentType = varargElementType;
originalSingleArgumentType = valueParameter.getOriginal().getVarargElementType();
assert originalSingleArgumentType != null :
"Value parameter and original value parameter have inconsistent varargs: " +
valueParameter + "; " + valueParameter.getOriginal();
} else {
singleArgumentType = valueParameter.getType();
originalSingleArgumentType = valueParameter.getOriginal().getType();
}
if (KotlinTypeKt.isError(singleArgumentType) || KotlinTypeKt.isError(originalSingleArgumentType)) {
return null;
}
KotlinType originalTypeToUse =
// This can be true in case when the value parameter is in the method of a generic type with out-projection.
// We approximate Inv<Captured#1> to Nothing, while Inv itself can be a SAM interface safe to call here
// (see testData genericSamProjectedOut.kt for details)
KotlinBuiltIns.isNothing(singleArgumentType)
// In such a case we can't have a proper supertype since wildcards are not allowed there,
// so we use Nothing arguments instead that leads to a raw type used for a SAM wrapper.
// See org.jetbrains.kotlin.codegen.state.KotlinTypeMapper#writeGenericType to understand how
// raw types and Nothing arguments relate.
? TypeUtilsKt.replaceArgumentsWithNothing(originalSingleArgumentType)
: singleArgumentType;
return create(TypeMapperUtilsKt.removeExternalProjections(originalTypeToUse));
}
public static SamType create(@NotNull KotlinType originalType) {
if (!JavaSingleAbstractMethodUtils.isSamType(originalType)) return null;
return new SamType(originalType);
}
private final KotlinType type;
private SamType(@NotNull KotlinType type) {
this.type = type;
}
@NotNull
public KotlinType getType() {
return type;
}
@NotNull
public ClassDescriptor getClassDescriptor() {
ClassifierDescriptor classifier = type.getConstructor().getDeclarationDescriptor();
assert classifier instanceof ClassDescriptor : "Sam/Fun interface not a class descriptor: " + classifier;
return (ClassDescriptor) classifier;
}
@NotNull
public KotlinType getKotlinFunctionType() {
ClassDescriptor descriptor = getClassDescriptor();
//noinspection ConstantConditions
return descriptor.getDefaultFunctionTypeForSamInterface();
}
@NotNull
public SimpleFunctionDescriptor getOriginalAbstractMethod() {
return (SimpleFunctionDescriptor) SamConversionResolverImplKt.getAbstractMembers(getClassDescriptor()).get(0);
}
@Override
public boolean equals(Object o) {
return o instanceof SamType && type.equals(((SamType) o).type);
}
@Override
public int hashCode() {
return type.hashCode();
}
@Override
public String toString() {
return "SamType(" + type + ")";
}
}

View File

@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.resolve.inline.InlineUtil
import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.kotlin.backend.common.SamType
class SamWrapperClasses(private val state: GenerationState) {

View File

@@ -38,6 +38,7 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKt;
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.backend.common.SamType;
import org.jetbrains.kotlin.util.OperatorNameConventions;
import org.jetbrains.org.objectweb.asm.Label;
import org.jetbrains.org.objectweb.asm.MethodVisitor;

View File

@@ -56,6 +56,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.backend.common.SamType;
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
import org.jetbrains.org.objectweb.asm.Type;
@@ -861,7 +862,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
if (valueArguments == null) return;
for (ValueParameterDescriptor valueParameter : valueParametersWithSAMConversion) {
SamType samType = SamType.createByValueParameter(valueParameter);
SamType samType = JvmSamTypeFactory.INSTANCE.createByValueParameter(valueParameter);
if (samType == null) continue;
ResolvedValueArgument resolvedValueArgument = valueArguments.get(valueParameter.getIndex());
@@ -873,7 +874,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
}
private void recordSamTypeOnArgumentExpression(ValueParameterDescriptor valueParameter, ValueArgument valueArgument) {
SamType samType = SamType.createByValueParameter(valueParameter);
SamType samType = JvmSamTypeFactory.INSTANCE.createByValueParameter(valueParameter);
if (samType == null) return;
recordSamTypeOnArgumentExpression(samType, valueArgument);
@@ -955,7 +956,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
bindingTrace.record(SAM_CONSTRUCTOR_TO_ARGUMENT, expression, argumentExpression);
//noinspection ConstantConditions
SamType samType = SamType.create(callableDescriptor.getReturnType());
SamType samType = JvmSamTypeFactory.INSTANCE.create(callableDescriptor.getReturnType());
bindingTrace.record(SAM_VALUE, argumentExpression, samType);
}
@@ -972,7 +973,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
FunctionDescriptor original = SamCodegenUtil.getOriginalIfSamAdapter((FunctionDescriptor) operationDescriptor);
if (original == null) return;
SamType samType = SamType.createByValueParameter(original.getValueParameters().get(0));
SamType samType = JvmSamTypeFactory.INSTANCE.createByValueParameter(original.getValueParameters().get(0));
if (samType == null) return;
IElementType token = expression.getOperationToken();
@@ -1001,7 +1002,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
List<KtExpression> indexExpressions = expression.getIndexExpressions();
List<ValueParameterDescriptor> parameters = original.getValueParameters();
for (ValueParameterDescriptor valueParameter : parameters) {
SamType samType = SamType.createByValueParameter(valueParameter);
SamType samType = JvmSamTypeFactory.INSTANCE.createByValueParameter(valueParameter);
if (samType == null) continue;
if (isSetter && valueParameter.getIndex() == parameters.size() - 1) {

View File

@@ -12,7 +12,7 @@ import kotlin.collections.CollectionsKt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.codegen.JvmCodegenUtil;
import org.jetbrains.kotlin.codegen.SamType;
import org.jetbrains.kotlin.backend.common.SamType;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.codegen.when.WhenByEnumsMapping;
import org.jetbrains.kotlin.descriptors.*;

View File

@@ -44,6 +44,7 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
import org.jetbrains.kotlin.serialization.DescriptorSerializer
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.typeUtil.makeNullable
import org.jetbrains.kotlin.backend.common.SamType
import org.jetbrains.kotlin.utils.sure
import org.jetbrains.org.objectweb.asm.Label
import org.jetbrains.org.objectweb.asm.MethodVisitor

View File

@@ -201,20 +201,38 @@ class CoroutineTransformerMethodVisitor(
// When suspension point is inlined, it is in range of fake inliner variables.
// Path from TABLESWITCH into unspilling goes to latter part of the range.
// In this case the variables are uninitialized, initialize them
// In this case the variables are uninitialized, initialize them, and split the local variable
// range so that the local variable is only defined when initialized.
private fun initializeFakeInlinerVariables(methodNode: MethodNode, stateLabels: List<LabelNode>) {
for (stateLabel in stateLabels) {
val newRecords = mutableListOf<LocalVariableNode>()
for (record in methodNode.localVariables) {
if (isFakeLocalVariableForInline(record.name) &&
methodNode.instructions.indexOf(record.start) < methodNode.instructions.indexOf(stateLabel) &&
methodNode.instructions.indexOf(stateLabel) < methodNode.instructions.indexOf(record.end)
) {
val newEnd = record.end
val newStart = LabelNode()
record.end = stateLabel
methodNode.instructions.insert(stateLabel, withInstructionAdapter {
iconst(0)
store(record.index, Type.INT_TYPE)
}.also {
it.add(newStart)
})
newRecords.add(
LocalVariableNode(
record.name,
record.desc,
record.signature,
newStart,
newEnd,
record.index
)
)
}
}
methodNode.localVariables.addAll(newRecords)
}
}

View File

@@ -75,6 +75,7 @@ import org.jetbrains.kotlin.types.checker.SimpleClassicTypeSystemContext
import org.jetbrains.kotlin.types.checker.convertVariance
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils.*
import org.jetbrains.kotlin.types.model.*
import org.jetbrains.kotlin.backend.common.SamType
import org.jetbrains.kotlin.util.OperatorNameConventions
import org.jetbrains.org.objectweb.asm.Opcodes.*
import org.jetbrains.org.objectweb.asm.Type

View File

@@ -304,6 +304,7 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
)
var checkStickyPhaseConditions: Boolean by FreezableVar(false)
@GradleOption(DefaultValues.BooleanFalseDefault::class)
@Argument(
value = "-Xuse-fir",
description = "Compile using Front-end IR. Warning: this feature is far from being production-ready"

View File

@@ -471,6 +471,14 @@ default: `indy-with-constants` for JVM target 9 or greater, `inline` otherwise""
)
var suppressDeprecatedJvmTargetWarning: Boolean by FreezableVar(false)
@Argument(
value = "-Xtype-enhancement-improvements-strict-mode",
description = "Enable strict mode for some improvements in the type enhancement for loaded Java types based on nullability annotations," +
"including freshly supported reading of the type use annotations from class files. " +
"See KT-45671 for more details"
)
var typeEnhancementImprovementsInStrictMode: Boolean by FreezableVar(false)
override fun configureAnalysisFlags(collector: MessageCollector): MutableMap<AnalysisFlag<*>, Any> {
val result = super.configureAnalysisFlags(collector)
result[JvmAnalysisFlags.strictMetadataVersionSemantics] = strictMetadataVersionSemantics
@@ -502,6 +510,9 @@ default: `indy-with-constants` for JVM target 9 or greater, `inline` otherwise""
if (strictJavaNullabilityAssertions) {
result[LanguageFeature.StrictJavaNullabilityAssertions] = LanguageFeature.State.ENABLED
}
if (typeEnhancementImprovementsInStrictMode) {
result[LanguageFeature.TypeEnhancementImprovementsInStrictMode] = LanguageFeature.State.ENABLED
}
return result
}

View File

@@ -13,7 +13,7 @@ class JitCompilationMeasurement(private val milliseconds: Long) : PerformanceMea
override fun render(): String = "JIT time is $milliseconds ms"
}
class CompilerInitializationMeasurement(private val milliseconds: Long) : PerformanceMeasurement {
class CompilerInitializationMeasurement(val milliseconds: Long) : PerformanceMeasurement {
override fun render(): String = "INIT: Compiler initialized in $milliseconds ms"
}

View File

@@ -38,7 +38,7 @@ class JvmPackagePartProvider(
languageVersionSettings: LanguageVersionSettings,
private val scope: GlobalSearchScope
) : JvmPackagePartProviderBase<VirtualFile>() {
private val deserializationConfiguration = CompilerDeserializationConfiguration(languageVersionSettings)
override val deserializationConfiguration = CompilerDeserializationConfiguration(languageVersionSettings)
override val loadedModules: MutableList<ModuleMappingInfo<VirtualFile>> = SmartList()

View File

@@ -689,7 +689,7 @@ class KotlinCoreEnvironment private constructor(
// For example, see the `unregisterExtension` call in `GenerationUtils.compileFilesUsingFrontendIR`.
// TODO: refactor this to avoid registering unneeded extensions in the first place, and avoid using deprecated API.
@Suppress("DEPRECATION")
PsiElementFinder.EP.getPoint(project).registerExtension(JavaElementFinder(this, kotlinAsJavaSupport))
PsiElementFinder.EP.getPoint(project).registerExtension(JavaElementFinder(this))
@Suppress("DEPRECATION")
PsiElementFinder.EP.getPoint(project).registerExtension(PsiElementFinderImpl(this))
}

View File

@@ -683,7 +683,7 @@ class KotlinCoreEnvironment private constructor(
// For example, see the `unregisterExtension` call in `GenerationUtils.compileFilesUsingFrontendIR`.
// TODO: refactor this to avoid registering unneeded extensions in the first place, and avoid using deprecated API.
@Suppress("DEPRECATION")
PsiElementFinder.EP.getPoint(project).registerExtension(JavaElementFinder(this, kotlinAsJavaSupport))
PsiElementFinder.EP.getPoint(project).registerExtension(JavaElementFinder(this))
@Suppress("DEPRECATION")
PsiElementFinder.EP.getPoint(project).registerExtension(PsiElementFinderImpl(this))
}

View File

@@ -61,6 +61,7 @@ import org.jetbrains.kotlin.fir.createSessionWithDependencies
import org.jetbrains.kotlin.ir.backend.jvm.jvmResolveLibraries
import org.jetbrains.kotlin.javac.JavacWrapper
import org.jetbrains.kotlin.load.kotlin.ModuleVisibilityManager
import org.jetbrains.kotlin.load.kotlin.incremental.IncrementalPackagePartProvider
import org.jetbrains.kotlin.modules.Module
import org.jetbrains.kotlin.modules.TargetId
import org.jetbrains.kotlin.name.FqName
@@ -308,12 +309,19 @@ object KotlinToJVMBytecodeCompiler {
val projectConfiguration = environment.configuration
val localFileSystem = VirtualFileManager.getInstance().getFileSystem(StandardFileSystems.FILE_PROTOCOL)
val outputs = newLinkedHashMapWithExpectedSize<Module, GenerationState>(chunk.size)
val targetIds = environment.configuration.get(JVMConfigurationKeys.MODULES)?.map(::TargetId)
val incrementalComponents = environment.configuration.get(JVMConfigurationKeys.INCREMENTAL_COMPILATION_COMPONENTS)
for (module in chunk) {
performanceManager?.notifyAnalysisStarted()
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
val ktFiles = module.getSourceFiles(environment, localFileSystem, chunk.size > 1, buildFile)
if (!checkKotlinPackageUsage(environment, ktFiles)) return false
val syntaxErrors = ktFiles.fold(false) { errorsFound, ktFile ->
AnalyzerWithCompilerReport.reportSyntaxErrors(ktFile, environment.messageCollector).isHasErrors or errorsFound
}
val moduleConfiguration = projectConfiguration.applyModuleProperties(module, buildFile)
val sourceScope = GlobalSearchScope.filesScope(project, ktFiles.map { it.virtualFile })
@@ -328,7 +336,15 @@ object KotlinToJVMBytecodeCompiler {
languageVersionSettings,
sourceScope,
librariesScope,
environment::createPackagePartProvider
lookupTracker = environment.configuration.get(CommonConfigurationKeys.LOOKUP_TRACKER),
getPackagePartProvider = { environment.createPackagePartProvider(it) },
getAdditionalModulePackagePartProvider = {
if (targetIds == null || incrementalComponents == null) null
else IncrementalPackagePartProvider(
environment.createPackagePartProvider(it),
targetIds.map(incrementalComponents::getIncrementalCache)
)
}
) {
if (extendedAnalysisMode) {
registerExtendedCommonCheckers()
@@ -345,7 +361,7 @@ object KotlinToJVMBytecodeCompiler {
)
performanceManager?.notifyAnalysisFinished()
if (firDiagnostics.any { it.severity == Severity.ERROR }) {
if (syntaxErrors || firDiagnostics.any { it.severity == Severity.ERROR }) {
return false
}

View File

@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.context.ModuleContext
import org.jetbrains.kotlin.context.MutableModuleContext
import org.jetbrains.kotlin.context.ProjectContext
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ModuleCapability
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.descriptors.PackageFragmentProvider
import org.jetbrains.kotlin.descriptors.impl.CompositePackageFragmentProvider
@@ -143,13 +144,14 @@ object TopDownAnalyzerFacadeForJVM {
klibList: List<KotlinLibrary> = emptyList(),
implicitsResolutionFilter: ImplicitsExtensionsResolutionFilter? = null,
explicitModuleDependencyList: List<ModuleDescriptorImpl> = emptyList(),
explicitModuleFriendsList: List<ModuleDescriptorImpl> = emptyList()
explicitModuleFriendsList: List<ModuleDescriptorImpl> = emptyList(),
moduleCapabilities: Map<ModuleCapability<*>, Any?> = emptyMap()
): ComponentProvider {
val jvmTarget = configuration.get(JVMConfigurationKeys.JVM_TARGET, JvmTarget.DEFAULT)
val languageVersionSettings = configuration.languageVersionSettings
val jvmPlatform = JvmPlatforms.jvmPlatformByTargetVersion(jvmTarget)
val moduleContext = createModuleContext(project, configuration, jvmPlatform)
val moduleContext = createModuleContext(project, configuration, jvmPlatform, moduleCapabilities)
val storageManager = moduleContext.storageManager
val module = moduleContext.module
@@ -215,7 +217,7 @@ object TopDownAnalyzerFacadeForJVM {
val partProvider = packagePartProvider(sourceScope).let { fragment ->
if (targetIds == null || incrementalComponents == null) fragment
else IncrementalPackagePartProvider(fragment, targetIds.map(incrementalComponents::getIncrementalCache), storageManager)
else IncrementalPackagePartProvider(fragment, targetIds.map(incrementalComponents::getIncrementalCache))
}
// Note that it's necessary to create container for sources _after_ creation of container for dependencies because
@@ -318,11 +320,17 @@ object TopDownAnalyzerFacadeForJVM {
}
}
private fun createModuleContext(project: Project, configuration: CompilerConfiguration, platform: TargetPlatform?): MutableModuleContext {
private fun createModuleContext(
project: Project,
configuration: CompilerConfiguration,
platform: TargetPlatform?,
capabilities: Map<ModuleCapability<*>, Any?> = emptyMap()
): MutableModuleContext {
val projectContext = ProjectContext(project, "TopDownAnalyzer for JVM")
val builtIns = JvmBuiltIns(projectContext.storageManager, JvmBuiltIns.Kind.FROM_DEPENDENCIES)
return ContextForNewModule(
projectContext, Name.special("<${configuration.getNotNull(CommonConfigurationKeys.MODULE_NAME)}>"), builtIns, platform
projectContext, Name.special("<${configuration.getNotNull(CommonConfigurationKeys.MODULE_NAME)}>"),
builtIns, platform, capabilities
).apply {
builtIns.builtInsModule = module
}

View File

@@ -202,11 +202,13 @@ fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerAr
put(JVMConfigurationKeys.PARAMETERS_METADATA, arguments.javaParameters)
// TODO: ignore previous configuration value when we do not need old backend in scripting by default
val useOldBackend = arguments.useOldBackend || (!arguments.useIR && get(JVMConfigurationKeys.IR) == false)
val useIR = arguments.useFir ||
if (languageVersionSettings.supportsFeature(LanguageFeature.JvmIrEnabledByDefault)) {
!arguments.useOldBackend
!useOldBackend
} else {
arguments.useIR && !arguments.useOldBackend
arguments.useIR && !useOldBackend
}
if (arguments.useIR && arguments.useOldBackend) {

View File

@@ -920,6 +920,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
public void testConstValNotTopLevelOrObject() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/constVal/constValNotTopLevelOrObject.kt");
}
@TestMetadata("constValWithGetterOrDelegate.kt")
public void testConstValWithGetterOrDelegate() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/constVal/constValWithGetterOrDelegate.kt");
}
}
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/constructors")

View File

@@ -28,9 +28,9 @@ fun test_2(a: A<C>) {
}
fun test_3(a: A<D>) {
<!AMBIGUITY!>a[0] += D()<!> // ambiguity
a[0] <!AMBIGUITY!>+=<!> D() // ambiguity
}
fun test_4(b: B) {
<!UNRESOLVED_REFERENCE!><!UNRESOLVED_REFERENCE!>b[0]<!> += B()<!> // unresolved
b<!NO_GET_METHOD!>[0]<!> <!UNRESOLVED_REFERENCE!>+=<!> B() // unresolved
}

View File

@@ -0,0 +1,33 @@
FILE: constValWithGetterOrDelegate.kt
public final const val f: R|kotlin/Int| = Int(24)
public get(): R|kotlin/Int|
public final const val l: R|kotlin/Int| = Int(3)
public get(): R|kotlin/Int|
public final const val k: R|kotlin/Int|
public get(): R|kotlin/Int|
public final const val t: R|kotlin/Int|
public get(): R|kotlin/Int| {
^ Int(24)
}
public final class Test : R|kotlin/Any| {
public constructor(): R|Test| {
super<R|kotlin/Any|>()
}
public final operator fun getValue(nothing: R|kotlin/Nothing?|, property: R|kotlin/reflect/KProperty<*>|): R|kotlin/Int| {
^getValue Int(123)
}
}
public final const val delegated: R|kotlin/Int|by R|/Test.Test|()
public get(): R|kotlin/Int| {
^ D|/delegated|.R|/Test.getValue|(Null(null), ::R|/delegated|)
}
public final const val e: R|kotlin/Boolean|
public get(): R|kotlin/Boolean| {
^ Boolean(false)
}
public final const val property: R|kotlin/String| = String(123)
public get(): R|kotlin/String| {
^ F|/property|.R|kotlin/String.plus|(String( 123 123))
}

View File

@@ -0,0 +1,26 @@
import kotlin.reflect.KProperty
const val f = 24
const val l = 3
<!CONST_VAL_WITH_GETTER!>get<!>
<!MUST_BE_INITIALIZED!>const val k: Int<!>
<!CONST_VAL_WITH_GETTER!>get<!>
const val t: Int
<!CONST_VAL_WITH_GETTER!>get() = 24<!>
class Test {
operator fun getValue(nothing: Nothing?, property: KProperty<*>): Int {
return 123
}
}
const val delegated: Int by <!CONST_VAL_WITH_DELEGATE!>Test()<!>
const val e: Boolean
<!CONST_VAL_WITH_GETTER!>get() = false<!>
const val property: String = "123"
<!CONST_VAL_WITH_GETTER!>get() = field + " 123 123"<!>

View File

@@ -21,7 +21,7 @@ class LinkedList<T> : java.util.LinkedList<T>()
package util
class HashSet<T> : java.util.HashSet<T>
class HashSet<T> : <!SUPERTYPE_NOT_INITIALIZED!>java.util.HashSet<T><!>
// FILE: main.kt

View File

@@ -10,18 +10,18 @@ open class A3(x: String, y: String = "") {
constructor(x: String, b: Boolean = true) : this(x, x)
}
class B3_1 : <!AMBIGUITY{LT}!><!AMBIGUITY{PSI}!>A3<!>("")<!>
class B3_1 : <!AMBIGUITY!>A3<!>("")
class B3_2 : A3("", "asas")
class B3_3 : A3("", true)
class B3_4 : <!NONE_APPLICABLE{LT}!><!NONE_APPLICABLE{PSI}!>A3<!>("", Unit)<!>
class B3_4 : <!NONE_APPLICABLE!>A3<!>("", Unit)
open class A4(val x: Byte)
class B4 : <!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>A4<!>( 1 + 1)<!>
class B4 : <!INAPPLICABLE_CANDIDATE!>A4<!>( 1 + 1)
open class A5 {
constructor(x: Byte)
constructor(x: Short)
}
class B5_1 : <!NONE_APPLICABLE{LT}!><!NONE_APPLICABLE{PSI}!>A5<!>(1 + 1)<!>
class B5_2 : <!NONE_APPLICABLE{LT}!><!NONE_APPLICABLE{PSI}!>A5<!>(100 * 2)<!>
class B5_1 : <!NONE_APPLICABLE!>A5<!>(1 + 1)
class B5_2 : <!NONE_APPLICABLE!>A5<!>(100 * 2)

View File

@@ -16,7 +16,7 @@ abstract class A : C() {
}
}
class B : A() {
<!ABSTRACT_CLASS_MEMBER_NOT_IMPLEMENTED!>class B<!> : A() {
override fun f() {
}

View File

@@ -16,7 +16,7 @@ fun test(z: Int, c: Char) {}
}<!>
<!REDECLARATION!>class B : A {
<!REDECLARATION!>class B : <!SUPERTYPE_NOT_INITIALIZED!>A<!> {
<!CONFLICTING_OVERLOADS!>override fun rest(s: String)<!> {}
<!CONFLICTING_OVERLOADS!>fun rest(s: String)<!> {}

View File

@@ -22,7 +22,7 @@ abstract class K {
<!INCOMPATIBLE_MODIFIERS!>private<!> <!INCOMPATIBLE_MODIFIERS!>abstract<!> val i2: Int
}
private open class L : K()
private open <!INVISIBLE_ABSTRACT_MEMBER_FROM_SUPER!>class L<!> : K()
private abstract class M : K()
class X {

View File

@@ -1,7 +1,7 @@
interface A {
<!ANY_METHOD_IMPLEMENTED_IN_INTERFACE!>override fun toString() = "Hello"<!>
<!ANY_METHOD_IMPLEMENTED_IN_INTERFACE!>override fun equals(other: Any?) = true<!>
<!ANY_METHOD_IMPLEMENTED_IN_INTERFACE!>override fun hashCode(): Int {
<!METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE!>override fun toString() = "Hello"<!>
<!METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE!>override fun equals(other: Any?) = true<!>
<!METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE!>override fun hashCode(): Int {
return 42;
}<!>
}
@@ -13,9 +13,9 @@ interface B {
}
interface C {
<!ANY_METHOD_IMPLEMENTED_IN_INTERFACE!>override operator fun toString(): String = "Rest"<!>
<!ANY_METHOD_IMPLEMENTED_IN_INTERFACE!>override operator fun equals(other: Any?): Boolean = false<!>
<!ANY_METHOD_IMPLEMENTED_IN_INTERFACE!>override operator fun hashCode(): Int = 2<!>
<!METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE!>override operator fun toString(): String = "Rest"<!>
<!METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE!>override operator fun equals(other: Any?): Boolean = false<!>
<!METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE!>override operator fun hashCode(): Int = 2<!>
}
interface D {

View File

@@ -2,7 +2,7 @@ class A {
fun f() {}
}
class B : A {
class B : <!SUPERTYPE_NOT_INITIALIZED!>A<!> {
fun g() {
<!NOT_A_SUPERTYPE!>super<String><!>.<!UNRESOLVED_REFERENCE!>f<!>()
super<A>.f()

View File

@@ -2,7 +2,7 @@ open class A {
open var test: Number = 10
}
open class B : A {
open class B : <!SUPERTYPE_NOT_INITIALIZED!>A<!> {
override var test: <!VAR_TYPE_MISMATCH_ON_OVERRIDE!>Double<!> = 20.0
}
@@ -26,7 +26,7 @@ class G<E : Double>(val balue: E) : F<E>(balue) {
override var rest: E = balue
}
class H<E : String>(val balue: E) : <!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>F<E><!>(balue)<!> {
class H<E : String>(val balue: E) : <!INAPPLICABLE_CANDIDATE!>F<E><!>(balue) {
override var rest: E = balue // no report because of INAPPLICABLE_CANDIDATE
}

View File

@@ -2,7 +2,7 @@ open class A {
open fun test(): Number = 10
}
open class B : A {
open class B : <!SUPERTYPE_NOT_INITIALIZED!>A<!> {
override fun test(): Double = 20.0
fun test(x: Int) = x
}
@@ -27,7 +27,7 @@ class G<E : Double>(val balue: E) : F<E>(balue) {
override fun rest(): E = balue
}
class H<E : String>(val balue: E) : <!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>F<E><!>(balue)<!> {
class H<E : String>(val balue: E) : <!INAPPLICABLE_CANDIDATE!>F<E><!>(balue) {
override fun rest(): E = balue // no report because of INAPPLICABLE_CANDIDATE
}

View File

@@ -1,8 +1,8 @@
class A
class B : A
class B : <!SUPERTYPE_NOT_INITIALIZED!>A<!>
class C(x: Int)
<!INAPPLICABLE_CANDIDATE!>class D : C<!>
<!INAPPLICABLE_CANDIDATE!>class D : <!SUPERTYPE_NOT_INITIALIZED!>C<!><!>
class E : C(10)
class F() : C(10)

View File

@@ -22,8 +22,8 @@ FILE: upperBoundViolated.kt
lval b1: R|B<kotlin/Int>| = R|/B.B|<R|kotlin/Int|>()
lval b2: R|B<C>| = R|/B.B|<R|C|>()
lval b3: R|B<kotlin/Any?>| = R|/B.B|<R|kotlin/Any?|>()
lval b4: R|B<A>| = R|/B.B|<<ERROR TYPE REF: Symbol not found, for `UnexistingType`>>()
lval b5: R|B<B<ERROR CLASS: Symbol not found, for `UnexistingType`>>| = R|/B.B|<R|B<ERROR CLASS: Symbol not found, for `UnexistingType`>|>()
lval b4: R|B<A>| = R|/B.B|<<ERROR TYPE REF: Symbol not found for UnexistingType>>()
lval b5: R|B<B<ERROR CLASS: Symbol not found for UnexistingType>>| = R|/B.B|<R|B<ERROR CLASS: Symbol not found for UnexistingType>|>()
R|/fest|<R|kotlin/Boolean|>()
R|/fest|<R|C|>()
R|/fest|<R|C|>()

View File

@@ -26,11 +26,11 @@ enum class EnumClass {
override val bar: String = "a"
},
E2 {
<!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>E2<!> {
},
E3();
<!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>E3<!>();
abstract fun foo(): Int
abstract val bar: String

View File

@@ -2,7 +2,7 @@
sealed class Base
class A : Base
class A : <!SUPERTYPE_NOT_INITIALIZED!>Base<!>
// FILE: b.kt

View File

@@ -15,13 +15,13 @@ class CallBasedInExpressionGenerator(
operatorReference: KtSimpleNameExpression
) : InExpressionGenerator {
private val resolvedCall = operatorReference.<!UNRESOLVED_REFERENCE!>getResolvedCallWithAssert<!>(codegen.<!UNRESOLVED_REFERENCE!>bindingContext<!>)
private val isInverted = operatorReference.<!UNRESOLVED_REFERENCE!>getReferencedNameElementType<!>() == <!UNRESOLVED_REFERENCE!>KtTokens<!>.<!UNRESOLVED_REFERENCE!>NOT_IN<!>
private val isInverted = operatorReference.<!UNRESOLVED_REFERENCE!>getReferencedNameElementType<!>() == <!UNRESOLVED_REFERENCE!>KtTokens<!>.NOT_IN
override fun generate(argument: StackValue): BranchedValue =
gen(argument).let { if (isInverted) <!UNRESOLVED_REFERENCE!>Invert<!>(it) else it }
private fun gen(argument: StackValue): BranchedValue =
object : <!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>BranchedValue<!>(argument, null, argument.<!UNRESOLVED_REFERENCE!>type<!>, <!UNRESOLVED_REFERENCE!>Opcodes<!>.<!UNRESOLVED_REFERENCE!>IFEQ<!>)<!> {
object : <!INAPPLICABLE_CANDIDATE!>BranchedValue<!>(argument, null, argument.<!UNRESOLVED_REFERENCE!>type<!>, <!UNRESOLVED_REFERENCE!>Opcodes<!>.IFEQ) {
override fun putSelector(type: Type, kotlinType: KotlinType?, v: InstructionAdapter) {
invokeFunction(v)
<!UNRESOLVED_REFERENCE!>coerceTo<!>(type, kotlinType, v)
@@ -29,7 +29,7 @@ class CallBasedInExpressionGenerator(
override fun condJump(jumpLabel: Label, v: InstructionAdapter, jumpIfFalse: Boolean) {
invokeFunction(v)
v.<!UNRESOLVED_REFERENCE!>visitJumpInsn<!>(if (jumpIfFalse) <!UNRESOLVED_REFERENCE!>Opcodes<!>.<!UNRESOLVED_REFERENCE!>IFEQ<!> else <!UNRESOLVED_REFERENCE!>Opcodes<!>.<!UNRESOLVED_REFERENCE!>IFNE<!>, jumpLabel)
v.<!UNRESOLVED_REFERENCE!>visitJumpInsn<!>(if (jumpIfFalse) <!UNRESOLVED_REFERENCE!>Opcodes<!>.IFEQ else <!UNRESOLVED_REFERENCE!>Opcodes<!>.IFNE, jumpLabel)
}
private fun invokeFunction(v: InstructionAdapter) {

View File

@@ -21,7 +21,7 @@ class Bar {
}
// NB! abc() here is resolved to member Foo.abc(), and not to extension member of Bar
fun Foo.check() = <!NONE_APPLICABLE{LT}!>abc() <!NONE_APPLICABLE{PSI}!>+<!> bar()<!>
fun Foo.check() = abc() <!NONE_APPLICABLE!>+<!> bar()
// NB! + here is resolved to member String.plus (not to extension member above)
fun Foo.check2() = "" + bar()

View File

@@ -1,6 +1,6 @@
class A
open class B
class C : B
class C : <!SUPERTYPE_NOT_INITIALIZED!>B<!>
fun bar(a: A) = a

View File

@@ -4,10 +4,10 @@ class Your {
class My {
fun foo() {
val x = <!UNRESOLVED_REFERENCE!>::Nested<!> // Should be error
val x = ::<!UNRESOLVED_REFERENCE!>Nested<!> // Should be error
}
}
fun Your.foo() {
val x = <!UNRESOLVED_REFERENCE!>::Nested<!> // Still should be error
val x = ::<!UNRESOLVED_REFERENCE!>Nested<!> // Still should be error
}

View File

@@ -14,6 +14,6 @@ public abstract class Decorator<T extends LookupElement> extends LookupElement {
// FILE: test.kt
class MyDecorator : Decorator<LookupElement> {
class MyDecorator : <!SUPERTYPE_NOT_INITIALIZED!>Decorator<LookupElement><!> {
override fun getLookupString(): String = delegate.lookupString
}

View File

@@ -18,4 +18,4 @@ fun test() {
B.foo()
}
val bb = <!UNRESOLVED_REFERENCE!>B<!>.<!UNRESOLVED_REFERENCE!>foo<!>()
val bb = <!UNRESOLVED_REFERENCE!>B<!>.foo()

View File

@@ -6,5 +6,5 @@ object A {
object B
val err = B.<!UNRESOLVED_REFERENCE!>A<!>.<!UNRESOLVED_REFERENCE!>B<!>
val err = B.<!UNRESOLVED_REFERENCE!>A<!>.B
val correct = A.B.A

View File

@@ -7,7 +7,7 @@ class Foo {
fun test_1() {
val f = Foo()
<!UNRESOLVED_REFERENCE{LT}!>f <!UNRESOLVED_REFERENCE{PSI}!>+<!> f<!>
f <!UNRESOLVED_REFERENCE!>+<!> f
}
fun test_2() {

View File

@@ -1,3 +1,3 @@
FILE: fakeRecursiveTypealias.kt
public final typealias My = <ERROR TYPE REF: Symbol not found, for `incorrect.directory.My`>
public final typealias My = <ERROR TYPE REF: Symbol not found for incorrect.directory.My>
public final typealias Your = <ERROR TYPE REF: Loop in supertype: /Your -> /Your>

View File

@@ -14,6 +14,6 @@ class A {
<!VALUE_CLASS_CANNOT_BE_CLONEABLE!>inline<!> class CloneableClass2(val x: Int): java.lang.Cloneable
open class Test
inline class ExtendTest(val x: Int): <!INLINE_CLASS_CANNOT_EXTEND_CLASSES!>Test<!>
inline class ExtendTest(val x: Int): <!INLINE_CLASS_CANNOT_EXTEND_CLASSES, SUPERTYPE_NOT_INITIALIZED!>Test<!>
inline class ImplementByDelegation(val x: Int) : <!INLINE_CLASS_CANNOT_IMPLEMENT_INTERFACE_BY_DELEGATION!>Comparable<Int><!> by x

View File

@@ -28,7 +28,7 @@ FILE: main.kt
super<R|kotlin/Any|>()
}
public abstract fun createTest(): <ERROR TYPE REF: Symbol not found, for `Test`>
public abstract fun createTest(): <ERROR TYPE REF: Symbol not found for Test>
public abstract fun createObj(): R|test/Test.O|

View File

@@ -5,7 +5,7 @@ package test
sealed class Test {
object O : Test()
class Extra(val x: Int): Test
class Extra(val x: Int): <!SUPERTYPE_NOT_INITIALIZED!>Test<!>
}
// FILE: main.kt

View File

@@ -1,4 +1,4 @@
class Outer { inner class Inner }
fun test() {
val x = object : <!UNRESOLVED_REFERENCE{LT}!><!UNRESOLVED_REFERENCE{PSI}!>Outer.Inner<!>()<!> { }
val x = object : <!UNRESOLVED_REFERENCE!>Outer.Inner<!>() { }
}

View File

@@ -39,7 +39,7 @@ public class LightMember<D> : Member<D>, Light() {
override fun getName(): String = "Light"
}
public class LightClassWrapper : Light(), Klass {
public <!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>class LightClassWrapper<!> : Light(), Klass {
fun test() = typeParameters.single()
}

View File

@@ -17,8 +17,8 @@ class GenericTest {
}
fun test_2() {
val extensionValRef = <!UNRESOLVED_REFERENCE!>B<*>::extensionVal<!>
val extensionFunRef = <!UNRESOLVED_REFERENCE!>B<*>::extensionFun<!>
val extensionValRef = B<*>::<!UNRESOLVED_REFERENCE!>extensionVal<!>
val extensionFunRef = B<*>::<!UNRESOLVED_REFERENCE!>extensionFun<!>
}
}
@@ -36,8 +36,8 @@ class NoGenericTest {
fun B.extensionFun(): A = A()
fun test_1() {
val extensionValRef = B::extensionVal
val extensionFunRef = B::extensionFun
val extensionValRef = B::<!EXTENSION_IN_CLASS_REFERENCE_NOT_ALLOWED!>extensionVal<!>
val extensionFunRef = B::<!EXTENSION_IN_CLASS_REFERENCE_NOT_ALLOWED!>extensionFun<!>
}
fun test_2() {

View File

@@ -23,7 +23,7 @@ fun main() {
x <!UNRESOLVED_REFERENCE!>><!> 1
}
JavaUsage.<!INAPPLICABLE_CANDIDATE!>foo<!>({ <!UNRESOLVED_REFERENCE!>it<!> <!UNRESOLVED_REFERENCE!>><!> 1 })
JavaUsage.<!INAPPLICABLE_CANDIDATE!>foo<!>({ <!UNRESOLVED_REFERENCE!>it<!> > 1 })
val x = { x: Int -> x > 1 }

View File

@@ -6,5 +6,5 @@ sealed class WithPrivateConstructor private constructor(val x: Int) {
private constructor() : this(42)
}
object First : <!NONE_APPLICABLE{LT}!><!NONE_APPLICABLE{PSI}!>WithPrivateConstructor<!>()<!> // error
object Second : <!NONE_APPLICABLE{LT}!><!NONE_APPLICABLE{PSI}!>WithPrivateConstructor<!>(0)<!> // error
object First : <!NONE_APPLICABLE!>WithPrivateConstructor<!>() // error
object Second : <!NONE_APPLICABLE!>WithPrivateConstructor<!>(0) // error

View File

@@ -79,7 +79,7 @@ fun test_5(a: A, in1: In1<A>, in2: In1<in A>, in3: In1<out A>) {
fun test_6(a: A, out1: Out1<A>, out2: Out1<in A>, out3: Out1<out A>) {
out1.value().foo()
out2.<!UNRESOLVED_REFERENCE!>value<!>().<!UNRESOLVED_REFERENCE!>foo<!>()
out2.<!UNRESOLVED_REFERENCE!>value<!>().foo()
out3.value().foo()
}

View File

@@ -13,7 +13,7 @@ abstract class My<T : Some> {
abstract val z: <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>test.My.T<!>
class Some : <!UNRESOLVED_REFERENCE{LT}!><!SUPERTYPE_NOT_A_CLASS_OR_INTERFACE, UNRESOLVED_REFERENCE{PSI}!>T<!>()<!>
class Some : <!SUPERTYPE_NOT_A_CLASS_OR_INTERFACE, UNRESOLVED_REFERENCE!>T<!>()
}
abstract class Your<T : Some> : <!SUPERTYPE_NOT_A_CLASS_OR_INTERFACE!>T<!>

View File

@@ -92,7 +92,7 @@ FILE: exposedSupertype.kt
}
}
public final class Test7 : <ERROR TYPE REF: Symbol not found, for `D.PublicButProtected`> {
public final class Test7 : <ERROR TYPE REF: Symbol not found for D.PublicButProtected> {
public constructor(): R|Test7| {
super<R|kotlin/Any|>()
}

View File

@@ -28,7 +28,7 @@ private class C {
}
}
class D : A {
class D : <!SUPERTYPE_NOT_INITIALIZED!>A<!> {
class Test1 : A.AProtectedI {
}
@@ -38,11 +38,11 @@ interface E {
}
class Test2 : A.APublicI, <!UNRESOLVED_REFERENCE{LT}!><!UNRESOLVED_REFERENCE{PSI}!>B.BInner<!>()<!> {
class Test2 : A.APublicI, <!UNRESOLVED_REFERENCE!>B.BInner<!>() {
}
class Test3 : C.CPublicI, <!EXPOSED_SUPER_CLASS!>C<!> {
class Test3 : C.CPublicI, <!EXPOSED_SUPER_CLASS, SUPERTYPE_NOT_INITIALIZED!>C<!> {
}
@@ -50,11 +50,11 @@ class Test4 : E, A.AProtectedI {
}
class Test5 : C.CPublicI, <!UNRESOLVED_REFERENCE{LT}!><!UNRESOLVED_REFERENCE{PSI}!>B.BInner<!>()<!> {
class Test5 : C.CPublicI, <!UNRESOLVED_REFERENCE!>B.BInner<!>() {
}
class Test6 : E, <!EXPOSED_SUPER_CLASS!>C.CPublic<!> {
class Test6 : E, <!EXPOSED_SUPER_CLASS, SUPERTYPE_NOT_INITIALIZED!>C.CPublic<!> {
}

View File

@@ -2,12 +2,12 @@ class A {
private inner class Inner
}
class B {
typealias <!EXPOSED_TYPEALIAS_EXPANDED_TYPE!>AInner<!> = A.Inner
<!TOPLEVEL_TYPEALIASES_ONLY!>typealias <!EXPOSED_TYPEALIAS_EXPANDED_TYPE!>AInner<!> = A.Inner<!>
inner class Inner
}
class C {
typealias BInner = B.Inner
<!TOPLEVEL_TYPEALIASES_ONLY!>typealias BInner = B.Inner<!>
}
typealias <!EXPOSED_TYPEALIAS_EXPANDED_TYPE!>AInner0<!> = A.Inner
@@ -15,4 +15,4 @@ typealias BInner0 = B.Inner
private typealias MyString = String
fun foo(): MyString = ""
fun foo(): MyString = ""

View File

@@ -23,7 +23,7 @@ internal class Test4<T: B>
// valid, B is internal
private class Test5<T: B>
public class Container : C {
public class Container : <!SUPERTYPE_NOT_INITIALIZED!>C<!> {
// valid, D is protected in C
protected class Test6<T: C.D>

View File

@@ -19,5 +19,5 @@ abstract class A {
// FILE: main.kt
fun test(b: B): String {
return <!HIDDEN{LT}!>b <!HIDDEN{PSI}!>foo<!> "hello"<!> // should be an error
return b <!HIDDEN!>foo<!> "hello" // should be an error
}

View File

@@ -6,7 +6,7 @@ fun <T, R> foobaz(x: T): R = TODO()
fun foo() {
val x: (String) -> Int = ::bar
val y = <!UNRESOLVED_REFERENCE!>::bar<!>
val y = ::<!UNRESOLVED_REFERENCE!>bar<!>
val z = ::baz
val w: (String) -> Int = ::foobaz

View File

@@ -34,13 +34,13 @@ fun main() {
<!AMBIGUITY!>foo3<!>(KotlinClass::baz)
// Type mismatch
<!INAPPLICABLE_CANDIDATE!>foo1<!>(<!UNRESOLVED_REFERENCE!>KotlinClass::bar<!>)
<!INAPPLICABLE_CANDIDATE!>foo1<!>(KotlinClass::<!UNRESOLVED_REFERENCE!>bar<!>)
foo2(KotlinClass::bar)
foo3(KotlinClass::bar)
foo1(KotlinClass2::bar)
// Type mismatch
<!INAPPLICABLE_CANDIDATE!>foo2<!>(<!UNRESOLVED_REFERENCE!>KotlinClass2::bar<!>)
<!INAPPLICABLE_CANDIDATE!>foo2<!>(KotlinClass2::<!UNRESOLVED_REFERENCE!>bar<!>)
foo3(KotlinClass2::bar)
}

View File

@@ -4,5 +4,5 @@ fun foo(y: String) {}
fun <T> bar(f: (T) -> Unit) {}
fun test() {
bar(<!UNRESOLVED_REFERENCE!>::foo<!>)
bar(::<!UNRESOLVED_REFERENCE!>foo<!>)
}

View File

@@ -25,7 +25,7 @@ fun test() {
val t3 = bar(::baz)
bar(<!UNRESOLVED_REFERENCE!>::foo<!>)
bar(::<!UNRESOLVED_REFERENCE!>foo<!>)
}
}
}

View File

@@ -22,5 +22,5 @@ fun test() {
val a6 = foo(::singleA, ::singleB)
foo(<!UNRESOLVED_REFERENCE!>::multiple<!>, <!UNRESOLVED_REFERENCE!>::multiple<!>)
foo(::<!UNRESOLVED_REFERENCE!>multiple<!>, ::<!UNRESOLVED_REFERENCE!>multiple<!>)
}

View File

@@ -6,14 +6,14 @@ fun IB.extFun(x: IA) {}
fun test() {
val extFun1 = IA::extFun
val extFun2 = <!UNRESOLVED_REFERENCE!>IB::extFun<!>
val extFun2 = IB::<!UNRESOLVED_REFERENCE!>extFun<!>
}
fun testWithExpectedType() {
// NB: should be resolved to kotlin/FunctionX, not kotlin/reflect/FunctionX
val extFun_AB_A: IA.(IB) -> Unit = IA::extFun
val extFun_AA_B: IA.(IA) -> Unit = <!UNRESOLVED_REFERENCE!>IB::extFun<!>
val extFun_AA_B: IA.(IA) -> Unit = IB::<!UNRESOLVED_REFERENCE!>extFun<!>
val extFun_BB_A: IB.(IB) -> Unit = IA::extFun
val extFun_BA_B: IB.(IA) -> Unit = IB::extFun
val extFun_BB_B: IB.(IB) -> Unit = <!UNRESOLVED_REFERENCE!>IB::extFun<!>
val extFun_BB_B: IB.(IB) -> Unit = IB::<!UNRESOLVED_REFERENCE!>extFun<!>
}

View File

@@ -7,6 +7,6 @@ fun <T> bar(f: (T) -> Unit, e: T) {}
fun <T> baz(e: T, f: (T) -> Unit) {}
fun test(a: A, b: B) {
<!INAPPLICABLE_CANDIDATE!>baz<!>(a, <!UNRESOLVED_REFERENCE!>::fooB<!>)
<!INAPPLICABLE_CANDIDATE!>bar<!>(<!UNRESOLVED_REFERENCE!>::fooB<!>, a)
<!INAPPLICABLE_CANDIDATE!>baz<!>(a, ::<!UNRESOLVED_REFERENCE!>fooB<!>)
<!INAPPLICABLE_CANDIDATE!>bar<!>(::<!UNRESOLVED_REFERENCE!>fooB<!>, a)
}

View File

@@ -3,5 +3,5 @@ fun <T, R> use(x: (T) -> R): (T) -> R = x
fun foo() = use(::bar)
fun bar(x: String) = 1
fun loop1() = <!INAPPLICABLE_CANDIDATE!>use<!>(<!UNRESOLVED_REFERENCE!>::loop2<!>)
fun loop1() = <!INAPPLICABLE_CANDIDATE!>use<!>(::<!UNRESOLVED_REFERENCE!>loop2<!>)
fun loop2() = loop1()

View File

@@ -6,5 +6,5 @@ fun bar(): Int = 1
fun bar(x: String): Int = 1
fun main() {
<!AMBIGUITY!>foo<!>(<!UNRESOLVED_REFERENCE!>::bar<!>)
<!AMBIGUITY!>foo<!>(::<!UNRESOLVED_REFERENCE!>bar<!>)
}

View File

@@ -1,4 +1,4 @@
FILE: fillInStackTrace.kt
public final fun test(t: R|kotlin/Throwable|): R|kotlin/Unit| {
R|<local>/t|.R|java/lang/Throwable.fillInStackTrace|()
R|<local>/t|.R|kotlin/Throwable.fillInStackTrace|()
}

View File

@@ -6,17 +6,17 @@ FILE: test.kt
}
public final fun test(e: R|MyException|, stream: R|java/io/PrintStream|): R|kotlin/Unit| {
R|<local>/e|.R|java/lang/Throwable.printStackTrace|()
R|<local>/e|.R|java/lang/Throwable.printStackTrace|(R|<local>/stream|)
lval result: R|ft<kotlin/String, kotlin/String?>| = R|<local>/e|.R|java/lang/Throwable.getLocalizedMessage|()
R|<local>/e|.R|kotlin/Throwable.printStackTrace|()
R|<local>/e|.R|kotlin/Throwable.printStackTrace|(R|<local>/stream|)
lval result: R|ft<kotlin/String, kotlin/String?>| = R|<local>/e|.R|kotlin/Throwable.getLocalizedMessage|()
}
public final fun test(e: R|YourException|, stream: R|java/io/PrintStream|): R|kotlin/Unit| {
R|<local>/e|.R|java/lang/Throwable.printStackTrace|()
R|<local>/e|.R|java/lang/Throwable.printStackTrace|(R|<local>/stream|)
lval result: R|ft<kotlin/String, kotlin/String?>| = R|<local>/e|.R|java/lang/Throwable.getLocalizedMessage|()
R|<local>/e|.R|kotlin/Throwable.printStackTrace|()
R|<local>/e|.R|kotlin/Throwable.printStackTrace|(R|<local>/stream|)
lval result: R|ft<kotlin/String, kotlin/String?>| = R|<local>/e|.R|kotlin/Throwable.getLocalizedMessage|()
}
public final fun test(e: R|kotlin/Exception|, stream: R|java/io/PrintStream|): R|kotlin/Unit| {
R|<local>/e|.R|java/lang/Throwable.printStackTrace|()
R|<local>/e|.R|java/lang/Throwable.printStackTrace|(R|<local>/stream|)
lval result: R|ft<kotlin/String, kotlin/String?>| = R|<local>/e|.R|java/lang/Throwable.getLocalizedMessage|()
R|<local>/e|.R|kotlin/Throwable.printStackTrace|()
R|<local>/e|.R|kotlin/Throwable.printStackTrace|(R|<local>/stream|)
lval result: R|ft<kotlin/String, kotlin/String?>| = R|<local>/e|.R|kotlin/Throwable.getLocalizedMessage|()
}

View File

@@ -4,9 +4,9 @@ FILE: K1.kt
super<R|J1|>()
}
public final class Q : <ERROR TYPE REF: Symbol not found, for `Nested`> {
public final class Q : <ERROR TYPE REF: Symbol not found for Nested> {
public constructor(): R|K2.Q| {
super<<ERROR TYPE REF: Symbol not found, for `Nested`>>()
super<<ERROR TYPE REF: Symbol not found for Nested>>()
}
}

View File

@@ -0,0 +1,27 @@
FILE: lightMember.kt
public abstract interface PsiMember : R|kotlin/Any| {
}
public abstract interface PsiField : R|PsiMember| {
}
public abstract class LightMemberImpl<out D : R|PsiMember|> : R|kotlin/Any| {
public constructor<out D : R|PsiMember|>(computeRealDelegate: R|() -> D|): R|LightMemberImpl<D>| {
super<R|kotlin/Any|>()
}
public open val delegate: R|D|by R|kotlin/lazy|<R|D|>(R|<local>/computeRealDelegate|)
public get(): R|D| {
^ this@R|/LightMemberImpl|.D|/LightMemberImpl.delegate|.R|kotlin/getValue|<R|D|>(this@R|/LightMemberImpl|, ::R|/LightMemberImpl.delegate|)
}
}
public abstract class LightFieldImpl<D : R|PsiField|> : R|LightMemberImpl<PsiField>| {
public constructor<D : R|PsiField|>(computeRealDelegate: R|() -> D|): R|LightFieldImpl<D>| {
super<R|LightMemberImpl<PsiField>|>(R|<local>/computeRealDelegate|)
}
public open override val delegate: R|D|
public get(): R|D| {
^ this@R|/LightFieldImpl|.super<R|LightMemberImpl<PsiField>|>.R|SubstitutionOverride</LightMemberImpl.delegate: R|PsiField|>|
}
}

View File

@@ -0,0 +1,12 @@
interface PsiMember
interface PsiField : PsiMember
abstract class LightMemberImpl<out D : PsiMember>(computeRealDelegate: () -> D) {
open val delegate by lazy(computeRealDelegate)
}
abstract class LightFieldImpl<D : PsiField>(computeRealDelegate: () -> D) : LightMemberImpl<PsiField>(computeRealDelegate) {
override val delegate: D
get() = super.delegate
}

View File

@@ -1062,6 +1062,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
public void testConstValNotTopLevelOrObject() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/constVal/constValNotTopLevelOrObject.kt");
}
@Test
@TestMetadata("constValWithGetterOrDelegate.kt")
public void testConstValWithGetterOrDelegate() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/constVal/constValWithGetterOrDelegate.kt");
}
}
@Nested
@@ -5145,6 +5151,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/KJKComplexHierarchyNestedLoop.kt");
}
@Test
@TestMetadata("lightMember.kt")
public void testLightMember() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/lightMember.kt");
}
@Test
@TestMetadata("qualifierPriority.kt")
public void testQualifierPriority() throws Exception {

View File

@@ -1071,6 +1071,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
public void testConstValNotTopLevelOrObject() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/constVal/constValNotTopLevelOrObject.kt");
}
@Test
@TestMetadata("constValWithGetterOrDelegate.kt")
public void testConstValWithGetterOrDelegate() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/constVal/constValWithGetterOrDelegate.kt");
}
}
@Nested
@@ -5219,6 +5225,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/KJKComplexHierarchyNestedLoop.kt");
}
@Test
@TestMetadata("lightMember.kt")
public void testLightMember() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/lightMember.kt");
}
@Test
@TestMetadata("qualifierPriority.kt")
public void testQualifierPriority() throws Exception {

View File

@@ -2968,6 +2968,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/callableReference/property"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Test
@TestMetadata("backingField.kt")
public void testBackingField() throws Exception {
runTest("compiler/testData/diagnostics/tests/callableReference/property/backingField.kt");
}
@Test
@TestMetadata("classFromClass.kt")
public void testClassFromClass() throws Exception {
@@ -11759,6 +11765,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/tests/inference/capturedInProjectedFlexibleType.kt");
}
@Test
@TestMetadata("capturedTypesInSelfType.kt")
public void testCapturedTypesInSelfType() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/capturedTypesInSelfType.kt");
}
@Test
@TestMetadata("coerceFunctionLiteralToSuspend.kt")
public void testCoerceFunctionLiteralToSuspend() throws Exception {
@@ -12185,6 +12197,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/tests/inference/nullableUpperBound.kt");
}
@Test
@TestMetadata("onlyInputTypesWithMultilevelIncorporation.kt")
public void testOnlyInputTypesWithMultilevelIncorporation() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/onlyInputTypesWithMultilevelIncorporation.kt");
}
@Test
@TestMetadata("opposite.kt")
public void testOpposite() throws Exception {
@@ -18281,6 +18299,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
public void testExpectActualInlineClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/inlineClasses/expectActualInlineClass.kt");
}
@Test
@TestMetadata("jvmInlineExpectValueClass.kt")
public void testJvmInlineExpectValueClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/inlineClasses/jvmInlineExpectValueClass.kt");
}
}
@Nested

View File

@@ -46,9 +46,11 @@ enum class PositioningStrategy(private val strategy: String? = null) {
INNER_MODIFIER,
SELECTOR_BY_QUALIFIED,
REFERENCE_BY_QUALIFIED,
REFERENCED_NAME_BY_QUALIFIED,
PRIVATE_MODIFIER,
COMPANION_OBJECT,
CONST_MODIFIER,
ARRAY_ACCESS
;

View File

@@ -7,10 +7,11 @@ package org.jetbrains.kotlin.fir.checkers.generator.diagnostics
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiTypeElement
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.contracts.description.EventOccurrencesRange
import org.jetbrains.kotlin.descriptors.Visibility
import org.jetbrains.kotlin.diagnostics.WhenMissingCase
import org.jetbrains.kotlin.resolve.ForbiddenNamedArgumentsTarget
import org.jetbrains.kotlin.fir.FirEffectiveVisibility
import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.PrivateForInline
@@ -26,11 +27,23 @@ import org.jetbrains.kotlin.fir.types.ConeKotlinType
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.ForbiddenNamedArgumentsTarget
import kotlin.properties.PropertyDelegateProvider
import kotlin.properties.ReadOnlyProperty
@Suppress("UNUSED_VARIABLE", "LocalVariableName", "ClassName", "unused")
@OptIn(PrivateForInline::class)
object DIAGNOSTICS_LIST : DiagnosticList() {
val MetaErrors by object : DiagnosticGroup("Meta-errors") {
val UNSUPPORTED by error<FirSourceElement, PsiElement> {
parameter<String>("unsupported")
}
val UNSUPPORTED_FEATURE by error<FirSourceElement, PsiElement> {
parameter<Pair<LanguageFeature, LanguageVersionSettings>>("unsupportedFeature")
}
}
val Miscellaneous by object : DiagnosticGroup("Miscellaneous") {
val SYNTAX by error<FirSourceElement, PsiElement>()
val OTHER_ERROR by error<FirSourceElement, PsiElement>()
@@ -54,7 +67,7 @@ object DIAGNOSTICS_LIST : DiagnosticList() {
val HIDDEN by error<FirSourceElement, PsiElement>(PositioningStrategy.REFERENCE_BY_QUALIFIED) {
parameter<AbstractFirBasedSymbol<*>>("hidden")
}
val UNRESOLVED_REFERENCE by error<FirSourceElement, PsiElement>(PositioningStrategy.REFERENCE_BY_QUALIFIED) {
val UNRESOLVED_REFERENCE by error<FirSourceElement, PsiElement>(PositioningStrategy.REFERENCED_NAME_BY_QUALIFIED) {
parameter<String>("reference")
}
val UNRESOLVED_LABEL by error<FirSourceElement, PsiElement>()
@@ -66,16 +79,15 @@ object DIAGNOSTICS_LIST : DiagnosticList() {
}
val SUPER by object : DiagnosticGroup("Super") {
val SUPER_IS_NOT_AN_EXPRESSION by error<FirSourceElement, PsiElement>()
val SUPER_NOT_AVAILABLE by error<FirSourceElement, PsiElement>()
val ABSTRACT_SUPER_CALL by error<FirSourceElement, PsiElement>(PositioningStrategy.REFERENCE_BY_QUALIFIED)
val SUPER_IS_NOT_AN_EXPRESSION by error<FirSourceElement, PsiElement>(PositioningStrategy.REFERENCED_NAME_BY_QUALIFIED)
val SUPER_NOT_AVAILABLE by error<FirSourceElement, PsiElement>(PositioningStrategy.REFERENCED_NAME_BY_QUALIFIED)
val ABSTRACT_SUPER_CALL by error<FirSourceElement, PsiElement>(PositioningStrategy.REFERENCED_NAME_BY_QUALIFIED)
val INSTANCE_ACCESS_BEFORE_SUPER_CALL by error<FirSourceElement, PsiElement> {
parameter<String>("target")
}
}
val SUPERTYPES by object : DiagnosticGroup("Supertypes") {
val TYPE_PARAMETER_AS_SUPERTYPE by error<FirSourceElement, PsiElement>()
val ENUM_AS_SUPERTYPE by error<FirSourceElement, PsiElement>()
val RECURSION_IN_SUPERTYPES by error<FirSourceElement, PsiElement>()
val NOT_A_SUPERTYPE by error<FirSourceElement, PsiElement>()
@@ -100,10 +112,13 @@ object DIAGNOSTICS_LIST : DiagnosticList() {
val NON_PRIVATE_OR_PROTECTED_CONSTRUCTOR_IN_SEALED by error<FirSourceElement, PsiElement>()
val CYCLIC_CONSTRUCTOR_DELEGATION_CALL by warning<FirSourceElement, PsiElement>()
val PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED by warning<FirSourceElement, PsiElement>(PositioningStrategy.SECONDARY_CONSTRUCTOR_DELEGATION_CALL)
val SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR by warning<FirSourceElement, PsiElement>()
// TODO: change it to KtSuperTypeEntry when possible (after re-targeter implementation)
val SUPERTYPE_NOT_INITIALIZED by error<FirSourceElement, KtTypeReference>()
val SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR by error<FirSourceElement, PsiElement>()
val DELEGATION_SUPER_CALL_IN_ENUM_CONSTRUCTOR by warning<FirSourceElement, PsiElement>()
val PRIMARY_CONSTRUCTOR_REQUIRED_FOR_DATA_CLASS by error<FirSourceElement, KtNamedDeclaration>(PositioningStrategy.DECLARATION_NAME)
val EXPLICIT_DELEGATION_CALL_REQUIRED by warning<FirSourceElement, PsiElement>(PositioningStrategy.SECONDARY_CONSTRUCTOR_DELEGATION_CALL)
val EXPLICIT_DELEGATION_CALL_REQUIRED by error<FirSourceElement, PsiElement>(PositioningStrategy.SECONDARY_CONSTRUCTOR_DELEGATION_CALL)
val SEALED_CLASS_CONSTRUCTOR_CALL by error<FirSourceElement, PsiElement>()
// TODO: Consider creating a parameter list position strategy and report on the parameter list instead
@@ -133,9 +148,9 @@ object DIAGNOSTICS_LIST : DiagnosticList() {
val EXPOSED_VISIBILITY by object : DiagnosticGroup("Exposed visibility") {
val EXPOSED_TYPEALIAS_EXPANDED_TYPE by exposedVisibilityError<KtNamedDeclaration>(PositioningStrategy.DECLARATION_NAME)
val EXPOSED_FUNCTION_RETURN_TYPE by exposedVisibilityError<KtNamedDeclaration>(PositioningStrategy.DECLARATION_NAME)
val EXPOSED_RECEIVER_TYPE by exposedVisibilityError<KtTypeReference>()
val EXPOSED_PROPERTY_TYPE by exposedVisibilityError<KtNamedDeclaration>(PositioningStrategy.DECLARATION_NAME)
val EXPOSED_PROPERTY_TYPE_IN_CONSTRUCTOR by exposedVisibilityWarning<KtNamedDeclaration>(PositioningStrategy.DECLARATION_NAME)
val EXPOSED_PARAMETER_TYPE by exposedVisibilityError<KtParameter>(/* // NB: for parameter FE 1.0 reports not on a name for some reason */)
val EXPOSED_SUPER_INTERFACE by exposedVisibilityError<KtTypeReference>()
val EXPOSED_SUPER_CLASS by exposedVisibilityError<KtTypeReference>()
@@ -259,7 +274,11 @@ object DIAGNOSTICS_LIST : DiagnosticList() {
}
val REFLECTION by object : DiagnosticGroup("Reflection") {
val EXTENSION_IN_CLASS_REFERENCE_NOT_ALLOWED by error<FirSourceElement, KtExpression>(PositioningStrategy.REFERENCE_BY_QUALIFIED) {
parameter<FirCallableDeclaration<*>>("referencedDeclaration")
}
val CALLABLE_REFERENCE_LHS_NOT_A_CLASS by error<FirSourceElement, KtExpression>()
val CALLABLE_REFERENCE_TO_ANNOTATION_CONSTRUCTOR by error<FirSourceElement, KtExpression>(PositioningStrategy.REFERENCE_BY_QUALIFIED)
val CLASS_LITERAL_LHS_NOT_A_CLASS by error<FirSourceElement, KtExpression>()
val NULLABLE_TYPE_IN_CLASS_LITERAL_LHS by error<FirSourceElement, KtExpression>()
@@ -289,6 +308,31 @@ object DIAGNOSTICS_LIST : DiagnosticList() {
parameter<Name>("containingClassName")
}
val ABSTRACT_MEMBER_NOT_IMPLEMENTED by error<FirSourceElement, KtClassOrObject>(PositioningStrategy.DECLARATION_NAME) {
parameter<FirClass<*>>("classOrObject")
parameter<FirCallableDeclaration<*>>("missingDeclaration")
}
val ABSTRACT_CLASS_MEMBER_NOT_IMPLEMENTED by error<FirSourceElement, KtClassOrObject>(PositioningStrategy.DECLARATION_NAME) {
parameter<FirClass<*>>("classOrObject")
parameter<FirCallableDeclaration<*>>("missingDeclaration")
}
val INVISIBLE_ABSTRACT_MEMBER_FROM_SUPER by error<FirSourceElement, KtClassOrObject>(PositioningStrategy.DECLARATION_NAME) {
parameter<FirClass<*>>("classOrObject")
parameter<FirCallableDeclaration<*>>("invisibleDeclaration")
}
val INVISIBLE_ABSTRACT_MEMBER_FROM_SUPER_WARNING by warning<FirSourceElement, KtClassOrObject>(PositioningStrategy.DECLARATION_NAME) {
parameter<FirClass<*>>("classOrObject")
parameter<FirCallableDeclaration<*>>("invisibleDeclaration")
}
val MANY_IMPL_MEMBER_NOT_IMPLEMENTED by error<FirSourceElement, KtClassOrObject>(PositioningStrategy.DECLARATION_NAME) {
parameter<FirClass<*>>("classOrObject")
parameter<FirCallableDeclaration<*>>("missingDeclaration")
}
val MANY_INTERFACES_MEMBER_NOT_IMPLEMENTED by error<FirSourceElement, KtClassOrObject>(PositioningStrategy.DECLARATION_NAME) {
parameter<FirClass<*>>("classOrObject")
parameter<FirCallableDeclaration<*>>("missingDeclaration")
}
val RETURN_TYPE_MISMATCH_ON_OVERRIDE by error<FirSourceElement, KtNamedDeclaration>(PositioningStrategy.DECLARATION_RETURN_TYPE) {
parameter<FirMemberDeclaration>("function")
parameter<FirMemberDeclaration>("superFunction")
@@ -317,7 +361,7 @@ object DIAGNOSTICS_LIST : DiagnosticList() {
val REDECLARATION by error<FirSourceElement, PsiElement>() {
parameter<Collection<AbstractFirBasedSymbol<*>>>("conflictingDeclarations")
}
val ANY_METHOD_IMPLEMENTED_IN_INTERFACE by error<FirSourceElement, PsiElement>()
val METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE by error<FirSourceElement, PsiElement>()
}
val INVALID_LOCAL_DECLARATIONS by object : DiagnosticGroup("Invalid local declarations") {
@@ -391,6 +435,8 @@ object DIAGNOSTICS_LIST : DiagnosticList() {
val EXPECTED_PRIVATE_DECLARATION by error<FirSourceElement, KtModifierListOwner>(PositioningStrategy.VISIBILITY_MODIFIER)
val VAL_WITH_SETTER by error<FirSourceElement, KtPropertyAccessor>()
val CONST_VAL_NOT_TOP_LEVEL_OR_OBJECT by error<FirSourceElement, KtProperty>(PositioningStrategy.CONST_MODIFIER)
val CONST_VAL_WITH_GETTER by error<FirSourceElement, KtProperty>()
val CONST_VAL_WITH_DELEGATE by error<FirSourceElement, KtPropertyDelegate>()
}
val MPP_PROJECTS by object : DiagnosticGroup("Multi-platform projects") {
@@ -451,12 +497,12 @@ object DIAGNOSTICS_LIST : DiagnosticList() {
val UNSAFE_IMPLICIT_INVOKE_CALL by error<FirSourceElement, PsiElement>(PositioningStrategy.REFERENCE_BY_QUALIFIED) {
parameter<ConeKotlinType>("receiverType")
}
val UNSAFE_INFIX_CALL by error<FirSourceElement, KtExpression> {
val UNSAFE_INFIX_CALL by error<FirSourceElement, KtExpression>(PositioningStrategy.REFERENCE_BY_QUALIFIED) {
parameter<FirExpression>("lhs")
parameter<String>("operator")
parameter<FirExpression>("rhs")
}
val UNSAFE_OPERATOR_CALL by error<FirSourceElement, KtExpression> {
val UNSAFE_OPERATOR_CALL by error<FirSourceElement, KtExpression>(PositioningStrategy.REFERENCE_BY_QUALIFIED) {
parameter<FirExpression>("lhs")
parameter<String>("operator")
parameter<FirExpression>("rhs")
@@ -486,6 +532,15 @@ object DIAGNOSTICS_LIST : DiagnosticList() {
}
}
val CONVENTIONS by object : DiagnosticGroup("Conventions") {
val NO_GET_METHOD by error<FirSourceElement, KtArrayAccessExpression>(PositioningStrategy.ARRAY_ACCESS)
val NO_SET_METHOD by error<FirSourceElement, KtArrayAccessExpression>(PositioningStrategy.ARRAY_ACCESS)
}
val TYPE_ALIAS by object : DiagnosticGroup("Type alias") {
val TOPLEVEL_TYPEALIASES_ONLY by error<FirSourceElement, KtTypeAlias>()
}
val EXTENDED_CHECKERS by object : DiagnosticGroup("Extended checkers") {
val REDUNDANT_VISIBILITY_MODIFIER by warning<FirSourceElement, KtModifierListOwner>(PositioningStrategy.VISIBILITY_MODIFIER)
val REDUNDANT_MODALITY_MODIFIER by warning<FirSourceElement, KtModifierListOwner>(PositioningStrategy.MODALITY_MODIFIER)
@@ -506,10 +561,20 @@ object DIAGNOSTICS_LIST : DiagnosticList() {
}
}
private inline fun <reified P : PsiElement> DiagnosticGroup.exposedVisibilityError(
positioningStrategy: PositioningStrategy = PositioningStrategy.DEFAULT
) = error<FirSourceElement, P>(positioningStrategy) {
private val exposedVisibilityDiagnosticInit: DiagnosticBuilder.() -> Unit = {
parameter<FirEffectiveVisibility>("elementVisibility")
parameter<FirMemberDeclaration>("restrictingDeclaration")
parameter<FirEffectiveVisibility>("restrictingVisibility")
}
private inline fun <reified P : PsiElement> DiagnosticGroup.exposedVisibilityError(
positioningStrategy: PositioningStrategy = PositioningStrategy.DEFAULT
): PropertyDelegateProvider<Any?, ReadOnlyProperty<DiagnosticGroup, DiagnosticData>> {
return error<FirSourceElement, P>(positioningStrategy, exposedVisibilityDiagnosticInit)
}
private inline fun <reified P : PsiElement> DiagnosticGroup.exposedVisibilityWarning(
positioningStrategy: PositioningStrategy = PositioningStrategy.DEFAULT
): PropertyDelegateProvider<Any?, ReadOnlyProperty<DiagnosticGroup, DiagnosticData>> {
return warning<FirSourceElement, P>(positioningStrategy, exposedVisibilityDiagnosticInit)
}

View File

@@ -7,6 +7,8 @@ package org.jetbrains.kotlin.fir.analysis.diagnostics
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiTypeElement
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.contracts.description.EventOccurrencesRange
import org.jetbrains.kotlin.descriptors.Visibility
import org.jetbrains.kotlin.diagnostics.WhenMissingCase
@@ -24,6 +26,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
import org.jetbrains.kotlin.fir.types.ConeKotlinType
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.KtArrayAccessExpression
import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.psi.KtDestructuringDeclaration
@@ -40,6 +43,7 @@ import org.jetbrains.kotlin.psi.KtProperty
import org.jetbrains.kotlin.psi.KtPropertyAccessor
import org.jetbrains.kotlin.psi.KtPropertyDelegate
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
import org.jetbrains.kotlin.psi.KtTypeAlias
import org.jetbrains.kotlin.psi.KtTypeParameter
import org.jetbrains.kotlin.psi.KtTypeParameterList
import org.jetbrains.kotlin.psi.KtTypeReference
@@ -52,6 +56,10 @@ import org.jetbrains.kotlin.resolve.ForbiddenNamedArgumentsTarget
*/
object FirErrors {
// Meta-errors
val UNSUPPORTED by error1<FirSourceElement, PsiElement, String>()
val UNSUPPORTED_FEATURE by error1<FirSourceElement, PsiElement, Pair<LanguageFeature, LanguageVersionSettings>>()
// Miscellaneous
val SYNTAX by error0<FirSourceElement, PsiElement>()
val OTHER_ERROR by error0<FirSourceElement, PsiElement>()
@@ -69,7 +77,7 @@ object FirErrors {
// Unresolved
val HIDDEN by error1<FirSourceElement, PsiElement, AbstractFirBasedSymbol<*>>(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED)
val UNRESOLVED_REFERENCE by error1<FirSourceElement, PsiElement, String>(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED)
val UNRESOLVED_REFERENCE by error1<FirSourceElement, PsiElement, String>(SourceElementPositioningStrategies.REFERENCED_NAME_BY_QUALIFIED)
val UNRESOLVED_LABEL by error0<FirSourceElement, PsiElement>()
val DESERIALIZATION_ERROR by error0<FirSourceElement, PsiElement>()
val ERROR_FROM_JAVA_RESOLUTION by error0<FirSourceElement, PsiElement>()
@@ -78,13 +86,12 @@ object FirErrors {
val NO_THIS by error0<FirSourceElement, PsiElement>()
// Super
val SUPER_IS_NOT_AN_EXPRESSION by error0<FirSourceElement, PsiElement>()
val SUPER_NOT_AVAILABLE by error0<FirSourceElement, PsiElement>()
val ABSTRACT_SUPER_CALL by error0<FirSourceElement, PsiElement>(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED)
val SUPER_IS_NOT_AN_EXPRESSION by error0<FirSourceElement, PsiElement>(SourceElementPositioningStrategies.REFERENCED_NAME_BY_QUALIFIED)
val SUPER_NOT_AVAILABLE by error0<FirSourceElement, PsiElement>(SourceElementPositioningStrategies.REFERENCED_NAME_BY_QUALIFIED)
val ABSTRACT_SUPER_CALL by error0<FirSourceElement, PsiElement>(SourceElementPositioningStrategies.REFERENCED_NAME_BY_QUALIFIED)
val INSTANCE_ACCESS_BEFORE_SUPER_CALL by error1<FirSourceElement, PsiElement, String>()
// Supertypes
val TYPE_PARAMETER_AS_SUPERTYPE by error0<FirSourceElement, PsiElement>()
val ENUM_AS_SUPERTYPE by error0<FirSourceElement, PsiElement>()
val RECURSION_IN_SUPERTYPES by error0<FirSourceElement, PsiElement>()
val NOT_A_SUPERTYPE by error0<FirSourceElement, PsiElement>()
@@ -104,10 +111,11 @@ object FirErrors {
val NON_PRIVATE_OR_PROTECTED_CONSTRUCTOR_IN_SEALED by error0<FirSourceElement, PsiElement>()
val CYCLIC_CONSTRUCTOR_DELEGATION_CALL by warning0<FirSourceElement, PsiElement>()
val PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED by warning0<FirSourceElement, PsiElement>(SourceElementPositioningStrategies.SECONDARY_CONSTRUCTOR_DELEGATION_CALL)
val SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR by warning0<FirSourceElement, PsiElement>()
val SUPERTYPE_NOT_INITIALIZED by error0<FirSourceElement, KtTypeReference>()
val SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR by error0<FirSourceElement, PsiElement>()
val DELEGATION_SUPER_CALL_IN_ENUM_CONSTRUCTOR by warning0<FirSourceElement, PsiElement>()
val PRIMARY_CONSTRUCTOR_REQUIRED_FOR_DATA_CLASS by error0<FirSourceElement, KtNamedDeclaration>(SourceElementPositioningStrategies.DECLARATION_NAME)
val EXPLICIT_DELEGATION_CALL_REQUIRED by warning0<FirSourceElement, PsiElement>(SourceElementPositioningStrategies.SECONDARY_CONSTRUCTOR_DELEGATION_CALL)
val EXPLICIT_DELEGATION_CALL_REQUIRED by error0<FirSourceElement, PsiElement>(SourceElementPositioningStrategies.SECONDARY_CONSTRUCTOR_DELEGATION_CALL)
val SEALED_CLASS_CONSTRUCTOR_CALL by error0<FirSourceElement, PsiElement>()
val DATA_CLASS_WITHOUT_PARAMETERS by error0<FirSourceElement, KtPrimaryConstructor>()
val DATA_CLASS_VARARG_PARAMETER by error0<FirSourceElement, KtParameter>()
@@ -133,6 +141,7 @@ object FirErrors {
val EXPOSED_FUNCTION_RETURN_TYPE by error3<FirSourceElement, KtNamedDeclaration, FirEffectiveVisibility, FirMemberDeclaration, FirEffectiveVisibility>(SourceElementPositioningStrategies.DECLARATION_NAME)
val EXPOSED_RECEIVER_TYPE by error3<FirSourceElement, KtTypeReference, FirEffectiveVisibility, FirMemberDeclaration, FirEffectiveVisibility>()
val EXPOSED_PROPERTY_TYPE by error3<FirSourceElement, KtNamedDeclaration, FirEffectiveVisibility, FirMemberDeclaration, FirEffectiveVisibility>(SourceElementPositioningStrategies.DECLARATION_NAME)
val EXPOSED_PROPERTY_TYPE_IN_CONSTRUCTOR by warning3<FirSourceElement, KtNamedDeclaration, FirEffectiveVisibility, FirMemberDeclaration, FirEffectiveVisibility>(SourceElementPositioningStrategies.DECLARATION_NAME)
val EXPOSED_PARAMETER_TYPE by error3<FirSourceElement, KtParameter, FirEffectiveVisibility, FirMemberDeclaration, FirEffectiveVisibility>()
val EXPOSED_SUPER_INTERFACE by error3<FirSourceElement, KtTypeReference, FirEffectiveVisibility, FirMemberDeclaration, FirEffectiveVisibility>()
val EXPOSED_SUPER_CLASS by error3<FirSourceElement, KtTypeReference, FirEffectiveVisibility, FirMemberDeclaration, FirEffectiveVisibility>()
@@ -197,7 +206,9 @@ object FirErrors {
val TYPE_PARAMETER_AS_REIFIED by error1<FirSourceElement, PsiElement, FirTypeParameterSymbol>()
// Reflection
val EXTENSION_IN_CLASS_REFERENCE_NOT_ALLOWED by error1<FirSourceElement, KtExpression, FirCallableDeclaration<*>>(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED)
val CALLABLE_REFERENCE_LHS_NOT_A_CLASS by error0<FirSourceElement, KtExpression>()
val CALLABLE_REFERENCE_TO_ANNOTATION_CONSTRUCTOR by error0<FirSourceElement, KtExpression>(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED)
val CLASS_LITERAL_LHS_NOT_A_CLASS by error0<FirSourceElement, KtExpression>()
val NULLABLE_TYPE_IN_CLASS_LITERAL_LHS by error0<FirSourceElement, KtExpression>()
val EXPRESSION_OF_NULLABLE_TYPE_IN_CLASS_LITERAL_LHS by error1<FirSourceElement, PsiElement, ConeKotlinType>()
@@ -207,6 +218,12 @@ object FirErrors {
val CANNOT_WEAKEN_ACCESS_PRIVILEGE by error3<FirSourceElement, KtModifierListOwner, Visibility, FirCallableDeclaration<*>, Name>(SourceElementPositioningStrategies.VISIBILITY_MODIFIER)
val CANNOT_CHANGE_ACCESS_PRIVILEGE by error3<FirSourceElement, KtModifierListOwner, Visibility, FirCallableDeclaration<*>, Name>(SourceElementPositioningStrategies.VISIBILITY_MODIFIER)
val OVERRIDING_FINAL_MEMBER by error2<FirSourceElement, KtNamedDeclaration, FirCallableDeclaration<*>, Name>(SourceElementPositioningStrategies.OVERRIDE_MODIFIER)
val ABSTRACT_MEMBER_NOT_IMPLEMENTED by error2<FirSourceElement, KtClassOrObject, FirClass<*>, FirCallableDeclaration<*>>(SourceElementPositioningStrategies.DECLARATION_NAME)
val ABSTRACT_CLASS_MEMBER_NOT_IMPLEMENTED by error2<FirSourceElement, KtClassOrObject, FirClass<*>, FirCallableDeclaration<*>>(SourceElementPositioningStrategies.DECLARATION_NAME)
val INVISIBLE_ABSTRACT_MEMBER_FROM_SUPER by error2<FirSourceElement, KtClassOrObject, FirClass<*>, FirCallableDeclaration<*>>(SourceElementPositioningStrategies.DECLARATION_NAME)
val INVISIBLE_ABSTRACT_MEMBER_FROM_SUPER_WARNING by warning2<FirSourceElement, KtClassOrObject, FirClass<*>, FirCallableDeclaration<*>>(SourceElementPositioningStrategies.DECLARATION_NAME)
val MANY_IMPL_MEMBER_NOT_IMPLEMENTED by error2<FirSourceElement, KtClassOrObject, FirClass<*>, FirCallableDeclaration<*>>(SourceElementPositioningStrategies.DECLARATION_NAME)
val MANY_INTERFACES_MEMBER_NOT_IMPLEMENTED by error2<FirSourceElement, KtClassOrObject, FirClass<*>, FirCallableDeclaration<*>>(SourceElementPositioningStrategies.DECLARATION_NAME)
val RETURN_TYPE_MISMATCH_ON_OVERRIDE by error2<FirSourceElement, KtNamedDeclaration, FirMemberDeclaration, FirMemberDeclaration>(SourceElementPositioningStrategies.DECLARATION_RETURN_TYPE)
val PROPERTY_TYPE_MISMATCH_ON_OVERRIDE by error2<FirSourceElement, KtNamedDeclaration, FirMemberDeclaration, FirMemberDeclaration>(SourceElementPositioningStrategies.DECLARATION_RETURN_TYPE)
val VAR_TYPE_MISMATCH_ON_OVERRIDE by error2<FirSourceElement, KtNamedDeclaration, FirMemberDeclaration, FirMemberDeclaration>(SourceElementPositioningStrategies.DECLARATION_RETURN_TYPE)
@@ -218,7 +235,7 @@ object FirErrors {
val MANY_COMPANION_OBJECTS by error0<FirSourceElement, KtObjectDeclaration>(SourceElementPositioningStrategies.COMPANION_OBJECT)
val CONFLICTING_OVERLOADS by error1<FirSourceElement, PsiElement, Collection<AbstractFirBasedSymbol<*>>>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT)
val REDECLARATION by error1<FirSourceElement, PsiElement, Collection<AbstractFirBasedSymbol<*>>>()
val ANY_METHOD_IMPLEMENTED_IN_INTERFACE by error0<FirSourceElement, PsiElement>()
val METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE by error0<FirSourceElement, PsiElement>()
// Invalid local declarations
val LOCAL_OBJECT_NOT_ALLOWED by error1<FirSourceElement, KtNamedDeclaration, Name>(SourceElementPositioningStrategies.DECLARATION_NAME)
@@ -259,6 +276,8 @@ object FirErrors {
val EXPECTED_PRIVATE_DECLARATION by error0<FirSourceElement, KtModifierListOwner>(SourceElementPositioningStrategies.VISIBILITY_MODIFIER)
val VAL_WITH_SETTER by error0<FirSourceElement, KtPropertyAccessor>()
val CONST_VAL_NOT_TOP_LEVEL_OR_OBJECT by error0<FirSourceElement, KtProperty>(SourceElementPositioningStrategies.CONST_MODIFIER)
val CONST_VAL_WITH_GETTER by error0<FirSourceElement, KtProperty>()
val CONST_VAL_WITH_DELEGATE by error0<FirSourceElement, KtPropertyDelegate>()
// Multi-platform projects
val EXPECTED_DECLARATION_WITH_BODY by error0<FirSourceElement, KtDeclaration>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE)
@@ -284,8 +303,8 @@ object FirErrors {
// Nullability
val UNSAFE_CALL by error1<FirSourceElement, PsiElement, ConeKotlinType>(SourceElementPositioningStrategies.DOT_BY_QUALIFIED)
val UNSAFE_IMPLICIT_INVOKE_CALL by error1<FirSourceElement, PsiElement, ConeKotlinType>(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED)
val UNSAFE_INFIX_CALL by error3<FirSourceElement, KtExpression, FirExpression, String, FirExpression>()
val UNSAFE_OPERATOR_CALL by error3<FirSourceElement, KtExpression, FirExpression, String, FirExpression>()
val UNSAFE_INFIX_CALL by error3<FirSourceElement, KtExpression, FirExpression, String, FirExpression>(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED)
val UNSAFE_OPERATOR_CALL by error3<FirSourceElement, KtExpression, FirExpression, String, FirExpression>(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED)
// When expressions
val NO_ELSE_IN_WHEN by error1<FirSourceElement, KtWhenExpression, List<WhenMissingCase>>(SourceElementPositioningStrategies.WHEN_EXPRESSION)
@@ -298,6 +317,13 @@ object FirErrors {
// Function contracts
val ERROR_IN_CONTRACT_DESCRIPTION by error1<FirSourceElement, KtElement, String>(SourceElementPositioningStrategies.SELECTOR_BY_QUALIFIED)
// Conventions
val NO_GET_METHOD by error0<FirSourceElement, KtArrayAccessExpression>(SourceElementPositioningStrategies.ARRAY_ACCESS)
val NO_SET_METHOD by error0<FirSourceElement, KtArrayAccessExpression>(SourceElementPositioningStrategies.ARRAY_ACCESS)
// Type alias
val TOPLEVEL_TYPEALIASES_ONLY by error0<FirSourceElement, KtTypeAlias>()
// Extended checkers
val REDUNDANT_VISIBILITY_MODIFIER by warning0<FirSourceElement, KtModifierListOwner>(SourceElementPositioningStrategies.VISIBILITY_MODIFIER)
val REDUNDANT_MODALITY_MODIFIER by warning0<FirSourceElement, KtModifierListOwner>(SourceElementPositioningStrategies.MODALITY_MODIFIER)

View File

@@ -21,7 +21,7 @@ class FirCheckersResolveProcessor(
session: FirSession,
scopeSession: ScopeSession
) : FirTransformerBasedResolveProcessor(session, scopeSession) {
val diagnosticCollector = FirDiagnosticsCollector.create(session)
val diagnosticCollector = FirDiagnosticsCollector.create(session, scopeSession)
override val transformer: FirTransformer<Nothing?> = FirCheckersRunnerTransformer(diagnosticCollector)
}

View File

@@ -38,3 +38,4 @@ private fun FirLightSourceElement.getChild(types: Set<IElementType>, index: Int,
val visitor = LighterTreeElementFinderByType(treeStructure, types, index, depth)
return visitor.find(lighterASTNode)?.toFirLightSourceElement(treeStructure)
}

View File

@@ -188,9 +188,27 @@ interface FirDeclarationPresenter {
append(']')
appendRepresentation(it.symbol.classId)
}
fun represent(it: FirConstructor, owner: FirRegularClass) = buildString {
append('<')
it.typeParameters.forEach {
appendRepresentation(it)
append(',')
}
append('>')
append('[')
append(']')
appendRepresentation(owner.symbol.classId)
append('(')
it.valueParameters.forEach {
appendRepresentation(it)
append(',')
}
append(')')
}
}
private class FirDefaultDeclarationPresenter : FirDeclarationPresenter
internal class FirDefaultDeclarationPresenter : FirDeclarationPresenter
private val NO_NAME_PROVIDED = Name.special("<no name provided>")
@@ -209,49 +227,35 @@ private fun FirDeclaration.isCollectable() = when (this) {
/**
* Collects FirDeclarations for further analysis.
*/
class FirDeclarationInspector(
private val presenter: FirDeclarationPresenter = FirDefaultDeclarationPresenter()
open class FirDeclarationInspector(
protected val presenter: FirDeclarationPresenter = FirDefaultDeclarationPresenter()
) {
val otherDeclarations = mutableMapOf<String, MutableList<FirDeclaration>>()
val functionDeclarations = mutableMapOf<String, MutableList<FirSimpleFunction>>()
fun collect(declaration: FirDeclaration) {
if (!declaration.isCollectable()) {
return
when {
!declaration.isCollectable() -> {}
declaration is FirSimpleFunction -> collectFunction(presenter.represent(declaration), declaration)
declaration is FirRegularClass -> collectNonFunctionDeclaration(presenter.represent(declaration), declaration)
declaration is FirTypeAlias -> collectNonFunctionDeclaration(presenter.represent(declaration), declaration)
declaration is FirProperty -> collectNonFunctionDeclaration(presenter.represent(declaration), declaration)
}
if (declaration is FirSimpleFunction) {
return collectFunction(declaration)
}
val key = when (declaration) {
is FirRegularClass -> presenter.represent(declaration)
is FirTypeAlias -> presenter.represent(declaration)
is FirProperty -> presenter.represent(declaration)
else -> return
}
var value = otherDeclarations[key]
if (value == null) {
value = mutableListOf()
otherDeclarations[key] = value
}
value.add(declaration)
}
private fun collectFunction(declaration: FirSimpleFunction) {
val key = presenter.represent(declaration)
var value = functionDeclarations[key]
if (value == null) {
value = mutableListOf()
functionDeclarations[key] = value
protected open fun collectNonFunctionDeclaration(key: String, declaration: FirDeclaration): MutableList<FirDeclaration> =
otherDeclarations.getOrPut(key) {
mutableListOf()
}.also {
it.add(declaration)
}
value.add(declaration)
}
protected open fun collectFunction(key: String, declaration: FirSimpleFunction): MutableList<FirSimpleFunction> =
functionDeclarations.getOrPut(key) {
mutableListOf()
}.also {
it.add(declaration)
}
fun contains(declaration: FirDeclaration) = when (declaration) {
is FirSimpleFunction -> presenter.represent(declaration) in functionDeclarations

View File

@@ -42,6 +42,9 @@ import org.jetbrains.kotlin.psi.KtParameter.VAL_VAR_TOKEN_SET
import org.jetbrains.kotlin.psi.psiUtil.visibilityModifierType
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
internal fun FirClass<*>.unsubstitutedScope(context: CheckerContext) =
this.unsubstitutedScope(context.sessionHolder.session, context.sessionHolder.scopeSession, withForcedTypeCalculator = false)
/**
* Returns true if this is a superclass of other.
*/

View File

@@ -37,7 +37,7 @@ abstract class CheckerContext {
/**
* Returns the closest to the end of context.containingDeclarations
* T instance or null if no such item could be found.
* instance of type [T] or null if no such item could be found.
*/
inline fun <reified T : FirDeclaration> findClosest(): T? {
for (it in containingDeclarations.asReversed()) {
@@ -47,6 +47,18 @@ abstract class CheckerContext {
return null
}
/**
* Same as the one without specific [check]. For some cases, an instance of type [T] isn't good enough. E.g., property accessor is
* either getter or setter, but a type-based search could return, say, the closest setter, while we want to keep searching for a getter.
*/
inline fun <reified T : FirDeclaration> findClosest(check: (T) -> Boolean): T? {
for (it in containingDeclarations.asReversed()) {
return (it as? T)?.takeIf(check) ?: continue
}
return null
}
abstract fun addSuppressedDiagnostics(
diagnosticNames: Collection<String>,
allInfosSuppressed: Boolean,

View File

@@ -5,57 +5,289 @@
package org.jetbrains.kotlin.fir.analysis.checkers.declaration
import org.jetbrains.kotlin.fir.FirSymbolOwner
import org.jetbrains.kotlin.fir.*
import org.jetbrains.kotlin.fir.analysis.checkers.FirDeclarationInspector
import org.jetbrains.kotlin.fir.analysis.checkers.FirDeclarationPresenter
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOn
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
import org.jetbrains.kotlin.fir.declarations.FirFile
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.resolve.firProvider
import org.jetbrains.kotlin.fir.scopes.PACKAGE_MEMBER
import org.jetbrains.kotlin.fir.scopes.impl.FirPackageMemberScope
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol
import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.utils.SmartSet
object FirConflictsChecker : FirBasicDeclarationChecker() {
private class DeclarationInspector : FirDeclarationInspector() {
val declarationConflictingSymbols: HashMap<FirDeclaration, SmartSet<AbstractFirBasedSymbol<*>>> = hashMapOf()
override fun collectNonFunctionDeclaration(key: String, declaration: FirDeclaration): MutableList<FirDeclaration> =
super.collectNonFunctionDeclaration(key, declaration).also {
collectLocalConflicts(declaration, it)
}
override fun collectFunction(key: String, declaration: FirSimpleFunction): MutableList<FirSimpleFunction> =
super.collectFunction(key, declaration).also {
collectLocalConflicts(declaration, it)
}
private fun collectLocalConflicts(declaration: FirDeclaration, conflicting: List<FirDeclaration>) {
val localConflicts = SmartSet.create<AbstractFirBasedSymbol<*>>()
for (otherDeclaration in conflicting) {
if (otherDeclaration is FirSymbolOwner<*>) {
if (otherDeclaration != declaration && declaration is FirSymbolOwner<*> &&
!isExpectAndActual(declaration, otherDeclaration)
) {
localConflicts.add(otherDeclaration.symbol)
declarationConflictingSymbols.getOrPut(otherDeclaration) { SmartSet.create() }.add(declaration.symbol)
}
}
}
declarationConflictingSymbols[declaration] = localConflicts
}
private fun isExpectAndActual(declaration1: FirDeclaration, declaration2: FirDeclaration): Boolean {
if (declaration1 !is FirMemberDeclaration) return false
if (declaration2 !is FirMemberDeclaration) return false
return (declaration1.status.isExpect && declaration2.status.isActual) ||
(declaration1.status.isActual && declaration2.status.isExpect)
}
private fun areCompatibleMainFunctions(
declaration1: FirDeclaration, file1: FirFile, declaration2: FirDeclaration, file2: FirFile?
): Boolean {
// TODO: proper main function detector
if (declaration1 !is FirSimpleFunction || declaration2 !is FirSimpleFunction) return false
if (declaration1.name.asString() != "main" || declaration2.name.asString() != "main") return false
return file1 != file2
}
private fun collectExternalConflict(
declaration: FirDeclaration,
declarationPresentation: String,
containingFile: FirFile,
conflictingSymbol: AbstractFirBasedSymbol<*>,
conflictingPresentation: String?,
conflictingFile: FirFile?,
session: FirSession
) {
val conflicting = conflictingSymbol.fir as? FirDeclaration ?: return
if (declaration.session.moduleInfo != conflicting.session.moduleInfo) return
val actualConflictingPresentation = conflictingPresentation ?: presenter.represent(conflicting)
if (conflicting == declaration || actualConflictingPresentation != declarationPresentation) return
val actualConflictingFile =
conflictingFile ?: when (conflictingSymbol) {
is FirClassLikeSymbol<*> -> session.firProvider.getFirClassifierContainerFileIfAny(conflictingSymbol)
is FirCallableSymbol<*> -> session.firProvider.getFirCallableContainerFile(conflictingSymbol)
else -> null
}
if (containingFile == actualConflictingFile) return // TODO: rewrite local decls checker to the same logic and then remove the check
if (areCompatibleMainFunctions(declaration, containingFile, conflicting, actualConflictingFile)) return
if (isExpectAndActual(declaration, conflicting)) return
if (conflicting is FirMemberDeclaration && !(conflicting is FirSymbolOwner<*> &&
session.visibilityChecker.isVisible(conflicting, session, containingFile, emptyList(), null))
) {
return
}
declarationConflictingSymbols.getOrPut(declaration) { SmartSet.create() }.add(conflictingSymbol)
}
fun collectWithExternalConflicts(
declaration: FirDeclaration,
containingFile: FirFile,
session: FirSession,
packageMemberScope: FirPackageMemberScope
) {
collect(declaration)
var declarationName: Name? = null
val declarationPresentation = presenter.represent(declaration) ?: return
when (declaration) {
is FirSimpleFunction -> {
declarationName = declaration.name
if (!declarationName.isSpecial) {
packageMemberScope.processFunctionsByName(declarationName) {
collectExternalConflict(
declaration, declarationPresentation, containingFile, it, null, null, session
)
}
packageMemberScope.processClassifiersByNameWithSubstitution(declarationName) { symbol, _ ->
val classWithSameName = symbol.fir as? FirRegularClass
classWithSameName?.onConstructors { constructor ->
collectExternalConflict(
declaration, declarationPresentation, containingFile,
constructor.symbol, presenter.represent(constructor, classWithSameName), null,
session
)
}
}
}
}
is FirVariable<*> -> {
declarationName = declaration.name
if (!declarationName.isSpecial) {
packageMemberScope.processPropertiesByName(declarationName) {
collectExternalConflict(
declaration, declarationPresentation, containingFile, it, null, null, session
)
}
}
}
is FirRegularClass -> {
declarationName = declaration.name
if (!declarationName.isSpecial) {
packageMemberScope.processClassifiersByNameWithSubstitution(declarationName) { symbol, _ ->
collectExternalConflict(
declaration, declarationPresentation, containingFile, symbol, null, null, session
)
}
declaration.onConstructors { constructor ->
packageMemberScope.processFunctionsByName(declarationName!!) {
collectExternalConflict(
constructor, presenter.represent(constructor, declaration), containingFile,
it, null, null, session
)
}
}
session.nameConflictsTracker?.let { it as? FirNameConflictsTracker }
?.redeclaredClassifiers?.get(declaration.symbol.classId)?.forEach {
collectExternalConflict(
declaration,
declarationPresentation,
containingFile,
it.classifier,
null,
it.file,
session
)
}
}
}
is FirTypeAlias -> {
declarationName = declaration.name
if (!declarationName.isSpecial) {
packageMemberScope.processClassifiersByNameWithSubstitution(declarationName) { symbol, _ ->
collectExternalConflict(
declaration, declarationPresentation, containingFile, symbol, null, null, session
)
}
session.nameConflictsTracker?.let { it as? FirNameConflictsTracker }
?.redeclaredClassifiers?.get(declaration.symbol.classId)?.forEach {
collectExternalConflict(
declaration,
declarationPresentation,
containingFile,
it.classifier,
null,
it.file,
session
)
}
}
}
}
if (declarationName != null) {
session.lookupTracker?.recordLookup(
declarationName, containingFile.packageFqName.asString(), declaration.source, containingFile.source
)
}
}
}
override fun check(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) {
val inspector = FirDeclarationInspector()
val inspector = DeclarationInspector()
when (declaration) {
is FirFile -> checkFile(declaration, inspector)
is FirFile -> checkFile(declaration, inspector, context)
is FirRegularClass -> checkRegularClass(declaration, inspector)
else -> return
}
inspector.functionDeclarations.forEachNonSingle { it, symbols ->
reporter.reportOn(it.source, FirErrors.CONFLICTING_OVERLOADS, symbols, context)
}
inspector.otherDeclarations.forEachNonSingle { it, symbols ->
reporter.reportOn(it.source, FirErrors.REDECLARATION, symbols, context)
}
}
private fun Map<String, List<FirDeclaration>>.forEachNonSingle(action: (FirDeclaration, Collection<AbstractFirBasedSymbol<*>>) -> Unit) {
for (value in values) {
if (value.size > 1) {
val symbols = value.mapNotNull { (it as? FirSymbolOwner<*>)?.symbol }
value.forEach {
action(it, symbols)
inspector.declarationConflictingSymbols.forEach { (declaration, symbols) ->
when {
symbols.isEmpty() -> {}
declaration is FirSimpleFunction || declaration is FirConstructor -> {
reporter.reportOn(declaration.source, FirErrors.CONFLICTING_OVERLOADS, symbols, context)
}
else -> {
reporter.reportOn(declaration.source, FirErrors.REDECLARATION, symbols, context)
}
}
}
}
private fun checkFile(declaration: FirFile, inspector: FirDeclarationInspector) {
for (it in declaration.declarations) {
inspector.collect(it)
private fun checkFile(file: FirFile, inspector: DeclarationInspector, context: CheckerContext) {
val packageMemberScope: FirPackageMemberScope = context.sessionHolder.scopeSession.getOrBuild(file.packageFqName, PACKAGE_MEMBER) {
FirPackageMemberScope(file.packageFqName, context.sessionHolder.session)
}
for (topLevelDeclaration in file.declarations) {
inspector.collectWithExternalConflicts(topLevelDeclaration, file, context.session, packageMemberScope)
}
}
private fun checkRegularClass(declaration: FirRegularClass, inspector: FirDeclarationInspector) {
private fun checkRegularClass(declaration: FirRegularClass, inspector: DeclarationInspector) {
for (it in declaration.declarations) {
inspector.collect(it)
}
}
}
private fun FirDeclarationPresenter.represent(declaration: FirDeclaration): String? =
when (declaration) {
is FirSimpleFunction -> represent(declaration)
is FirRegularClass -> represent(declaration)
is FirTypeAlias -> represent(declaration)
is FirProperty -> represent(declaration)
else -> null
}
class FirNameConflictsTracker : FirNameConflictsTrackerComponent() {
data class ClassifierWithFile(
val classifier: FirClassLikeSymbol<*>,
val file: FirFile?
)
val redeclaredClassifiers = HashMap<ClassId, Set<ClassifierWithFile>>()
override fun registerClassifierRedeclaration(
classId: ClassId,
newSymbol: FirClassLikeSymbol<*>, newSymbolFile: FirFile,
prevSymbol: FirClassLikeSymbol<*>, prevSymbolFile: FirFile?
) {
redeclaredClassifiers.merge(
classId, linkedSetOf(ClassifierWithFile(newSymbol, newSymbolFile), ClassifierWithFile(prevSymbol, prevSymbolFile))
) { a, b -> a + b }
}
}
private fun FirDeclaration.onConstructors(action: (ctor: FirConstructor) -> Unit) {
class ClassConstructorVisitor : FirVisitorVoid() {
override fun visitElement(element: FirElement) {}
override fun visitConstructor(constructor: FirConstructor) {
action(constructor)
}
override fun visitDeclarationStatus(declarationStatus: FirDeclarationStatus) {}
override fun visitRegularClass(regularClass: FirRegularClass) {}
override fun visitProperty(property: FirProperty) {}
override fun visitSimpleFunction(simpleFunction: FirSimpleFunction) {}
}
acceptChildren(ClassConstructorVisitor())
}

View File

@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.fir.analysis.checkers.declaration
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.fir.FirFakeSourceElementKind
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
@@ -31,9 +32,15 @@ object FirConstPropertyChecker : FirPropertyChecker() {
reporter.reportOn(declaration.source, FirErrors.CONST_VAL_NOT_TOP_LEVEL_OR_OBJECT, context)
}
if (declaration.getter?.source?.kind !is FirFakeSourceElementKind) {
reporter.reportOn(declaration.getter?.source, FirErrors.CONST_VAL_WITH_GETTER, context)
}
if (declaration.delegate != null) {
reporter.reportOn(declaration.delegate?.source, FirErrors.CONST_VAL_WITH_DELEGATE, context)
}
// TODO: Implement checkers for these errors (see ConstModifierChecker in FE1.0):
// - CONST_VAL_WITH_DELEGATE
// - CONST_VAL_WITH_GETTER
// - TYPE_CANT_BE_USED_FOR_CONST_VAL
// - CONST_VAL_WITHOUT_INITIALIZER
// - CONST_VAL_WITH_NON_CONST_INITIALIZER

View File

@@ -5,11 +5,9 @@
package org.jetbrains.kotlin.fir.analysis.checkers.declaration
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.fir.FirElement
import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
import org.jetbrains.kotlin.fir.analysis.checkers.modality
@@ -18,11 +16,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOn
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor
import org.jetbrains.kotlin.fir.expressions.FirVariableAssignment
import org.jetbrains.kotlin.fir.languageVersionSettings
import org.jetbrains.kotlin.fir.references.FirBackingFieldReference
import org.jetbrains.kotlin.fir.types.FirImplicitTypeRef
import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid
import org.jetbrains.kotlin.lexer.KtTokens
internal fun isInsideExpectClass(containingClass: FirRegularClass, context: CheckerContext): Boolean {
@@ -175,34 +169,6 @@ internal fun checkPropertyAccessors(
context: CheckerContext
) {
if (property.isVal) {
if (property.getter != null) {
var reassignment: FirBackingFieldReference? = null
// TODO: consider replacing this with normal VariableAssignmentChecker and reporting all 'field = ...' in getter (not just 1st)
// This way is a bit hacky and does not handle diagnostic suppression normally
val visitor = object : FirVisitorVoid() {
override fun visitElement(element: FirElement) {
element.acceptChildren(this)
}
override fun visitVariableAssignment(variableAssignment: FirVariableAssignment) {
// Report the first violation (to match FE 1.0 behavior)
if (reassignment != null) return
val backingFieldReference = variableAssignment.lValue as? FirBackingFieldReference
if (backingFieldReference?.resolvedSymbol?.fir == property) {
reassignment = backingFieldReference
}
}
}
property.getter?.body?.accept(visitor, null)
reassignment?.source?.let {
if (context.session.languageVersionSettings.supportsFeature(LanguageFeature.RestrictionOfValReassignmentViaBackingField)) {
reporter.reportOn(it, FirErrors.VAL_REASSIGNMENT_VIA_BACKING_FIELD_ERROR, property.symbol, context)
} else {
reporter.reportOn(it, FirErrors.VAL_REASSIGNMENT_VIA_BACKING_FIELD, property.symbol, context)
}
}
}
property.setter?.source?.let {
reporter.reportOn(it, FirErrors.VAL_WITH_SETTER, context)
}
@@ -220,3 +186,16 @@ internal fun FirRegularClass.isInlineOrValueClass(): Boolean {
return isInline || hasModifier(KtTokens.VALUE_KEYWORD)
}
internal val FirMemberDeclaration.isLocalMember: Boolean
get() = when (this) {
is FirProperty -> this.isLocal
is FirRegularClass -> this.isLocal
is FirSimpleFunction -> this.isLocal
else -> false
}
internal val FirCallableMemberDeclaration<*>.isExtensionMember: Boolean
get() {
return receiverTypeRef != null && dispatchReceiverType != null
}

Some files were not shown because too many files have changed in this diff Show More