From 6420f50f2ec39bb814dd66cf02aaaa3eb580e2a4 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Wed, 25 Oct 2017 19:12:48 +0300 Subject: [PATCH] Fix accessing nullable location() method --- .../kotlin/idea/debugger/breakpoints/KotlinFieldBreakpoint.kt | 4 ++-- idea/src/org/jetbrains/kotlin/idea/debugger/debuggerUtil.kt | 2 +- .../debugger/filter/KotlinSyntheticTypeComponentProvider.kt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinFieldBreakpoint.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinFieldBreakpoint.kt index e845f2bfda0..80aa5b59040 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinFieldBreakpoint.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinFieldBreakpoint.kt @@ -253,7 +253,7 @@ class KotlinFieldBreakpoint( } fun matchesEvent(event: LocatableEvent): Boolean { - val method = event.location().method() + val method = event.location()?.method() // TODO check property type return method != null && method.name() in getMethodsName() } @@ -264,7 +264,7 @@ class KotlinFieldBreakpoint( } override fun getEventMessage(event: LocatableEvent): String { - val location = event.location() + val location = event.location()!! val locationQName = location.declaringType().name() + "." + location.method().name() val locationFileName = try { location.sourceName() diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/debuggerUtil.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/debuggerUtil.kt index 5f9b94b0c67..e9c9cffdc2e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/debuggerUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/debuggerUtil.kt @@ -169,7 +169,7 @@ fun suspendFunctionFirstLineLocation(location: Location): Int? { return null } - val lineNumber = location.method().location().lineNumber() + val lineNumber = location.method().location()?.lineNumber() if (lineNumber == -1) { return null } diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/filter/KotlinSyntheticTypeComponentProvider.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/filter/KotlinSyntheticTypeComponentProvider.kt index fa127ee8d62..4850ac662a6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/filter/KotlinSyntheticTypeComponentProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/filter/KotlinSyntheticTypeComponentProvider.kt @@ -39,7 +39,7 @@ class KotlinSyntheticTypeComponentProvider: SyntheticTypeComponentProvider { try { if (typeComponent.isDelegateToDefaultInterfaceImpl()) return true - if (typeComponent.location().lineNumber() != 1) return false + if (typeComponent.location()?.lineNumber() != 1) return false if (typeComponent.allLineLocations().any { it.lineNumber() != 1 }) { return false