[FIR] Report EXPECTED_CLASS_CONSTRUCTOR_DELEGATION_CALL
^KT-59069 Fixed
This commit is contained in:
committed by
Space Team
parent
f7269eb384
commit
8f4a580c17
+11
-2
@@ -25,8 +25,7 @@ object FirExpectConsistencyChecker : FirBasicDeclarationChecker() {
|
||||
if (
|
||||
declaration !is FirMemberDeclaration ||
|
||||
!isTopLevel && !isInsideClass ||
|
||||
!declaration.isExpect ||
|
||||
declaration is FirConstructor
|
||||
!declaration.isExpect
|
||||
) {
|
||||
return
|
||||
}
|
||||
@@ -34,6 +33,16 @@ object FirExpectConsistencyChecker : FirBasicDeclarationChecker() {
|
||||
val source = declaration.source ?: return
|
||||
if (source.kind is KtFakeSourceElementKind) return
|
||||
|
||||
if (declaration is FirConstructor) {
|
||||
if (!declaration.isPrimary) {
|
||||
val delegatedConstructorSource = declaration.delegatedConstructor?.source
|
||||
if (delegatedConstructorSource?.kind !is KtFakeSourceElementKind) {
|
||||
reporter.reportOn(delegatedConstructorSource, FirErrors.EXPECTED_CLASS_CONSTRUCTOR_DELEGATION_CALL, context)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (Visibilities.isPrivate(declaration.visibility)) {
|
||||
reporter.reportOn(source, FirErrors.EXPECTED_PRIVATE_DECLARATION, context)
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -3,11 +3,11 @@
|
||||
<!NO_ACTUAL_FOR_EXPECT!>expect open class A {
|
||||
constructor(s: String)
|
||||
|
||||
constructor(n: Number) : this("A")
|
||||
constructor(n: Number) : <!EXPECTED_CLASS_CONSTRUCTOR_DELEGATION_CALL!>this<!>("A")
|
||||
}<!>
|
||||
|
||||
<!NO_ACTUAL_FOR_EXPECT!>expect class B : A {
|
||||
constructor(i: Int)
|
||||
|
||||
constructor() : super("B")
|
||||
constructor() : <!EXPECTED_CLASS_CONSTRUCTOR_DELEGATION_CALL!>super<!>("B")
|
||||
}<!>
|
||||
|
||||
Vendored
+1
-1
@@ -13,7 +13,7 @@
|
||||
"no"
|
||||
}
|
||||
|
||||
constructor() : this("no")
|
||||
constructor() : <!EXPECTED_CLASS_CONSTRUCTOR_DELEGATION_CALL!>this<!>("no")
|
||||
|
||||
val prop: String = <!EXPECTED_PROPERTY_INITIALIZER!>"no"<!>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user