Skip to content

Commit 7aafc5f

Browse files
committed
Kotlin: Adjust diagnostic message severity
Make extraction messages `warning` if code is still extracted regardless of the reported issue. Make extraction messages `error` if some code is not extracted.
1 parent 7375970 commit 7aafc5f

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

java/kotlin-extractor/src/main/kotlin/ExternalDeclExtractor.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ExternalDeclExtractor(val logger: FileLogger, val invocationTrapFile: Stri
2121

2222
fun extractLater(d: IrDeclaration, signature: String): Boolean {
2323
if (d !is IrClass && !isExternalFileClassMember(d)) {
24-
logger.warnElement("External declaration is neither a class, nor a top-level declaration", d)
24+
logger.errorElement("External declaration is neither a class, nor a top-level declaration", d)
2525
return false
2626
}
2727
val ret = externalDeclsDone.add(d)
@@ -64,7 +64,7 @@ class ExternalDeclExtractor(val logger: FileLogger, val invocationTrapFile: Stri
6464

6565
val containingClass = getContainingClassOrSelf(irDecl)
6666
if (containingClass == null) {
67-
logger.warnElement("Unable to get containing class", irDecl)
67+
logger.errorElement("Unable to get containing class", irDecl)
6868
return
6969
}
7070
val binaryPath = getIrClassBinaryPath(containingClass)

java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ open class KotlinFileExtractor(
270270
if (kind == ClassKind.ENUM_CLASS) {
271271
tw.writeIsEnumType(classId)
272272
} else if (kind != ClassKind.CLASS && kind != ClassKind.OBJECT) {
273-
logger.warnElement("Unrecognised class kind $kind", c)
273+
logger.errorElement("Unrecognised class kind $kind", c)
274274
}
275275
}
276276

@@ -549,7 +549,7 @@ open class KotlinFileExtractor(
549549
val constructorId = useFunction<DbConstructor>(enclosingConstructor)
550550
val enclosingClass = enclosingConstructor.parentClassOrNull
551551
if (enclosingClass == null) {
552-
logger.warnElement("Constructor's parent is not a class", enclosingConstructor)
552+
logger.errorElement("Constructor's parent is not a class", enclosingConstructor)
553553
return
554554
}
555555

@@ -807,21 +807,21 @@ open class KotlinFileExtractor(
807807
}
808808
} else {
809809
if (p.modality != Modality.FINAL || !isExternalDeclaration(p)) {
810-
logger.errorElement("IrProperty without a getter", p)
810+
logger.warnElement("IrProperty without a getter", p)
811811
}
812812
}
813813

814814
if (setter != null) {
815815
if (!p.isVar) {
816-
logger.errorElement("!isVar property with a setter", p)
816+
logger.warnElement("!isVar property with a setter", p)
817817
}
818818
val setterId = extractFunction(setter, parentId, extractBody = extractFunctionBodies, extractMethodAndParameterTypeAccesses = extractFunctionBodies, typeSubstitution, classTypeArgsIncludingOuterClasses)?.cast<DbMethod>()
819819
if (setterId != null) {
820820
tw.writeKtPropertySetters(id, setterId)
821821
}
822822
} else {
823823
if (p.isVar && !isExternalDeclaration(p)) {
824-
logger.errorElement("isVar property without a setter", p)
824+
logger.warnElement("isVar property without a setter", p)
825825
}
826826
}
827827

@@ -1657,7 +1657,7 @@ open class KotlinFileExtractor(
16571657
// as they can't be extracted as external dependencies.
16581658
isBuiltinCallInternal(c, "less") -> {
16591659
if(c.origin != IrStatementOrigin.LT) {
1660-
logger.errorElement("Unexpected origin for LT: ${c.origin}", c)
1660+
logger.warnElement("Unexpected origin for LT: ${c.origin}", c)
16611661
}
16621662
val id = tw.getFreshIdLabel<DbLtexpr>()
16631663
val type = useType(c.type)
@@ -1667,7 +1667,7 @@ open class KotlinFileExtractor(
16671667
}
16681668
isBuiltinCallInternal(c, "lessOrEqual") -> {
16691669
if(c.origin != IrStatementOrigin.LTEQ) {
1670-
logger.errorElement("Unexpected origin for LTEQ: ${c.origin}", c)
1670+
logger.warnElement("Unexpected origin for LTEQ: ${c.origin}", c)
16711671
}
16721672
val id = tw.getFreshIdLabel<DbLeexpr>()
16731673
val type = useType(c.type)
@@ -1677,7 +1677,7 @@ open class KotlinFileExtractor(
16771677
}
16781678
isBuiltinCallInternal(c, "greater") -> {
16791679
if(c.origin != IrStatementOrigin.GT) {
1680-
logger.errorElement("Unexpected origin for GT: ${c.origin}", c)
1680+
logger.warnElement("Unexpected origin for GT: ${c.origin}", c)
16811681
}
16821682
val id = tw.getFreshIdLabel<DbGtexpr>()
16831683
val type = useType(c.type)
@@ -1687,7 +1687,7 @@ open class KotlinFileExtractor(
16871687
}
16881688
isBuiltinCallInternal(c, "greaterOrEqual") -> {
16891689
if(c.origin != IrStatementOrigin.GTEQ) {
1690-
logger.errorElement("Unexpected origin for GTEQ: ${c.origin}", c)
1690+
logger.warnElement("Unexpected origin for GTEQ: ${c.origin}", c)
16911691
}
16921692
val id = tw.getFreshIdLabel<DbGeexpr>()
16931693
val type = useType(c.type)
@@ -1697,7 +1697,7 @@ open class KotlinFileExtractor(
16971697
}
16981698
isBuiltinCallInternal(c, "EQEQ") -> {
16991699
if(c.origin != IrStatementOrigin.EQEQ) {
1700-
logger.errorElement("Unexpected origin for EQEQ: ${c.origin}", c)
1700+
logger.warnElement("Unexpected origin for EQEQ: ${c.origin}", c)
17011701
}
17021702
val id = tw.getFreshIdLabel<DbValueeqexpr>()
17031703
val type = useType(c.type)
@@ -1707,7 +1707,7 @@ open class KotlinFileExtractor(
17071707
}
17081708
isBuiltinCallInternal(c, "EQEQEQ") -> {
17091709
if(c.origin != IrStatementOrigin.EQEQEQ) {
1710-
logger.errorElement("Unexpected origin for EQEQEQ: ${c.origin}", c)
1710+
logger.warnElement("Unexpected origin for EQEQEQ: ${c.origin}", c)
17111711
}
17121712
val id = tw.getFreshIdLabel<DbEqexpr>()
17131713
val type = useType(c.type)
@@ -1717,7 +1717,7 @@ open class KotlinFileExtractor(
17171717
}
17181718
isBuiltinCallInternal(c, "ieee754equals") -> {
17191719
if(c.origin != IrStatementOrigin.EQEQ) {
1720-
logger.errorElement("Unexpected origin for ieee754equals: ${c.origin}", c)
1720+
logger.warnElement("Unexpected origin for ieee754equals: ${c.origin}", c)
17211721
}
17221722
val id = tw.getFreshIdLabel<DbEqexpr>()
17231723
val type = useType(c.type)
@@ -1727,7 +1727,7 @@ open class KotlinFileExtractor(
17271727
}
17281728
isBuiltinCallInternal(c, "CHECK_NOT_NULL") -> {
17291729
if(c.origin != IrStatementOrigin.EXCLEXCL) {
1730-
logger.errorElement("Unexpected origin for CHECK_NOT_NULL: ${c.origin}", c)
1730+
logger.warnElement("Unexpected origin for CHECK_NOT_NULL: ${c.origin}", c)
17311731
}
17321732

17331733
val id = tw.getFreshIdLabel<DbNotnullexpr>()
@@ -2394,7 +2394,7 @@ open class KotlinFileExtractor(
23942394
val stmtParent = parent.stmt(e, callable)
23952395
val irConstructor = declarationStack.peek() as? IrConstructor
23962396
if (irConstructor == null) {
2397-
logger.warnElement("IrInstanceInitializerCall outside constructor", e)
2397+
logger.errorElement("IrInstanceInitializerCall outside constructor", e)
23982398
return
23992399
}
24002400
extractInstanceInitializerBlock(stmtParent, irConstructor)
@@ -3368,7 +3368,7 @@ open class KotlinFileExtractor(
33683368
) {
33693369
with("function reference", functionReferenceExpr) {
33703370
val target = functionReferenceExpr.reflectionTarget ?: run {
3371-
logger.errorElement("Expected to find reflection target for function reference. Using underlying symbol instead.", functionReferenceExpr)
3371+
logger.warnElement("Expected to find reflection target for function reference. Using underlying symbol instead.", functionReferenceExpr)
33723372
functionReferenceExpr.symbol
33733373
}
33743374

0 commit comments

Comments
 (0)