EA-70292 - KNPE: BindingContext.TYPE_RESOLUTION_SCOPE returns null

#EA-70292 Fixed
This commit is contained in:
Valentin Kipyatkov
2015-08-14 18:26:05 +03:00
parent b715e2e9f5
commit b7c1bed809
@@ -271,7 +271,7 @@ public class ShortenReferences(val options: (JetElement) -> Options = { Options.
val target = referenceExpression.targets(bindingContext).singleOrNull() ?: return
val typeReference = type.getStrictParentOfType<JetTypeReference>()!!
val scope = bindingContext[BindingContext.TYPE_RESOLUTION_SCOPE, typeReference]!!
val scope = bindingContext[BindingContext.TYPE_RESOLUTION_SCOPE, typeReference] ?: return
val name = target.getName()
val targetByName = if (target is ClassifierDescriptor) scope.getClassifier(name, NoLookupLocation.FROM_IDE) else scope.getPackage(name)
val canShortenNow = targetByName?.asString() == target.asString()