Compare commits

...

189 Commits

Author SHA1 Message Date
Dmitry Petrov
4dc65c6a3e JVM_IR KT-45103 optimize direct invoke for lambdas and callable refs 2021-04-26 17:17:25 +03:00
Dmitry Petrov
05e642cacf JVM_IR KT-36646 fuze primitive equality with safe call 2021-04-26 13:10:32 +03:00
Dmitry Petrov
f830786b20 JVM_IR update test for KT-36637 2021-04-26 13:10:31 +03:00
Dmitry Petrov
22c5b3a990 JVM_IR use static 'hashCode' for boxed primitives on JVM 1.8+ 2021-04-26 13:10:31 +03:00
Mikhail Glukhikh
29d2a6acee FIR: fold String arguments inside string concatenation call
Related to KT-28006
2021-04-26 12:50:57 +03:00
Mikhail Glukhikh
f278de8768 FIR: don't call toString() inside string concatenations 2021-04-26 12:50:55 +03:00
Igor Chevdar
7dcdbf283b [box-tests] Added test 2021-04-26 11:53:27 +05:00
Igor Chevdar
eb1dcdb344 [K/N][IR] Fixed bug with enum companion init
Fixes https://youtrack.jetbrains.com/issue/KT-46048
2021-04-26 11:53:27 +05:00
Igor Chevdar
476b3befaf [K/N][IR] Refactored enums lowering a bit 2021-04-26 11:53:26 +05:00
Andrey Zinovyev
01dd3d6ed4 [lombok] Refactoring, cleaning, better tests
Add assertions to tests
Add lombok license
Provide String.[de]capitalize() implementation
Get rid of weak map because it seems it is useless here
2021-04-25 18:18:18 +03:00
Andrey Zinovyev
c4147bc2fd [lombok] Add integration test for gradle plugin 2021-04-25 18:18:17 +03:00
Andrey Zinovyev
5a6819daa8 [lombok] Check that nullability actually works 2021-04-25 18:18:16 +03:00
Andrey Zinovyev
1fb4590978 [lombok] Some cleaning and docs 2021-04-25 18:18:15 +03:00
Andrey Zinovyev
9ebce7849c [lombok] Skip generation with AccessLevel.NONE 2021-04-25 18:18:15 +03:00
Andrey Zinovyev
be4a518a25 [lombok] Support for lombok.accessors.prefix config 2021-04-25 18:18:14 +03:00
Andrey Zinovyev
17e4a6142c [lombok] Strip prefixes defined in @Accessors 2021-04-25 18:18:13 +03:00
Andrey Zinovyev
f2c0b8c68d [lombok] Strip 'is' prefix in boolean properties 2021-04-25 18:18:12 +03:00
Andrey Zinovyev
8a2279de2b [lombok] Use config values as default in annotation parsing 2021-04-25 18:18:11 +03:00
Andrey Zinovyev
c7b2c731af [lombok] Basic @Value support 2021-04-25 18:18:11 +03:00
Andrey Zinovyev
97fc187e77 [lombok] @Data support 2021-04-25 18:18:10 +03:00
Andrey Zinovyev
99f9b79c87 [lombok] Add simple way to use lombok plugin in one project with kapt 2021-04-25 18:18:09 +03:00
Andrey Zinovyev
79d49e6dbd [lombok] Gradle sublugin for no-kapt project 2021-04-25 18:18:08 +03:00
Andrey Zinovyev
8011452c28 [lombok] Don't generate members that already exist 2021-04-25 18:18:07 +03:00
Andrey Zinovyev
d459cde010 [lombok] Run compiled code 2021-04-25 18:18:06 +03:00
Andrey Zinovyev
411441c332 [lombok] Generic classes support 2021-04-25 18:18:06 +03:00
Andrey Zinovyev
afcb2ca904 [lombok] Support @RequiredArgsConstructor 2021-04-25 18:18:05 +03:00
Andrey Zinovyev
b336a335bf [lombok] Support @AllArgsConstructor 2021-04-25 18:18:04 +03:00
Andrey Zinovyev
59f936fdef [lombok] Generate no-arg static factory method 2021-04-25 18:18:03 +03:00
Andrey Zinovyev
37926f333e [lombok] Generate no-arg constructor 2021-04-25 18:18:03 +03:00
Andrey Zinovyev
e9a33e0335 [lombok] Introduce synthetic constructors generation 2021-04-25 18:18:02 +03:00
Andrey Zinovyev
e0216cc9f4 [lombok] Add readme with (not) supported features 2021-04-25 18:18:01 +03:00
Andrey Zinovyev
e0a95ff556 [lombok] @With support 2021-04-25 18:18:00 +03:00
Andrey Zinovyev
7fd8f7b3bc [lombok] @Setter support 2021-04-25 18:17:59 +03:00
Andrey Zinovyev
70e3877efc [lombok] Basic config support 2021-04-25 18:17:57 +03:00
Andrey Zinovyev
5ceefa3e3b [lombok] Support for class level @Getter 2021-04-25 18:17:56 +03:00
Andrey Zinovyev
e4bd33eb4f [lombok] Support for fluent getters 2021-04-25 18:17:55 +03:00
Andrey Zinovyev
f71e08df4d [lombok] Experimental lombok plugin prototype
Add extension point for java descriptors
Add simple usage of this point to generate getter method
Add simple test infrastructure to test compilation with lombok plugin
2021-04-25 18:17:53 +03:00
Yahor Berdnikau
ac86ad252f Optionally make java executable path contribute to the daemon id.
This change will allow to start Kotlin daemon instances using different
from the current user JDK version and use it to compile Kotlin files.
Old behaviour, when java executable path is not set, is still working
 and still,by default, using current user JDK version.

For example, user for some reason wants to use JDK 1.8 as active one,
 but compile current project using JDK 16.

Main goal is to support Gradle toolchains.

^KT-45611 In Progress
2021-04-24 11:12:47 +03:00
Yahor Berdnikau
1d47f4ad2b Consolidate compiler id digest.
Change all calculations of compiler id digest to use
 'CompilerId#digest()' method.

^KT-45611 In Progress
2021-04-24 11:12:46 +03:00
Simon Ogorodnik
c6fa363487 [FIR] Add warning if FIR is used 2021-04-23 19:49:46 +03:00
Victor Petukhov
7a81d0de8a Regenerate tests 2021-04-23 19:28:26 +03:00
sebastian.sellmair
7be48a0b4b CommonizerHierarchicalIT: Enable test commonizeHierarchicallyMultiModule
^KT-46107 Fixed
2021-04-23 16:25:59 +00:00
sebastian.sellmair
63e5298be9 Update 'versions.kotlin-native' to 1.5.20-dev-5613
^KT-46107
2021-04-23 16:25:59 +00:00
Konstantin Tskhovrebov
b894b7df6e Add integration tests for "assembleAppleFrameworkForXcode" and "embedAndSignAppleFrameworkForXcode" tasks. 2021-04-23 19:23:58 +03:00
Konstantin Tskhovrebov
c8ef0715b9 Register "assembleAppleFrameworkForXcode" and "embedAndSignAppleFrameworkForXcode" tasks when gradle is run from Xcode.
#KT-27240
2021-04-23 19:23:57 +03:00
Alexander Udalov
0c3f2eefe0 Migrate bytecodeListing tests to new test infrastructure 2021-04-23 17:58:16 +02:00
Alexander Udalov
7e170770ea Minor, move around bytecode listing tests 2021-04-23 17:58:16 +02:00
sebastian.sellmair
28690b7f32 KotlinToolRunner: Add "java.system.class.loader" to execSystemPropertiesBlacklist
IDE integration tests will forward an unvailable intellij classloader
which will fail the execution.
2021-04-23 14:34:17 +00:00
sebastian.sellmair
7b8926f85b [Commonizer] Allow propagation of leaf targets
^KT-46248 Verification Pending
2021-04-23 14:34:17 +00:00
sebastian.sellmair
7c1520a424 [Commonizer] Implement SingleTargetPropagationTest to cover KT-46248
^KT-46248
2021-04-23 14:34:16 +00:00
sebastian.sellmair
965e328766 CommonizerIT: implement test KT-46248 single supported native target dependency propagation to cover KT-46248
^KT-46248
2021-04-23 14:34:15 +00:00
Mikhail Glukhikh
683872ecbf FIR: use more precise checkers when possible 2021-04-23 17:29:43 +03:00
Mikhail Glukhikh
5c224ad17c FIR: fix positioning in fun interface checker 2021-04-23 17:29:34 +03:00
Артём
393a19db54 FIR: introduce FunInterfaceDeclarationChecker 2021-04-23 17:29:25 +03:00
Victor Petukhov
867d7b5bca Allow type variable fixation into intersection type if it isn't meaningless (i.e. has one or more final classes, or two or more open classes)
^KT-46186 Fixed
2021-04-23 15:12:13 +03:00
Victor Petukhov
310d98c4f7 Don't require existence of the corresponding type argument during computing target type to apply type use annotation loaded from class file
^KT-46131 Fixed
2021-04-23 15:12:12 +03:00
sebastian.sellmair
13b1664edf CommonizerIT: Implement additional test KT-46142 standalone native source set
^46142
Before this test, the behaviour was tested as integration test in the IDE.
This Gradle integration test will detect issues even earlier.
2021-04-23 15:02:15 +03:00
Konstantin Tskhovrebov
ee4a1d173d Revert "Add integration tests for "assembleAppleFrameworkForXcode" and "embedAndSignAppleFrameworkForXcode" tasks."
This reverts commit 6db3960d
2021-04-23 12:11:42 +03:00
Konstantin Tskhovrebov
8840a9ecd1 Revert "Register "assembleAppleFrameworkForXcode" and "embedAndSignAppleFrameworkForXcode" tasks when gradle is run from Xcode."
This reverts commit c2cdf9c7
2021-04-23 12:11:19 +03:00
Ilmir Usmanov
f7a9bc3521 Minor. Make test actually suspend and add a test without suspension 2021-04-23 03:50:08 +02:00
pyos
23ffbe4d9e JVM_IR: do not box inline classes in suspend multifile bridges 2021-04-23 03:49:47 +02:00
pyos
7d95943b8b JVM_IR: do not box inline classes in suspend synthetic accessors 2021-04-23 03:49:43 +02:00
Alexander Likhachev
857bee6ced [Build] Remove empty source directories warning
There're should be no more cache misses on empty directories with Gradle 6.8. See https://docs.gradle.org/6.8/release-notes.html#more-cache-hits-when-empty-directories-are-present
2021-04-23 03:52:45 +03:00
Alexander Likhachev
03f9d78eb3 [Build] Add workaround to make local publishing serializable
Also signing plugin now being applied only when signing is required.
#KT-44611 In Progress
2021-04-23 03:52:41 +03:00
Sergey Igushkin
4e6c483ccc Add a final override for project in KotlinGradleFragmentInternal 2021-04-23 00:43:14 +03:00
Sergey Igushkin
bb35d9271f Minor fix: don't use lazy in KotlinPm20ProjectExtension.modules 2021-04-23 00:43:14 +03:00
Sergey Igushkin
53f02a53f0 Add caching to dependency resolvers in PM20 + some refactoring 2021-04-23 00:43:13 +03:00
Sergey Igushkin
1f0089c5de Refactor the dependency graph resolver to be more readable 2021-04-23 00:43:13 +03:00
Sergey Igushkin
d07c76fca4 Add kotlin-project-model artifacts to the set of trusted artifacts 2021-04-23 00:43:12 +03:00
Sergey Igushkin
6be33448d6 Rework adding sources to FilteringSourceRootsContainer in JVM tasks
Support adding lazily-evaluated file collections (i.e. tracking their
source roots lazily, as opposed to eagerly evaluating the source roots.
2021-04-23 00:43:12 +03:00
Sergey Igushkin
e59a57d11c Add ":kotlin-project-model" to the list of modules installed for tests 2021-04-23 00:43:11 +03:00
Sergey Igushkin
e7b81c52a7 Get rid of DependencyDiscovery in favor of DependencyGraphResolver 2021-04-23 00:43:11 +03:00
Sergey Igushkin
d602470027 Fix compilation of the tests in kotlin-project-model 2021-04-23 00:43:10 +03:00
Sergey Igushkin
fe351f26ef For now, publish the sources elements variant with usage=kotlin-sources 2021-04-23 00:43:10 +03:00
Sergey Igushkin
a94597d85a Experimental sources publication in the PM2.0 prototype 2021-04-23 00:43:10 +03:00
Sergey Igushkin
44fcd7e891 Use KotlinCompilationTaskConfigurator for metadata compilation tasks 2021-04-23 00:43:09 +03:00
Sergey Igushkin
4cb6303fa8 Get rid of kotlinPluginVersion in the constructors throughout the plugin
We passed the kotlinPluginVersion which was only used for a single
purpose in countless constructors.

In fact, the plugin version is easy to load at the call site, as it gets
loaded from the plugin's resources.

So rework the plugin version loading code so that it doesn't rely on the
applied plugin, and don't pass the plugin version in all those
constructors.
2021-04-23 00:43:09 +03:00
Sergey Igushkin
2a5d511b66 Minor fix: handle kotlinOptions more carefully, store them where needed 2021-04-23 00:43:08 +03:00
Sergey Igushkin
00e5e462ea Further refactor compile task configuration: extract the configurator 2021-04-23 00:43:08 +03:00
Anton Lakotka
1a85da5ff8 Make language settings nullable in KotlinModuleFragment
There is no lang settings when importing from klibs (yet)
2021-04-23 00:43:07 +03:00
Anton Lakotka
c3264a2979 Add language consistency checks for fragments
Migrate exiting consistency checker for source sets to be generic
and reuse it for fragments
2021-04-23 00:43:07 +03:00
Anton Lakotka
de4221afd8 Add immutable LanguageSettings interface and apply it to compilation
LanguageSettingsBuilder extends LanguageSettings
2021-04-23 00:43:06 +03:00
Sergey Igushkin
54c6ae2cce (minor) Rename modelClasses.kt -> KotlinJvmVariantFactory.kt 2021-04-23 00:43:06 +03:00
Sergey Igushkin
3be2734c63 Refactor the setup of compilation in the PM20 implementation prototype 2021-04-23 00:43:05 +03:00
Sergey Igushkin
c1fe0d7158 Add publishing configurator, call it from the variant factories 2021-04-23 00:43:05 +03:00
Sergey Igushkin
1271fabffa Fix Maven scope mapping for the runtime dependencies in PM20 publishing 2021-04-23 00:43:04 +03:00
Sergey Igushkin
27015a657c Don't pass the IDE paths to the extracted klibs that don't exist 2021-04-23 00:43:04 +03:00
Sergey Igushkin
470103bfac Don't rely on the current project in dep-resolution if module is given 2021-04-23 00:43:04 +03:00
Sergey Igushkin
f029179fe0 Add basic support for Kotlin/Native variants to the PM20 Gradle plugin 2021-04-23 00:43:00 +03:00
Sergey Igushkin
401fbae8d8 Handle dependency module IDs more carefully in dependency resolution 2021-04-23 00:42:37 +03:00
Sergey Igushkin
ea458e6848 Add some API interfaces for Gradle PM20 entities in the API module 2021-04-23 00:42:37 +03:00
Sergey Igushkin
a52c6858a9 Minor fixes in exposed configurations 2021-04-23 00:42:37 +03:00
Sergey Igushkin
134fb7741e Fix getChosenVariant implementation for project(...) dependencies 2021-04-23 00:42:36 +03:00
Sergey Igushkin
ec3fa2610e Support basic publishing with maven-publish in the PM20 plugin 2021-04-23 00:42:36 +03:00
Sergey Igushkin
0bf408e147 (minor) Add isAllowCommonizer stub to the PM2.0 project extension
This prevents the IDE from failures during Gradle project sync
2021-04-23 00:42:35 +03:00
Sergey Igushkin
4e0485c523 Expose compiled metadata for project deps, set capabilities on elements 2021-04-23 00:42:35 +03:00
Sergey Igushkin
147fd22cfb (minor) Fix static init issue with Gradle multi-threaded resolve 2021-04-23 00:42:35 +03:00
Sergey Igushkin
f1f97b4104 Support published MPP consumption with PM2.0 projects 2021-04-23 00:42:34 +03:00
Sergey Igushkin
70b88ada93 Gradle plugin prototype that uses the project model 2.0 2021-04-23 00:42:34 +03:00
Sergey Igushkin
d66f95b80e Resolve dependencies as graph, support multiple modules in a project 2021-04-22 23:42:06 +03:00
Sergey Igushkin
f1fb438d00 Refactor: make fragments resolver consistent with variant resolver 2021-04-22 23:42:05 +03:00
Sergey Igushkin
7103aa3100 ModuleOrigin -> ModuleIdentifier 2021-04-22 23:42:04 +03:00
Sergey Igushkin
66b8a444c2 Add a basic markdown doc explaining dependency resolution. 2021-04-22 23:42:02 +03:00
Sergey Igushkin
6aee396e4b Build PM2.0 in o.j.k.multiplatform (+ dependency resolution API) 2021-04-22 23:42:01 +03:00
Sergey Igushkin
994f940a31 Dependency resolution API in PM2.0 2021-04-22 23:42:00 +03:00
Sergey Igushkin
f189ebc983 Project Model 2.0 initial commit: core entities 2021-04-22 23:41:59 +03:00
Konstantin Tskhovrebov
6db3960d56 Add integration tests for "assembleAppleFrameworkForXcode" and "embedAndSignAppleFrameworkForXcode" tasks. 2021-04-22 20:33:20 +03:00
Konstantin Tskhovrebov
c2cdf9c796 Register "assembleAppleFrameworkForXcode" and "embedAndSignAppleFrameworkForXcode" tasks when gradle is run from Xcode.
#KT-27240
2021-04-22 20:33:20 +03:00
Alexander Udalov
99e022d023 IR: minor, remove duplicate visibility field 2021-04-22 17:42:18 +02:00
Dmitriy Novozhilov
d4162f876f [FIR] Fix some warnings 2021-04-22 14:32:06 +03:00
Dmitriy Novozhilov
234ab3b35d [FIR] Fix all illegal usages of declarationSiteSession in compiler
There are still some usages in IDE which should be investigated
2021-04-22 14:32:04 +03:00
Dmitriy Novozhilov
f98f41bbc3 [FIR] Rename session to declarationSiteSession in declaration builders 2021-04-22 14:32:03 +03:00
Dmitriy Novozhilov
c3b1be1a39 [FIR] Rename FirDeclaration.session to declarationSiteSession 2021-04-22 14:32:02 +03:00
Dmitriy Novozhilov
46f5c2073d [FIR] Make most of declarations a sealed classes/interfaces 2021-04-22 14:32:00 +03:00
Dmitriy Novozhilov
7f7373dad2 [FIR] Support sealed classes and interfaces in FIR tree generator 2021-04-22 14:31:59 +03:00
Dmitriy Novozhilov
951daeea3a [FIR] Add typealias to AbstractFirBasedSymbol<*> in FirDiagnosticsList 2021-04-22 14:31:58 +03:00
Vasily Levchenko
1ae41443a2 [kotlin-native][build] clean task fix 2021-04-22 11:16:55 +00:00
Jinseong Jeon
24d792fb49 FIR checker: warn useless elvis 2021-04-22 13:10:54 +03:00
Alexander Udalov
b2005302dc JVM, JVM IR: erase generic SAM supertypes
Also, do not try to use invokedynamic on SAM calls with intersection
types, because intersection type is not allowed as an immediate type
projection of a supertype, and constructing a fake override in
LambdaMetafactoryArgumentsBuilder led to an exception. This fixes the
problem which was worked around earlier in e6c089ef, effectively
reverting that commit.

The main motivation for this change is that LambdaMetafactory also
doesn't generate generic signature for SAM wrapper classes at runtime.
Since these classes are synthetic, nobody should rely on the fact that
they have generic supertypes, which was observable only via Java
reflection.

 #KT-46149 Fixed
 #KT-46238 Fixed
2021-04-22 10:53:15 +02:00
Andrey Zinovyev
1093bffc62 [KAPT] Cache annotation processors' classloaders
Adds experimental feature to cache annotation processors' classloaders
It should increase speed of KAPT for consecutive runs
Works for gradle only (it stores cl in gradle daemon)
#KT-28901 Fixed
2021-04-22 11:51:14 +03:00
Mikhail Glukhikh
e6b9935df9 FIR: drop source-based check from InferenceUtils 2021-04-22 10:26:47 +03:00
sebastian.sellmair
75d9cd3814 [Minor] KotlinLibraryResolverImpl: Improve readability in resolveDependencies 2021-04-21 20:05:57 +00:00
sebastian.sellmair
3c4d0a1814 CInteropCommonizerTask: Mark dependency on commonized native distribution as @Classpath 2021-04-21 20:05:56 +00:00
sebastian.sellmair
f4617b2c03 Do not forward external dependencies on c-interop commonization.
^KT-46109
^KT-46107 Fixed
2021-04-21 20:05:56 +00:00
sebastian.sellmair
22ea5c7de4 Demote fatal error to warning on unresolved libraries mentioned in Klib's manifest 'depends' for metadata compilation
^KT-46107
2021-04-21 20:05:55 +00:00
sebastian.sellmair
95a1a4e66a CommonizerHierarchicalIT: Implement test commonizeHierarchicallyMultiModule
^KT-46107
2021-04-21 20:05:54 +00:00
sebastian.sellmair
5fb30b05ff Implement CommonizerIT.test KT-46234 intermediate source set with only one native target to cover KT-46234
^KT-46234
2021-04-21 20:05:06 +00:00
Ilya Kirillov
e2786197ff FIR IDE: support reporting of FirLightSourceElement based diagnostics 2021-04-21 22:22:32 +03:00
Ilya Kirillov
47e8b2f9dc FIR IDE: remove copy-pasted code from DeclarationCopyBuilder 2021-04-21 21:17:00 +03:00
Ilya Kirillov
a76c5d66eb FIR: introduce FirDeclarationBuilder as a base class for all FIR declaration builders 2021-04-21 21:16:58 +03:00
Ilya Kirillov
da6c5e13d5 FIR IDE: add completion support to classes and to type aliases 2021-04-21 21:16:56 +03:00
Ilya Kirillov
a5c33c8d42 FIR IDE: simplify completion context retrieving 2021-04-21 21:16:55 +03:00
Mikhail Zarechenskiy
f8efe3b5df Make function open to overrie it IDE specific part
Namely, this function is overrided in 211 & 212 platforms, see ScriptDefinitionsManager
2021-04-21 20:00:22 +03:00
Dmitry Petrov
5324cbe729 Minor: update tests 2021-04-21 19:10:32 +03:00
Steven Schäfer
8c9ad81c76 Psi2Ir: Fold constants when generating IR
This is necessary to avoid stack overflow errors on large constant
expressions.
2021-04-21 19:10:31 +03:00
Steven Schäfer
e87d816994 Psi2Ir: Remove unused code 2021-04-21 19:10:31 +03:00
Steven Schäfer
d3d4e94cd6 JVM: Fix constant folding for unsigned values 2021-04-21 19:10:31 +03:00
Dmitry Petrov
732405895f Add tests for KT-45308 2021-04-21 17:36:12 +03:00
Dmitry Petrov
f228c3bb04 Add tests for KT-45236 2021-04-21 17:24:41 +03:00
Yahor Berdnikau
4f352950d9 Include Dukat generated sources into generic 'sourcesJar' output.
Gradle 7 complains that "sourcesJar" task uses inputs from Dukat
generate task outputs directory, but this tasks does not have explicit
dependency.

^KT-46006 Fixed
2021-04-21 16:48:16 +03:00
Mikhail Glukhikh
a097a58edf Introduce helper FirExpression.unwrapArgument() in fir:tree 2021-04-21 16:19:09 +03:00
pyos
e6d923f65c FIR: rename HIDDEN to INVISIBLE_REFERENCE
Some of them should be INVISIBLE_MEMBER though
2021-04-21 16:18:21 +03:00
pyos
f1cf6b54e7 FIR2IR: convert some error calls to non-error IR
This allows suppressing "invisible reference"-type errors, which some
people do in production code.
2021-04-21 16:02:01 +03:00
Mikhail Glukhikh
6833e83a6f Minor fix in FirInlineClassDeclarationChecker 2021-04-21 16:01:51 +03:00
Alexander Udalov
7fe10e27a1 Minor, fix failing codegen tests on different JDKs
#KT-46238
2021-04-21 14:43:10 +02:00
Anton Yalyshev
fe5e968896 Add change-notes for 1.5.0 release 2021-04-21 14:13:46 +03:00
Vladimir Dolzhenko
590a8d088d Refine locking to avoid dead lock
#KT-46215 Fixed
2021-04-21 11:01:12 +00:00
Mikhail Glukhikh
6ae4c3f281 Drop state from FirMethodOfAnyImplementedInInterfaceChecker 2021-04-21 13:22:14 +03:00
Mikhail Glukhikh
e0fe122ee9 Drop stored types from FirInlineClassDeclarationChecker 2021-04-21 13:22:13 +03:00
Mikhail Glukhikh
9bc3404833 Drop state from FirInapplicableLateinitChecker 2021-04-21 13:22:11 +03:00
Mikhail Glukhikh
e0c8a6658b FIR: handle annotations on non-containers more precisely 2021-04-21 13:22:10 +03:00
Mikhail Glukhikh
04daf8fce8 FIR: add messages for two accessor diagnostics 2021-04-21 13:22:09 +03:00
Julia
387dafb8c5 [FIR] Introduce AnnotationUsedAsAnnotationArgumentChecker 2021-04-21 13:22:07 +03:00
Alexander Udalov
27ddc31f15 Ignore codegen test using streams on Android 2021-04-21 11:39:08 +02:00
Dmitry Petrov
59de12c609 Minor: mute bytecode text check in some box tests failing in FIR 2021-04-21 11:27:12 +03:00
Dmitry Petrov
f519150c08 JVM_IR KT-46189 lower tailrec functions after local declarations 2021-04-21 11:27:11 +03:00
Sergey Bogolepov
645014092c Add a mention of KT-46231. 2021-04-21 15:14:33 +07:00
Ilya Gorbunov
4ae5efd6da Prevent calling AssertContentEquals with two Set arguments
It's unclear whether these sets are intended to be compared with
the unordered Set equality, or with the ordered Iterable equality.

KT-32996
2021-04-21 03:08:35 +03:00
Alexander Udalov
21e9bd7ea2 Add regression tests for obsolete issues
#KT-9304
 #KT-14961
 #KT-16549
 #KT-21080
 #KT-28234
 #KT-30102
 #KT-31994
 #KT-34291
 #KT-38099
 #KT-41174
 #KT-44622
 #KT-44701
 #KT-44781
 #KT-44849
 #KT-44978
 #KT-45081
 #KT-45286
 #KT-45383
 #KT-45444
 #KT-45907
2021-04-20 21:24:29 +02:00
Ivan Gavrilovic
2666a93e6a [Gradle] Avoid using dependsOn and add output provider to the file collection 2021-04-20 22:13:25 +03:00
Alexander Udalov
e6c089ef40 IR: fix SAM conversion for types with contravariant intersection argument type
In the added test, the problem was that the SAM type as computed by
`SamTypeFactory.createByValueParameter` was `Consumer<{BaseClass &
BaseInterface}>`, which was latter approximated in psi2ir during the
KotlinType->IrType conversion to `Consumer<out Any?>` (here:
3034d9d791/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ArgumentsGenerationUtils.kt (L606)),
because intersection type argument is approximated to `out Any?`.

To avoid this, replace intersection type in immediate arguments of a SAM
type with the common supertype of its components at the same place where
we're getting rid of projections.

 #KT-45945 Fixed
2021-04-20 17:31:14 +02:00
Andrey Zinovyev
ac0af39660 [FIR][LT] Enable parallel execution for LT tests 2021-04-20 18:13:07 +03:00
Andrey Zinovyev
0a811bdd1a [FIR][LT] Don't store lexer in static context 2021-04-20 18:13:06 +03:00
Andrey Zinovyev
5fc1514104 [FIR][LightTree] Better expression identification
And some refactoring
Regenerate IDE parts
2021-04-20 18:13:06 +03:00
Andrey Zinovyev
2f7d6da22f [FIR][LightTree] Generate and fix missing tests
Add TYPE_PARAMETERS_LIST positioning
Use whole branch as source in when branches
2021-04-20 18:13:05 +03:00
Andrey Zinovyev
b9ae22207e [FIR] Fix tests data for diagnostic tests
For tests failed after light tree changes
2021-04-20 18:13:03 +03:00
Andrey Zinovyev
ee48fc320d [FIR][LightTree] Mark fake nodes in FOR loop
+ fix bunch of tests
2021-04-20 18:13:02 +03:00
Andrey Zinovyev
0a68edf3bd [FIR][LightTree] More fixes in diagnostic positioning
Keep tree padding for modifiers
More REFERENCE_EXPRESSIONS kinds
Fix source for some call expressions
2021-04-20 18:13:01 +03:00
Andrey Zinovyev
f3dc8dfb21 [FIR][LightTree] Use same fake elements kinds as in psi
Otherwise type resolution(!) for empty lambda works differently
2021-04-20 18:13:00 +03:00
Andrey Zinovyev
e8e9f67069 [FIR][LightTree] Enum and property source fixes
Also set dispatchReceiverType for properties from value params
2021-04-20 18:12:59 +03:00
Andrey Zinovyev
1fb8c3b1d7 [FIR][LightTree] Properly unwrap function inside parentheses 2021-04-20 18:12:58 +03:00
Andrey Zinovyev
05f0507cbb [FIR][LightTree] Proper source for enum constructor call 2021-04-20 18:12:57 +03:00
Andrey Zinovyev
bed45affe1 [FIR][LightTree] Don't report diagnostics on some nameless declarations 2021-04-20 18:12:56 +03:00
Andrey Zinovyev
684c4c2825 [FIR][LightTree] Don't position on trailing comments 2021-04-20 18:12:55 +03:00
Andrey Zinovyev
0d99b01dcb [FIR][LightTree] Pass source elements in FOR loop parts 2021-04-20 18:12:54 +03:00
Andrey Zinovyev
8bbdc20809 [FIR][LightTree] Pass source elements in when conditions 2021-04-20 18:12:54 +03:00
Andrey Zinovyev
9c8e92f5af [FIR][LightTree] Fix DEFAULT positioning strategy for object literals 2021-04-20 18:12:53 +03:00
Andrey Zinovyev
70f9b77cce [FIR][LightTree] Keep source in FOR loop elements 2021-04-20 18:12:52 +03:00
Andrey Zinovyev
27766c2575 [FIR] Consistent isLocal for objects inside Enum entries 2021-04-20 18:12:51 +03:00
Andrey Zinovyev
7084fec651 [FIR][LightTree] Position strategies fixes
Skip leading comments in DEFAULT strategy
Keep node offset 'padding' when getting child
2021-04-20 18:12:50 +03:00
Andrey Zinovyev
8ea3b52454 [FIR][LightTree] Fix finding error nodes in tree
When there are links to to 'upper levels' lt elements in fir tree
2021-04-20 18:12:49 +03:00
Andrey Zinovyev
dc19e39dd2 [FIR][LightTree] Properly locate return keyword 2021-04-20 18:12:47 +03:00
Andrey Zinovyev
088db0e138 [FIR] Report SEALED_CLASS_CONSTRUCTOR_CALL on expression 2021-04-20 18:12:46 +03:00
Andrey Zinovyev
48994976d4 [FIR][LightTree] Skip comments and whitespaces when marking elements 2021-04-20 18:12:45 +03:00
Andrey Zinovyev
dcbb1fb22b [FIR][LightTree] Extract syntax errors from subtrees 2021-04-20 18:12:45 +03:00
Andrey Zinovyev
7dedd04ed9 [FIR] Add SYNTAX diagnostics for light tree 2021-04-20 18:12:43 +03:00
Dmitriy Novozhilov
3e0eb06e3e [FIR] Add FirOldFrontendDiagnosticsWithLightTreeTestGenerated 2021-04-20 18:12:42 +03:00
Igor Yakovlev
e4870740e1 [LC] Fixed light classes nullability for Kotlin 1.5
Fixed #KT-44472
2021-04-20 15:21:12 +02:00
Igor Yakovlev
63160293fb [LC] Fix invalid nullability for properties
Fixed #KT-46097 and #KT-41671
2021-04-20 15:21:12 +02:00
1106 changed files with 55602 additions and 4399 deletions

View File

@@ -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.20-dev-4865"
extra["versions.kotlin-native"] = "1.5.20-dev-5613"
}
val intellijUltimateEnabled by extra(project.kotlinBuildProperties.intellijUltimateEnabled)
@@ -368,7 +368,8 @@ val gradlePluginProjects = listOf(
":kotlin-annotation-processing-gradle",
":kotlin-noarg",
":kotlin-sam-with-receiver",
":kotlin-parcelize-compiler"
":kotlin-parcelize-compiler",
":kotlin-lombok"
)
apply {
@@ -577,26 +578,6 @@ allprojects {
}
}
if ((gradle.startParameter as? org.gradle.api.internal.StartParameterInternal)?.isConfigurationCache != true) {
// TODO: remove it once Gradle is bumped to 6.8:
// See https://docs.gradle.org/6.8/release-notes.html#more-cache-hits-when-empty-directories-are-present
gradle.buildFinished {
val taskGraph = gradle?.taskGraph
if (taskGraph != null) {
taskGraph.allTasks
.filterIsInstance<SourceTask>()
.filter { it.didWork }
.forEach {
it.source.visit {
if (file.isDirectory && file.listFiles()?.isEmpty() == true) {
logger.warn("Empty source directories may cause build cache misses: " + file.absolutePath)
}
}
}
}
}
}
gradle.taskGraph.whenReady {
fun Boolean.toOnOff(): String = if (this) "on" else "off"
val profile = if (isTeamcityBuild) "CI" else "Local"

View File

@@ -5,6 +5,7 @@
package plugins
import PublishToMavenLocalSerializable
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.attributes.Usage
@@ -13,10 +14,10 @@ import org.gradle.api.plugins.JavaBasePlugin
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
import org.gradle.api.publish.maven.tasks.PublishToMavenLocal
import org.gradle.api.publish.maven.tasks.PublishToMavenRepository
import org.gradle.api.tasks.TaskProvider
import org.gradle.kotlin.dsl.*
import org.gradle.plugins.signing.Sign
import org.gradle.plugins.signing.SigningExtension
import org.gradle.plugins.signing.SigningPlugin
import java.util.*
@@ -27,7 +28,6 @@ class KotlinBuildPublishingPlugin @Inject constructor(
) : Plugin<Project> {
override fun apply(target: Project): Unit = with(target) {
apply<MavenPublishPlugin>()
apply<SigningPlugin>()
val publishedRuntime = configurations.maybeCreate(RUNTIME_CONFIGURATION).apply {
isCanBeConsumed = false
@@ -132,32 +132,40 @@ fun Project.configureDefaultPublishing() {
}
}
configureSigning()
val signingRequired = project.providers.gradleProperty("signingRequired").forUseAtConfigurationTime().orNull?.toBoolean()
?: project.providers.gradleProperty("isSonatypeRelease").forUseAtConfigurationTime().orNull?.toBoolean() ?: false
if (signingRequired) {
apply<SigningPlugin>()
configureSigning()
}
tasks.register("install") {
dependsOn(tasks.named("publishToMavenLocal"))
}
// workaround for Gradle configuration cache
// TODO: remove it when https://github.com/gradle/gradle/pull/16945 merged into used in build Gradle version
tasks.withType(PublishToMavenLocal::class.java) {
val originalTask = this
val serializablePublishTask =
tasks.register(originalTask.name + "Serializable", PublishToMavenLocalSerializable::class.java) {
publication = originalTask.publication
}
originalTask.onlyIf { false }
originalTask.dependsOn(serializablePublishTask)
}
tasks.withType<PublishToMavenRepository>()
.matching { it.name.endsWith("PublicationTo${KotlinBuildPublishingPlugin.REPOSITORY_NAME}Repository") }
.all { configureRepository() }
}
private fun Project.configureSigning() {
val signingRequired = provider {
project.findProperty("signingRequired")?.toString()?.toBoolean()
?: project.property("isSonatypeRelease") as Boolean
}
configure<SigningExtension> {
setRequired(signingRequired)
sign(extensions.getByType<PublishingExtension>().publications) // all publications
useGpgCmd()
}
tasks.withType<Sign>().configureEach {
setOnlyIf { signingRequired.get() }
}
}
fun TaskProvider<PublishToMavenRepository>.configureRepository() =
@@ -181,4 +189,4 @@ private fun PublishToMavenRepository.configureRepository() {
}
}
}
}
}

View File

@@ -7,13 +7,22 @@
// usages in build scripts are not tracked properly
@file:Suppress("unused")
import org.gradle.api.InvalidUserDataException
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.file.FileSystemOperations
import org.gradle.api.internal.tasks.testing.filter.DefaultTestFilter
import org.gradle.api.publish.internal.PublishOperation
import org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal
import org.gradle.api.publish.maven.internal.publisher.MavenNormalizedPublication
import org.gradle.api.publish.maven.internal.publisher.MavenPublisher
import org.gradle.api.publish.maven.internal.publisher.ValidatingMavenPublisher
import org.gradle.api.publish.maven.tasks.AbstractPublishToMaven
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.TaskProvider
import org.gradle.api.tasks.testing.Test
import org.gradle.internal.serialization.Cached
import org.gradle.kotlin.dsl.extra
import org.gradle.kotlin.dsl.project
import org.gradle.kotlin.dsl.support.serviceOf
@@ -38,6 +47,7 @@ val kotlinGradlePluginAndItsRequired = arrayOf(
":kotlin-compiler-runner",
":kotlin-daemon-embeddable",
":kotlin-daemon-client",
":kotlin-project-model",
":kotlin-gradle-plugin-api",
":kotlin-gradle-plugin",
":kotlin-gradle-plugin-model",
@@ -279,3 +289,30 @@ fun Task.useAndroidSdk() {
fun Task.useAndroidJar() {
TaskUtils.useAndroidJar(this)
}
// Workaround to make PublishToMavenLocal compatible with Gradle configuration cache
// TODO: remove it when https://github.com/gradle/gradle/pull/16945 merged into used in build Gradle version
abstract class PublishToMavenLocalSerializable : AbstractPublishToMaven() {
private val normalizedPublication = Cached.of { this.computeNormalizedPublication() }
private fun computeNormalizedPublication(): MavenNormalizedPublication {
val publicationInternal: MavenPublicationInternal = publicationInternal
?: throw InvalidUserDataException("The 'publication' property is required")
duplicatePublicationTracker.checkCanPublishToMavenLocal(publicationInternal)
return publicationInternal.asNormalisedPublication()
}
@TaskAction
open fun publish() {
val normalizedPublication = normalizedPublication.get()
object : PublishOperation(normalizedPublication.name, "mavenLocal") {
override fun publish() {
val localPublisher = mavenPublishers.getLocalPublisher(
temporaryDirFactory
)
val validatingPublisher: MavenPublisher = ValidatingMavenPublisher(localPublisher)
validatingPublisher.publish(normalizedPublication, null)
}
}.run()
}
}

View File

@@ -87,4 +87,4 @@ open class SamTypeFactory {
companion object {
val INSTANCE = SamTypeFactory()
}
}
}

View File

@@ -158,7 +158,14 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
for (int i = 0; i < superInterfaceTypes.size(); i++) {
KotlinType superInterfaceType = superInterfaceTypes.get(i);
sw.writeInterface();
superInterfaceAsmTypes[i] = typeMapper.mapSupertype(superInterfaceType, sw).getInternalName();
Type superInterfaceAsmType;
if (samType != null && superInterfaceType.getConstructor() == samType.getType().getConstructor()) {
superInterfaceAsmType = typeMapper.mapSupertype(superInterfaceType, null);
sw.writeAsmType(superInterfaceAsmType);
} else {
superInterfaceAsmType = typeMapper.mapSupertype(superInterfaceType, sw);
}
superInterfaceAsmTypes[i] = superInterfaceAsmType.getInternalName();
sw.writeInterfaceEnd();
}

View File

@@ -39,7 +39,7 @@ class RedundantBoxingMethodTransformer(private val generationState: GenerationSt
override fun transform(internalClassName: String, node: MethodNode) {
val interpreter = RedundantBoxingInterpreter(node.instructions, generationState)
val frames = MethodTransformer.analyze(internalClassName, node, interpreter)
val frames = analyze(internalClassName, node, interpreter)
interpretPopInstructionsForBoxedValues(interpreter, node, frames)
@@ -168,7 +168,8 @@ class RedundantBoxingMethodTransformer(private val generationState: GenerationSt
val frame = frames[i] ?: continue
val insn = insnList[i]
if ((insn.opcode == Opcodes.ASTORE || insn.opcode == Opcodes.ALOAD) &&
(insn as VarInsnNode).`var` == localVariableNode.index) {
(insn as VarInsnNode).`var` == localVariableNode.index
) {
if (insn.getOpcode() == Opcodes.ASTORE) {
values.add(frame.top()!!)
} else {

View File

@@ -87,11 +87,6 @@ fun CallableMemberDescriptor.createTypeParameterWithNewName(
return newDescriptor
}
fun KotlinType.removeExternalProjections(): KotlinType {
val newArguments = arguments.map { TypeProjectionImpl(Variance.INVARIANT, it.type) }
return replace(newArguments)
}
fun isInlineClassConstructorAccessor(descriptor: FunctionDescriptor): Boolean =
descriptor is AccessorForConstructorDescriptor &&
descriptor.calleeDescriptor.constructedClass.isInlineClass()

View File

@@ -33,13 +33,11 @@ import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.extensions.ExtensionsArea
import com.intellij.openapi.fileTypes.PlainTextFileType
import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.LanguageLevelProjectExtension
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.util.io.FileUtilRt
import com.intellij.openapi.util.text.StringUtil
import com.intellij.openapi.vfs.*
import com.intellij.openapi.vfs.impl.ZipHandler
import com.intellij.pom.java.LanguageLevel
import com.intellij.psi.PsiElementFinder
import com.intellij.psi.PsiManager
import com.intellij.psi.impl.JavaClassSupersImpl
@@ -94,6 +92,7 @@ import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.resolve.CodeAnalyzerInitializer
import org.jetbrains.kotlin.resolve.ModuleAnnotationsResolver
import org.jetbrains.kotlin.resolve.extensions.ExtraImportsProviderExtension
import org.jetbrains.kotlin.resolve.jvm.extensions.SyntheticJavaResolveExtension
import org.jetbrains.kotlin.resolve.extensions.SyntheticResolveExtension
import org.jetbrains.kotlin.resolve.jvm.KotlinJavaPsiFacade
import org.jetbrains.kotlin.resolve.jvm.extensions.AnalysisHandlerExtension
@@ -577,6 +576,7 @@ class KotlinCoreEnvironment private constructor(
fun registerPluginExtensionPoints(project: MockProject) {
ExpressionCodegenExtension.registerExtensionPoint(project)
SyntheticResolveExtension.registerExtensionPoint(project)
SyntheticJavaResolveExtension.registerExtensionPoint(project)
ClassBuilderInterceptorExtension.registerExtensionPoint(project)
AnalysisHandlerExtension.registerExtensionPoint(project)
PackageFragmentProviderExtension.registerExtensionPoint(project)

View File

@@ -96,6 +96,7 @@ import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.resolve.CodeAnalyzerInitializer
import org.jetbrains.kotlin.resolve.ModuleAnnotationsResolver
import org.jetbrains.kotlin.resolve.extensions.ExtraImportsProviderExtension
import org.jetbrains.kotlin.resolve.jvm.extensions.SyntheticJavaResolveExtension
import org.jetbrains.kotlin.resolve.extensions.SyntheticResolveExtension
import org.jetbrains.kotlin.resolve.jvm.KotlinJavaPsiFacade
import org.jetbrains.kotlin.resolve.jvm.extensions.AnalysisHandlerExtension
@@ -569,6 +570,7 @@ class KotlinCoreEnvironment private constructor(
fun registerPluginExtensionPoints(project: MockProject) {
ExpressionCodegenExtension.registerExtensionPoint(project)
SyntheticResolveExtension.registerExtensionPoint(project)
SyntheticJavaResolveExtension.registerExtensionPoint(project)
ClassBuilderInterceptorExtension.registerExtensionPoint(project)
AnalysisHandlerExtension.registerExtensionPoint(project)
PackageFragmentProviderExtension.registerExtensionPoint(project)

View File

@@ -37,8 +37,7 @@ import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.cli.common.checkKotlinPackageUsage
import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoot
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.OUTPUT
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.WARNING
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.*
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.cli.common.messages.OutputMessageUtil
import org.jetbrains.kotlin.cli.common.output.writeAll
@@ -305,6 +304,11 @@ object KotlinToJVMBytecodeCompiler {
val project = environment.project
val performanceManager = environment.configuration.get(CLIConfigurationKeys.PERF_MANAGER)
environment.messageCollector.report(
STRONG_WARNING,
"ATTENTION!\n This build uses in-dev FIR: \n -Xuse-fir"
)
PsiElementFinder.EP.getPoint(project).unregisterExtension(JavaElementFinder::class.java)
val projectConfiguration = environment.configuration

View File

@@ -367,8 +367,14 @@ object KotlinCompilerClient {
}
private fun startDaemon(compilerId: CompilerId, daemonJVMOptions: DaemonJVMOptions, daemonOptions: DaemonOptions, reportingTargets: DaemonReportingTargets): Boolean {
val javaExecutable = File(File(CompilerSystemProperties.JAVA_HOME.safeValue, "bin"), "java")
private fun startDaemon(
compilerId: CompilerId,
daemonJVMOptions: DaemonJVMOptions,
daemonOptions: DaemonOptions,
reportingTargets: DaemonReportingTargets
): Boolean {
val daemonJavaExecutable = compilerId.javaExecutable
?: File(File(CompilerSystemProperties.JAVA_HOME.safeValue, "bin"), "java")
val serverHostname = CompilerSystemProperties.JAVA_RMI_SERVER_HOSTNAME.value ?: error("${CompilerSystemProperties.JAVA_RMI_SERVER_HOSTNAME.property} is not set!")
val platformSpecificOptions = listOf(
// hide daemon window
@@ -380,7 +386,7 @@ object KotlinCompilerClient {
listOf("--illegal-access=permit")
else emptyList()
val args = listOf(
javaExecutable.absolutePath, "-cp", compilerId.compilerClasspath.joinToString(File.pathSeparator)) +
daemonJavaExecutable.absolutePath, "-cp", compilerId.compilerClasspath.joinToString(File.pathSeparator)) +
platformSpecificOptions +
daemonJVMOptions.mappers.flatMap { it.toArgs("-") } +
javaIllegalAccessWorkaround +

View File

@@ -49,7 +49,7 @@ suspend fun walkDaemonsAsync(
useRMI: Boolean = true,
useSockets: Boolean = true
): List<DaemonWithMetadataAsync> { // TODO: replace with Deferred<List<DaemonWithMetadataAsync>> and use mapNotNullAsync to speed this up
val classPathDigest = compilerId.compilerClasspath.map { File(it).absolutePath }.distinctStringsDigest().toHexString()
val classPathDigest = compilerId.digest()
val portExtractor = makePortFromRunFilenameExtractor(classPathDigest)
return registryDir.walk().toList() // list, since walk returns Sequence and Sequence.map{...} is not inline => coroutines dont work
.map { Pair(it, portExtractor(it.name)) }

View File

@@ -217,7 +217,7 @@ class CompileServiceRMIWrapper(val server: CompileServiceServerSide, daemonOptio
runFileDir,
makeRunFilenameString(
timestamp = "%tFT%<tH-%<tM-%<tS.%<tLZ".format(Calendar.getInstance(TimeZone.getTimeZone("Z"))),
digest = compilerId.compilerClasspath.map { File(it).absolutePath }.distinctStringsDigest().toHexString(),
digest = compilerId.digest(),
port = port.toString()
)
)

View File

@@ -55,7 +55,7 @@ fun walkDaemons(registryDir: File,
filter: (File, Int) -> Boolean = { _, _ -> true },
report: (DaemonReportCategory, String) -> Unit = { _, _ -> }
): Sequence<DaemonWithMetadata> {
val classPathDigest = compilerId.compilerClasspath.map { File(it).absolutePath }.distinctStringsDigest().toHexString()
val classPathDigest = compilerId.digest()
val portExtractor = makePortFromRunFilenameExtractor(classPathDigest)
return registryDir.walk()
.map { Pair(it, portExtractor(it.name)) }

View File

@@ -231,12 +231,38 @@ fun ByteArray.toHexString(): String = joinToString("", transform = { "%02x".form
data class CompilerId(
var compilerClasspath: List<String> = listOf(),
var compilerVersion: String = ""
var compilerVersion: String = "",
var javaExecutable: File? = null
) : OptionsGroup {
override val mappers: List<PropMapper<*, *, *>>
get() = listOf(PropMapper(this, CompilerId::compilerClasspath, toString = { it.joinToString(File.pathSeparator) }, fromString = { it.trimQuotes().split(File.pathSeparator) }),
StringPropMapper(this, CompilerId::compilerVersion))
get() = listOf(
PropMapper(
dest = this,
prop = CompilerId::compilerClasspath,
toString = { it.joinToString(File.pathSeparator) },
fromString = { it.trimQuotes().split(File.pathSeparator) }
),
StringPropMapper(
dest = this,
prop = CompilerId::compilerVersion
),
PropMapper(
dest = this,
prop = CompilerId::javaExecutable,
toString = { it?.absolutePath },
fromString = { File(it.trimQuotes()) },
skipIf = { it == null }
)
)
fun digest(): String = compilerClasspath
.map { File(it).absolutePath }
.run {
javaExecutable?.let { plus(it.absolutePath) } ?: this
}
.distinctStringsDigest()
.toHexString()
companion object {
@JvmStatic
@@ -245,6 +271,15 @@ data class CompilerId(
@JvmStatic
fun makeCompilerId(paths: Iterable<File>): CompilerId =
CompilerId(compilerClasspath = paths.map { it.absolutePath })
@JvmStatic
fun makeCompilerId(
paths: Iterable<File>,
javaExecutable: File
): CompilerId = CompilerId(
compilerClasspath = paths.map { it.absolutePath },
javaExecutable = javaExecutable
)
}
}

View File

@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.daemon
import com.intellij.openapi.util.SystemInfo
import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.util.io.FileUtilRt
import junit.framework.TestCase
@@ -277,6 +278,129 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
}
}
private fun getJdk8Location() = System.getenv("JDK_18") ?: System.getenv("JAVA_HOME")
fun testNewDaemonIsNotStartedForSameJavaExecutable() {
withFlagFile(getTestName(true), "-client1.alive") { flagFile1 ->
withFlagFile(getTestName(true), "-client2.alive") { flagFile2 ->
val daemonOptions = makeTestDaemonOptions(getTestName(true))
val compilerIdJdk8 = CompilerId.makeCompilerId(
compilerClassPath +
File(KotlinIntegrationTestBase.getCompilerLib(), "kotlin-compiler-sources.jar"),
File(getJdk8Location()).resolve("bin/java")
)
withLogFile("kotlin-daemon-test-1") { logFile ->
val daemonJVMOptions = makeTestDaemonJvmOptions(logFile)
assertTrue(logFile.length() == 0L)
val daemon1 = KotlinCompilerClient.connectToCompileService(
compilerIdJdk8,
flagFile1,
daemonJVMOptions,
daemonOptions,
DaemonReportingTargets(out = System.err),
autostart = true
)
assertNotNull("failed to connect daemon", daemon1)
logFile.assertLogContainsSequence("INFO: starting daemon")
val daemon2 = KotlinCompilerClient.connectToCompileService(
compilerIdJdk8,
flagFile2,
daemonJVMOptions,
daemonOptions,
DaemonReportingTargets(out = System.err),
autostart = true
)
assertNotNull("failed to connect daemon", daemon2)
val logContent = logFile.readText().lines()
assert(
logContent.filter { it.contains("INFO: starting daemon") }.size == 1
) {
"Second daemon instance was started!"
}
assert(
logContent.filter {
it.contains("INFO: Registered a client alive file: ${flagFile2.absolutePath}")
}.size == 1
) {
"Second client was not connected to the same instance!"
}
KotlinCompilerClient.shutdownCompileService(compilerIdJdk8, daemonOptions)
Thread.sleep(100)
logFile.assertLogContainsSequence("Shutdown started")
}
}
}
}
// Ignored on Windows OS due to https://bugs.openjdk.java.net/browse/JDK-8189953 bug in JDK 9
// Should be unignored once JDK10+ will be available by default on CI agents
fun testNewDaemonIsStartedOnJavaExecutableChange() {
if (SystemInfo.isWindows) return
withFlagFile(getTestName(true), "-client1.alive") { flagFile1 ->
withFlagFile(getTestName(true), "-client2.alive") { flagFile2 ->
val daemonOptions = makeTestDaemonOptions(getTestName(true))
val compilerIdJdk8 = CompilerId.makeCompilerId(
compilerClassPath +
File(KotlinIntegrationTestBase.getCompilerLib(), "kotlin-compiler-sources.jar"),
File(getJdk8Location()).resolve("bin/java")
)
val compilerIdJdk9 = CompilerId.makeCompilerId(
compilerClassPath +
File(KotlinIntegrationTestBase.getCompilerLib(), "kotlin-compiler-sources.jar"),
File(System.getenv("JDK_9")).resolve("bin/java")
)
withLogFile("kotlin-daemon-test-1") { logFile1 ->
withLogFile("kotlin-daemon-test-2") { logFile2 ->
val daemonJdk8JVMOptions = makeTestDaemonJvmOptions(logFile1)
assertTrue(logFile1.length() == 0L)
val daemonJdk9JVMOptions = makeTestDaemonJvmOptions(logFile2)
assertTrue(logFile2.length() == 0L)
val daemonJdk7 = KotlinCompilerClient.connectToCompileService(
compilerIdJdk8,
flagFile1,
daemonJdk8JVMOptions,
daemonOptions,
DaemonReportingTargets(out = System.err),
autostart = true
)
assertNotNull("failed to connect daemon", daemonJdk7)
logFile1.assertLogContainsSequence("INFO: starting daemon")
val daemonJdk9 = KotlinCompilerClient.connectToCompileService(
compilerIdJdk9,
flagFile2,
daemonJdk9JVMOptions,
daemonOptions,
DaemonReportingTargets(out = System.err),
autostart = true
)
assertNotNull("failed to connect daemon", daemonJdk9)
logFile2.assertLogContainsSequence("INFO: starting daemon")
KotlinCompilerClient.shutdownCompileService(compilerIdJdk8, daemonOptions)
KotlinCompilerClient.shutdownCompileService(compilerIdJdk9, daemonOptions)
Thread.sleep(100)
logFile1.assertLogContainsSequence("Shutdown started")
logFile2.assertLogContainsSequence("Shutdown started")
}
}
}
}
}
fun testDaemonRunError() {
withFlagFile(getTestName(true), ".alive") { flagFile ->
val daemonOptions = DaemonOptions(shutdownDelayMilliseconds = 1, verbose = true, runFilesPath = File(testTempDir, getTestName(true)).absolutePath)

View File

@@ -243,7 +243,7 @@ abstract class CompileServiceImplBase(
runFileDir,
makeRunFilenameString(
timestamp = "%tFT%<tH-%<tM-%<tS.%<tLZ".format(Calendar.getInstance(TimeZone.getTimeZone("Z"))),
digest = compilerId.compilerClasspath.map { File(it).absolutePath }.distinctStringsDigest().toHexString(),
digest = compilerId.digest(),
port = port.toString()
)
)

View File

@@ -29,6 +29,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
}
@TestMetadata("annotationUsedAsAnnotationArgument.kt")
public void testAnnotationUsedAsAnnotationArgument() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/annotationUsedAsAnnotationArgument.kt");
}
@TestMetadata("asImports.kt")
public void testAsImports() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/asImports.kt");
@@ -174,6 +179,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
runTest("compiler/fir/analysis-tests/testData/resolve/ft.kt");
}
@TestMetadata("funInterfaceDeclaration.kt")
public void testFunInterfaceDeclaration() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/funInterfaceDeclaration.kt");
}
@TestMetadata("functionTypeAlias.kt")
public void testFunctionTypeAlias() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/functionTypeAlias.kt");

View File

@@ -0,0 +1,27 @@
FILE: annotationUsedAsAnnotationArgument.kt
public final annotation class Ann : R|kotlin/Annotation| {
public constructor(): R|Ann| {
super<R|kotlin/Any|>()
}
}
public final annotation class Ann2 : R|kotlin/Annotation| {
public constructor(): R|Ann2| {
super<R|kotlin/Any|>()
}
}
public final annotation class Ann3 : R|kotlin/Annotation| {
public constructor(arg: R|kotlin/Int|, s: R|kotlin/String|): R|Ann3| {
super<R|kotlin/Any|>()
}
public final val arg: R|kotlin/Int| = R|<local>/arg|
public get(): R|kotlin/Int|
public final val s: R|kotlin/String| = R|<local>/s|
public get(): R|kotlin/String|
}
@R|Ann3|(@R|Ann3|(@R|Ann|() Int(5), String()) @R|Ann2|() Int(1), String()) public final val a: R|kotlin/Int| = Int(0)
public get(): R|kotlin/Int|

View File

@@ -0,0 +1,11 @@
annotation class Ann
annotation class Ann2
annotation class Ann3(val arg: Int, val s: String)
@Ann3(
<!ANNOTATION_USED_AS_ANNOTATION_ARGUMENT!>@Ann3(
<!ANNOTATION_USED_AS_ANNOTATION_ARGUMENT!>@Ann<!> 5, ""
)<!> <!ANNOTATION_USED_AS_ANNOTATION_ARGUMENT!>@Ann2<!> 1, ""
) val a = 0

View File

@@ -15,5 +15,5 @@ class B : A() {
}
fun test(b: B) {
b.<!HIDDEN!>foo<!>("")
b.<!INVISIBLE_REFERENCE!>foo<!>("")
}

View File

@@ -8,5 +8,5 @@ FILE: stringTemplates.kt
public final fun foo(s: R|kotlin/String|): R|kotlin/Unit| {
}
public final fun test(a: R|A|): R|kotlin/Unit| {
R|/foo|(<strcat>(R|<local>/a|.R|kotlin/Any.toString|()))
R|/foo|(<strcat>(R|<local>/a|))
}

View File

@@ -11,7 +11,7 @@ FILE: const.kt
public get(): R|kotlin/String|
public final const val f: R|kotlin/Int| = Int(1).R|kotlin/Int.plus|(Int(2)).R|kotlin/Int.times|(Int(3)).R|kotlin/Int.div|(Int(4)).R|kotlin/Int.rem|(Int(5)).R|kotlin/Int.minus|(Int(1))
public get(): R|kotlin/Int|
public final const val g: R|kotlin/String| = <strcat>(String(string ), R|/f|.R|kotlin/Any.toString|())
public final const val g: R|kotlin/String| = <strcat>(String(string ), R|/f|)
public get(): R|kotlin/String|
public final const val h: R|kotlin/String| = String(string).R|kotlin/String.plus|(R|/g|)
public get(): R|kotlin/String|

View File

@@ -50,5 +50,5 @@ FILE: annotationArgumentMustBeConst.kt
public get(): R|kotlin/Int|
}
@R|Ann1|(vararg(R|/foo|, R|/foo|.R|kotlin/String.plus|(R|/bar|), <strcat>(R|/foo|.R|kotlin/Any.toString|(), String( ), R|/bar|.R|kotlin/Any.toString|()), <strcat>(R|/baz|().R|kotlin/Any.toString|(), String( )))) @R|Ann2|(<implicitArrayOf>(R|/bar|, R|/baz|(), R|/bar|.R|kotlin/Int.plus|(R|/cnst|))) @R|Ann3|(R|/arr|) public final fun test(): R|kotlin/Unit| {
@R|Ann1|(vararg(R|/foo|, R|/foo|.R|kotlin/String.plus|(R|/bar|), <strcat>(R|/foo|, String( ), R|/bar|), <strcat>(R|/baz|(), String( )))) @R|Ann2|(<implicitArrayOf>(R|/bar|, R|/baz|(), R|/bar|.R|kotlin/Int.plus|(R|/cnst|))) @R|Ann3|(R|/arr|) public final fun test(): R|kotlin/Unit| {
}

View File

@@ -2,7 +2,7 @@ fun foo() {
<!LOCAL_ANNOTATION_CLASS_ERROR!>annotation class Ann<!>
@Ann class Local {
<!LOCAL_ANNOTATION_CLASS_ERROR{LT}!>// There should also be NESTED_CLASS_NOT_ALLOWED report here.
<!LOCAL_ANNOTATION_CLASS_ERROR{PSI}!>annotation <!NESTED_CLASS_NOT_ALLOWED!>class Nested<!><!><!>
// There should also be NESTED_CLASS_NOT_ALLOWED report here.
<!LOCAL_ANNOTATION_CLASS_ERROR!>annotation <!NESTED_CLASS_NOT_ALLOWED!>class Nested<!><!>
}
}

View File

@@ -1,3 +1,3 @@
sealed class A
val b = <!HIDDEN!>A<!>()
val b = <!INVISIBLE_REFERENCE!>A<!>()

View File

@@ -21,7 +21,7 @@ val a = <!TYPE_ARGUMENTS_NOT_ALLOWED!>rest<Int><!>.<!UNRESOLVED_REFERENCE!>MyCla
val b = Best.<!UNRESOLVED_REFERENCE!>MyClass<!><String>
class B<E>
class C<F<!SYNTAX{PSI}!><<!><!SYNTAX{PSI}!>Boolean<!><!SYNTAX{PSI}!>><!><!SYNTAX{PSI}!>><!> <!SYNTAX{PSI}!>:<!> <!SYNTAX{PSI}!>B<!><!SYNTAX{PSI}!><<!><!SYNTAX{PSI}!>F<!><!SYNTAX{PSI}!><<!><!SYNTAX{PSI}!>Boolean<!><!SYNTAX{PSI}!>><!><!SYNTAX{PSI}!>><!><!SYNTAX{PSI}!>(<!><!SYNTAX{PSI}!>)<!>
class C<F<!SYNTAX!><<!><!SYNTAX!>Boolean<!><!SYNTAX!>><!><!SYNTAX!>><!> <!SYNTAX!>:<!> <!SYNTAX!>B<!><!SYNTAX!><<!><!SYNTAX!>F<!><!SYNTAX!><<!><!SYNTAX!>Boolean<!><!SYNTAX!>><!><!SYNTAX!>><!><!SYNTAX!>(<!><!SYNTAX!>)<!>
fun <G> gest() {}

View File

@@ -14,7 +14,7 @@ fun test() {
val b1 = B<<!UPPER_BOUND_VIOLATED!>Int<!>>()
val b2 = B<C>()
val b3 = B<<!UPPER_BOUND_VIOLATED!>Any?<!>>()
val b4 = B<<!UNRESOLVED_REFERENCE!>UnexistingType<!>>()<!UNRESOLVED_REFERENCE{PSI}!>NL<!><!SYNTAX{PSI}!><<!>Int<!SYNTAX{PSI}!>><!>()NumberPhile<!SYNTAX{PSI}!><!>
val b4 = B<<!UNRESOLVED_REFERENCE!>UnexistingType<!>>()<!UNRESOLVED_REFERENCE!>NL<!><!SYNTAX!><<!>Int<!SYNTAX!>><!>()NumberPhile<!SYNTAX!><!>
val b5 = B<<!UPPER_BOUND_VIOLATED!>B<<!UNRESOLVED_REFERENCE!>UnexistingType<!>><!>>()
fest<<!UPPER_BOUND_VIOLATED!>Boolean<!>>()
fest<C>()
@@ -40,7 +40,7 @@ fun <K, L : K> rest() {
class NumColl<T : Collection<Number>>
typealias NL<K> = NumColl<List<K>>
val test7 = NL<Int>()<!UNRESOLVED_REFERENCE{PSI}!>NumberPhile<!><!SYNTAX{PSI}!><!>
val test7 = NL<Int>()<!UNRESOLVED_REFERENCE!>NumberPhile<!><!SYNTAX!><!>
val test8 = NL<String>()
class NumberPhile<T: Number>(x: T)

View File

@@ -17,11 +17,11 @@ FILE: lambda.kt
}
)
R|/itIs|(<L> = itIs@fun <anonymous>(it: R|kotlin/String|): R|kotlin/String| <inline=NoInline> {
^ <strcat>(String(this is ), R|<local>/it|.R|kotlin/Any.toString|(), String( test))
^ <strcat>(String(this is ), R|<local>/it|, String( test))
}
)
R|/multipleArgs|(<L> = multipleArgs@fun <anonymous>(a: R|kotlin/String|, b: R|kotlin/String|): R|kotlin/String| <inline=NoInline> {
^ <strcat>(String(This is test of ), R|<local>/a|.R|kotlin/Any.toString|(), String(, ), R|<local>/b|.R|kotlin/Any.toString|())
^ <strcat>(String(This is test of ), R|<local>/a|, String(, ), R|<local>/b|)
}
)
lval s: R|kotlin/String| = fun <anonymous>(): R|kotlin/String| <inline=Unknown> {

View File

@@ -11,8 +11,8 @@ open class Outer {
class Derived : Outer() {
fun foo() {
Outer.<!HIDDEN!>PrivateNested<!>()
super.<!HIDDEN!>PrivateInner<!>()
Outer.<!INVISIBLE_REFERENCE!>PrivateNested<!>()
super.<!INVISIBLE_REFERENCE!>PrivateInner<!>()
Outer.ProtectedNested()
super.ProtectedInner()
@@ -23,11 +23,11 @@ class Derived : Outer() {
}
fun foo() {
Outer.<!HIDDEN!>PrivateNested<!>()
Outer().<!HIDDEN!>PrivateInner<!>()
Outer.<!INVISIBLE_REFERENCE!>PrivateNested<!>()
Outer().<!INVISIBLE_REFERENCE!>PrivateInner<!>()
Outer.<!HIDDEN!>ProtectedNested<!>()
Outer().<!HIDDEN!>ProtectedInner<!>()
Outer.<!INVISIBLE_REFERENCE!>ProtectedNested<!>()
Outer().<!INVISIBLE_REFERENCE!>ProtectedInner<!>()
Outer.PublicNested()
Outer().PublicInner()

View File

@@ -9,21 +9,21 @@ private class Private {
bar()
Nested()
fromCompanion()
NotCompanion.<!HIDDEN!>foo<!>() // hidden
NotCompanion.<!INVISIBLE_REFERENCE!>foo<!>() // hidden
}
inner class Inner {
fun foo() {
bar()
fromCompanion()
NotCompanion.<!HIDDEN!>foo<!>() // hidden
NotCompanion.<!INVISIBLE_REFERENCE!>foo<!>() // hidden
}
}
private class Nested {
fun foo() {
fromCompanion()
NotCompanion.<!HIDDEN!>foo<!>() // hidden
NotCompanion.<!INVISIBLE_REFERENCE!>foo<!>() // hidden
}
}
@@ -54,7 +54,7 @@ fun withLocals() {
Local().baz()
Local().<!HIDDEN!>bar<!>() // hidden
Local().<!INVISIBLE_REFERENCE!>bar<!>() // hidden
}
fun test() {
@@ -62,14 +62,14 @@ fun test() {
Private().baz()
Private().Inner()
Private().<!HIDDEN!>bar<!>() // hidden
Private.<!HIDDEN!>Nested<!>() // hidden
Private.<!HIDDEN!>fromCompanion<!>() // hidden
Private().<!INVISIBLE_REFERENCE!>bar<!>() // hidden
Private.<!INVISIBLE_REFERENCE!>Nested<!>() // hidden
Private.<!INVISIBLE_REFERENCE!>fromCompanion<!>() // hidden
}
// FILE: second.kt
fun secondTest() {
<!HIDDEN!>foo<!>() // hidden
<!HIDDEN!>Private<!>() // hidden
<!INVISIBLE_REFERENCE!>foo<!>() // hidden
<!INVISIBLE_REFERENCE!>Private<!>() // hidden
}

View File

@@ -31,7 +31,7 @@ class Derived : Protected() {
fun foo() {
bar()
Nested().foo()
Nested().<!HIDDEN!>bar<!>() // hidden
Nested().<!INVISIBLE_REFERENCE!>bar<!>() // hidden
fromCompanion()
protectedFromCompanion()
@@ -48,8 +48,8 @@ fun test() {
Protected().baz()
Protected().Inner()
Protected().<!HIDDEN!>bar<!>() // hidden
Protected.<!HIDDEN!>Nested<!>() // hidden
Protected().<!INVISIBLE_REFERENCE!>bar<!>() // hidden
Protected.<!INVISIBLE_REFERENCE!>Nested<!>() // hidden
}
open class Generic<T>(val x: T) {

View File

@@ -1,7 +1,7 @@
FILE: StringTemplate.kt
public abstract interface IC : R|kotlin/Any| {
public open fun toString(x: R|kotlin/String|): R|kotlin/String| {
^toString <strcat>(String(IC), R|<local>/x|.R|kotlin/Any.toString|())
^toString <strcat>(String(IC), R|<local>/x|)
}
}

View File

@@ -57,7 +57,7 @@ FILE: RedundantExplicitTypeChecker.kt
}
public final fun foo(): R|kotlin/Unit| {
lval s: R|kotlin/String| = <strcat>(String(Hello ), Int(10).R|kotlin/Int.plus|(Int(1)).R|kotlin/Any.toString|())
lval s: R|kotlin/String| = <strcat>(String(Hello ), Int(10).R|kotlin/Int.plus|(Int(1)))
lval str: R|kotlin/String?| = String()
lval o: R|Obj| = Q|Obj|
lval p: R|Point| = R|/PointImpl.PointImpl|(Int(1), Int(2))

View File

@@ -14,7 +14,7 @@ FILE: RedundantSetterParameterTypeChecker.kt
public final var x: R|kotlin/String| = String()
public get(): R|kotlin/String|
public set(param: R|kotlin/String|): R|kotlin/Unit| {
F|/x| = <strcat>(R|<local>/param|.R|kotlin/Any.toString|(), String( ))
F|/x| = <strcat>(R|<local>/param|, String( ))
}
public final class My : R|kotlin/Any| {
public constructor(): R|My| {

View File

@@ -1,12 +1,12 @@
FILE: RedundantSingleExpressionStringTemplateChecker.kt
public final val x: R|kotlin/String| = String(Hello)
public get(): R|kotlin/String|
public final val y: R|kotlin/String| = <strcat>(R|/x|.R|kotlin/Any.toString|())
public final val y: R|kotlin/String| = <strcat>(R|/x|)
public get(): R|kotlin/String|
public final val z: R|kotlin/String| = <strcat>(R|/y|.R|kotlin/Any.hashCode|().R|kotlin/Any.toString|())
public final val z: R|kotlin/String| = <strcat>(R|/y|.R|kotlin/Any.hashCode|())
public get(): R|kotlin/String|
public final fun toString(x: R|kotlin/String|): R|kotlin/String| {
^toString <strcat>(String(IC), R|<local>/x|.R|kotlin/Any.toString|())
^toString <strcat>(String(IC), R|<local>/x|)
}
public final data class ProductGroup : R|kotlin/Any| {
public constructor(short_name: R|kotlin/String|, parent: R|ProductGroup?|): R|ProductGroup| {
@@ -24,7 +24,7 @@ FILE: RedundantSingleExpressionStringTemplateChecker.kt
this@R|/ProductGroup|.R|/ProductGroup.short_name|
}
else -> {
<strcat>(this@R|/ProductGroup|.R|/ProductGroup.parent|.R|/ProductGroup.name|.R|kotlin/Any.toString|(), String( ), this@R|/ProductGroup|.R|/ProductGroup.short_name|.R|kotlin/Any.toString|())
<strcat>(this@R|/ProductGroup|.R|/ProductGroup.parent|.R|/ProductGroup.name|, String( ), this@R|/ProductGroup|.R|/ProductGroup.short_name|)
}
}

View File

@@ -2,7 +2,7 @@ FILE: NotNullTypeChain.kt
public final val list1: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/collections/listOf|<R|kotlin/Int|>(Int(1))
public get(): R|kotlin/collections/List<kotlin/Int>|
public final val list: R|kotlin/collections/List<kotlin/String>| = R|/list1|.R|kotlin/collections/orEmpty|<R|kotlin/Int|>().R|kotlin/collections/map|<R|kotlin/Int|, R|kotlin/String|>(<L> = map@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/String| <inline=Inline, kind=UNKNOWN> {
^ <strcat>(R|<local>/it|.R|kotlin/Any.toString|())
^ <strcat>(R|<local>/it|)
}
)
public get(): R|kotlin/collections/List<kotlin/String>|

View File

@@ -0,0 +1,61 @@
FILE: funInterfaceDeclaration.kt
public abstract interface Test1 : R|kotlin/Any| {
public abstract fun foo(): R|kotlin/Unit|
public abstract fun boo(): R|kotlin/Unit|
}
public abstract interface Test2 : R|kotlin/Any| {
}
public abstract interface Test3 : R|kotlin/Any| {
public abstract val a: R|kotlin/Int|
public get(): R|kotlin/Int|
public abstract fun foo(): R|kotlin/Unit|
}
public abstract interface Test4 : R|kotlin/Any| {
public abstract fun <T> foo(a: R|T|): R|kotlin/Unit|
}
public abstract interface Test5 : R|kotlin/Any| {
public abstract fun foo(a: R|kotlin/Int| = Int(5)): R|kotlin/Unit|
}
public abstract interface Test6 : R|kotlin/Any| {
public abstract suspend fun foo(): R|kotlin/Unit|
}
public abstract interface Test7 : R|kotlin/Any| {
public abstract fun foo(): R|kotlin/Unit|
}
public abstract interface Test8 : R|Test7| {
public abstract fun boo(): R|kotlin/Unit|
}
public abstract interface Test9 : R|kotlin/Any| {
public open fun num(m: R|kotlin/Int|): R|kotlin/Int| {
^num R|<local>/m|.R|kotlin/Int.times|(R|<local>/m|)
}
}
public abstract interface Test10 : R|Test9| {
public abstract fun test(): R|kotlin/Unit|
}
public abstract interface Test11 : R|kotlin/Any| {
public abstract val a: R|kotlin/Int|
public get(): R|kotlin/Int|
}
public abstract interface Test12 : R|Test11| {
public abstract fun test(): R|kotlin/Unit|
}
public abstract interface Test14 : R|kotlin/Any| {
public abstract suspend fun test(): R|kotlin/Unit|
}
public abstract interface Test15 : R|Test14| {
}

View File

@@ -0,0 +1,45 @@
// !LANGUAGE: -SuspendFunctionsInFunInterfaces
<!FUN_INTERFACE_WRONG_COUNT_OF_ABSTRACT_MEMBERS!>fun<!> interface Test1{
fun foo()
fun boo()
}
<!FUN_INTERFACE_WRONG_COUNT_OF_ABSTRACT_MEMBERS!>fun<!> interface Test2 {}
fun interface Test3 {
<!FUN_INTERFACE_CANNOT_HAVE_ABSTRACT_PROPERTIES!>val<!> a: Int
fun foo()
}
fun interface Test4{
fun <!FUN_INTERFACE_ABSTRACT_METHOD_WITH_TYPE_PARAMETERS!><T><!> foo(a: T)
}
fun interface Test5{
fun foo(<!FUN_INTERFACE_ABSTRACT_METHOD_WITH_DEFAULT_VALUE!>a: Int = 5<!>)
}
fun interface Test6{
<!FUN_INTERFACE_WITH_SUSPEND_FUNCTION!>suspend<!> fun foo()
}
fun interface Test7{
fun foo()
}
<!FUN_INTERFACE_WRONG_COUNT_OF_ABSTRACT_MEMBERS!>fun<!> interface Test8: Test7{
fun boo()
}
interface Test9 {
fun num(m: Int): Int {
return m * m
}
}
fun interface Test10 : Test9 {
fun test()
}
interface Test11 {
val a: Int
}
<!FUN_INTERFACE_CANNOT_HAVE_ABSTRACT_PROPERTIES!>fun<!> interface Test12 : Test11 {
fun test()
}
interface Test14 {
suspend fun test()
}
<!FUN_INTERFACE_WITH_SUSPEND_FUNCTION!>fun<!> interface Test15 : Test14

View File

@@ -2,11 +2,11 @@ fun interface MyRunnable {
fun foo(x: Int): Boolean
}
fun interface WithProperty {
val x: Int
<!FUN_INTERFACE_WRONG_COUNT_OF_ABSTRACT_MEMBERS!>fun<!> interface WithProperty {
<!FUN_INTERFACE_CANNOT_HAVE_ABSTRACT_PROPERTIES!>val<!> x: Int
}
fun interface TwoAbstract : MyRunnable {
<!FUN_INTERFACE_WRONG_COUNT_OF_ABSTRACT_MEMBERS!>fun<!> interface TwoAbstract : MyRunnable {
fun bar()
}

View File

@@ -4,7 +4,7 @@ fun a(): Int {
if (c == null ||
0 < c // FE 1.0: smart cast impossible, see KT-10240
) c = 0
return c ?: 0
return c <!USELESS_ELVIS!>?: 0<!>
}
var c: Int = 0

View File

@@ -14,5 +14,5 @@ class Test5<T, B> {
fun <Z> topLevelFun() {
<!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS!>class Test8<!> : Error()
val obj = <!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS{LT}!><!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS{PSI}!>object<!> : Throwable() {}<!>
val obj = <!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS!>object<!> : Throwable() {}
}

View File

@@ -2,12 +2,12 @@ class A {
companion object Comp {}
fun foo() {
<!HIDDEN!>Comp<!>()
<!INVISIBLE_REFERENCE!>Comp<!>()
}
}
object B {
private val x = <!HIDDEN!>B<!>()
private val x = <!INVISIBLE_REFERENCE!>B<!>()
}
class D {

View File

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

View File

@@ -22,24 +22,24 @@ import j.JavaProtected
import j.JavaPackageLocal
class A {
val p1 = JavaPackageLocal.<!HIDDEN!>javaPPackage<!>
val p2 = JavaProtected.<!HIDDEN!>javaPProtectedStatic<!>
val p3 = JavaProtected().<!HIDDEN!>javaPProtectedPackage<!>
val p1 = JavaPackageLocal.<!INVISIBLE_REFERENCE!>javaPPackage<!>
val p2 = JavaProtected.<!INVISIBLE_REFERENCE!>javaPProtectedStatic<!>
val p3 = JavaProtected().<!INVISIBLE_REFERENCE!>javaPProtectedPackage<!>
fun test() {
JavaProtected.<!HIDDEN!>javaMProtectedStatic<!>()
JavaPackageLocal.<!HIDDEN!>javaMPackage<!>()
JavaProtected.<!INVISIBLE_REFERENCE!>javaMProtectedStatic<!>()
JavaPackageLocal.<!INVISIBLE_REFERENCE!>javaMPackage<!>()
}
}
class B : JavaProtected() {
val p1 = JavaPackageLocal.<!HIDDEN!>javaPPackage<!>
val p1 = JavaPackageLocal.<!INVISIBLE_REFERENCE!>javaPPackage<!>
val p2 = JavaProtected.javaPProtectedStatic
val p3 = javaPProtectedPackage
fun test() {
JavaProtected.javaMProtectedStatic()
JavaPackageLocal.<!HIDDEN!>javaMPackage<!>()
JavaPackageLocal.<!INVISIBLE_REFERENCE!>javaMPackage<!>()
}
}

View File

@@ -7,7 +7,7 @@ FILE: test.kt
lval otherResult: R|ft<kotlin/String, kotlin/String?>| = R|<local>/map|.R|SubstitutionOverride</MyMap.getOrDefault: R|ft<kotlin/String, kotlin/String?>|>|(String(key), String(value))
lval anotherResult: R|kotlin/String?| = R|<local>/map|.R|SubstitutionOverride</MyMap.replace: R|kotlin/String?|>|(String(key), String(value))
R|<local>/map|.R|SubstitutionOverride</MyMap.forEach: R|kotlin/Unit|>|(<L> = forEach@fun <anonymous>(key: R|ft<kotlin/String, kotlin/String?>|, value: R|ft<kotlin/String, kotlin/String?>|): R|kotlin/Unit| <inline=NoInline> {
R|kotlin/io/println|(<strcat>(R|<local>/key|.R|kotlin/Any.toString|(), String(: ), R|<local>/value|.R|kotlin/Any.toString|()))
R|kotlin/io/println|(<strcat>(R|<local>/key|, String(: ), R|<local>/value|))
R|<local>/key|.R|kotlin/String.length|
R|<local>/value|.R|kotlin/String.length|
}
@@ -15,7 +15,7 @@ FILE: test.kt
R|<local>/map|.R|kotlin/collections/forEach|<R|ft<kotlin/String, kotlin/String?>|, R|ft<kotlin/String, kotlin/String?>|>(<L> = forEach@fun <anonymous>(<destruct>: R|kotlin/collections/Map.Entry<ft<kotlin/String, kotlin/String?>, ft<kotlin/String, kotlin/String?>>|): R|kotlin/Unit| <inline=Inline, kind=UNKNOWN> {
lval key: R|ft<kotlin/String, kotlin/String?>| = R|<local>/<destruct>|.R|kotlin/collections/component1|<R|ft<kotlin/String, kotlin/String?>|, R|ft<kotlin/String, kotlin/String?>|>()
lval value: R|ft<kotlin/String, kotlin/String?>| = R|<local>/<destruct>|.R|kotlin/collections/component2|<R|ft<kotlin/String, kotlin/String?>|, R|ft<kotlin/String, kotlin/String?>|>()
R|kotlin/io/println|(<strcat>(R|<local>/key|.R|kotlin/Any.toString|(), String(: ), R|<local>/value|.R|kotlin/Any.toString|()))
R|kotlin/io/println|(<strcat>(R|<local>/key|, String(: ), R|<local>/value|))
R|<local>/key|.R|kotlin/String.length|
R|<local>/value|.R|kotlin/String.length|
}
@@ -29,7 +29,7 @@ FILE: test.kt
lval otherResult: R|kotlin/String| = R|<local>/map|.R|SubstitutionOverride<kotlin/collections/MutableMap.getOrDefault: R|kotlin/String|>|(String(key), String(value))
lval anotherResult: R|kotlin/String?| = R|<local>/map|.R|SubstitutionOverride<kotlin/collections/MutableMap.replace: R|kotlin/String?|>|(String(key), String(value))
R|<local>/map|.R|SubstitutionOverride<kotlin/collections/MutableMap.forEach: R|kotlin/Unit|>|(<L> = forEach@fun <anonymous>(key: R|ft<kotlin/String, kotlin/String?>|, value: R|ft<kotlin/String, kotlin/String?>|): R|kotlin/Unit| <inline=NoInline> {
R|kotlin/io/println|(<strcat>(R|<local>/key|.R|kotlin/Any.toString|(), String(: ), R|<local>/value|.R|kotlin/Any.toString|()))
R|kotlin/io/println|(<strcat>(R|<local>/key|, String(: ), R|<local>/value|))
R|<local>/key|.R|kotlin/String.length|
R|<local>/value|.R|kotlin/String.length|
}
@@ -37,7 +37,7 @@ FILE: test.kt
R|<local>/map|.R|kotlin/collections/forEach|<R|kotlin/String|, R|kotlin/String|>(<L> = forEach@fun <anonymous>(<destruct>: R|kotlin/collections/Map.Entry<kotlin/String, kotlin/String>|): R|kotlin/Unit| <inline=Inline, kind=UNKNOWN> {
lval key: R|kotlin/String| = R|<local>/<destruct>|.R|kotlin/collections/component1|<R|kotlin/String|, R|kotlin/String|>()
lval value: R|kotlin/String| = R|<local>/<destruct>|.R|kotlin/collections/component2|<R|kotlin/String|, R|kotlin/String|>()
R|kotlin/io/println|(<strcat>(R|<local>/key|.R|kotlin/Any.toString|(), String(: ), R|<local>/value|.R|kotlin/Any.toString|()))
R|kotlin/io/println|(<strcat>(R|<local>/key|, String(: ), R|<local>/value|))
R|<local>/key|.R|kotlin/String.length|
R|<local>/value|.R|kotlin/String.length|
}

View File

@@ -1,5 +1,5 @@
<!CONFLICTING_OVERLOADS!>@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
<!HIDDEN!>@kotlin.internal.LowPriorityInOverloadResolution<!>
@kotlin.internal.LowPriorityInOverloadResolution
fun foo(): Int<!> = 1
<!CONFLICTING_OVERLOADS!>fun foo(): String<!> = ""

View File

@@ -26,6 +26,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
}
@Test
@TestMetadata("annotationUsedAsAnnotationArgument.kt")
public void testAnnotationUsedAsAnnotationArgument() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/annotationUsedAsAnnotationArgument.kt");
}
@Test
@TestMetadata("asImports.kt")
public void testAsImports() throws Exception {
@@ -200,6 +206,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
runTest("compiler/fir/analysis-tests/testData/resolve/ft.kt");
}
@Test
@TestMetadata("funInterfaceDeclaration.kt")
public void testFunInterfaceDeclaration() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/funInterfaceDeclaration.kt");
}
@Test
@TestMetadata("functionTypeAlias.kt")
public void testFunctionTypeAlias() throws Exception {

View File

@@ -7,8 +7,6 @@ package org.jetbrains.kotlin.test.runners;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.util.KtTestUtil;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
@@ -22,13 +20,18 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Resolve {
@Test
public void testAllFilesPresentInResolve() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
}
@Test
@TestMetadata("annotationUsedAsAnnotationArgument.kt")
public void testAnnotationUsedAsAnnotationArgument() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/annotationUsedAsAnnotationArgument.kt");
}
@Test
@TestMetadata("asImports.kt")
public void testAsImports() throws Exception {
@@ -203,6 +206,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
runTest("compiler/fir/analysis-tests/testData/resolve/ft.kt");
}
@Test
@TestMetadata("funInterfaceDeclaration.kt")
public void testFunInterfaceDeclaration() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/funInterfaceDeclaration.kt");
}
@Test
@TestMetadata("functionTypeAlias.kt")
public void testFunctionTypeAlias() throws Exception {
@@ -572,7 +581,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/arguments")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Arguments {
@Test
public void testAllFilesPresentInArguments() throws Exception {
@@ -781,7 +789,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/arrays")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Arrays {
@Test
public void testAllFilesPresentInArrays() throws Exception {
@@ -804,7 +811,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/builtins")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Builtins {
@Test
public void testAllFilesPresentInBuiltins() throws Exception {
@@ -821,7 +827,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/callResolution")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class CallResolution {
@Test
public void testAllFilesPresentInCallResolution() throws Exception {
@@ -934,7 +939,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/cfg")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Cfg {
@Test
public void testAllFilesPresentInCfg() throws Exception {
@@ -1095,7 +1099,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/constVal")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class ConstVal {
@Test
public void testAllFilesPresentInConstVal() throws Exception {
@@ -1124,7 +1127,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/constructors")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Constructors {
@Test
public void testAllFilesPresentInConstructors() throws Exception {
@@ -1141,7 +1143,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/contracts")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Contracts {
@Test
public void testAllFilesPresentInContracts() throws Exception {
@@ -1158,7 +1159,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/delegates")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Delegates {
@Test
public void testAllFilesPresentInDelegates() throws Exception {
@@ -1205,7 +1205,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/diagnostics")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Diagnostics {
@Test
@TestMetadata("abstractSuperCall.kt")
@@ -1521,7 +1520,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/diagnostics/functionAsExpression")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class FunctionAsExpression {
@Test
public void testAllFilesPresentInFunctionAsExpression() throws Exception {
@@ -1539,7 +1537,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/exhaustiveness")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Exhaustiveness {
@Test
public void testAllFilesPresentInExhaustiveness() throws Exception {
@@ -1549,7 +1546,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/negative")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Negative {
@Test
public void testAllFilesPresentInNegative() throws Exception {
@@ -1590,7 +1586,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Positive {
@Test
public void testAllFilesPresentInPositive() throws Exception {
@@ -1662,7 +1657,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/expresssions")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Expresssions {
@Test
@TestMetadata("access.kt")
@@ -2038,7 +2032,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/expresssions/inference")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Inference {
@Test
public void testAllFilesPresentInInference() throws Exception {
@@ -2067,7 +2060,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/expresssions/invoke")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Invoke {
@Test
public void testAllFilesPresentInInvoke() throws Exception {
@@ -2168,7 +2160,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/expresssions/operators")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Operators {
@Test
public void testAllFilesPresentInOperators() throws Exception {
@@ -2198,7 +2189,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/extendedCheckers")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class ExtendedCheckers {
@Test
public void testAllFilesPresentInExtendedCheckers() throws Exception {
@@ -2256,7 +2246,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class CanBeReplacedWithOperatorAssignment {
@Test
public void testAllFilesPresentInCanBeReplacedWithOperatorAssignment() throws Exception {
@@ -2381,7 +2370,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/emptyRangeChecker")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class EmptyRangeChecker {
@Test
public void testAllFilesPresentInEmptyRangeChecker() throws Exception {
@@ -2404,7 +2392,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantCallOfConversionMethod")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class RedundantCallOfConversionMethod {
@Test
public void testAllFilesPresentInRedundantCallOfConversionMethod() throws Exception {
@@ -2535,7 +2522,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Unused {
@Test
public void testAllFilesPresentInUnused() throws Exception {
@@ -2588,7 +2574,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/extendedCheckers/UselessCallOnNotNullChecker")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class UselessCallOnNotNullChecker {
@Test
public void testAllFilesPresentInUselessCallOnNotNullChecker() throws Exception {
@@ -2666,7 +2651,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/fromBuilder")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class FromBuilder {
@Test
public void testAllFilesPresentInFromBuilder() throws Exception {
@@ -2707,7 +2691,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/inference")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Inference {
@Test
public void testAllFilesPresentInInference() throws Exception {
@@ -2838,7 +2821,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/inlineClasses")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class InlineClasses {
@Test
public void testAllFilesPresentInInlineClasses() throws Exception {
@@ -2867,7 +2849,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/innerClasses")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class InnerClasses {
@Test
public void testAllFilesPresentInInnerClasses() throws Exception {
@@ -2902,7 +2883,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/localClasses")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class LocalClasses {
@Test
public void testAllFilesPresentInLocalClasses() throws Exception {
@@ -2931,7 +2911,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/multifile")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Multifile {
@Test
public void testAllFilesPresentInMultifile() throws Exception {
@@ -3008,7 +2987,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/overrides")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Overrides {
@Test
public void testAllFilesPresentInOverrides() throws Exception {
@@ -3067,7 +3045,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/problems")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Problems {
@Test
public void testAllFilesPresentInProblems() throws Exception {
@@ -3192,7 +3169,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/properties")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Properties {
@Test
public void testAllFilesPresentInProperties() throws Exception {
@@ -3239,7 +3215,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/references")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class References {
@Test
public void testAllFilesPresentInReferences() throws Exception {
@@ -3286,7 +3261,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/samConstructors")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class SamConstructors {
@Test
public void testAllFilesPresentInSamConstructors() throws Exception {
@@ -3339,7 +3313,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/samConversions")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class SamConversions {
@Test
public void testAllFilesPresentInSamConversions() throws Exception {
@@ -3404,7 +3377,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/smartcasts")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Smartcasts {
@Test
public void testAllFilesPresentInSmartcasts() throws Exception {
@@ -3486,7 +3458,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Booleans {
@Test
public void testAllFilesPresentInBooleans() throws Exception {
@@ -3521,7 +3492,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class BoundSmartcasts {
@Test
public void testAllFilesPresentInBoundSmartcasts() throws Exception {
@@ -3556,7 +3526,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class ControlStructures {
@Test
public void testAllFilesPresentInControlStructures() throws Exception {
@@ -3597,7 +3566,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/smartcasts/lambdas")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Lambdas {
@Test
public void testAllFilesPresentInLambdas() throws Exception {
@@ -3626,7 +3594,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/smartcasts/loops")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Loops {
@Test
public void testAllFilesPresentInLoops() throws Exception {
@@ -3649,7 +3616,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/smartcasts/problems")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Problems {
@Test
public void testAllFilesPresentInProblems() throws Exception {
@@ -3666,7 +3632,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/smartcasts/receivers")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Receivers {
@Test
public void testAllFilesPresentInReceivers() throws Exception {
@@ -3701,7 +3666,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class SafeCalls {
@Test
public void testAllFilesPresentInSafeCalls() throws Exception {
@@ -3742,7 +3706,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/smartcasts/stability")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Stability {
@Test
public void testAllFilesPresentInStability() throws Exception {
@@ -3759,7 +3722,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/smartcasts/variables")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Variables {
@Test
public void testAllFilesPresentInVariables() throws Exception {
@@ -3783,7 +3745,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/stdlib")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Stdlib {
@Test
public void testAllFilesPresentInStdlib() throws Exception {
@@ -3793,7 +3754,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/stdlib/j+k")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class J_k {
@Test
public void testAllFilesPresentInJ_k() throws Exception {
@@ -3817,7 +3777,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/suppress")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Suppress {
@Test
public void testAllFilesPresentInSuppress() throws Exception {
@@ -3852,7 +3811,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/types")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Types {
@Test
public void testAllFilesPresentInTypes() throws Exception {
@@ -3881,7 +3839,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/visibility")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Visibility {
@Test
public void testAllFilesPresentInVisibility() throws Exception {
@@ -3959,7 +3916,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class ResolveWithStdlib {
@Test
@TestMetadata("addAllOnJavaCollection.kt")
@@ -4299,7 +4255,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class CallableReferences {
@Test
public void testAllFilesPresentInCallableReferences() throws Exception {
@@ -4453,7 +4408,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class FromBasicDiagnosticTests {
@Test
public void testAllFilesPresentInFromBasicDiagnosticTests() throws Exception {
@@ -4543,7 +4497,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Contracts {
@Test
public void testAllFilesPresentInContracts() throws Exception {
@@ -4553,7 +4506,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromLibrary")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class FromLibrary {
@Test
public void testAllFilesPresentInFromLibrary() throws Exception {
@@ -4582,7 +4534,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class FromSource {
@Test
public void testAllFilesPresentInFromSource() throws Exception {
@@ -4592,7 +4543,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/bad")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Bad {
@Test
public void testAllFilesPresentInBad() throws Exception {
@@ -4602,7 +4552,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/bad/callsInPlace")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class CallsInPlace {
@Test
public void testAllFilesPresentInCallsInPlace() throws Exception {
@@ -4637,7 +4586,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/bad/returnsImplies")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class ReturnsImplies {
@Test
public void testAllFilesPresentInReturnsImplies() throws Exception {
@@ -4661,7 +4609,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Good {
@Test
public void testAllFilesPresentInGood() throws Exception {
@@ -4671,7 +4618,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/callsInPlace")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class CallsInPlace {
@Test
public void testAllFilesPresentInCallsInPlace() throws Exception {
@@ -4730,7 +4676,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/returnsImplies")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class ReturnsImplies {
@Test
public void testAllFilesPresentInReturnsImplies() throws Exception {
@@ -4807,7 +4752,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/variousContracts")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class VariousContracts {
@Test
public void testAllFilesPresentInVariousContracts() throws Exception {
@@ -4817,7 +4761,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/variousContracts/newSyntax")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class NewSyntax {
@Test
public void testAllFilesPresentInNewSyntax() throws Exception {
@@ -4838,7 +4781,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Delegates {
@Test
public void testAllFilesPresentInDelegates() throws Exception {
@@ -4891,7 +4833,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Diagnostics {
@Test
public void testAllFilesPresentInDiagnostics() throws Exception {
@@ -4907,7 +4848,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics/functionReturnTypeMismatchChecker")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class FunctionReturnTypeMismatchChecker {
@Test
public void testAllFilesPresentInFunctionReturnTypeMismatchChecker() throws Exception {
@@ -4924,7 +4864,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics/initializerTypeMismatchChecker")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class InitializerTypeMismatchChecker {
@Test
public void testAllFilesPresentInInitializerTypeMismatchChecker() throws Exception {
@@ -4942,7 +4881,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/inference")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Inference {
@Test
public void testAllFilesPresentInInference() throws Exception {
@@ -4995,7 +4933,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/initialization")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Initialization {
@Test
public void testAllFilesPresentInInitialization() throws Exception {
@@ -5012,7 +4949,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class J_k {
@Test
public void testAllFilesPresentInJ_k() throws Exception {
@@ -5305,7 +5241,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/multiModule")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class MultiModule {
@Test
public void testAllFilesPresentInMultiModule() throws Exception {
@@ -5346,7 +5281,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Problems {
@Test
public void testAllFilesPresentInProblems() throws Exception {
@@ -5441,7 +5375,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/reinitializations")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Reinitializations {
@Test
public void testAllFilesPresentInReinitializations() throws Exception {
@@ -5458,7 +5391,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/smartcasts")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Smartcasts {
@Test
public void testAllFilesPresentInSmartcasts() throws Exception {

View File

@@ -29029,6 +29029,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/tests/typeParameters/kt42472.kt");
}
@Test
@TestMetadata("kt46186.kt")
public void testKt46186() throws Exception {
runTest("compiler/testData/diagnostics/tests/typeParameters/kt46186.kt");
}
@Test
@TestMetadata("misplacedConstraints.kt")
public void testMisplacedConstraints() throws Exception {

View File

@@ -24,6 +24,14 @@ fun main(args: Array<String>) {
alias<FirWhenExpression>("WhenExpressionChecker")
alias<FirReturnExpression>("ReturnExpressionChecker")
alias<FirBlock>("BlockChecker")
alias<FirAnnotationCall>("AnnotationCallChecker")
alias<FirCheckNotNullCall>("CheckNotNullCallChecker")
alias<FirElvisExpression>("ElvisExpressionChecker")
alias<FirGetClassCall>("GetClassCallChecker")
alias<FirSafeCallExpression>("SafeCallExpressionChecker")
alias<FirEqualityOperatorCall>("EqualityOperatorCallChecker")
alias<FirAnonymousFunction>("AnonymousFunctionAsExpressionChecker")
alias<FirStringConcatenationCall>("StringConcatenationCallChecker")
}
val declarationPackage = "org.jetbrains.kotlin.fir.analysis.checkers.declaration"

View File

@@ -52,6 +52,7 @@ enum class PositioningStrategy(private val strategy: String? = null) {
CONST_MODIFIER,
ARRAY_ACCESS,
SAFE_ACCESS,
USELESS_ELVIS,
NAME_OF_NAMED_ARGUMENT,
VALUE_ARGUMENTS,
SUPERTYPES_LIST,
@@ -62,6 +63,10 @@ enum class PositioningStrategy(private val strategy: String? = null) {
FLOAT_LITERAL_OUT_OF_RANGE,
LONG_LITERAL_SUFFIX,
REIFIED_MODIFIER,
TYPE_PARAMETERS_LIST,
FUN_MODIFIER,
SUSPEND_MODIFIER,
FUN_INTERFACE,
;

View File

@@ -14,7 +14,6 @@ import org.jetbrains.kotlin.contracts.description.EventOccurrencesRange
import org.jetbrains.kotlin.descriptors.EffectiveVisibility
import org.jetbrains.kotlin.descriptors.Visibility
import org.jetbrains.kotlin.diagnostics.WhenMissingCase
import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.PrivateForInline
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.expressions.FirExpression
@@ -69,8 +68,8 @@ object DIAGNOSTICS_LIST : DiagnosticList() {
}
val UNRESOLVED by object : DiagnosticGroup("Unresolved") {
val HIDDEN by error<PsiElement>(PositioningStrategy.REFERENCE_BY_QUALIFIED) {
parameter<AbstractFirBasedSymbol<*>>("hidden")
val INVISIBLE_REFERENCE by error<PsiElement>(PositioningStrategy.REFERENCE_BY_QUALIFIED) {
parameter<Symbol>("reference")
}
val UNRESOLVED_REFERENCE by error<PsiElement>(PositioningStrategy.REFERENCED_NAME_BY_QUALIFIED) {
parameter<String>("reference")
@@ -149,6 +148,7 @@ object DIAGNOSTICS_LIST : DiagnosticList() {
val NULLABLE_TYPE_OF_ANNOTATION_MEMBER by error<KtTypeReference>()
val VAR_ANNOTATION_PARAMETER by error<KtParameter>(PositioningStrategy.VAL_OR_VAR_NODE)
val SUPERTYPES_FOR_ANNOTATION_CLASS by error<KtClass>(PositioningStrategy.SUPERTYPES_LIST)
val ANNOTATION_USED_AS_ANNOTATION_ARGUMENT by error<KtAnnotation>()
}
val EXPOSED_VISIBILITY by object : DiagnosticGroup("Exposed visibility") {
@@ -215,11 +215,11 @@ object DIAGNOSTICS_LIST : DiagnosticList() {
val APPLICABILITY by object : DiagnosticGroup("Applicability") {
val NONE_APPLICABLE by error<PsiElement>(PositioningStrategy.REFERENCE_BY_QUALIFIED) {
parameter<Collection<AbstractFirBasedSymbol<*>>>("candidates")
parameter<Collection<Symbol>>("candidates")
}
val INAPPLICABLE_CANDIDATE by error<PsiElement>(PositioningStrategy.REFERENCE_BY_QUALIFIED) {
parameter<AbstractFirBasedSymbol<*>>("candidate")
parameter<Symbol>("candidate")
}
val ARGUMENT_TYPE_MISMATCH by error<PsiElement> {
@@ -255,10 +255,10 @@ object DIAGNOSTICS_LIST : DiagnosticList() {
val AMBIGUITY by object : DiagnosticGroup("Ambiguity") {
val OVERLOAD_RESOLUTION_AMBIGUITY by error<PsiElement>(PositioningStrategy.REFERENCE_BY_QUALIFIED) {
parameter<Collection<AbstractFirBasedSymbol<*>>>("candidates")
parameter<Collection<Symbol>>("candidates")
}
val ASSIGN_OPERATOR_AMBIGUITY by error<PsiElement> {
parameter<Collection<AbstractFirBasedSymbol<*>>>("candidates")
parameter<Collection<Symbol>>("candidates")
}
val ITERATOR_AMBIGUITY by error<PsiElement>(PositioningStrategy.REFERENCE_BY_QUALIFIED) {
parameter<Collection<AbstractFirBasedSymbol<*>>>("candidates")
@@ -338,7 +338,7 @@ object DIAGNOSTICS_LIST : DiagnosticList() {
val REIFIED_TYPE_PARAMETER_NO_INLINE by error<KtTypeParameter>(PositioningStrategy.REIFIED_MODIFIER)
val TYPE_PARAMETERS_NOT_ALLOWED by error<KtDeclaration>()
val TYPE_PARAMETERS_NOT_ALLOWED by error<KtDeclaration>(PositioningStrategy.TYPE_PARAMETERS_LIST)
val TYPE_PARAMETER_OF_PROPERTY_NOT_USED_IN_RECEIVER by error<KtTypeParameter>()
@@ -349,7 +349,7 @@ object DIAGNOSTICS_LIST : DiagnosticList() {
val CYCLIC_GENERIC_UPPER_BOUND by error<PsiElement>()
val DEPRECATED_TYPE_PARAMETER_SYNTAX by error<KtTypeParameterList>()
val DEPRECATED_TYPE_PARAMETER_SYNTAX by error<KtDeclaration>(PositioningStrategy.TYPE_PARAMETERS_LIST)
val MISPLACED_TYPE_PARAMETER_CONSTRAINTS by warning<KtTypeParameter>()
@@ -447,10 +447,10 @@ object DIAGNOSTICS_LIST : DiagnosticList() {
val REDECLARATIONS by object : DiagnosticGroup("Redeclarations") {
val MANY_COMPANION_OBJECTS by error<KtObjectDeclaration>(PositioningStrategy.COMPANION_OBJECT)
val CONFLICTING_OVERLOADS by error<PsiElement>(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT) {
parameter<Collection<AbstractFirBasedSymbol<*>>>("conflictingOverloads")
parameter<Collection<Symbol>>("conflictingOverloads")
}
val REDECLARATION by error<PsiElement> {
parameter<Collection<AbstractFirBasedSymbol<*>>>("conflictingDeclarations")
parameter<Collection<Symbol>>("conflictingDeclarations")
}
val METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE by error<PsiElement>()
}
@@ -499,6 +499,11 @@ object DIAGNOSTICS_LIST : DiagnosticList() {
val FUN_INTERFACES by object : DiagnosticGroup("Fun interfaces") {
val FUN_INTERFACE_CONSTRUCTOR_REFERENCE by error<KtExpression>(PositioningStrategy.REFERENCE_BY_QUALIFIED)
val FUN_INTERFACE_WRONG_COUNT_OF_ABSTRACT_MEMBERS by error<KtClass>(PositioningStrategy.FUN_MODIFIER)
val FUN_INTERFACE_CANNOT_HAVE_ABSTRACT_PROPERTIES by error<KtDeclaration>(PositioningStrategy.FUN_INTERFACE)
val FUN_INTERFACE_ABSTRACT_METHOD_WITH_TYPE_PARAMETERS by error<KtDeclaration>(PositioningStrategy.FUN_INTERFACE)
val FUN_INTERFACE_ABSTRACT_METHOD_WITH_DEFAULT_VALUE by error<KtDeclaration>(PositioningStrategy.FUN_INTERFACE)
val FUN_INTERFACE_WITH_SUSPEND_FUNCTION by error<KtDeclaration>(PositioningStrategy.FUN_INTERFACE)
}
val PROPERTIES_AND_ACCESSORS by object : DiagnosticGroup("Properties & accessors") {
@@ -568,7 +573,7 @@ object DIAGNOSTICS_LIST : DiagnosticList() {
}
val COMPONENT_FUNCTION_AMBIGUITY by error<PsiElement> {
parameter<Name>("functionWithAmbiguityName")
parameter<Collection<AbstractFirBasedSymbol<*>>>("candidates")
parameter<Collection<Symbol>>("candidates")
}
val COMPONENT_FUNCTION_ON_NULLABLE by error<KtExpression> {
parameter<Name>("componentFunctionName")
@@ -600,12 +605,12 @@ object DIAGNOSTICS_LIST : DiagnosticList() {
parameter<FirPropertySymbol>("property")
}
val WRONG_INVOCATION_KIND by warning<PsiElement> {
parameter<AbstractFirBasedSymbol<*>>("declaration")
parameter<Symbol>("declaration")
parameter<EventOccurrencesRange>("requiredRange")
parameter<EventOccurrencesRange>("actualRange")
}
val LEAKED_IN_PLACE_LAMBDA by error<PsiElement> {
parameter<AbstractFirBasedSymbol<*>>("lambda")
parameter<Symbol>("lambda")
}
val WRONG_IMPLIES_CONDITION by warning<PsiElement>()
}
@@ -637,6 +642,10 @@ object DIAGNOSTICS_LIST : DiagnosticList() {
}
val NOT_NULL_ASSERTION_ON_LAMBDA_EXPRESSION by warning<KtExpression>(PositioningStrategy.OPERATOR)
val NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE by warning<KtExpression>(PositioningStrategy.OPERATOR)
val USELESS_ELVIS by warning<KtBinaryExpression>(PositioningStrategy.USELESS_ELVIS) {
parameter<ConeKotlinType>("receiverType")
}
val USELESS_ELVIS_RIGHT_IS_NULL by warning<KtBinaryExpression>(PositioningStrategy.USELESS_ELVIS)
}
val WHEN_EXPRESSIONS by object : DiagnosticGroup("When expressions") {
@@ -735,3 +744,5 @@ private inline fun <reified P : PsiElement> DiagnosticGroup.exposedVisibilityWar
): PropertyDelegateProvider<Any?, ReadOnlyProperty<DiagnosticGroup, DiagnosticData>> {
return warning<P>(positioningStrategy, exposedVisibilityDiagnosticInit)
}
typealias Symbol = AbstractFirBasedSymbol<*>

View File

@@ -29,6 +29,22 @@ internal class ComposedExpressionCheckers : ExpressionCheckers() {
get() = _returnExpressionCheckers
override val blockCheckers: Set<FirBlockChecker>
get() = _blockCheckers
override val annotationCallCheckers: Set<FirAnnotationCallChecker>
get() = _annotationCallCheckers
override val checkNotNullCallCheckers: Set<FirCheckNotNullCallChecker>
get() = _checkNotNullCallCheckers
override val elvisExpressionCheckers: Set<FirElvisExpressionChecker>
get() = _elvisExpressionCheckers
override val getClassCallCheckers: Set<FirGetClassCallChecker>
get() = _getClassCallCheckers
override val safeCallExpressionCheckers: Set<FirSafeCallExpressionChecker>
get() = _safeCallExpressionCheckers
override val equalityOperatorCallCheckers: Set<FirEqualityOperatorCallChecker>
get() = _equalityOperatorCallCheckers
override val anonymousFunctionAsExpressionCheckers: Set<FirAnonymousFunctionAsExpressionChecker>
get() = _anonymousFunctionAsExpressionCheckers
override val stringConcatenationCallCheckers: Set<FirStringConcatenationCallChecker>
get() = _stringConcatenationCallCheckers
private val _basicExpressionCheckers: MutableSet<FirBasicExpressionChecker> = mutableSetOf()
private val _qualifiedAccessCheckers: MutableSet<FirQualifiedAccessChecker> = mutableSetOf()
@@ -38,6 +54,14 @@ internal class ComposedExpressionCheckers : ExpressionCheckers() {
private val _whenExpressionCheckers: MutableSet<FirWhenExpressionChecker> = mutableSetOf()
private val _returnExpressionCheckers: MutableSet<FirReturnExpressionChecker> = mutableSetOf()
private val _blockCheckers: MutableSet<FirBlockChecker> = mutableSetOf()
private val _annotationCallCheckers: MutableSet<FirAnnotationCallChecker> = mutableSetOf()
private val _checkNotNullCallCheckers: MutableSet<FirCheckNotNullCallChecker> = mutableSetOf()
private val _elvisExpressionCheckers: MutableSet<FirElvisExpressionChecker> = mutableSetOf()
private val _getClassCallCheckers: MutableSet<FirGetClassCallChecker> = mutableSetOf()
private val _safeCallExpressionCheckers: MutableSet<FirSafeCallExpressionChecker> = mutableSetOf()
private val _equalityOperatorCallCheckers: MutableSet<FirEqualityOperatorCallChecker> = mutableSetOf()
private val _anonymousFunctionAsExpressionCheckers: MutableSet<FirAnonymousFunctionAsExpressionChecker> = mutableSetOf()
private val _stringConcatenationCallCheckers: MutableSet<FirStringConcatenationCallChecker> = mutableSetOf()
@CheckersComponentInternal
internal fun register(checkers: ExpressionCheckers) {
@@ -49,5 +73,13 @@ internal class ComposedExpressionCheckers : ExpressionCheckers() {
_whenExpressionCheckers += checkers.whenExpressionCheckers
_returnExpressionCheckers += checkers.returnExpressionCheckers
_blockCheckers += checkers.blockCheckers
_annotationCallCheckers += checkers.annotationCallCheckers
_checkNotNullCallCheckers += checkers.checkNotNullCallCheckers
_elvisExpressionCheckers += checkers.elvisExpressionCheckers
_getClassCallCheckers += checkers.getClassCallCheckers
_safeCallExpressionCheckers += checkers.safeCallExpressionCheckers
_equalityOperatorCallCheckers += checkers.equalityOperatorCallCheckers
_anonymousFunctionAsExpressionCheckers += checkers.anonymousFunctionAsExpressionCheckers
_stringConcatenationCallCheckers += checkers.stringConcatenationCallCheckers
}
}

View File

@@ -25,6 +25,14 @@ abstract class ExpressionCheckers {
open val whenExpressionCheckers: Set<FirWhenExpressionChecker> = emptySet()
open val returnExpressionCheckers: Set<FirReturnExpressionChecker> = emptySet()
open val blockCheckers: Set<FirBlockChecker> = emptySet()
open val annotationCallCheckers: Set<FirAnnotationCallChecker> = emptySet()
open val checkNotNullCallCheckers: Set<FirCheckNotNullCallChecker> = emptySet()
open val elvisExpressionCheckers: Set<FirElvisExpressionChecker> = emptySet()
open val getClassCallCheckers: Set<FirGetClassCallChecker> = emptySet()
open val safeCallExpressionCheckers: Set<FirSafeCallExpressionChecker> = emptySet()
open val equalityOperatorCallCheckers: Set<FirEqualityOperatorCallChecker> = emptySet()
open val anonymousFunctionAsExpressionCheckers: Set<FirAnonymousFunctionAsExpressionChecker> = emptySet()
open val stringConcatenationCallCheckers: Set<FirStringConcatenationCallChecker> = emptySet()
@CheckersComponentInternal internal val allBasicExpressionCheckers: Set<FirBasicExpressionChecker> get() = basicExpressionCheckers
@CheckersComponentInternal internal val allQualifiedAccessCheckers: Set<FirQualifiedAccessChecker> get() = qualifiedAccessCheckers + basicExpressionCheckers
@@ -34,4 +42,12 @@ abstract class ExpressionCheckers {
@CheckersComponentInternal internal val allWhenExpressionCheckers: Set<FirWhenExpressionChecker> get() = whenExpressionCheckers + basicExpressionCheckers
@CheckersComponentInternal internal val allReturnExpressionCheckers: Set<FirReturnExpressionChecker> get() = returnExpressionCheckers + basicExpressionCheckers
@CheckersComponentInternal internal val allBlockCheckers: Set<FirBlockChecker> get() = blockCheckers + basicExpressionCheckers
@CheckersComponentInternal internal val allAnnotationCallCheckers: Set<FirAnnotationCallChecker> get() = annotationCallCheckers + basicExpressionCheckers
@CheckersComponentInternal internal val allCheckNotNullCallCheckers: Set<FirCheckNotNullCallChecker> get() = checkNotNullCallCheckers + basicExpressionCheckers
@CheckersComponentInternal internal val allElvisExpressionCheckers: Set<FirElvisExpressionChecker> get() = elvisExpressionCheckers + basicExpressionCheckers
@CheckersComponentInternal internal val allGetClassCallCheckers: Set<FirGetClassCallChecker> get() = getClassCallCheckers + basicExpressionCheckers
@CheckersComponentInternal internal val allSafeCallExpressionCheckers: Set<FirSafeCallExpressionChecker> get() = safeCallExpressionCheckers + basicExpressionCheckers
@CheckersComponentInternal internal val allEqualityOperatorCallCheckers: Set<FirEqualityOperatorCallChecker> get() = equalityOperatorCallCheckers + basicExpressionCheckers
@CheckersComponentInternal internal val allAnonymousFunctionAsExpressionCheckers: Set<FirAnonymousFunctionAsExpressionChecker> get() = anonymousFunctionAsExpressionCheckers + basicExpressionCheckers
@CheckersComponentInternal internal val allStringConcatenationCallCheckers: Set<FirStringConcatenationCallChecker> get() = stringConcatenationCallCheckers + basicExpressionCheckers
}

View File

@@ -10,11 +10,19 @@ package org.jetbrains.kotlin.fir.analysis.checkers.expression
* DO NOT MODIFY IT MANUALLY
*/
import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirBlock
import org.jetbrains.kotlin.fir.expressions.FirCheckNotNullCall
import org.jetbrains.kotlin.fir.expressions.FirElvisExpression
import org.jetbrains.kotlin.fir.expressions.FirEqualityOperatorCall
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
import org.jetbrains.kotlin.fir.expressions.FirGetClassCall
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression
import org.jetbrains.kotlin.fir.expressions.FirReturnExpression
import org.jetbrains.kotlin.fir.expressions.FirSafeCallExpression
import org.jetbrains.kotlin.fir.expressions.FirStatement
import org.jetbrains.kotlin.fir.expressions.FirStringConcatenationCall
import org.jetbrains.kotlin.fir.expressions.FirTryExpression
import org.jetbrains.kotlin.fir.expressions.FirVariableAssignment
import org.jetbrains.kotlin.fir.expressions.FirWhenExpression
@@ -27,3 +35,11 @@ typealias FirTryExpressionChecker = FirExpressionChecker<FirTryExpression>
typealias FirWhenExpressionChecker = FirExpressionChecker<FirWhenExpression>
typealias FirReturnExpressionChecker = FirExpressionChecker<FirReturnExpression>
typealias FirBlockChecker = FirExpressionChecker<FirBlock>
typealias FirAnnotationCallChecker = FirExpressionChecker<FirAnnotationCall>
typealias FirCheckNotNullCallChecker = FirExpressionChecker<FirCheckNotNullCall>
typealias FirElvisExpressionChecker = FirExpressionChecker<FirElvisExpression>
typealias FirGetClassCallChecker = FirExpressionChecker<FirGetClassCall>
typealias FirSafeCallExpressionChecker = FirExpressionChecker<FirSafeCallExpression>
typealias FirEqualityOperatorCallChecker = FirExpressionChecker<FirEqualityOperatorCall>
typealias FirAnonymousFunctionAsExpressionChecker = FirExpressionChecker<FirAnonymousFunction>
typealias FirStringConcatenationCallChecker = FirExpressionChecker<FirStringConcatenationCall>

View File

@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
import org.jetbrains.kotlin.fir.types.ConeKotlinType
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.KtAnnotation
import org.jetbrains.kotlin.psi.KtArrayAccessExpression
import org.jetbrains.kotlin.psi.KtBinaryExpression
import org.jetbrains.kotlin.psi.KtClass
@@ -95,7 +96,7 @@ object FirErrors {
val DIVISION_BY_ZERO by warning0<KtExpression>()
// Unresolved
val HIDDEN by error1<PsiElement, AbstractFirBasedSymbol<*>>(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED)
val INVISIBLE_REFERENCE by error1<PsiElement, AbstractFirBasedSymbol<*>>(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED)
val UNRESOLVED_REFERENCE by error1<PsiElement, String>(SourceElementPositioningStrategies.REFERENCED_NAME_BY_QUALIFIED)
val UNRESOLVED_LABEL by error0<PsiElement>()
val DESERIALIZATION_ERROR by error0<PsiElement>()
@@ -155,6 +156,7 @@ object FirErrors {
val NULLABLE_TYPE_OF_ANNOTATION_MEMBER by error0<KtTypeReference>()
val VAR_ANNOTATION_PARAMETER by error0<KtParameter>(SourceElementPositioningStrategies.VAL_OR_VAR_NODE)
val SUPERTYPES_FOR_ANNOTATION_CLASS by error0<KtClass>(SourceElementPositioningStrategies.SUPERTYPES_LIST)
val ANNOTATION_USED_AS_ANNOTATION_ARGUMENT by error0<KtAnnotation>()
// Exposed visibility
val EXPOSED_TYPEALIAS_EXPANDED_TYPE by error3<KtNamedDeclaration, EffectiveVisibility, FirMemberDeclaration, EffectiveVisibility>(SourceElementPositioningStrategies.DECLARATION_NAME)
@@ -245,11 +247,11 @@ object FirErrors {
val NAME_IN_CONSTRAINT_IS_NOT_A_TYPE_PARAMETER by error2<KtSimpleNameExpression, Name, FirDeclaration>()
val BOUND_ON_TYPE_ALIAS_PARAMETER_NOT_ALLOWED by error0<KtTypeReference>()
val REIFIED_TYPE_PARAMETER_NO_INLINE by error0<KtTypeParameter>(SourceElementPositioningStrategies.REIFIED_MODIFIER)
val TYPE_PARAMETERS_NOT_ALLOWED by error0<KtDeclaration>()
val TYPE_PARAMETERS_NOT_ALLOWED by error0<KtDeclaration>(SourceElementPositioningStrategies.TYPE_PARAMETERS_LIST)
val TYPE_PARAMETER_OF_PROPERTY_NOT_USED_IN_RECEIVER by error0<KtTypeParameter>()
val RETURN_TYPE_MISMATCH by error2<KtExpression, ConeKotlinType, ConeKotlinType>(SourceElementPositioningStrategies.WHOLE_ELEMENT)
val CYCLIC_GENERIC_UPPER_BOUND by error0<PsiElement>()
val DEPRECATED_TYPE_PARAMETER_SYNTAX by error0<KtTypeParameterList>()
val DEPRECATED_TYPE_PARAMETER_SYNTAX by error0<KtDeclaration>(SourceElementPositioningStrategies.TYPE_PARAMETERS_LIST)
val MISPLACED_TYPE_PARAMETER_CONSTRAINTS by warning0<KtTypeParameter>()
val DYNAMIC_UPPER_BOUND by error0<KtTypeReference>()
@@ -308,6 +310,11 @@ object FirErrors {
// Fun interfaces
val FUN_INTERFACE_CONSTRUCTOR_REFERENCE by error0<KtExpression>(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED)
val FUN_INTERFACE_WRONG_COUNT_OF_ABSTRACT_MEMBERS by error0<KtClass>(SourceElementPositioningStrategies.FUN_MODIFIER)
val FUN_INTERFACE_CANNOT_HAVE_ABSTRACT_PROPERTIES by error0<KtDeclaration>(SourceElementPositioningStrategies.FUN_INTERFACE)
val FUN_INTERFACE_ABSTRACT_METHOD_WITH_TYPE_PARAMETERS by error0<KtDeclaration>(SourceElementPositioningStrategies.FUN_INTERFACE)
val FUN_INTERFACE_ABSTRACT_METHOD_WITH_DEFAULT_VALUE by error0<KtDeclaration>(SourceElementPositioningStrategies.FUN_INTERFACE)
val FUN_INTERFACE_WITH_SUSPEND_FUNCTION by error0<KtDeclaration>(SourceElementPositioningStrategies.FUN_INTERFACE)
// Properties & accessors
val ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS by error2<KtModifierListOwner, FirMemberDeclaration, FirMemberDeclaration>(SourceElementPositioningStrategies.MODALITY_MODIFIER)
@@ -376,6 +383,8 @@ object FirErrors {
val UNNECESSARY_NOT_NULL_ASSERTION by warning1<KtExpression, ConeKotlinType>(SourceElementPositioningStrategies.OPERATOR)
val NOT_NULL_ASSERTION_ON_LAMBDA_EXPRESSION by warning0<KtExpression>(SourceElementPositioningStrategies.OPERATOR)
val NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE by warning0<KtExpression>(SourceElementPositioningStrategies.OPERATOR)
val USELESS_ELVIS by warning1<KtBinaryExpression, ConeKotlinType>(SourceElementPositioningStrategies.USELESS_ELVIS)
val USELESS_ELVIS_RIGHT_IS_NULL by warning0<KtBinaryExpression>(SourceElementPositioningStrategies.USELESS_ELVIS)
// When expressions
val NO_ELSE_IN_WHEN by error1<KtWhenExpression, List<WhenMissingCase>>(SourceElementPositioningStrategies.WHEN_EXPRESSION)

View File

@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.fir.analysis
import com.intellij.lang.LighterASTNode
import com.intellij.psi.tree.IElementType
import com.intellij.psi.tree.TokenSet
import org.jetbrains.kotlin.fir.*
@@ -36,6 +37,19 @@ private fun FirPsiSourceElement<*>.getChild(types: Set<IElementType>, index: Int
private fun FirLightSourceElement.getChild(types: Set<IElementType>, index: Int, depth: Int): FirSourceElement? {
val visitor = LighterTreeElementFinderByType(treeStructure, types, index, depth)
return visitor.find(lighterASTNode)?.toFirLightSourceElement(treeStructure)
val childNode = visitor.find(lighterASTNode) ?: return null
return buildChildSourceElement(childNode)
}
/**
* Keeps 'padding' of parent node in child node
*/
internal fun FirLightSourceElement.buildChildSourceElement(childNode: LighterASTNode): FirLightSourceElement {
val offsetDelta = startOffset - lighterASTNode.startOffset
return childNode.toFirLightSourceElement(
treeStructure,
startOffset = childNode.startOffset + offsetDelta,
endOffset = childNode.endOffset + offsetDelta
)
}

View File

@@ -44,6 +44,7 @@ import kotlin.contracts.contract
object FirCallsEffectAnalyzer : FirControlFlowChecker() {
override fun analyze(graph: ControlFlowGraph, reporter: DiagnosticReporter, context: CheckerContext) {
val session = context.session
val function = (graph.declaration as? FirFunction<*>) ?: return
if (function !is FirContractDescriptionOwner) return
if (function.contractDescription.coneEffects?.any { it is ConeCallsEffectDeclaration } != true) return
@@ -51,13 +52,13 @@ object FirCallsEffectAnalyzer : FirControlFlowChecker() {
val functionalTypeEffects = mutableMapOf<AbstractFirBasedSymbol<*>, ConeCallsEffectDeclaration>()
function.valueParameters.forEachIndexed { index, parameter ->
if (parameter.returnTypeRef.isFunctionalTypeRef(function.session)) {
if (parameter.returnTypeRef.isFunctionalTypeRef(session)) {
val effectDeclaration = function.contractDescription.getParameterCallsEffectDeclaration(index)
if (effectDeclaration != null) functionalTypeEffects[parameter.symbol] = effectDeclaration
}
}
if (function.receiverTypeRef.isFunctionalTypeRef(function.session)) {
if (function.receiverTypeRef.isFunctionalTypeRef(session)) {
val effectDeclaration = function.contractDescription.getParameterCallsEffectDeclaration(-1)
if (effectDeclaration != null) functionalTypeEffects[function.symbol] = effectDeclaration
}

View File

@@ -33,8 +33,6 @@ import org.jetbrains.kotlin.fir.types.intersectTypesOrNull
import org.jetbrains.kotlin.fir.types.isNullable
import org.jetbrains.kotlin.types.AbstractTypeChecker
import org.jetbrains.kotlin.types.ConstantValueKind
import org.jetbrains.kotlin.types.model.KotlinTypeMarker
import org.jetbrains.kotlin.types.model.TypeCheckerProviderContext
import org.jetbrains.kotlin.utils.addIfNotNull
object FirReturnsImpliesAnalyzer : FirControlFlowChecker() {
@@ -50,7 +48,7 @@ object FirReturnsImpliesAnalyzer : FirControlFlowChecker() {
if (effects.isNullOrEmpty()) return
val logicSystem = object : PersistentLogicSystem(function.session.typeContext) {
val logicSystem = object : PersistentLogicSystem(context.session.typeContext) {
override fun processUpdatedReceiverVariable(flow: PersistentFlow, variable: RealVariable) =
throw IllegalStateException("Receiver variable update is not possible for this logic system")
@@ -84,8 +82,8 @@ object FirReturnsImpliesAnalyzer : FirControlFlowChecker() {
context: CheckerContext
): Boolean {
val effect = effectDeclaration.effect as ConeReturnsEffectDeclaration
val builtinTypes = function.session.builtinTypes
val typeContext = function.session.typeContext
val builtinTypes = context.session.builtinTypes
val typeContext = context.session.typeContext
val flow = dataFlowInfo.flowOnNodes.getValue(node) as PersistentFlow
val isReturn = node is JumpNode && node.fir is FirReturnExpression
@@ -104,7 +102,7 @@ object FirReturnsImpliesAnalyzer : FirControlFlowChecker() {
if (effect.value != ConeConstantReference.WILDCARD) {
val operation = effect.value.toOperation()
if (expressionType != null && expressionType.isInapplicableWith(operation, function.session)) return false
if (expressionType != null && expressionType.isInapplicableWith(operation, context.session)) return false
if (resultExpression is FirConstExpression<*>) {
if (!resultExpression.isApplicableWith(operation)) return false
@@ -179,7 +177,7 @@ object FirReturnsImpliesAnalyzer : FirControlFlowChecker() {
is ConeIsNullPredicate -> {
val fir = function.getParameterSymbol(arg.parameterIndex, context).fir
val realVar = variableStorage.getOrCreateRealVariable(flow, fir.symbol, fir)
realVar?.to(simpleTypeStatement(realVar, isNegated, function.session.builtinTypes.anyType.type))?.let { mutableMapOf(it) }
realVar?.to(simpleTypeStatement(realVar, isNegated, context.session.builtinTypes.anyType.type))?.let { mutableMapOf(it) }
}
is ConeLogicalNot -> arg.buildTypeStatements(function, logicSystem, variableStorage, flow, context)
?.mapValuesTo(mutableMapOf()) { (_, value) -> value.invert() }

View File

@@ -53,44 +53,10 @@ private val INLINE_ONLY_ANNOTATION_CLASS_ID = ClassId.topLevel(FqName("kotlin.in
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.
*/
fun FirClass<*>.isSuperclassOf(other: FirClass<*>): Boolean {
/**
* Hides additional parameters.
*/
fun FirClass<*>.isSuperclassOf(other: FirClass<*>, exclude: MutableSet<FirClass<*>>): Boolean {
for (it in other.superTypeRefs) {
val that = it.firClassLike(session)
?.followAllAlias(session)
?.safeAs<FirClass<*>>()
?: continue
if (that in exclude) {
continue
}
if (that.classKind == ClassKind.CLASS) {
if (that == this) {
return true
}
exclude.add(that)
return this.isSuperclassOf(that, exclude)
}
}
return false
}
return isSuperclassOf(other, mutableSetOf())
}
/**
* Returns true if this is a supertype of other.
*/
fun FirClass<*>.isSupertypeOf(other: FirClass<*>): Boolean {
fun FirClass<*>.isSupertypeOf(other: FirClass<*>, session: FirSession): Boolean {
/**
* Hides additional parameters.
*/

View File

@@ -81,7 +81,7 @@ object FirConflictsChecker : FirBasicDeclarationChecker() {
session: FirSession
) {
val conflicting = conflictingSymbol.fir as? FirDeclaration ?: return
if (declaration.session.moduleInfo != conflicting.session.moduleInfo) return
if (declaration.declarationSiteSession.moduleInfo != conflicting.declarationSiteSession.moduleInfo) return
val actualConflictingPresentation = conflictingPresentation ?: presenter.represent(conflicting)
if (conflicting == declaration || actualConflictingPresentation != declarationPresentation) return
val actualConflictingFile =

View File

@@ -44,7 +44,7 @@ object FirExposedVisibilityDeclarationChecker : FirMemberDeclarationChecker() {
val isInterface = declaration.classKind == ClassKind.INTERFACE
for (supertypeRef in supertypes) {
val supertype = supertypeRef.coneTypeSafe<ConeClassLikeType>() ?: continue
val clazz = supertype.toRegularClass(declaration.session) ?: continue
val clazz = supertype.toRegularClass(context.session) ?: continue
val superIsInterface = clazz.classKind == ClassKind.INTERFACE
if (superIsInterface != isInterface) {
continue

View File

@@ -0,0 +1,97 @@
/*
* 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.fir.analysis.checkers.declaration
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.fir.analysis.checkers.getContainingClass
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
import org.jetbrains.kotlin.fir.analysis.checkers.unsubstitutedScope
import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.FUN_INTERFACE_ABSTRACT_METHOD_WITH_DEFAULT_VALUE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.FUN_INTERFACE_ABSTRACT_METHOD_WITH_TYPE_PARAMETERS
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.FUN_INTERFACE_CANNOT_HAVE_ABSTRACT_PROPERTIES
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.FUN_INTERFACE_WITH_SUSPEND_FUNCTION
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.FUN_INTERFACE_WRONG_COUNT_OF_ABSTRACT_MEMBERS
import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOn
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.languageVersionSettings
import org.jetbrains.kotlin.fir.scopes.getFunctions
import org.jetbrains.kotlin.fir.scopes.getProperties
object FirFunInterfaceDeclarationChecker : FirRegularClassChecker() {
override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) {
if (!declaration.isInterface || !declaration.isFun) return
val scope = declaration.unsubstitutedScope(context)
var abstractFunction: FirSimpleFunction? = null
for (name in scope.getCallableNames()) {
val functions = scope.getFunctions(name)
val properties = scope.getProperties(name)
for (function in functions) {
if (function.fir.isAbstract) {
if (abstractFunction == null) {
abstractFunction = function.fir
} else {
reporter.reportOn(declaration.source, FUN_INTERFACE_WRONG_COUNT_OF_ABSTRACT_MEMBERS, context)
}
}
}
for (property in properties) {
val firProperty = property.fir as? FirProperty ?: continue
if (firProperty.isAbstract) {
val source =
if (firProperty.getContainingClass(context) != declaration)
declaration.source
else
firProperty.source
reporter.reportOn(source, FUN_INTERFACE_CANNOT_HAVE_ABSTRACT_PROPERTIES, context)
}
}
}
if (abstractFunction == null) {
reporter.reportOn(declaration.source, FUN_INTERFACE_WRONG_COUNT_OF_ABSTRACT_MEMBERS, context)
return
}
val inFunInterface = abstractFunction.getContainingClass(context) === declaration
when {
abstractFunction.typeParameters.isNotEmpty() ->
reporter.reportOn(
if (inFunInterface) abstractFunction.source else declaration.source,
FUN_INTERFACE_ABSTRACT_METHOD_WITH_TYPE_PARAMETERS,
context
)
abstractFunction.isSuspend ->
if (!context.session.languageVersionSettings.supportsFeature(LanguageFeature.SuspendFunctionsInFunInterfaces)) {
reporter.reportOn(
if (inFunInterface) abstractFunction.source else declaration.source,
FUN_INTERFACE_WITH_SUSPEND_FUNCTION,
context
)
}
}
abstractFunction.valueParameters.forEach {
if (it.defaultValue != null) {
reporter.reportOn(
if (inFunInterface) it.source else declaration.source,
FUN_INTERFACE_ABSTRACT_METHOD_WITH_DEFAULT_VALUE,
context
)
}
}
}
}

View File

@@ -21,7 +21,7 @@ object FirFunctionTypeParametersChecker : FirSimpleFunctionChecker() {
val nameNode = source.treeStructure.nameIdentifier(source.lighterASTNode)
if (typeParamsNode != null && nameNode != null && typeParamsNode.startOffset > nameNode.startOffset) {
reporter.reportOn(
typeParamsNode.toFirLightSourceElement(source.treeStructure),
source,
FirErrors.DEPRECATED_TYPE_PARAMETER_SYNTAX,
context
)

View File

@@ -13,28 +13,10 @@ import org.jetbrains.kotlin.fir.declarations.FirProperty
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyGetter
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertySetter
import org.jetbrains.kotlin.fir.declarations.isLateInit
import org.jetbrains.kotlin.fir.types.ConeKotlinType
import org.jetbrains.kotlin.fir.types.ConeTypeParameterType
import org.jetbrains.kotlin.fir.types.coneType
import org.jetbrains.kotlin.fir.types.isNullable
class FirInapplicableLateinitChecker : FirPropertyChecker() {
var primitives: Set<ConeKotlinType>? = null
private fun getPrimitiveTypes(context: CheckerContext) = primitives ?: mutableSetOf<ConeKotlinType>().apply {
with(context.session.builtinTypes) {
add(intType.coneType)
add(booleanType.coneType)
add(charType.coneType)
add(shortType.coneType)
add(byteType.coneType)
add(longType.coneType)
add(doubleType.coneType)
add(floatType.coneType)
}
primitives = this
}
import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.name.StandardClassIds
object FirInapplicableLateinitChecker : FirPropertyChecker() {
override fun check(declaration: FirProperty, context: CheckerContext, reporter: DiagnosticReporter) {
if (!declaration.isLateInit) {
return
@@ -56,7 +38,7 @@ class FirInapplicableLateinitChecker : FirPropertyChecker() {
declaration.isNullable() ->
reporter.reportOn(declaration.source, "is not allowed on properties of a type with nullable upper bound", context)
declaration.returnTypeRef.coneType in getPrimitiveTypes(context) -> if (declaration.isLocal) {
declaration.returnTypeRef.coneType.classId in StandardClassIds.primitiveTypes -> if (declaration.isLocal) {
reporter.reportOn(declaration.source, "is not allowed on local variables of primitive types", context)
} else {
reporter.reportOn(declaration.source, "is not allowed on properties of primitive types", context)

View File

@@ -16,17 +16,19 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOnWithSuppression
import org.jetbrains.kotlin.fir.analysis.diagnostics.withSuppressedDiagnostics
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.resolve.calls.isPotentiallyArray
import org.jetbrains.kotlin.fir.resolve.defaultType
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
import org.jetbrains.kotlin.fir.resolve.lookupSuperTypes
import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.types.AbstractTypeChecker
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.StandardClassIds
class FirInlineClassDeclarationChecker : FirRegularClassChecker() {
object FirInlineClassDeclarationChecker : FirRegularClassChecker() {
private val reservedFunctionNames = setOf("box", "unbox", "equals", "hashCode")
private val kotlinCloneableType = ClassId.fromString("kotlin/Cloneable").constructClassLikeType(emptyArray(), false)
private val javaCloneableType = ClassId.fromString("java/lang/Cloneable").constructClassLikeType(emptyArray(), false)
private val javaLangFqName = FqName("java.lang")
private val cloneableFqName = FqName("Cloneable")
@Suppress("NAME_SHADOWING")
override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) {
@@ -48,7 +50,7 @@ class FirInlineClassDeclarationChecker : FirRegularClassChecker() {
}
}
if (declaration.isSubtypeOfCloneable(context)) {
if (declaration.isSubtypeOfCloneable(context.session)) {
reporter.reportOn(declaration.source, FirErrors.VALUE_CLASS_CANNOT_BE_CLONEABLE, context)
}
@@ -208,11 +210,15 @@ class FirInlineClassDeclarationChecker : FirRegularClassChecker() {
?.isRecursiveInlineClassType(visited, session) == true
}
private fun FirRegularClass.isSubtypeOfCloneable(context: CheckerContext): Boolean {
val coneType = this.defaultType()
val typeContext = context.session.typeContext
private fun FirRegularClass.isSubtypeOfCloneable(session: FirSession): Boolean {
if (classId.isCloneableId()) return true
return AbstractTypeChecker.isSubtypeOf(typeContext, coneType, kotlinCloneableType) ||
AbstractTypeChecker.isSubtypeOf(typeContext, coneType, javaCloneableType)
return lookupSuperTypes(this, lookupInterfaces = true, deep = true, session).any { superType ->
(superType as? ConeClassLikeType)?.fullyExpandedType(session)?.lookupTag?.classId?.isCloneableId() == true
}
}
private fun ClassId.isCloneableId(): Boolean =
relativeClassName == cloneableFqName &&
packageFqName == StandardClassIds.BASE_KOTLIN_PACKAGE || packageFqName == javaLangFqName
}

View File

@@ -5,35 +5,20 @@
package org.jetbrains.kotlin.fir.analysis.checkers.declaration
import org.jetbrains.kotlin.fir.analysis.checkers.FirDeclarationInspector
import org.jetbrains.kotlin.fir.HASHCODE_NAME
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.analysis.diagnostics.withSuppressedDiagnostics
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.resolve.symbolProvider
import org.jetbrains.kotlin.fir.types.isNullableAny
import org.jetbrains.kotlin.name.CallableId
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
class FirMethodOfAnyImplementedInInterfaceChecker : FirRegularClassChecker(), FirDeclarationPresenter {
private var inspector: FirDeclarationInspector? = null
private fun getInspector(context: CheckerContext) = inspector ?: FirDeclarationInspector(this).apply {
val anyClassId = context.session.builtinTypes.anyType.id
context.session.symbolProvider.getClassLikeSymbolByFqName(anyClassId)
?.fir.safeAs<FirRegularClass>()
?.declarations
?.filterIsInstance<FirSimpleFunction>()
?.filter { it !is FirConstructor }
?.forEach {
collect(it)
}
inspector = this
}
import org.jetbrains.kotlin.util.OperatorNameConventions.EQUALS
import org.jetbrains.kotlin.util.OperatorNameConventions.TO_STRING
object FirMethodOfAnyImplementedInInterfaceChecker : FirRegularClassChecker(), FirDeclarationPresenter {
// We need representations that look like JVM signatures. Thus, just function names, not fully qualified ones.
override fun StringBuilder.appendRepresentation(it: CallableId) {
append(it.callableName)
@@ -49,13 +34,24 @@ class FirMethodOfAnyImplementedInInterfaceChecker : FirRegularClassChecker(), Fi
return
}
for (it in declaration.declarations) {
if (it !is FirSimpleFunction || !it.isOverride || !it.hasBody) continue
for (function in declaration.declarations) {
if (function !is FirSimpleFunction || !function.isOverride || !function.hasBody) continue
var methodOfAny = false
if (function.valueParameters.isEmpty() &&
(function.name == HASHCODE_NAME || function.name == TO_STRING)
) {
methodOfAny = true
} else {
val singleParameter = function.valueParameters.singleOrNull() ?: continue
if (singleParameter.returnTypeRef.isNullableAny && function.name == EQUALS) {
methodOfAny = true
}
}
val inspector = getInspector(context)
if (inspector.contains(it)) {
reporter.reportOn(it.source, FirErrors.METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE, context)
if (methodOfAny) {
withSuppressedDiagnostics(function, context) {
reporter.reportOn(function.source, FirErrors.METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE, context)
}
}
}
}

View File

@@ -34,14 +34,15 @@ internal sealed class FirModifierList {
class FirLightModifierList(
val modifierList: LighterASTNode,
val tree: FlyweightCapableTreeStructure<LighterASTNode>
val tree: FlyweightCapableTreeStructure<LighterASTNode>,
private val offsetDelta: Int
) : FirModifierList() {
override val modifiers: List<FirModifier.FirLightModifier>
get() {
val modifierNodes = modifierList.getChildren(tree)
return modifierNodes.filterNotNull()
.filter { it.tokenType is KtModifierKeywordToken }
.map { FirModifier.FirLightModifier(it, it.tokenType as KtModifierKeywordToken, tree) }
.map { FirModifier.FirLightModifier(it, it.tokenType as KtModifierKeywordToken, tree, offsetDelta) }
}
}
@@ -65,10 +66,15 @@ internal sealed class FirModifier<Node : Any>(val node: Node, val token: KtModif
class FirLightModifier(
node: LighterASTNode,
token: KtModifierKeywordToken,
val tree: FlyweightCapableTreeStructure<LighterASTNode>
val tree: FlyweightCapableTreeStructure<LighterASTNode>,
private val offsetDelta: Int
) : FirModifier<LighterASTNode>(node, token) {
override val source: FirSourceElement
get() = node.toFirLightSourceElement(tree)
get() = node.toFirLightSourceElement(
tree,
startOffset = node.startOffset + offsetDelta,
endOffset = node.endOffset + offsetDelta
)
}
abstract val source: FirSourceElement
@@ -81,7 +87,8 @@ internal fun FirSourceElement?.getModifierList(): FirModifierList? {
is FirLightSourceElement -> {
val modifierListNode = lighterASTNode.getChildren(treeStructure).find { it?.tokenType == KtNodeTypes.MODIFIER_LIST }
?: return null
FirModifierList.FirLightModifierList(modifierListNode, treeStructure)
val offsetDelta = startOffset - lighterASTNode.startOffset
FirModifierList.FirLightModifierList(modifierListNode, treeStructure, offsetDelta)
}
}
}

View File

@@ -58,7 +58,7 @@ object FirNotImplementedOverrideChecker : FirClassChecker() {
!visibility.visibleFromPackage(classPackage, symbol.callableId.packageName)
) return true
if (visibility == Visibilities.Internal &&
session !== declaration.session
declarationSiteSession !== declaration.declarationSiteSession
) return true
return false
}

View File

@@ -59,6 +59,7 @@ object FirOverrideChecker : FirClassChecker() {
private fun ConeKotlinType.substituteAllTypeParameters(
overrideDeclaration: FirCallableMemberDeclaration<*>,
baseDeclaration: FirCallableDeclaration<*>,
context: CheckerContext
): ConeKotlinType {
if (overrideDeclaration.typeParameters.isEmpty()) {
return this
@@ -77,7 +78,7 @@ object FirOverrideChecker : FirClassChecker() {
map[from.symbol] = to.toConeType()
}
return substitutorByMap(map).substituteOrSelf(this)
return substitutorByMap(map, context.session).substituteOrSelf(this)
}
private fun checkModality(
@@ -144,7 +145,7 @@ object FirOverrideChecker : FirClassChecker() {
for (it in bounds.indices) {
val overriddenDeclaration = overriddenSymbols[it].fir
val overriddenReturnType = bounds[it].substituteAllTypeParameters(this, overriddenDeclaration)
val overriddenReturnType = bounds[it].substituteAllTypeParameters(this, overriddenDeclaration, context)
val isReturnTypeOkForOverride =
if (overriddenDeclaration is FirProperty && overriddenDeclaration.isVar)

View File

@@ -0,0 +1,24 @@
/*
* 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.fir.analysis.checkers.expression
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.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.unwrapArgument
object FirAnnotationUsedAsAnnotationArgumentChecker : FirAnnotationCallChecker() {
override fun check(expression: FirAnnotationCall, context: CheckerContext, reporter: DiagnosticReporter) {
val args = expression.argumentList.arguments
for (arg in args) {
for (ann in arg.unwrapArgument().annotations) {
reporter.reportOn(ann.source, FirErrors.ANNOTATION_USED_AS_ANNOTATION_ARGUMENT, context)
}
}
}
}

View File

@@ -8,14 +8,9 @@ package org.jetbrains.kotlin.fir.analysis.checkers.expression
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
import org.jetbrains.kotlin.fir.analysis.diagnostics.*
import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction
import org.jetbrains.kotlin.fir.expressions.FirStatement
import org.jetbrains.kotlin.fir.toFirLightSourceElement
object FirAnonymousFunctionChecker : FirExpressionChecker<FirStatement>() {
override fun check(expression: FirStatement, context: CheckerContext, reporter: DiagnosticReporter) {
if (expression !is FirAnonymousFunction) {
return
}
object FirAnonymousFunctionChecker : FirAnonymousFunctionAsExpressionChecker() {
override fun check(expression: FirAnonymousFunction, context: CheckerContext, reporter: DiagnosticReporter) {
for (valueParameter in expression.valueParameters) {
val source = valueParameter.source ?: continue
if (valueParameter.defaultValue != null) {
@@ -30,14 +25,14 @@ object FirAnonymousFunctionChecker : FirExpressionChecker<FirStatement>() {
}
private fun checkTypeParameters(
expression: FirStatement,
expression: FirAnonymousFunction,
reporter: DiagnosticReporter,
context: CheckerContext
) {
val source = expression.source ?: return
source.treeStructure.typeParametersList(source.lighterASTNode)?.let { typeParamsNode ->
source.treeStructure.typeParametersList(source.lighterASTNode)?.let { _ ->
reporter.reportOn(
typeParamsNode.toFirLightSourceElement(source.treeStructure),
source,
FirErrors.TYPE_PARAMETERS_NOT_ALLOWED,
context
)

View File

@@ -18,7 +18,7 @@ import org.jetbrains.kotlin.fir.expressions.FirCallableReferenceAccess
import org.jetbrains.kotlin.fir.expressions.FirGetClassCall
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
import org.jetbrains.kotlin.fir.resolve.containingClass
import org.jetbrains.kotlin.fir.resolve.getContainingClass
import org.jetbrains.kotlin.fir.symbols.impl.FirBackingFieldSymbol
object FirCallableReferenceChecker : FirQualifiedAccessChecker() {
@@ -43,7 +43,7 @@ object FirCallableReferenceChecker : FirQualifiedAccessChecker() {
if (source.kind is FirFakeSourceElementKind) return
val referredDeclaration = reference.resolvedSymbol.fir
if (referredDeclaration is FirConstructor && referredDeclaration.containingClass?.classKind == ClassKind.ANNOTATION_CLASS) {
if (referredDeclaration is FirConstructor && referredDeclaration.getContainingClass(context.session)?.classKind == ClassKind.ANNOTATION_CLASS) {
reporter.reportOn(source, FirErrors.CALLABLE_REFERENCE_TO_ANNOTATION_CONSTRUCTOR, context)
}
if ((referredDeclaration as? FirCallableMemberDeclaration<*>)?.isExtensionMember == true &&

View File

@@ -21,9 +21,8 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.lexer.KtTokens.QUEST
object FirGetClassCallChecker : FirBasicExpressionChecker() {
override fun check(expression: FirStatement, context: CheckerContext, reporter: DiagnosticReporter) {
if (expression !is FirGetClassCall) return
object FirClassLiteralChecker : FirGetClassCallChecker() {
override fun check(expression: FirGetClassCall, context: CheckerContext, reporter: DiagnosticReporter) {
val source = expression.source ?: return
if (source.kind is FirFakeSourceElementKind) return

View File

@@ -28,7 +28,7 @@ object FirNotASupertypeChecker : FirQualifiedAccessChecker() {
?: return
val surrounding = context.findClosestClass(superReference.labelName) ?: return
if (!targetClass.isSupertypeOf(surrounding)) {
if (!targetClass.isSupertypeOf(surrounding, context.session)) {
reporter.reportOn(expression.source, FirErrors.NOT_A_SUPERTYPE, context)
}
}

View File

@@ -13,14 +13,11 @@ import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction
import org.jetbrains.kotlin.fir.expressions.FirCallableReferenceAccess
import org.jetbrains.kotlin.fir.expressions.FirCheckNotNullCall
import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier
import org.jetbrains.kotlin.fir.expressions.FirStatement
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
import org.jetbrains.kotlin.fir.types.*
object FirCheckNotNullCallChecker : FirBasicExpressionChecker() {
override fun check(expression: FirStatement, context: CheckerContext, reporter: DiagnosticReporter) {
if (expression !is FirCheckNotNullCall) return
object FirNotNullAssertionChecker : FirCheckNotNullCallChecker() {
override fun check(expression: FirCheckNotNullCall, context: CheckerContext, reporter: DiagnosticReporter) {
val argument = expression.argumentList.arguments.singleOrNull() ?: return
if (argument is FirAnonymousFunction && argument.isLambda) {
reporter.reportOn(expression.source, FirErrors.NOT_NULL_ASSERTION_ON_LAMBDA_EXPRESSION, context)

View File

@@ -44,7 +44,7 @@ object FirQualifiedSupertypeExtendedByOtherSupertypeChecker : FirQualifiedAccess
?.followAllAlias(context.session).safeAs<FirClass<*>>()
?: continue
val isSupertype = explicitType.isSupertypeOf(that)
val isSupertype = explicitType.isSupertypeOf(that, context.session)
if (explicitType == that || isSupertype) {
if (isSupertype) {

View File

@@ -33,7 +33,7 @@ object FirSealedClassConstructorCallChecker : FirQualifiedAccessChecker() {
?: return
if (typeFir.status.modality == Modality.SEALED) {
reporter.reportOn(expression.calleeReference.source, FirErrors.SEALED_CLASS_CONSTRUCTOR_CALL, context)
reporter.reportOn(expression.source, FirErrors.SEALED_CLASS_CONSTRUCTOR_CALL, context)
}
}
}

View File

@@ -10,16 +10,13 @@ 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.expressions.FirSafeCallExpression
import org.jetbrains.kotlin.fir.expressions.FirStatement
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
import org.jetbrains.kotlin.fir.types.canBeNull
import org.jetbrains.kotlin.fir.types.coneType
import org.jetbrains.kotlin.fir.types.isUnit
object FirSafeCallExpressionChecker : FirBasicExpressionChecker() {
override fun check(expression: FirStatement, context: CheckerContext, reporter: DiagnosticReporter) {
if (expression !is FirSafeCallExpression) return
object FirUnnecessarySafeCallChecker : FirSafeCallExpressionChecker() {
override fun check(expression: FirSafeCallExpression, context: CheckerContext, reporter: DiagnosticReporter) {
val receiverType = expression.receiver.typeRef.coneType.fullyExpandedType(context.session)
if (receiverType.isUnit) {
reporter.reportOn(expression.source, FirErrors.UNEXPECTED_SAFE_CALL, context)

View File

@@ -59,7 +59,8 @@ object FirUpperBoundViolatedChecker : FirQualifiedAccessChecker() {
// we substitute actual values to the
// type parameters from the declaration
val substitutor = substitutorByMap(
parameterPairs.mapValues { it.value.coneType }
parameterPairs.mapValues { it.value.coneType },
context.session
)
parameterPairs.forEach { (proto, actual) ->
@@ -147,7 +148,8 @@ object FirUpperBoundViolatedChecker : FirQualifiedAccessChecker() {
// parameters to the ones used in the
// typealias target
val declarationSiteSubstitutor = substitutorByMap(
constructorsParameterPairs.toMap().mapValues { it.value.type }
constructorsParameterPairs.toMap().mapValues { it.value.type },
context.session
)
constructorsParameterPairs.forEach { (proto, actual) ->
@@ -209,7 +211,8 @@ object FirUpperBoundViolatedChecker : FirQualifiedAccessChecker() {
}
val substitutor = substitutorByMap(
parameterPairs.toMap().mapValues { it.value.type }
parameterPairs.toMap().mapValues { it.value.type },
context.session
)
parameterPairs.forEach { (proto, actual) ->

View File

@@ -0,0 +1,36 @@
/*
* 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.fir.analysis.checkers.expression
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.expressions.FirElvisExpression
import org.jetbrains.kotlin.fir.types.ConeKotlinErrorType
import org.jetbrains.kotlin.fir.types.canBeNull
import org.jetbrains.kotlin.fir.types.coneType
import org.jetbrains.kotlin.fir.types.isNullLiteral
object FirUselessElvisChecker : FirElvisExpressionChecker() {
override fun check(expression: FirElvisExpression, context: CheckerContext, reporter: DiagnosticReporter) {
// If the overall expression is not resolved/completed, the corresponding error will be reported separately.
// See [FirControlFlowStatementsResolveTransformer#transformElvisExpression],
// where an error type is recorded as the expression's return type.
if (expression.typeRef.coneType is ConeKotlinErrorType) return
val lhsType = expression.lhs.typeRef.coneType
if (lhsType is ConeKotlinErrorType) return
if (!lhsType.canBeNull) {
reporter.reportOn(expression.source, FirErrors.USELESS_ELVIS, lhsType, context)
return
}
if (expression.rhs.isNullLiteral) {
reporter.reportOn(expression.source, FirErrors.USELESS_ELVIS_RIGHT_IS_NULL, context)
}
}
}

View File

@@ -7,19 +7,17 @@ package org.jetbrains.kotlin.fir.analysis.checkers.extended
import org.jetbrains.kotlin.fir.FirFakeSourceElement
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirBasicExpressionChecker
import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirFunctionCallChecker
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.expressions.FirConstExpression
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
import org.jetbrains.kotlin.fir.expressions.FirStatement
import org.jetbrains.kotlin.fir.scopes.impl.FirIntegerOperatorCall
object EmptyRangeChecker : FirBasicExpressionChecker() {
override fun check(expression: FirStatement, context: CheckerContext, reporter: DiagnosticReporter) {
object EmptyRangeChecker : FirFunctionCallChecker() {
override fun check(expression: FirFunctionCall, context: CheckerContext, reporter: DiagnosticReporter) {
if (expression.source is FirFakeSourceElement<*>) return
if (expression !is FirFunctionCall) return
val left = expression.rangeLeft ?: return
val right = expression.rangeRight ?: return

View File

@@ -27,7 +27,6 @@ import org.jetbrains.kotlin.psi.KtSafeQualifiedExpression
object RedundantCallOfConversionMethod : FirQualifiedAccessChecker() {
override fun check(expression: FirQualifiedAccessExpression, context: CheckerContext, reporter: DiagnosticReporter) {
if (expression !is FirFunctionCall) return
if (expression.source?.kind == FirFakeSourceElementKind.GeneratedToStringCallOnTemplateEntry) return
val functionName = expression.calleeReference.name.asString()
val qualifiedType = targetClassMap[functionName] ?: return

View File

@@ -7,18 +7,16 @@ package org.jetbrains.kotlin.fir.analysis.checkers.extended
import org.jetbrains.kotlin.fir.FirFakeSourceElementKind
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirBasicDeclarationChecker
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirSimpleFunctionChecker
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.FirSimpleFunction
import org.jetbrains.kotlin.fir.expressions.impl.FirSingleExpressionBlock
import org.jetbrains.kotlin.fir.types.isUnit
object RedundantReturnUnitType : FirBasicDeclarationChecker() {
override fun check(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) {
if (declaration !is FirSimpleFunction) return
object RedundantReturnUnitType : FirSimpleFunctionChecker() {
override fun check(declaration: FirSimpleFunction, context: CheckerContext, reporter: DiagnosticReporter) {
if (declaration.body is FirSingleExpressionBlock) return
val returnType = declaration.returnTypeRef
if (returnType.source == null) return

View File

@@ -9,42 +9,37 @@ import com.intellij.lang.LighterASTNode
import com.intellij.lang.PsiBuilder
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.KtNodeTypes
import org.jetbrains.kotlin.fir.FirFakeSourceElementKind
import org.jetbrains.kotlin.fir.FirLightSourceElement
import org.jetbrains.kotlin.fir.FirPsiSourceElement
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirBasicExpressionChecker
import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirStringConcatenationCallChecker
import org.jetbrains.kotlin.fir.analysis.checkers.getChildren
import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.REDUNDANT_SINGLE_EXPRESSION_STRING_TEMPLATE
import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOn
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
import org.jetbrains.kotlin.fir.expressions.FirStatement
import org.jetbrains.kotlin.fir.expressions.FirStringConcatenationCall
import org.jetbrains.kotlin.fir.expressions.arguments
import org.jetbrains.kotlin.name.StandardClassIds
import org.jetbrains.kotlin.fir.types.classId
import org.jetbrains.kotlin.fir.types.coneType
import org.jetbrains.kotlin.psi.KtStringTemplateExpression
object RedundantSingleExpressionStringTemplateChecker : FirBasicExpressionChecker() {
override fun check(expression: FirStatement, context: CheckerContext, reporter: DiagnosticReporter) {
if (expression.source?.kind != FirFakeSourceElementKind.GeneratedToStringCallOnTemplateEntry) return
if (expression !is FirFunctionCall) return
if (
expression.explicitReceiver?.typeRef?.coneType?.classId == StandardClassIds.String
&& expression.stringParentChildrenCount() == 1 // there is no more children in original string template
) {
reporter.reportOn(expression.source, REDUNDANT_SINGLE_EXPRESSION_STRING_TEMPLATE, context)
object RedundantSingleExpressionStringTemplateChecker : FirStringConcatenationCallChecker() {
override fun check(expression: FirStringConcatenationCall, context: CheckerContext, reporter: DiagnosticReporter) {
for (argumentExpression in expression.arguments) {
if (argumentExpression.typeRef.coneType.classId == StandardClassIds.String &&
argumentExpression.stringParentChildrenCount() == 1 // there is no more children in original string template
) {
reporter.reportOn(argumentExpression.source, REDUNDANT_SINGLE_EXPRESSION_STRING_TEMPLATE, context)
}
}
}
private fun FirStatement.stringParentChildrenCount(): Int? {
return when (val source = source) {
is FirPsiSourceElement<*> -> {
source.psi.stringParentChildrenCount()
}
is FirLightSourceElement -> {
source.lighterASTNode.stringParentChildrenCount(source)
}
is FirPsiSourceElement<*> -> source.psi.stringParentChildrenCount()
is FirLightSourceElement -> source.lighterASTNode.stringParentChildrenCount(source)
else -> null
}
}

View File

@@ -22,7 +22,7 @@ class ExpressionCheckersDiagnosticComponent(
) : AbstractDiagnosticCollectorComponent(collector) {
override fun visitAnonymousFunction(anonymousFunction: FirAnonymousFunction, data: CheckerContext) {
checkers.allBasicExpressionCheckers.check(anonymousFunction, data, reporter)
checkers.allAnonymousFunctionAsExpressionCheckers.check(anonymousFunction, data, reporter)
}
override fun visitTypeOperatorCall(typeOperatorCall: FirTypeOperatorCall, data: CheckerContext) {
@@ -34,7 +34,7 @@ class ExpressionCheckersDiagnosticComponent(
}
override fun visitAnnotationCall(annotationCall: FirAnnotationCall, data: CheckerContext) {
checkers.allBasicExpressionCheckers.check(annotationCall, data, reporter)
checkers.allAnnotationCallCheckers.check(annotationCall, data, reporter)
}
override fun visitQualifiedAccessExpression(qualifiedAccessExpression: FirQualifiedAccessExpression, data: CheckerContext) {
@@ -70,15 +70,19 @@ class ExpressionCheckersDiagnosticComponent(
}
override fun visitStringConcatenationCall(stringConcatenationCall: FirStringConcatenationCall, data: CheckerContext) {
checkers.allBasicExpressionCheckers.check(stringConcatenationCall, data, reporter)
checkers.allStringConcatenationCallCheckers.check(stringConcatenationCall, data, reporter)
}
override fun visitCheckNotNullCall(checkNotNullCall: FirCheckNotNullCall, data: CheckerContext) {
checkers.allBasicExpressionCheckers.check(checkNotNullCall, data, reporter)
checkers.allCheckNotNullCallCheckers.check(checkNotNullCall, data, reporter)
}
override fun visitElvisExpression(elvisExpression: FirElvisExpression, data: CheckerContext) {
checkers.allElvisExpressionCheckers.check(elvisExpression, data, reporter)
}
override fun visitSafeCallExpression(safeCallExpression: FirSafeCallExpression, data: CheckerContext) {
checkers.basicExpressionCheckers.check(safeCallExpression, data, reporter)
checkers.allSafeCallExpressionCheckers.check(safeCallExpression, data, reporter)
}
override fun visitTryExpression(tryExpression: FirTryExpression, data: CheckerContext) {
@@ -90,11 +94,11 @@ class ExpressionCheckersDiagnosticComponent(
}
override fun visitGetClassCall(getClassCall: FirGetClassCall, data: CheckerContext) {
checkers.allBasicExpressionCheckers.check(getClassCall, data, reporter)
checkers.allGetClassCallCheckers.check(getClassCall, data, reporter)
}
override fun visitEqualityOperatorCall(equalityOperatorCall: FirEqualityOperatorCall, data: CheckerContext) {
checkers.allBasicExpressionCheckers.check(equalityOperatorCall, data, reporter)
checkers.allEqualityOperatorCallCheckers.check(equalityOperatorCall, data, reporter)
}
override fun visitVariableAssignment(variableAssignment: FirVariableAssignment, data: CheckerContext) {

View File

@@ -36,6 +36,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ABSTRACT_SUPER_CA
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ANNOTATION_ARGUMENT_MUST_BE_CONST
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ANNOTATION_CLASS_MEMBER
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ANNOTATION_PARAMETER_DEFAULT_VALUE_MUST_BE_CONSTANT
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ANNOTATION_USED_AS_ANNOTATION_ARGUMENT
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ANONYMOUS_FUNCTION_PARAMETER_WITH_DEFAULT_VALUE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ARGUMENT_PASSED_TWICE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ARGUMENT_TYPE_MISMATCH
@@ -110,11 +111,16 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.EXTENSION_PROPERT
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.EXTENSION_PROPERTY_WITH_BACKING_FIELD
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.FINAL_UPPER_BOUND
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.FORBIDDEN_VARARG_PARAMETER_TYPE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.FUNCTION_DECLARATION_WITH_NO_NAME
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.FUN_INTERFACE_CONSTRUCTOR_REFERENCE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.FUN_INTERFACE_ABSTRACT_METHOD_WITH_DEFAULT_VALUE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.FUN_INTERFACE_ABSTRACT_METHOD_WITH_TYPE_PARAMETERS
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.FUN_INTERFACE_CANNOT_HAVE_ABSTRACT_PROPERTIES
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.FUN_INTERFACE_WITH_SUSPEND_FUNCTION
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.FUN_INTERFACE_WRONG_COUNT_OF_ABSTRACT_MEMBERS
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.FUNCTION_DECLARATION_WITH_NO_NAME
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.GENERIC_THROWABLE_SUBCLASS
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.HAS_NEXT_FUNCTION_AMBIGUITY
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.HIDDEN
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ILLEGAL_CONST_EXPRESSION
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ILLEGAL_UNDERSCORE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INAPPLICABLE_CANDIDATE
@@ -138,6 +144,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INSTANCE_ACCESS_B
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INTERFACE_WITH_SUPERCLASS
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INVALID_IF_AS_EXPRESSION
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INVALID_TYPE_OF_ANNOTATION_MEMBER
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INVISIBLE_REFERENCE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ITERATOR_AMBIGUITY
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.KCLASS_WITH_NULLABLE_TYPE_PARAMETER_IN_SIGNATURE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.LEAKED_IN_PLACE_LAMBDA
@@ -261,6 +268,8 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.UNSUPPORTED_FEATU
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.UNUSED_VARIABLE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.UPPER_BOUND_IS_EXTENSION_FUNCTION_TYPE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.UPPER_BOUND_VIOLATED
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.USELESS_ELVIS
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.USELESS_ELVIS_RIGHT_IS_NULL
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.USELESS_VARARG_ON_PARAMETER
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.VALUE_CLASS_CANNOT_BE_CLONEABLE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.VALUE_PARAMETER_WITH_NO_TYPE_ANNOTATION
@@ -280,6 +289,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.WRONG_INVOCATION_
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.WRONG_MODIFIER_TARGET
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.WRONG_NUMBER_OF_TYPE_ARGUMENTS
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.WRONG_SETTER_PARAMETER_TYPE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.WRONG_SETTER_RETURN_TYPE
@Suppress("unused")
class FirDefaultErrorMessages : DefaultErrorMessages.Extension {
@@ -317,7 +327,7 @@ class FirDefaultErrorMessages : DefaultErrorMessages.Extension {
map.put(NESTED_CLASS_NOT_ALLOWED, "{0} is not allowed here", TO_STRING)
// Unresolved
map.put(HIDDEN, "Symbol {0} is invisible", SYMBOL)
map.put(INVISIBLE_REFERENCE, "Symbol {0} is invisible", SYMBOL)
map.put(UNRESOLVED_REFERENCE, "Unresolved reference: {0}", NULLABLE_STRING)
map.put(UNRESOLVED_LABEL, "Unresolved label")
map.put(DESERIALIZATION_ERROR, "Deserialization error")
@@ -374,6 +384,7 @@ class FirDefaultErrorMessages : DefaultErrorMessages.Extension {
map.put(DATA_CLASS_NOT_PROPERTY_PARAMETER, "Data class primary constructor must have only property (val / var) parameters")
// Annotations
map.put(ANNOTATION_USED_AS_ANNOTATION_ARGUMENT, "An annotation can't be used as the annotations argument")
map.put(ANNOTATION_CLASS_MEMBER, "Members are not allowed in annotation class")
map.put(ANNOTATION_ARGUMENT_MUST_BE_CONST, "An annotation argument must be a compile-time constant")
map.put(
@@ -692,6 +703,15 @@ class FirDefaultErrorMessages : DefaultErrorMessages.Extension {
"An anonymous function is not allowed to specify default values for its parameters"
)
map.put(USELESS_VARARG_ON_PARAMETER, "Vararg on this parameter is useless")
map.put(
FUN_INTERFACE_WRONG_COUNT_OF_ABSTRACT_MEMBERS,
"Fun interface must have exactly one abstract function"
)
map.put(FUN_INTERFACE_CANNOT_HAVE_ABSTRACT_PROPERTIES, "Fun interface can not have abstract properties")
map.put(FUN_INTERFACE_ABSTRACT_METHOD_WITH_TYPE_PARAMETERS, "Fun interface can not have abstract metod with type parameters")
map.put(FUN_INTERFACE_ABSTRACT_METHOD_WITH_DEFAULT_VALUE, "Fun interface abstract method can not have default value")
map.put(FUN_INTERFACE_WITH_SUSPEND_FUNCTION, "Fun interface abstract method can not be suspend")
map.put(MULTIPLE_VARARG_PARAMETERS, "Multiple vararg-parameters are prohibited")
map.put(FORBIDDEN_VARARG_PARAMETER_TYPE, "Forbidden vararg parameter type: {0}", RENDER_TYPE)
map.put(VALUE_PARAMETER_WITH_NO_TYPE_ANNOTATION, "A type annotation is required on a value parameter")
@@ -740,6 +760,8 @@ class FirDefaultErrorMessages : DefaultErrorMessages.Extension {
RENDER_TYPE
)
map.put(INITIALIZER_TYPE_MISMATCH, "Initializer type mismatch: expected {0}, actual {1}", RENDER_TYPE, RENDER_TYPE)
map.put(GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY, "Getter visibility must be the same as property visibility")
map.put(WRONG_SETTER_RETURN_TYPE, "Setter return type must be Unit")
map.put(CONST_VAL_NOT_TOP_LEVEL_OR_OBJECT, "Const 'val' are only allowed on top level or in objects")
map.put(CONST_VAL_WITH_GETTER, "Const 'val' should not have a getter")
@@ -830,6 +852,8 @@ class FirDefaultErrorMessages : DefaultErrorMessages.Extension {
map.put(NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE, "Non-null assertion (!!) is called on a callable reference expression")
map.put(UNNECESSARY_SAFE_CALL, "Unnecessary safe call on a non-null receiver of type {0}", RENDER_TYPE)
map.put(UNEXPECTED_SAFE_CALL, "Safe-call is not allowed here")
map.put(USELESS_ELVIS, "Elvis operator (?:) always returns the left operand of non-nullable type {0}", RENDER_TYPE)
map.put(USELESS_ELVIS_RIGHT_IS_NULL, "Right operand of elvis operator (?:) is useless if it is null")
// When expressions
map.put(NO_ELSE_IN_WHEN, "''when'' expression must be exhaustive, add necessary {0}", WHEN_MISSING_CASES)

View File

@@ -8,18 +8,18 @@ package org.jetbrains.kotlin.fir.analysis.diagnostics
import com.intellij.lang.LighterASTNode
import com.intellij.openapi.util.Ref
import com.intellij.openapi.util.TextRange
import com.intellij.psi.impl.source.tree.ElementType
import com.intellij.psi.tree.IElementType
import com.intellij.psi.tree.TokenSet
import com.intellij.util.diff.FlyweightCapableTreeStructure
import org.jetbrains.kotlin.KtNodeType
import org.jetbrains.kotlin.KtNodeTypes
import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.analysis.checkers.getChildren
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.lexer.KtTokens.MODALITY_MODIFIERS
import org.jetbrains.kotlin.lexer.KtTokens.VISIBILITY_MODIFIERS
import org.jetbrains.kotlin.psi.KtParameter.VAL_VAR_TOKEN_SET
import org.jetbrains.kotlin.psi.stubs.elements.KtConstantExpressionElementType
import org.jetbrains.kotlin.psi.stubs.elements.KtStringTemplateExpressionElementType
import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult
object LightTreePositioningStrategies {
@@ -31,6 +31,10 @@ object LightTreePositioningStrategies {
tree: FlyweightCapableTreeStructure<LighterASTNode>
): List<TextRange> {
when (node.tokenType) {
KtNodeTypes.OBJECT_LITERAL -> {
val objectKeyword = tree.findDescendantByType(node, KtTokens.OBJECT_KEYWORD)!!
return markElement(objectKeyword, startOffset, endOffset, tree, node)
}
KtNodeTypes.OBJECT_DECLARATION -> {
val objectKeyword = tree.objectKeyword(node)!!
return markRange(
@@ -125,7 +129,12 @@ object LightTreePositioningStrategies {
startOffset: Int,
endOffset: Int,
tree: FlyweightCapableTreeStructure<LighterASTNode>
): List<TextRange> {
): List<TextRange> = markElement(getElementToMark(node, tree), startOffset, endOffset, tree, node)
override fun isValid(node: LighterASTNode, tree: FlyweightCapableTreeStructure<LighterASTNode>): Boolean =
super.isValid(getElementToMark(node, tree), tree)
private fun getElementToMark(node: LighterASTNode, tree: FlyweightCapableTreeStructure<LighterASTNode>): LighterASTNode {
val (returnTypeRef, nameIdentifierOrPlaceHolder) = when {
node.tokenType == KtNodeTypes.PROPERTY_ACCESSOR ->
tree.typeReference(node) to tree.accessorNamePlaceholder(node)
@@ -134,13 +143,7 @@ object LightTreePositioningStrategies {
else ->
null to null
}
if (returnTypeRef != null) {
return markElement(returnTypeRef, startOffset, endOffset, tree, node)
}
if (nameIdentifierOrPlaceHolder != null) {
return markElement(nameIdentifierOrPlaceHolder, startOffset, endOffset, tree, node)
}
return DEFAULT.mark(node, startOffset, endOffset, tree)
return returnTypeRef ?: (nameIdentifierOrPlaceHolder ?: node)
}
}
@@ -168,6 +171,20 @@ object LightTreePositioningStrategies {
}
return DEFAULT.mark(node, startOffset, endOffset, tree)
}
override fun isValid(node: LighterASTNode, tree: FlyweightCapableTreeStructure<LighterASTNode>): Boolean {
//in FE 1.0 this is part of DeclarationHeader abstract strategy
if (node.tokenType != KtNodeTypes.OBJECT_DECLARATION
&& node.tokenType != KtNodeTypes.FUN
&& node.tokenType != KtNodeTypes.SECONDARY_CONSTRUCTOR
&& node.tokenType != KtNodeTypes.OBJECT_LITERAL
) {
if (tree.nameIdentifier(node) == null) {
return false
}
}
return super.isValid(node, tree)
}
}
val DECLARATION_SIGNATURE: LightTreePositioningStrategy = object : LightTreePositioningStrategy() {
@@ -250,7 +267,7 @@ object LightTreePositioningStrategies {
endOffset: Int,
tree: FlyweightCapableTreeStructure<LighterASTNode>
): List<TextRange> {
val value = tree.lastChild(node) ?: node
val value = node.nonFillerLastChildOrSelf(tree)
return markElement(value, startOffset, endOffset, tree, node)
}
}
@@ -323,6 +340,15 @@ object LightTreePositioningStrategies {
val CONST_MODIFIER: LightTreePositioningStrategy =
ModifierSetBasedLightTreePositioningStrategy(TokenSet.create(KtTokens.CONST_KEYWORD))
val FUN_MODIFIER: LightTreePositioningStrategy =
ModifierSetBasedLightTreePositioningStrategy(TokenSet.create(KtTokens.FUN_KEYWORD))
val SUSPEND_MODIFIER: LightTreePositioningStrategy =
ModifierSetBasedLightTreePositioningStrategy(TokenSet.create(KtTokens.SUSPEND_KEYWORD))
private val SUSPEND_OR_FUN_MODIFIER: LightTreePositioningStrategy =
ModifierSetBasedLightTreePositioningStrategy(TokenSet.create(KtTokens.SUSPEND_KEYWORD, KtTokens.FUN_KEYWORD))
val INLINE_OR_VALUE_MODIFIER: LightTreePositioningStrategy =
ModifierSetBasedLightTreePositioningStrategy(TokenSet.create(KtTokens.INLINE_KEYWORD, KtTokens.VALUE_KEYWORD))
@@ -384,6 +410,7 @@ object LightTreePositioningStrategies {
endOffset: Int,
tree: FlyweightCapableTreeStructure<LighterASTNode>
): List<TextRange> {
//PSI counterpart simply search for first RPAR descendant, but this one is more correct
return tree.findDescendantByType(node, KtNodeTypes.VALUE_ARGUMENT_LIST)?.let { valueArgumentList ->
tree.findLastChildByType(valueArgumentList, KtTokens.RPAR)?.let { rpar ->
markElement(rpar, startOffset, endOffset, tree, node)
@@ -425,6 +452,29 @@ object LightTreePositioningStrategies {
}
}
val FUN_INTERFACE: LightTreePositioningStrategy = object : LightTreePositioningStrategy() {
override fun mark(
node: LighterASTNode,
startOffset: Int,
endOffset: Int,
tree: FlyweightCapableTreeStructure<LighterASTNode>
): List<TextRange> {
return when (node.tokenType) {
KtNodeTypes.CLASS -> FUN_MODIFIER.mark(node, startOffset, endOffset, tree)
KtNodeTypes.PROPERTY -> VAL_OR_VAR_NODE.mark(node, startOffset, endOffset, tree)
KtNodeTypes.FUN -> {
if (tree.typeParametersList(node) != null) {
TYPE_PARAMETERS_LIST.mark(node, startOffset, endOffset, tree)
} else {
SUSPEND_OR_FUN_MODIFIER.mark(node, startOffset, endOffset, tree)
}
}
else -> DEFAULT.mark(node, startOffset, endOffset, tree)
}
}
}
val REFERENCE_BY_QUALIFIED: LightTreePositioningStrategy = FindReferencePositioningStrategy(false)
val REFERENCED_NAME_BY_QUALIFIED: LightTreePositioningStrategy = FindReferencePositioningStrategy(true)
@@ -441,6 +491,9 @@ object LightTreePositioningStrategies {
if (node.tokenType == KtNodeTypes.CALL_EXPRESSION || node.tokenType == KtNodeTypes.CONSTRUCTOR_DELEGATION_CALL) {
return markElement(tree.referenceExpression(node, locateReferencedName) ?: node, startOffset, endOffset, tree, node)
}
if (node.tokenType == KtNodeTypes.PROPERTY_DELEGATE) {
return markElement(tree.findReferenceExpressionDeep(node) ?: node, startOffset, endOffset, tree, node)
}
if (node.tokenType in nodeTypesWithOperation) {
return markElement(tree.operationReference(node) ?: node, startOffset, endOffset, tree, node)
}
@@ -455,7 +508,7 @@ object LightTreePositioningStrategies {
when (selector.tokenType) {
KtNodeTypes.REFERENCE_EXPRESSION ->
return markElement(selector, startOffset, endOffset, tree, node)
KtNodeTypes.CALL_EXPRESSION, KtNodeTypes.CONSTRUCTOR_DELEGATION_CALL,KtNodeTypes.SUPER_TYPE_CALL_ENTRY ->
KtNodeTypes.CALL_EXPRESSION, KtNodeTypes.CONSTRUCTOR_DELEGATION_CALL, KtNodeTypes.SUPER_TYPE_CALL_ENTRY ->
return markElement(
tree.referenceExpression(selector, locateReferencedName) ?: selector,
startOffset,
@@ -534,6 +587,17 @@ object LightTreePositioningStrategies {
}
}
val USELESS_ELVIS = object : LightTreePositioningStrategy() {
override fun mark(
node: LighterASTNode,
startOffset: Int,
endOffset: Int,
tree: FlyweightCapableTreeStructure<LighterASTNode>
): List<TextRange> {
return markRange(tree.operationReference(node) ?: node, tree.lastChild(node) ?: node, startOffset, endOffset, tree, node)
}
}
val RETURN_WITH_LABEL = object : LightTreePositioningStrategy() {
override fun mark(
node: LighterASTNode,
@@ -545,17 +609,39 @@ object LightTreePositioningStrategies {
if (labeledExpression != null) {
return markRange(node, labeledExpression, startOffset, endOffset, tree, node)
}
return markElement(tree.returnKeyword(node) ?: node, startOffset, endOffset, tree)
return markElement(tree.returnKeyword(node) ?: node, startOffset, endOffset, tree, node)
}
}
val WHOLE_ELEMENT = object : LightTreePositioningStrategy() { }
val WHOLE_ELEMENT = object : LightTreePositioningStrategy() {}
val LONG_LITERAL_SUFFIX = object : LightTreePositioningStrategy() {
override fun mark(
node: LighterASTNode,
startOffset: Int,
endOffset: Int,
tree: FlyweightCapableTreeStructure<LighterASTNode>
): List<TextRange> {
if (node.tokenType == KtNodeTypes.INTEGER_CONSTANT) {
return listOf(TextRange.create(endOffset - 1, endOffset))
}
return super.mark(node, startOffset, endOffset, tree)
}
}
val REIFIED_MODIFIER: LightTreePositioningStrategy =
ModifierSetBasedLightTreePositioningStrategy(TokenSet.create(KtTokens.REIFIED_KEYWORD))
val TYPE_PARAMETERS_LIST: LightTreePositioningStrategy = object : LightTreePositioningStrategy() {
override fun mark(
node: LighterASTNode,
startOffset: Int,
endOffset: Int,
tree: FlyweightCapableTreeStructure<LighterASTNode>
): List<TextRange> {
return markElement(tree.typeParametersList(node) ?: node, startOffset, endOffset, tree, node)
}
}
}
fun FirSourceElement.hasValOrVar(): Boolean =
@@ -600,6 +686,23 @@ internal fun FlyweightCapableTreeStructure<LighterASTNode>.nameIdentifier(node:
private fun FlyweightCapableTreeStructure<LighterASTNode>.operationReference(node: LighterASTNode): LighterASTNode? =
findChildByType(node, KtNodeTypes.OPERATION_REFERENCE)
private val EXPRESSIONS_SET = listOf(
KtNodeTypes.REFERENCE_EXPRESSION,
KtNodeTypes.DOT_QUALIFIED_EXPRESSION,
KtNodeTypes.LAMBDA_EXPRESSION,
KtNodeTypes.FUN
)
fun LighterASTNode.isExpression(): Boolean {
return when (this.tokenType) {
is KtNodeType,
is KtConstantExpressionElementType,
is KtStringTemplateExpressionElementType,
in EXPRESSIONS_SET -> true
else -> false
}
}
/**
* @param locateReferencedName whether to remove any nested parentheses while locating the reference element. This is useful for diagnostics
* on super and unresolved references. For example, with the following, only the part inside the parentheses should be highlighted.
@@ -620,8 +723,7 @@ private fun FlyweightCapableTreeStructure<LighterASTNode>.referenceExpression(
val childrenRef = Ref<Array<LighterASTNode?>>()
getChildren(node, childrenRef)
var result = childrenRef.get()?.firstOrNull {
it?.tokenType == KtNodeTypes.REFERENCE_EXPRESSION || it?.tokenType == KtNodeTypes.CONSTRUCTOR_DELEGATION_REFERENCE ||
it?.tokenType == KtNodeTypes.SUPER_EXPRESSION || it?.tokenType == KtNodeTypes.PARENTHESIZED
it?.isExpression() == true || it?.tokenType == KtNodeTypes.PARENTHESIZED
}
while (locateReferencedName && result != null && result.tokenType == KtNodeTypes.PARENTHESIZED) {
result = referenceExpression(result, locateReferencedName = true)
@@ -629,6 +731,9 @@ private fun FlyweightCapableTreeStructure<LighterASTNode>.referenceExpression(
return result
}
private fun FlyweightCapableTreeStructure<LighterASTNode>.findReferenceExpressionDeep(node: LighterASTNode): LighterASTNode? =
findFirstDescendant(node) { it.isExpression() }
private fun FlyweightCapableTreeStructure<LighterASTNode>.rightParenthesis(node: LighterASTNode): LighterASTNode? =
findChildByType(node, KtTokens.RPAR)
@@ -733,6 +838,23 @@ fun FlyweightCapableTreeStructure<LighterASTNode>.findDescendantByType(node: Lig
?.firstNotNullResult { child -> child?.let { findDescendantByType(it, type) } }
}
fun FlyweightCapableTreeStructure<LighterASTNode>.findDescendantByTypes(node: LighterASTNode, types: Set<IElementType>): LighterASTNode? {
val childrenRef = Ref<Array<LighterASTNode?>>()
getChildren(node, childrenRef)
return childrenRef.get()?.firstOrNull { types.contains(it?.tokenType) } ?: childrenRef.get()
?.firstNotNullResult { child -> child?.let { findDescendantByTypes(it, types) } }
}
fun FlyweightCapableTreeStructure<LighterASTNode>.findFirstDescendant(
node: LighterASTNode,
predicate: (LighterASTNode) -> Boolean
): LighterASTNode? {
val childrenRef = Ref<Array<LighterASTNode?>>()
getChildren(node, childrenRef)
return childrenRef.get()?.firstOrNull { it != null && predicate(it) }
?: childrenRef.get()?.firstNotNullResult { child -> child?.let { findFirstDescendant(it, predicate) } }
}
private fun FlyweightCapableTreeStructure<LighterASTNode>.findChildByType(node: LighterASTNode, type: TokenSet): LighterASTNode? {
val childrenRef = Ref<Array<LighterASTNode?>>()
getChildren(node, childrenRef)
@@ -763,7 +885,7 @@ private fun FlyweightCapableTreeStructure<LighterASTNode>.firstChild(node: Light
}
private fun FlyweightCapableTreeStructure<LighterASTNode>.lastChild(node: LighterASTNode): LighterASTNode? {
val childrenRef = Ref<Array<LighterASTNode>>()
val childrenRef = Ref<Array<LighterASTNode?>>()
getChildren(node, childrenRef)
return childrenRef.get().lastOrNull()
return childrenRef.get().lastOrNull { it != null }
}

View File

@@ -10,6 +10,7 @@ import com.intellij.openapi.util.Ref
import com.intellij.openapi.util.TextRange
import com.intellij.psi.TokenType
import com.intellij.util.diff.FlyweightCapableTreeStructure
import org.jetbrains.kotlin.fir.analysis.checkers.getChildren
import org.jetbrains.kotlin.lexer.KtSingleValueToken
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.lexer.KtTokens.WHITE_SPACE
@@ -35,12 +36,7 @@ fun markElement(
endOffset: Int,
tree: FlyweightCapableTreeStructure<LighterASTNode>,
originalNode: LighterASTNode = node,
): List<TextRange> {
if (node === originalNode) return listOf(TextRange(startOffset, endOffset))
val startDelta = tree.getStartOffset(node) - tree.getStartOffset(originalNode)
val endDelta = tree.getEndOffset(node) - tree.getEndOffset(originalNode)
return listOf(TextRange(startDelta + startOffset, endDelta + endOffset))
}
): List<TextRange> = markRange(node, node, startOffset, endOffset, tree, originalNode)
fun markRange(
from: LighterASTNode,
@@ -50,8 +46,10 @@ fun markRange(
tree: FlyweightCapableTreeStructure<LighterASTNode>,
originalNode: LighterASTNode
): List<TextRange> {
val startDelta = tree.getStartOffset(from) - tree.getStartOffset(originalNode)
val endDelta = tree.getEndOffset(to) - tree.getEndOffset(originalNode)
val betterFrom = from.nonFillerFirstChildOrSelf(tree)
val betterTo = to.nonFillerLastChildOrSelf(tree)
val startDelta = tree.getStartOffset(betterFrom) - tree.getStartOffset(originalNode)
val endDelta = tree.getEndOffset(betterTo) - tree.getEndOffset(originalNode)
return listOf(TextRange(startDelta + startOffset, endDelta + endOffset))
}
@@ -60,6 +58,21 @@ private val DOC_AND_COMMENT_TOKENS = setOf(
KtTokens.EOL_COMMENT, KtTokens.BLOCK_COMMENT, KtTokens.SHEBANG_COMMENT, KtTokens.DOC_COMMENT
)
private val FILLER_TOKENS = setOf(
KtTokens.WHITE_SPACE,
KtTokens.EOL_COMMENT,
KtTokens.BLOCK_COMMENT,
KtTokens.SHEBANG_COMMENT,
KtTokens.DOC_COMMENT,
)
private fun LighterASTNode.nonFillerFirstChildOrSelf(tree: FlyweightCapableTreeStructure<LighterASTNode>): LighterASTNode =
getChildren(tree).firstOrNull { it != null && it.tokenType !in FILLER_TOKENS } ?: this
internal fun LighterASTNode.nonFillerLastChildOrSelf(tree: FlyweightCapableTreeStructure<LighterASTNode>): LighterASTNode =
getChildren(tree).lastOrNull { it != null && it.tokenType !in FILLER_TOKENS } ?: this
private fun hasSyntaxErrors(node: LighterASTNode, tree: FlyweightCapableTreeStructure<LighterASTNode>): Boolean {
if (node.tokenType == TokenType.ERROR_ELEMENT) return true

View File

@@ -18,6 +18,11 @@ object SourceElementPositioningStrategies {
PositioningStrategies.VAL_OR_VAR_NODE
)
val FUN_INTERFACE = SourceElementPositioningStrategy(
LightTreePositioningStrategies.FUN_INTERFACE,
PositioningStrategies.FUN_INTERFACE
)
val COMPANION_OBJECT = SourceElementPositioningStrategy(
LightTreePositioningStrategies.COMPANION_OBJECT,
PositioningStrategies.COMPANION_OBJECT
@@ -103,6 +108,17 @@ object SourceElementPositioningStrategies {
PositioningStrategies.INNER_MODIFIER
)
val FUN_MODIFIER = SourceElementPositioningStrategy(
LightTreePositioningStrategies.FUN_MODIFIER,
PositioningStrategies.FUN_MODIFIER
)
val SUSPEND_MODIFIER = SourceElementPositioningStrategy(
LightTreePositioningStrategies.SUSPEND_MODIFIER,
PositioningStrategies.SUSPEND_MODIFIER
)
val OPERATOR = SourceElementPositioningStrategy(
LightTreePositioningStrategies.OPERATOR,
PositioningStrategies.OPERATOR
@@ -178,6 +194,11 @@ object SourceElementPositioningStrategies {
PositioningStrategies.SAFE_ACCESS
)
val USELESS_ELVIS = SourceElementPositioningStrategy(
LightTreePositioningStrategies.USELESS_ELVIS,
PositioningStrategies.USELESS_ELVIS
)
val RETURN_WITH_LABEL = SourceElementPositioningStrategy(
LightTreePositioningStrategies.RETURN_WITH_LABEL,
PositioningStrategies.RETURN_WITH_LABEL
@@ -202,4 +223,9 @@ object SourceElementPositioningStrategies {
LightTreePositioningStrategies.REIFIED_MODIFIER,
PositioningStrategies.REIFIED_MODIFIER
)
val TYPE_PARAMETERS_LIST = SourceElementPositioningStrategy(
LightTreePositioningStrategies.TYPE_PARAMETERS_LIST,
PositioningStrategies.TYPE_PARAMETERS_LIST
)
}

View File

@@ -30,7 +30,7 @@ private fun ConeDiagnostic.toFirDiagnostic(
is ConeUnresolvedSymbolError -> FirErrors.UNRESOLVED_REFERENCE.on(source, this.classId.asString())
is ConeUnresolvedNameError -> FirErrors.UNRESOLVED_REFERENCE.on(source, this.name.asString())
is ConeUnresolvedQualifierError -> FirErrors.UNRESOLVED_REFERENCE.on(source, this.qualifier)
is ConeHiddenCandidateError -> FirErrors.HIDDEN.on(source, this.candidateSymbol)
is ConeHiddenCandidateError -> FirErrors.INVISIBLE_REFERENCE.on(source, this.candidateSymbol)
is ConeAmbiguityError -> if (this.applicability.isSuccess) {
FirErrors.OVERLOAD_RESOLUTION_AMBIGUITY.on(source, this.candidates.map { it.symbol })
} else if (this.applicability == CandidateApplicability.UNSAFE_CALL) {
@@ -63,6 +63,7 @@ private fun ConeDiagnostic.toFirDiagnostic(
is ConeContractDescriptionError -> FirErrors.ERROR_IN_CONTRACT_DESCRIPTION.on(source, this.reason)
is ConeTypeParameterSupertype -> FirErrors.SUPERTYPE_NOT_A_CLASS_OR_INTERFACE.on(source, this.reason)
is ConeTypeParameterInQualifiedAccess -> null // reported in various checkers instead
is ConeNotAnnotationContainer -> null
else -> throw IllegalArgumentException("Unsupported diagnostic type: ${this.javaClass}")
}

View File

@@ -317,7 +317,7 @@ class MultiModuleHtmlFirDump(private val outputRoot: File) {
require(inModule)
val dumpOutput = index.files[file] ?: error("No location for ${file.name}")
val dumper = HtmlFirDump(LinkResolver(dumpOutput), file.session)
val dumper = HtmlFirDump(LinkResolver(dumpOutput), file.declarationSiteSession)
val builder = StringBuilder()
dumper.generate(file, builder)

View File

@@ -45,7 +45,7 @@ object CommonDeclarationCheckers : DeclarationCheckers() {
override val propertyCheckers: Set<FirPropertyChecker>
get() = setOf(
FirInapplicableLateinitChecker(),
FirInapplicableLateinitChecker,
FirDestructuringDeclarationChecker,
FirConstPropertyChecker,
FirPropertyAccessorChecker,
@@ -74,15 +74,16 @@ object CommonDeclarationCheckers : DeclarationCheckers() {
FirInterfaceWithSuperclassChecker,
FirLocalEntityNotAllowedChecker,
FirManyCompanionObjectsChecker,
FirMethodOfAnyImplementedInInterfaceChecker(),
FirMethodOfAnyImplementedInInterfaceChecker,
FirDataClassPrimaryConstructorChecker,
FirPrimaryConstructorSuperTypeChecker,
FirTypeParametersInObjectChecker,
FirMemberFunctionsChecker,
FirMemberPropertiesChecker,
FirNestedClassChecker,
FirInlineClassDeclarationChecker(),
)
FirFunInterfaceDeclarationChecker,
FirMemberFunctionsChecker,
FirMemberPropertiesChecker,
FirNestedClassChecker,
FirInlineClassDeclarationChecker,
)
override val constructorCheckers: Set<FirConstructorChecker>
get() = setOf(

View File

@@ -8,12 +8,13 @@ package org.jetbrains.kotlin.fir.checkers
import org.jetbrains.kotlin.fir.analysis.checkers.expression.*
object CommonExpressionCheckers : ExpressionCheckers() {
override val annotationCallCheckers: Set<FirAnnotationCallChecker>
get() = setOf(
FirAnnotationUsedAsAnnotationArgumentChecker,
)
override val basicExpressionCheckers: Set<FirBasicExpressionChecker>
get() = setOf(
FirAnonymousFunctionChecker,
FirCheckNotNullCallChecker,
FirGetClassCallChecker,
FirSafeCallExpressionChecker,
)
override val qualifiedAccessCheckers: Set<FirQualifiedAccessChecker>
@@ -31,7 +32,7 @@ object CommonExpressionCheckers : ExpressionCheckers() {
FirSealedClassConstructorCallChecker,
FirUninitializedEnumChecker,
FirFunInterfaceConstructorReferenceChecker,
)
)
override val functionCallCheckers: Set<FirFunctionCallChecker>
get() = setOf(
@@ -65,4 +66,29 @@ object CommonExpressionCheckers : ExpressionCheckers() {
get() = setOf(
FirForLoopChecker
)
override val checkNotNullCallCheckers: Set<FirCheckNotNullCallChecker>
get() = setOf(
FirNotNullAssertionChecker,
)
override val elvisExpressionCheckers: Set<FirElvisExpressionChecker>
get() = setOf(
FirUselessElvisChecker,
)
override val getClassCallCheckers: Set<FirGetClassCallChecker>
get() = setOf(
FirClassLiteralChecker,
)
override val safeCallExpressionCheckers: Set<FirSafeCallExpressionChecker>
get() = setOf(
FirUnnecessarySafeCallChecker,
)
override val anonymousFunctionAsExpressionCheckers: Set<FirAnonymousFunctionAsExpressionChecker>
get() = setOf(
FirAnonymousFunctionChecker,
)
}

View File

@@ -7,10 +7,7 @@ package org.jetbrains.kotlin.fir.checkers
import org.jetbrains.kotlin.fir.analysis.cfa.AbstractFirPropertyInitializationChecker
import org.jetbrains.kotlin.fir.analysis.checkers.cfa.FirControlFlowChecker
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.DeclarationCheckers
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirBasicDeclarationChecker
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirDeclarationChecker
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirMemberDeclarationChecker
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.*
import org.jetbrains.kotlin.fir.analysis.checkers.extended.*
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
@@ -18,7 +15,6 @@ object ExtendedDeclarationCheckers : DeclarationCheckers() {
override val basicDeclarationCheckers: Set<FirBasicDeclarationChecker>
get() = setOf(
RedundantVisibilityModifierChecker,
RedundantReturnUnitType,
)
override val memberDeclarationCheckers: Set<FirMemberDeclarationChecker>
@@ -37,4 +33,9 @@ object ExtendedDeclarationCheckers : DeclarationCheckers() {
get() = setOf(
UnusedChecker,
)
override val simpleFunctionCheckers: Set<FirSimpleFunctionChecker>
get() = setOf(
RedundantReturnUnitType,
)
}

View File

@@ -5,18 +5,13 @@
package org.jetbrains.kotlin.fir.checkers
import org.jetbrains.kotlin.fir.analysis.checkers.expression.ExpressionCheckers
import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirBasicExpressionChecker
import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirQualifiedAccessChecker
import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirVariableAssignmentChecker
import org.jetbrains.kotlin.fir.analysis.checkers.expression.*
import org.jetbrains.kotlin.fir.analysis.checkers.extended.*
object ExtendedExpressionCheckers : ExpressionCheckers() {
override val basicExpressionCheckers: Set<FirBasicExpressionChecker>
get() = setOf(
ArrayEqualityCanBeReplacedWithEquals,
RedundantSingleExpressionStringTemplateChecker,
EmptyRangeChecker,
)
override val variableAssignmentCheckers: Set<FirVariableAssignmentChecker>
@@ -29,4 +24,14 @@ object ExtendedExpressionCheckers : ExpressionCheckers() {
RedundantCallOfConversionMethod,
UselessCallOnNotNullChecker,
)
override val functionCallCheckers: Set<FirFunctionCallChecker>
get() = setOf(
EmptyRangeChecker,
)
override val stringConcatenationCallCheckers: Set<FirStringConcatenationCallChecker>
get() = setOf(
RedundantSingleExpressionStringTemplateChecker,
)
}

View File

@@ -40,7 +40,7 @@ fun FirSession.registerCommonComponents(languageVersionSettings: LanguageVersion
register(FirLanguageSettingsComponent::class, FirLanguageSettingsComponent(languageVersionSettings))
register(InferenceComponents::class, InferenceComponents(this))
register(FirDeclaredMemberScopeProvider::class, FirDeclaredMemberScopeProvider())
register(FirDeclaredMemberScopeProvider::class, FirDeclaredMemberScopeProvider(this))
register(FirCorrespondingSupertypesCache::class, FirCorrespondingSupertypesCache(this))
register(FirDefaultParametersResolver::class, FirDefaultParametersResolver())

View File

@@ -102,7 +102,7 @@ fun deserializeClassToSymbol(
}
}
buildRegularClass {
this.session = session
declarationSiteSession = session
this.origin = origin
name = classId.shortClassName
this.status = status
@@ -159,7 +159,7 @@ fun deserializeClassToSymbol(
val enumType = ConeClassLikeTypeImpl(symbol.toLookupTag(), emptyArray(), false)
val property = buildEnumEntry {
this.session = session
declarationSiteSession = session
this.origin = FirDeclarationOrigin.Library
returnTypeRef = buildResolvedTypeRef { type = enumType }
name = enumEntryName
@@ -255,7 +255,7 @@ private fun FirRegularClassBuilder.addCloneForArrayIfNeeded(classId: ClassId, di
)
}
declarations += buildSimpleFunction {
session = this@addCloneForArrayIfNeeded.session
declarationSiteSession = this@addCloneForArrayIfNeeded.declarationSiteSession
origin = FirDeclarationOrigin.Library
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
returnTypeRef = buildResolvedTypeRef {

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