use of org.jetbrains.kotlin.descriptors.FunctionDescriptor in project kotlin by JetBrains.
the class JSTestGenerator method doGenerateTestCalls.
private static void doGenerateTestCalls(@NotNull List<FunctionDescriptor> functionDescriptors, @NotNull TranslationContext context, @NotNull JSTester jsTester) {
for (FunctionDescriptor functionDescriptor : functionDescriptors) {
ClassDescriptor classDescriptor = DescriptorUtils.getContainingClass(functionDescriptor);
if (classDescriptor == null) {
return;
}
generateCodeForTestMethod(context, functionDescriptor, classDescriptor, jsTester);
}
}
use of org.jetbrains.kotlin.descriptors.FunctionDescriptor in project kotlin by JetBrains.
the class FunctionBodyTranslator method translateFunctionBody.
@NotNull
public static JsBlock translateFunctionBody(@NotNull FunctionDescriptor descriptor, @NotNull KtDeclarationWithBody declarationWithBody, @NotNull TranslationContext functionBodyContext) {
Map<DeclarationDescriptor, JsExpression> aliases = new HashMap<DeclarationDescriptor, JsExpression>();
LocalFunctionCollector functionCollector = new LocalFunctionCollector(functionBodyContext.bindingContext());
declarationWithBody.acceptChildren(functionCollector, null);
for (FunctionDescriptor localFunction : functionCollector.getFunctions()) {
String localIdent = localFunction.getName().isSpecial() ? "lambda" : localFunction.getName().asString();
JsName localName = functionBodyContext.scope().getParent().declareTemporaryName(NameSuggestion.sanitizeName(localIdent));
MetadataProperties.setDescriptor(localName, localFunction);
JsExpression alias = JsAstUtils.pureFqn(localName, null);
aliases.put(localFunction, alias);
}
if (!aliases.isEmpty()) {
functionBodyContext = functionBodyContext.innerContextWithDescriptorsAliased(aliases);
}
return (new FunctionBodyTranslator(descriptor, declarationWithBody, functionBodyContext)).translate();
}
use of org.jetbrains.kotlin.descriptors.FunctionDescriptor in project kotlin by JetBrains.
the class BoundsSubstitutorTest method doTest.
//public void testWithWhereTwoBoundsLoop() throws Exception {
// doTest("fun <T, R> f(l: List<R>): R where T : R, R : T",
// "");
//}
private void doTest(String text, String expected) {
KtFile ktFile = KtPsiFactoryKt.KtPsiFactory(getProject()).createFile("fun.kt", text);
ModuleDescriptor module = JvmResolveUtil.analyze(ktFile, getEnvironment()).getModuleDescriptor();
Collection<SimpleFunctionDescriptor> functions = module.getPackage(FqName.ROOT).getMemberScope().getContributedFunctions(Name.identifier("f"), NoLookupLocation.FROM_TEST);
FunctionDescriptor substituted = BoundsSubstitutor.substituteBounds(CollectionsKt.single(functions));
String actual = DescriptorRenderer.COMPACT.render(substituted);
assertEquals(expected, actual);
}
use of org.jetbrains.kotlin.descriptors.FunctionDescriptor in project kotlin by JetBrains.
the class KotlinOverridingTest method assertOverridabilityRelation.
private void assertOverridabilityRelation(String superFun, String subFun, boolean expectedIsError) {
FunctionDescriptor a = makeFunction(superFun);
FunctionDescriptor b = makeFunction(subFun);
OverridingUtil.OverrideCompatibilityInfo overridableWith = OverridingUtil.DEFAULT.isOverridableBy(a, b, null);
assertEquals(overridableWith.getDebugMessage(), expectedIsError, overridableWith.getResult() != OverridingUtil.OverrideCompatibilityInfo.Result.OVERRIDABLE);
}
Aggregations