Search in sources :

Example 6 with ModuleDescriptor

use of org.jetbrains.kotlin.descriptors.ModuleDescriptor 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);
}
Also used : ModuleDescriptor(org.jetbrains.kotlin.descriptors.ModuleDescriptor) SimpleFunctionDescriptor(org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor) KtFile(org.jetbrains.kotlin.psi.KtFile) FunctionDescriptor(org.jetbrains.kotlin.descriptors.FunctionDescriptor) SimpleFunctionDescriptor(org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor)

Aggregations

ModuleDescriptor (org.jetbrains.kotlin.descriptors.ModuleDescriptor)6 KtFile (org.jetbrains.kotlin.psi.KtFile)4 File (java.io.File)3 FqName (org.jetbrains.kotlin.name.FqName)3 ClassDescriptor (org.jetbrains.kotlin.descriptors.ClassDescriptor)2 Disposable (com.intellij.openapi.Disposable)1 ArrayList (java.util.ArrayList)1 ZipEntry (java.util.zip.ZipEntry)1 Unit (kotlin.Unit)1 Function1 (kotlin.jvm.functions.Function1)1 NotNull (org.jetbrains.annotations.NotNull)1 AnalysisResult (org.jetbrains.kotlin.analyzer.AnalysisResult)1 BuiltInsPackageFragmentProviderKt.createBuiltInPackageFragmentProvider (org.jetbrains.kotlin.builtins.BuiltInsPackageFragmentProviderKt.createBuiltInPackageFragmentProvider)1 KotlinCoreEnvironment (org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment)1 CompilerConfiguration (org.jetbrains.kotlin.config.CompilerConfiguration)1 ClassifierDescriptor (org.jetbrains.kotlin.descriptors.ClassifierDescriptor)1 FunctionDescriptor (org.jetbrains.kotlin.descriptors.FunctionDescriptor)1 PackageFragmentDescriptor (org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor)1 PackageFragmentProvider (org.jetbrains.kotlin.descriptors.PackageFragmentProvider)1 PackageViewDescriptor (org.jetbrains.kotlin.descriptors.PackageViewDescriptor)1