@@ -25,7 +25,6 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.VAR_IMPLEMENTED_B
25
25
import org.jetbrains.kotlin.fir.containingClassLookupTag
26
26
import org.jetbrains.kotlin.fir.declarations.FirClass
27
27
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
28
- import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
29
28
import org.jetbrains.kotlin.fir.declarations.FirEnumEntry
30
29
import org.jetbrains.kotlin.fir.declarations.utils.*
31
30
import org.jetbrains.kotlin.fir.delegatedWrapperData
@@ -116,7 +115,7 @@ object FirNotImplementedOverrideChecker : FirClassChecker(MppCheckerKind.Platfor
116
115
classScope.processPropertiesByName(name, ::collectSymbol)
117
116
}
118
117
119
- varsImplementedByInheritedVal.firstOrNull()?. let { symbol ->
118
+ varsImplementedByInheritedVal.forEach { symbol ->
120
119
val implementationVal = symbol.intersections.first { it is FirPropertySymbol && it.isVal && ! it.isAbstract }
121
120
val abstractVar = symbol.intersections.first { it is FirPropertySymbol && it.isVar && it.isAbstract }
122
121
reporter.reportOn(
@@ -128,36 +127,54 @@ object FirNotImplementedOverrideChecker : FirClassChecker(MppCheckerKind.Platfor
128
127
context,
129
128
)
130
129
}
131
- if (! canHaveAbstractDeclarations && notImplementedSymbols.isNotEmpty()) {
132
- val notImplemented = (notImplementedSymbols.firstOrNull { ! it.isFromInterfaceOrEnum(context) } ? : notImplementedSymbols.first())
133
- .unwrapFakeOverrides()
134
- if (notImplemented.isFromInterfaceOrEnum(context)) {
135
- val containingDeclaration = context.containingDeclarations.lastOrNull()
136
- if (declaration.isInitializerOfEnumEntry(containingDeclaration)) {
137
- reporter.reportOn(
138
- source,
139
- ABSTRACT_MEMBER_NOT_IMPLEMENTED_BY_ENUM_ENTRY ,
140
- containingDeclaration.symbol,
141
- notImplementedSymbols,
142
- context
143
- )
144
- } else {
145
- reporter.reportOn(source, ABSTRACT_MEMBER_NOT_IMPLEMENTED , classSymbol, notImplemented, context)
146
- }
147
- } else {
148
- reporter.reportOn(source, ABSTRACT_CLASS_MEMBER_NOT_IMPLEMENTED , classSymbol, notImplemented, context)
130
+ if (! canHaveAbstractDeclarations) {
131
+ val (fromInterfaceOrEnum, notFromInterfaceOrEnum) = notImplementedSymbols.partition {
132
+ it.unwrapFakeOverrides().isFromInterfaceOrEnum(context)
133
+ }
134
+ val containingDeclaration = context.containingDeclarations.lastOrNull()
135
+ val (fromInitializerOfEnumEntry, notFromInitializerOfEnumEntry) = fromInterfaceOrEnum.partition {
136
+ declaration.isInitializerOfEnumEntry(containingDeclaration)
137
+ }
138
+
139
+ if (containingDeclaration is FirEnumEntry && fromInitializerOfEnumEntry.isNotEmpty()) {
140
+ reporter.reportOn(
141
+ source,
142
+ ABSTRACT_MEMBER_NOT_IMPLEMENTED_BY_ENUM_ENTRY ,
143
+ containingDeclaration.symbol,
144
+ fromInitializerOfEnumEntry,
145
+ context,
146
+ )
147
+ }
148
+
149
+ if (notFromInitializerOfEnumEntry.isNotEmpty()) {
150
+ reporter.reportOn(
151
+ source,
152
+ ABSTRACT_MEMBER_NOT_IMPLEMENTED ,
153
+ classSymbol,
154
+ notFromInitializerOfEnumEntry.map { it.unwrapFakeOverrides() },
155
+ context,
156
+ )
157
+ }
158
+
159
+ if (notFromInterfaceOrEnum.isNotEmpty()) {
160
+ reporter.reportOn(
161
+ source,
162
+ ABSTRACT_CLASS_MEMBER_NOT_IMPLEMENTED ,
163
+ classSymbol,
164
+ notFromInterfaceOrEnum.map { it.unwrapFakeOverrides() },
165
+ context,
166
+ )
149
167
}
150
168
}
151
169
if (! canHaveAbstractDeclarations && invisibleSymbols.isNotEmpty()) {
152
- val invisible = invisibleSymbols.first()
153
- reporter.reportOn(source, INVISIBLE_ABSTRACT_MEMBER_FROM_SUPER , classSymbol, invisible, context)
170
+ reporter.reportOn(source, INVISIBLE_ABSTRACT_MEMBER_FROM_SUPER , classSymbol, invisibleSymbols, context)
154
171
}
155
172
156
- manyImplementationsDelegationSymbols.firstOrNull()?. let {
173
+ manyImplementationsDelegationSymbols.forEach {
157
174
reporter.reportOn(source, MANY_IMPL_MEMBER_NOT_IMPLEMENTED , classSymbol, it, context)
158
175
}
159
176
160
- delegationOverrideOfFinal.firstOrNull()?. let { (delegated, final) ->
177
+ delegationOverrideOfFinal.forEach { (delegated, final) ->
161
178
reporter.reportOn(
162
179
source,
163
180
OVERRIDING_FINAL_MEMBER_BY_DELEGATION ,
@@ -167,7 +184,7 @@ object FirNotImplementedOverrideChecker : FirClassChecker(MppCheckerKind.Platfor
167
184
)
168
185
}
169
186
170
- delegationOverrideOfOpen.firstOrNull()?. let { (delegated, open) ->
187
+ delegationOverrideOfOpen.forEach { (delegated, open) ->
171
188
reporter.reportOn(
172
189
source,
173
190
DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE ,
@@ -177,25 +194,26 @@ object FirNotImplementedOverrideChecker : FirClassChecker(MppCheckerKind.Platfor
177
194
)
178
195
}
179
196
180
- if (manyImplementationsDelegationSymbols.isEmpty() && notImplementedIntersectionSymbols.isNotEmpty()) {
181
- val notImplementedIntersectionSymbol = notImplementedIntersectionSymbols.first()
182
- val (abstractIntersections, implIntersections) =
183
- (notImplementedIntersectionSymbol as FirIntersectionCallableSymbol ).intersections.partition {
184
- it.modality == Modality .ABSTRACT
185
- }
186
- if (implIntersections.any {
187
- it.containingClassLookupTag()?.toRegularClassSymbol(context.session)?.classKind == ClassKind .CLASS
188
- }
189
- ) {
190
- reporter.reportOn(source, MANY_IMPL_MEMBER_NOT_IMPLEMENTED , classSymbol, notImplementedIntersectionSymbol, context)
191
- } else {
192
- if (canHaveAbstractDeclarations && abstractIntersections.any {
197
+ if (manyImplementationsDelegationSymbols.isEmpty()) {
198
+ notImplementedIntersectionSymbols.forEach { notImplementedIntersectionSymbol ->
199
+ val (abstractIntersections, implIntersections) =
200
+ (notImplementedIntersectionSymbol as FirIntersectionCallableSymbol ).intersections.partition {
201
+ it.modality == Modality .ABSTRACT
202
+ }
203
+ if (implIntersections.any {
193
204
it.containingClassLookupTag()?.toRegularClassSymbol(context.session)?.classKind == ClassKind .CLASS
194
205
}
195
206
) {
196
- return
207
+ reporter.reportOn(source, MANY_IMPL_MEMBER_NOT_IMPLEMENTED , classSymbol, notImplementedIntersectionSymbol, context)
208
+ } else {
209
+ if (canHaveAbstractDeclarations && abstractIntersections.any {
210
+ it.containingClassLookupTag()?.toRegularClassSymbol(context.session)?.classKind == ClassKind .CLASS
211
+ }
212
+ ) {
213
+ return
214
+ }
215
+ reporter.reportOn(source, MANY_INTERFACES_MEMBER_NOT_IMPLEMENTED , classSymbol, notImplementedIntersectionSymbol, context)
197
216
}
198
- reporter.reportOn(source, MANY_INTERFACES_MEMBER_NOT_IMPLEMENTED , classSymbol, notImplementedIntersectionSymbol, context)
199
217
}
200
218
}
201
219
}
0 commit comments