Fix NPE in KaptJavaLog
See https://issuetracker.google.com/issues/162446295 for more context, but in short: this will fail if the project: * targets java 8 * consumes external libraries targeting a higher version (java 9+). This includes Android SDK 30's android.jar, which targets java 9 * has `mapDiagnosticLocations` enabled for kapt targetElement is a nullable type, so this seems like a pretty cut-and-dry NPE fix
This commit is contained in:
@@ -82,7 +82,7 @@ class KaptJavaLog(
|
||||
}
|
||||
}
|
||||
|
||||
if (mapDiagnosticLocations && sourceFile != null && targetElement.tree != null) {
|
||||
if (mapDiagnosticLocations && sourceFile != null && targetElement?.tree != null) {
|
||||
val kotlinPosition = stubLineInfo.getPositionInKotlinFile(sourceFile, targetElement.tree)
|
||||
val kotlinFile = kotlinPosition?.let { getKotlinSourceFile(it) }
|
||||
if (kotlinPosition != null && kotlinFile != null) {
|
||||
|
||||
Reference in New Issue
Block a user