use of org.jetbrains.kotlin.resolve.scopes.LexicalScope in project kotlin by JetBrains.
the class CallExpressionTranslator method getVariableByName.
@Nullable
private static VariableDescriptor getVariableByName(@NotNull LexicalScope scope, @NotNull Name name) {
while (true) {
Collection<VariableDescriptor> variables = scope.getContributedVariables(name, NoLookupLocation.FROM_BACKEND);
if (!variables.isEmpty()) {
return variables.size() == 1 ? variables.iterator().next() : null;
}
if (!(scope.getParent() instanceof LexicalScope))
break;
LexicalScope parentScope = (LexicalScope) scope.getParent();
if (scope.getOwnerDescriptor() != parentScope.getOwnerDescriptor())
break;
scope = parentScope;
}
return null;
}
use of org.jetbrains.kotlin.resolve.scopes.LexicalScope in project kotlin by JetBrains.
the class KotlinOverridingTest method makeFunction.
private FunctionDescriptor makeFunction(String funDecl) {
KtNamedFunction function = KtPsiFactoryKt.KtPsiFactory(getProject()).createFunction(funDecl);
LexicalScope scope = TypeTestUtilsKt.builtInPackageAsLexicalScope(module);
return functionDescriptorResolver.resolveFunctionDescriptor(module, scope, function, KotlinTestUtils.DUMMY_TRACE, DataFlowInfoFactory.EMPTY);
}
use of org.jetbrains.kotlin.resolve.scopes.LexicalScope in project kotlin by JetBrains.
the class KotlinTypeCheckerTest method assertType.
private void assertType(String contextType, String expression, String expectedType) {
KotlinType thisType = makeType(contextType);
ReceiverParameterDescriptorImpl receiverParameterDescriptor = new ReceiverParameterDescriptorImpl(scopeWithImports.getOwnerDescriptor(), new TransientReceiver(thisType));
LexicalScope scope = new LexicalScopeImpl(scopeWithImports, scopeWithImports.getOwnerDescriptor(), false, receiverParameterDescriptor, LexicalScopeKind.SYNTHETIC);
assertType(scope, expression, expectedType);
}
Aggregations