From 3ad628522ac25caf5bee12f80d9e56e7cfd82a22 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 28 Sep 2015 15:35:19 +0300 Subject: [PATCH] ReplaceWith now functions correctly in built-ins #KT-9351 Fixed --- .../replaceWith/ReplaceWithAnnotationAnalyzer.kt | 10 ++++++++-- idea/testData/inspections/cleanup/cleanup.kt | 1 + idea/testData/inspections/cleanup/cleanup.kt.after | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/ReplaceWithAnnotationAnalyzer.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/ReplaceWithAnnotationAnalyzer.kt index 89252c0dee3..662d0348aa2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/ReplaceWithAnnotationAnalyzer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/ReplaceWithAnnotationAnalyzer.kt @@ -222,8 +222,14 @@ object ReplaceWithAnnotationAnalyzer { resolutionFacade: ResolutionFacade ): BindingContext { val traceContext = BindingTraceContext() - resolutionFacade.getFrontendService(module, ExpressionTypingServices::class.java) - .getTypeInfo(scope, expression, TypeUtils.NO_EXPECTED_TYPE, DataFlowInfo.EMPTY, traceContext, false) + val frontendService = if (module.builtIns.builtInsModule == module) { + // TODO: doubtful place, do we require this module or not? Built-ins module doesn't have some necessary components... + resolutionFacade.getFrontendService(ExpressionTypingServices::class.java) + } + else { + resolutionFacade.getFrontendService(module, ExpressionTypingServices::class.java) + } + frontendService.getTypeInfo(scope, expression, TypeUtils.NO_EXPECTED_TYPE, DataFlowInfo.EMPTY, traceContext, false) return traceContext.bindingContext } diff --git a/idea/testData/inspections/cleanup/cleanup.kt b/idea/testData/inspections/cleanup/cleanup.kt index eec0e5308c3..568e5fc95b5 100644 --- a/idea/testData/inspections/cleanup/cleanup.kt +++ b/idea/testData/inspections/cleanup/cleanup.kt @@ -20,6 +20,7 @@ fun foo() { val xx = valX varX = 50 varY = 60 + 1.identityEquals(2) } fun unnecessarySafeCall(x: String) { diff --git a/idea/testData/inspections/cleanup/cleanup.kt.after b/idea/testData/inspections/cleanup/cleanup.kt.after index 5200c8fe76d..a808c2fe9bc 100644 --- a/idea/testData/inspections/cleanup/cleanup.kt.after +++ b/idea/testData/inspections/cleanup/cleanup.kt.after @@ -19,6 +19,7 @@ fun foo() { val xx = valX varX = 50 varY = 60 + 1 === 2 } fun unnecessarySafeCall(x: String) {