From 2896ec67ba11ab6dc9701a3af648772033745aae Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Thu, 16 Jul 2015 18:03:32 +0300 Subject: [PATCH] Support synthetic java properties in REPL Use brand new iterable injection --- .../kotlin/frontend/java/di/injection.kt | 3 +-- .../kotlin/resolve/lazy/FileScopeProviderImpl.kt | 4 ++-- .../testData/repl/useJava/syntheticProperty.repl | 2 ++ .../kotlin/repl/ReplInterpreterTestGenerated.java | 15 +++++++++++++++ 4 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 compiler/testData/repl/useJava/syntheticProperty.repl diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/frontend/java/di/injection.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/frontend/java/di/injection.kt index 2f671afa407..a3d0cd297a6 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/frontend/java/di/injection.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/frontend/java/di/injection.kt @@ -66,6 +66,7 @@ public fun StorageComponentContainer.configureJavaTopDownAnalysis(moduleContentS useImpl() useImpl() useImpl() + useImpl() } public fun createContainerForLazyResolveWithJava( @@ -75,7 +76,6 @@ public fun createContainerForLazyResolveWithJava( configureModule(moduleContext, KotlinJvmCheckerProvider(moduleContext.module), bindingTrace) configureJavaTopDownAnalysis(moduleContentScope, moduleContext.project) - useImpl() useInstance(moduleClassResolver) useInstance(declarationProviderFactory) @@ -97,7 +97,6 @@ public fun createContainerForTopDownAnalyzerForJvm( configureModule(moduleContext, KotlinJvmCheckerProvider(moduleContext.module), bindingTrace) configureJavaTopDownAnalysis(moduleContentScope, moduleContext.project) - useImpl() useInstance(declarationProviderFactory) useInstance(BodyResolveCache.ThrowException) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/FileScopeProviderImpl.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/FileScopeProviderImpl.kt index 55931fda2d0..42a5d6769e3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/FileScopeProviderImpl.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/FileScopeProviderImpl.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.storage.get public class FileScopeProviderImpl( private val resolveSession: ResolveSession, - private val additionalScopes: FileScopeProvider.AdditionalScopes + private val additionalScopes: Iterable ) : FileScopeProvider { private val defaultImports by resolveSession.getStorageManager().createLazyValue { @@ -37,7 +37,7 @@ public class FileScopeProviderImpl( private fun createFileScope(file: JetFile): LazyFileScope { val tempTrace = TemporaryBindingTrace.create(resolveSession.getTrace(), "Transient trace for default imports lazy resolve") return LazyFileScope.create( - resolveSession, file, defaultImports, additionalScopes.scopes(file), + resolveSession, file, defaultImports, additionalScopes.flatMap { it.scopes(file) }, resolveSession.getTrace(), tempTrace, "LazyFileScope for file " + file.getName() ) } diff --git a/compiler/testData/repl/useJava/syntheticProperty.repl b/compiler/testData/repl/useJava/syntheticProperty.repl new file mode 100644 index 00000000000..a43a5f40c56 --- /dev/null +++ b/compiler/testData/repl/useJava/syntheticProperty.repl @@ -0,0 +1,2 @@ +>>> java.util.Date(0).time +0 diff --git a/compiler/tests/org/jetbrains/kotlin/repl/ReplInterpreterTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/repl/ReplInterpreterTestGenerated.java index 8bd0b971b61..88e6b383b61 100644 --- a/compiler/tests/org/jetbrains/kotlin/repl/ReplInterpreterTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/repl/ReplInterpreterTestGenerated.java @@ -286,4 +286,19 @@ public class ReplInterpreterTestGenerated extends AbstractReplInterpreterTest { doTest(fileName); } } + + @TestMetadata("compiler/testData/repl/useJava") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class UseJava extends AbstractReplInterpreterTest { + public void testAllFilesPresentInUseJava() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/repl/useJava"), Pattern.compile("^(.+)\\.repl$"), true); + } + + @TestMetadata("syntheticProperty.repl") + public void testSyntheticProperty() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/repl/useJava/syntheticProperty.repl"); + doTest(fileName); + } + } }